Timed harm tile/traps

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Timed harm tile/traps

Post by guo »

Hi,

What would be the best way to implement a timed trap? For instance a jet of flame or perhaps spikes protrude from the ground every few seconds before retracting - but you are only harmed in the time that they are visible. I have tried setting one or two frames of an animation sequence as harm tiles but it didn't seem to work. You would also have to take damage if you were standing still on the tile at the wrong time, so I don't think step on NPCs would work.

On tick script checking hero's position + a tag or variable that is turned off and on at regular intervals?

Regards.
vvight.wordpress.com
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

You could use a timer, have it start on the autorun, and then cause an animation every so many ticks. I think zones might actually be easier to use here, so you don't have to disable the harm tiles. You could have the timer run a script that checks whether the player is on the specified zone, run the animation, deal damage to the hero (or not), then set the timer again.
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Instead of having the script perform the tile animation, you can use a normal tile animation and the "current display tile" or "get tile animation offset" commands to figure out whether the tile should be currently harmful. Otherwise, what kylekrack wrote is easiest.
Last edited by TMC on Wed Sep 14, 2016 4:19 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Cheers, I'll play around and post results & a sample script in the near future.
vvight.wordpress.com
Post Reply