• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Destroy event & Local variable

Status
Not open for further replies.
Level 12
Joined
Apr 29, 2005
Messages
999
No you can't remove an event from a trigger. Why do you want to do that?

No local variables are locals. They exist only in the function where they are declared. To pass variables between functions without using globals, you have to use handle variables.
 
Level 11
Joined
Jul 2, 2004
Messages
471
Damn.. Then you use the action add new event to trigger it dosent remove the other event..

I want to make i trigger like this:

Trigger 1:
Event: Unit is attacked

Action:
Set Local unit X= attacked unit
Remove all event from trigger 2
Add new event to trigger to: Local Unit X takes damage.

Trigger 2:
Action:
Display damage taken from Unit X.


I thoght I found a way to detect damage taken by any unit.. But i didnt.. Only a bugged way..
 
Level 12
Joined
Apr 29, 2005
Messages
999
This is the bug heache (spelled correctly?)for all spell makers. There is no good 100% chance method to detect damage dealed to any unit. You know the damage taken response only works for Event - Unit takes damage. Any you must choose a specific unit for that event. Did you read my comment to your Damage Check spell?

But in your trigger 2, you add the event after you removed it, why???

Let me see the JASS code please.
 
Level 1
Joined
Nov 16, 2005
Messages
3
try this way
Trigger1
event-unit enter playable map
actions-
custom script: local trigger trig=CreateTrigger()
custom script: call TriggerRegisterUnitEvent(trig,GetEnteringUnit(),EVENT_UNIT_DAMAGED)
custom script: call TriggerAddAction(trig,function DisplayDamage)

paste the following function to your map's custom script section
function DisplayDamage takes nothing returns nothing
local unit u=GetTriggerUnit()
if GetUnitState(u,UNIT_STATE_LIFE)<=0 then
call DestroyTrigger(GetTriggeringTrigger())
endif
call DisplayTextToPlayer(GetLocalPlayer(),0,0,R2S(GetEventDamage()))
endfunction
 
Status
Not open for further replies.
Top