Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Tango

minor DECORATE timing issues

Recommended Posts

I want to create an item that can be placed on maps that produces a small explosion periodically, and be able to use said item multiple times with different timing offsets so that they can be used to create a chain of explosions that go off in sequence, and then a few seconds later repeat. the best solution I could come up with was just making copies of the item, and varying the length of the first frame of the item with each iteration. so, for example, FireTrap0's first frame is TNT1 A 0, while FireTrap1's first frame is TNT1 A 10. after the flame is produced, it loops back around to the beginning but skips this first timer frame, so that the timing of all the explosions stays consistent and nothing gets out of sync.

it's a seemingly simple task but I can't for the life of me figure out what's going wrong. I have FireTrap 0 - 4, each with a start timer that is 10 frames more than the previous. they should thus go off in sequence, but instead the timing and sequence seems to be different every time I start the game. what am I missing here?

link to the wad, load up map01 to see what I mean. and here's what the DECORATE code looks like:

Spoiler

Actor FireTrap0 10700
{ //$Category FireTraps
  States
  {
  Spawn:
    TNT1 A 0
  Traploop:
	TNT1 A 0 A_Playsound("PlumeStart")
    PLUM KLMNOPQRST 2 Bright
	TNT1 A 2
	TNT1 A 0 A_PlaySound("PlumeExplode")
	PLUM ABCDEFG 2 Bright A_Explode(28, 28)
	PLUM HIJ 2
	TNT1 A 160
    Goto Traploop
  }
}

Actor FireTrap1 10701
{ //$Category FireTraps
  States
  {
  Spawn:
    TNT1 A 10
  Traploop:
	TNT1 A 0 A_Playsound("PlumeStart")
    PLUM KLMNOPQRST 2 Bright
	TNT1 A 2
	TNT1 A 0 A_PlaySound("PlumeExplode")
	PLUM ABCDEFG 2 Bright A_Explode(28, 28)
	PLUM HIJ 2
	TNT1 A 160
    Goto Traploop
  }
}

Actor FireTrap2 10702
{ //$Category FireTraps
  States
  {
  Spawn:
    TNT1 A 20
  Traploop:
	TNT1 A 0 A_Playsound("PlumeStart")
    PLUM KLMNOPQRST 2 Bright
	TNT1 A 2
	TNT1 A 0 A_PlaySound("PlumeExplode")
	PLUM ABCDEFG 2 Bright A_Explode(28, 28)
	PLUM HIJ 2
	TNT1 A 160
    Goto Traploop
  }
}

Actor FireTrap3 10703
{ //$Category FireTraps
  States
  {
  Spawn:
    TNT1 A 30
  Traploop:
	TNT1 A 0 A_Playsound("PlumeStart")
    PLUM KLMNOPQRST 2 Bright
	TNT1 A 2
	TNT1 A 0 A_PlaySound("PlumeExplode")
	PLUM ABCDEFG 2 Bright A_Explode(28, 28)
	PLUM HIJ 2
	TNT1 A 160
    Goto Traploop
  }
}

Actor FireTrap4 10704
{ //$Category FireTraps
  States
  {
  Spawn:
    TNT1 A 40
  Traploop:
	TNT1 A 0 A_Playsound("PlumeStart")
    PLUM KLMNOPQRST 2 Bright
	TNT1 A 2
	TNT1 A 0 A_PlaySound("PlumeExplode")
	PLUM ABCDEFG 2 Bright A_Explode(28, 28)
	PLUM HIJ 2
	TNT1 A 160
    Goto Traploop
  }
}

Share this post


Link to post

In vanilla Doom all item animations have their very first frame's length randomized so they're not all synced up. ZDoom might retain that. Try giving them all a 1-tic starting frame and then a loop after that.

Share this post


Link to post

that seems to do it. can't believe I spent so long trying to get this to work when the solution was so simple. thanks Linguica :D

another related question, is there a way to use a combination of DECORATE and item arguments (set in the map editor) to achieve this same effect but without having to make so many copies of the same item? I had the idea at first of making it so the item's first argument is what defines the delay timer at the beginning, but you can't use arg[x] as a frame counter (I tried doing TNT1 A arg[0] and it gave me an error). it seems doable with ACS but I'd rather not have to use scripts...

Share this post


Link to post

Use arg[0] to give a dummy inventory to the item at start. Then lower the inventory each tic until it reaches 0. Only then enter the main loop with explosions/anything. Something like this:

actor dummy : inventory { inventory.maxamount 255 }

[...] // start your actor definition

States {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_GiveInventory("dummy",arg[0])
    TNT1 A 0 A_JumpIfInventory("dummy",1,"NeedsToWait")
  TrapLoop:
    TNT1 A 35 DO_WHAT_YOU_WANT
    goto TrapLoop
  NeedsToWait:
    TNT1 A 1 A_TakeInventory("dummy",1)
    TNT1 A 0 A_JumpIfInventory("dummy",1,"NeedsToWait")
    goto TrapLoop
}

Share this post


Link to post

scifista, that is an awesome solution, great thinking. thank you :D

MaxED, awesome, good to know that's a feature. probably should have checked there first haha. thanks man!

edit: just a quick little note to myself/anyone in the future that could find this useful, from the ZDoom wiki page on A_GiveInventory, a count of 0 is interpreted as 1, so even if the item's argument is 0, it gives a dummy item. thus, first argument being 0 and 1 are functionally the same, so the real difference begins when the argument is assigned to 2.

also, my last post (and subsequently scifista's post) contains a typo; it's args[x], not arg[x]. my bad

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×