A_Jump

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

A_Jump

Post by Sergeant Hoppy »

Trying to make my treasure chest a little bit more fancy by using A_Jump to only spawn 1 item at a time, but I'm having some trouble with the syntax. I am guessing I'm not doing the " TNT A 0 A_SpawnItem "Clip" correctly, as I get an error message saying "Sprite names must be exactly 4 characters"

Should I replace TNT1 with SMOKA1 since it is at that frame of the animation I want the item to pop in?

Code: Select all

//Wooden chest actor
Actor WoodChest : SwitchableDecoration
{
   Activation THINGSPEC_Activate
 +SOLID
 +DONTMORPH
 +NOBLOOD
    +USESPECIAL
  Monster
  health 50
  radius 18
  height 20

   States
   {
   Spawn:
      WCST A -1
      Stop
	Active:
	SMOK ABCD 0 A_NoBlocking
	SMOK B 0 A_PlaySound("chestopen")
	SMOK ABCD 4
	SMOK A 0 A_Jump(127, "CLIP")
	SMOK A 0 A_Jump(127, "BURGER")

	Stop
	CLIP:
	TNT A 0 A_SpawnItem "Clip"
	Stop
	BURGER:
	TNT A 0 A_SpawnItem "BigMac"
   Death:
    BEXP D 5 Bright A_Scream
    BEXP E 10 Bright A_Explode
    TNT1 A 1050 Bright A_BarrelDestroy
    TNT1 A 5 A_Respawn
    Wait
   }
}
User avatar
Enjay
 
 
Posts: 27275
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_Jump

Post by Enjay »

The sprite is called TNT1A0. So use TNT1 (which you did later on anyway).

There would be no harm in you using your SMOK sprite either though.
User avatar
Enjay
 
 
Posts: 27275
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: A_Jump

Post by Enjay »

Just looking at your code, there is a 50% chance that your chest will jump to CLIP. If it doesn't, there is then a 50% chance that it will jump to BURGER.

i.e. the overall chance of jumping to CLIP is 50%, BURGER 25% and doing nothing also 25%. Is that what you want?

If you want it to always jump to one or the other, use:

Code: Select all

TNT1 A 0 A_Jump(256, "CLIP", "BURGER")
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Re: A_Jump

Post by Sergeant Hoppy »

Mm, okay. But I get an error saying "SC_GetNumber: Bad numeric constant "CLIP"."
How come?

Code: Select all

//Wooden chest actor
Actor WoodChest : SwitchableDecoration
{
   Activation THINGSPEC_Activate
 +SOLID
 +DONTMORPH
 +NOBLOOD
    +USESPECIAL
  Monster
  health 50
  radius 18
  height 20

   States
   {
   Spawn:
      WCST A -1
      Stop
	Active:
	SMOK ABCD 0 A_NoBlocking
	SMOK B 0 A_PlaySound("chestopen")
	SMOK ABCD 4
	TNT1 A 0 A_Jump(256, "CLIP", "BURGER")
	Stop
	CLIP:
	SMOK A 0 A_SpawnItem "Clip"
	Stop
	CLIP:
	SMOK A 0 A_SpawnItem "BigMac"
	Stop
   Death:
    BEXP D 5 Bright A_Scream
    BEXP E 10 Bright A_Explode
    TNT1 A 1050 Bright A_BarrelDestroy
    TNT1 A 5 A_Respawn
    Wait
   }
}
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: A_Jump

Post by wildweasel »

The arguments for action functions need to be in parentheses - both of your A_SpawnItem functions are not properly enclosed.

Code: Select all

A_SpawnItem("Clip")
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Re: A_Jump

Post by Sergeant Hoppy »

I see, that did indeed fix it, thank you for correcting me.
Post Reply

Return to “Scripting”