How to spawn projectiles when the player moves (Question)

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Bael
Posts: 19
Joined: Sat Dec 02, 2017 3:15 pm

How to spawn projectiles when the player moves (Question)

Post by Bael »

Basically i want to know how to spawn projectiles when the player moves to create footsteps and and achieve this effect:

https://www.youtube.com/watch?v=UkybQ-0 ... annel=pain

Can anyone show me how the decorate would look like?
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: How to spawn projectiles when the player moves (Question

Post by Jekyll Grim Payne »

It's a bit dirty but it'd be something like this

Code: Select all

Actor CustomDoomplayer : Doomplayer
{
player.attackzoffset 20
player.startitem Pistol
player.startitem Clip, 50
player.startitem Fist
states
	{
	See:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Step",1,6)
		TNT1 A 0 A_SpawnItem("Footstep",10,15)
		PLAY A 6
		PLAY B 6
		TNT1 A 0 A_GiveInventory("Step",1)
		goto spawn

		TNT1 A 0
		TNT1 A 0 A_SpawnItem("Footstep",10,15)
		PLAY C 6
		PLAY D 6
		TNT1 A 0 A_TakeInventory("Step",1)
		goto spawn
	}
}

Actor Step : Inventory
{
inventory.maxamount 1
}

actor Footstep
{
+NOBLOCKMAP
-NOGRAVITY
-DONTSPLASH
radius 1
height 1
mass 1000
gravity 40
States
	{
		Spawn:
			TNT1 A 2
			stop
	}
}
Bael
Posts: 19
Joined: Sat Dec 02, 2017 3:15 pm

Re: How to spawn projectiles when the player moves (Question

Post by Bael »

This is in the same "see" state?

Code: Select all

states
   {
   See:
      TNT1 A 0
      TNT1 A 0 A_JumpIfInventory("Step",1,6)
      TNT1 A 0 A_SpawnItem("Footstep",10,15)
      PLAY A 6
      PLAY B 6
      TNT1 A 0 A_GiveInventory("Step",1)
      goto spawn
                                                                                                                        
      TNT1 A 0                                                           
      TNT1 A 0 A_SpawnItem("Footstep",10,15)           
      PLAY C 6                                                          ← ← ← ← ← This
      PLAY D 6                                                           
      TNT1 A 0 A_TakeInventory("Step",1)                   
      goto spawn                                                        
   }
}
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: How to spawn projectiles when the player moves (Question

Post by Jekyll Grim Payne »

Bael wrote:This is in the same "see" state?
Yes, of course. It's only done so separate the doomguy animation (so that the footstep actor first spawns when the sprite's right leg touches the floor, then the left leg, etc.)
Bael
Posts: 19
Joined: Sat Dec 02, 2017 3:15 pm

Re: How to spawn projectiles when the player moves (Question

Post by Bael »

I managed to make the water waves to respond to projectiles and when you jump, and i've done the decorate but i don't know why isn't working when you run on water

if you think you can manage to do something here is the file...or at least explain me what is wrong on the pk3

http://www.mediafire.com/file/ej2wqv5x1 ... s.pk3/file
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: How to spawn projectiles when the player moves (Question

Post by Jekyll Grim Payne »

Well, that's simple: your playerclass isn't used. You need to add it in [wiki]MAPINFO[/wiki]:

Code: Select all

gameinfo
{
	PlayerClasses = "CustomDoomPlayer"
}

Also here's updated code:

Code: Select all

actor Footstep
{
+NOBLOCKMAP
-NOGRAVITY
-DONTSPLASH
radius 1
height 1
mass 1000
gravity 40
States
   {
    Spawn:
		TNT1 A 2
		stop
   }
}

Actor Step : Inventory
{
inventory.maxamount 1
-INVBAR -COUNTITEM
}

Actor CustomDoomplayer : Doomplayer
{
player.attackzoffset 20
player.startitem Pistol
player.startitem Clip, 50
player.startitem Fist
states
   {
   See:
      TNT1 A 0 A_JumpIfInventory("Step",1,6)
	  TNT1 A 0 A_JumpIf(GetZAt(0,0) != floorz,2)
      TNT1 A 0 A_SpawnItemEx("Footstep",0,0,15,velx*2,vely,velz,angle)
      PLAY AB 6
      TNT1 A 0 A_GiveInventory("Step",1)
      goto spawn

	  TNT1 A 0 A_JumpIf(GetZAt(0,0) != floorz,2)
      TNT1 A 0 A_SpawnItemEx("Footstep",0,0,15,velx*2,vely,velz,angle)
      PLAY CD 6
      TNT1 A 0 A_TakeInventory("Step",1)
      goto spawn
   }
}
Bael
Posts: 19
Joined: Sat Dec 02, 2017 3:15 pm

Re: How to spawn projectiles when the player moves (Question

Post by Bael »

It worked! thanks here is the link of the finished splash waves effect: http://www.mediafire.com/file/audkwfcwp ... l.pk3/file

i have a last little doubt: i was wondering how to make this splash sprite appear:

https://s8.postimg.cc/4xqw235t1/Screens ... 200409.png

I´ve put the sprites in the pk3 file and those are defined in the puff.dec file too, but somehow it doesn't appear when you shoot a projectile in the water
Post Reply

Return to “Scripting”