Jump to content


Photo

Damage the player when it's supposed to.


  • Please log in to reply
8 replies to this topic

#1 Flygonair

Flygonair

    GMC Member

  • GMC Member
  • 129 posts

Posted 07 May 2012 - 04:11 PM

Hey guys. Sorry for asking so many questions, but I really can't figure out this one.

In the enemy step event I have this:
Posted Image
And in the Alarm 0 event I have this:
Posted Image
Now when obj_snuri is near obj_player (distance to object less than 10), the health has to decrease every 10 steps, but it doesn't work, it only happens when obj_player first gets in the less than 10 distance and then leaves the less than 10 distance.

Can anyone solve this?
  • 0

#2 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 07 May 2012 - 04:24 PM

In alarm 0 put:
if distance to player is less then 10
start block
the alarm0=10
instance create object hit
health -5
end block
Else
Start block
alarm0 = -1
End block

Edited by theepicgeno, 07 May 2012 - 04:27 PM.

  • 0

#3 Flygonair

Flygonair

    GMC Member

  • GMC Member
  • 129 posts

Posted 07 May 2012 - 04:38 PM

Where do I put the -5 health? Because it still doesn't work..
  • 0

#4 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 07 May 2012 - 04:54 PM

In between the alarm0= 10, and instance create object hit. I think you should also check relative

Edited by theepicgeno, 07 May 2012 - 04:55 PM.

  • 0

#5 Flygonair

Flygonair

    GMC Member

  • GMC Member
  • 129 posts

Posted 07 May 2012 - 05:01 PM

Still doesn't work :/
  • 0

#6 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 07 May 2012 - 05:11 PM

hmm ohhh. Alarms for some reason don't work with steps... you'll have to use a variable for it to work, I think.
  • 0

#7 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1025 posts
  • Version:GM8.1

Posted 07 May 2012 - 05:27 PM

Your problem here is that the enemy object will set Alarm0 to 10 EVERY step, so the alarm keeps resetting and never triggers. After, the ELSE remove the block you have and put this one instead:

Posted Image
Posted Image If Alarm0 = -1
Posted Image Set Alarm0 to 10
Posted Image (Stand still)
Posted Image

This will check if Alarm0 is running or not (when alarms are not being used, they're set to -1), and set it to 10 if it isn't. Note that the IF only applies to the alarm; the "stand still" code will run regardless of the IF, because there are no blocks.

Edited by PetzI, 07 May 2012 - 05:35 PM.

  • 0

#8 Flygonair

Flygonair

    GMC Member

  • GMC Member
  • 129 posts

Posted 07 May 2012 - 06:00 PM

Your problem here is that the enemy object will set Alarm0 to 10 EVERY step, so the alarm keeps resetting and never triggers. After, the ELSE remove the block you have and put this one instead:Posted ImagePosted Image If Alarm0 = -1Posted Image Set Alarm0 to 10Posted Image (Stand still)Posted ImageThis will check if Alarm0 is running or not (when alarms are not being used, they're set to -1), and set it to 10 if it isn't. Note that the IF only applies to the alarm; the "stand still" code will run regardless of the IF, because there are no blocks.


Ah, that's it! Thanks very much! It wasn't Alarm0 by the way it was alarm[0] in the variable, had to google that for a sec, but thanks! :thumbsup: :thumbsup:
  • 0

#9 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 07 May 2012 - 07:36 PM

your welcome c:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users