Jump to content

Help with a damage health script


saintgrimm92

Recommended Posts

Hello!

 

I'm trying to make a trigger box cause damage to the player every so often as long as the player is inside of the trigger box, however, I'm a very novice scripter and the only scripts I can actually be AT ALL confident about are quest scripts...

 

I tried to use my knowledge of quest scripting for trigger boxes, but it seems it won't compile. Here is my script:

 

Float Property DamageHealthAmount Auto
Float Property TimeBetween Auto
Actor Property PlayerREF Auto


Event OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == PlayerREF
Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount)
RegisterForSingleUpdate(TimeBetween)
EndIf
EndEvent


Event OnUpdate()
Game.GetPlayer().DamageActorValue("Health",DamageHealthAmount)
RegisterForSingleUpdate(TimeBetween)
EndEvent


Event OnTriggerLeave(ObjectRefence akActionRef)
If akActionRef == PlayerREF
UnRegisterForUpdate()
EndIf
EndEvent

I get more than one error from this:

1. Unknown Type ObjectReference

2. Cannot compare a objectreference to a actor (cast missing or types unrelated)

3. the parameter types of function ontriggerleave in the empty state on script do not match the parent script object reference

 

 

 

Any help is highly appreciated!

 

Link to comment
Share on other sites

You cannot decide how often OnTrigger fires per second, so OnTriggerEnter/Leave is more reliable, but I would recommend to add a bool is_on_trigger = false which is set inside the ontrigger###### events and make it stop the onUpdate-block to prevent race conditions.

You can't decide how often, no. But if you don't need to then you can use it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...