Warcraft III resources & community, 2003–2006 · archived

Destroy event & Local variable

9 posts
#1

Destroy event & Local variable

Is there anyway to remove/destroy an event? And can I use the same local unit variable in two different triggers?

thanks
#2
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.
#3
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..
#4
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.
#5
Daminon
But in your trigger 2, you add the event after you removed it, why???


Because its add an event every time an unit attack.
And in one game, there will be over 10000 blow..

Daminon
Let me see the JASS code please.


I havent any JASS code, because if i cant destroy/remove i cant make this system..
#6
Daminon
But in your trigger 2, you add the event after you removed it, why???


Because its add an event every time an unit attack.
And in one game, there will be over 10000 blow..

Daminon
Let me see the JASS code please.


I havent any JASS code, because if i cant destroy/remove i cant make this system..
#7
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
#8
@cdp726
This thing is only usefull if you want to have all damage dealed shown in the game. I don't that is what Emergenzy truly want. I suppose he want to have the damage vaule in some ability.
#9
Thanks i try it out..

No i dont want to show all units damage in the game..
It was only an example.. I want to add another action.. Like floating text that display the damaged taken by any unit.. Could use it for my rpg.