• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Returning the attacking unit

Status
Not open for further replies.
Level 12
Joined
Dec 10, 2008
Messages
850
I was wondering, is it possible to return the attacking unit and see if its activated the trigger before? An example is appreciated, since I'm not that great.
I reliese I'll probably need a DDD for this to work properly, but I'm not sure how I can check if a unit has activated the trigger before or if its its first time. I think it might be possible by attaching a struct to the unit to detect what number an integer is at, but I don't wanna waste time writing a script that might not work.

I also need to know if its possible to detect that a unit has a passive ability or not, since thats basicly how it works, the unit needs the ability for it to pass the condition.

Thanks in advance to whomever helps me.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
EDIT : Haha, forgot the
JASS:
 prefix... :D

[trigger]
flame
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spell
    Actions
        Set TriggerCheck = (Load (Key Boolean) of (Key (Triggering unit)) from TriggerActivationHash)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TriggerCheck Not equal to True
            Then - Actions
                Unit - Create 1 Footman for Player 1 (Red) at (Position of (Triggering unit)) facing Default building facing degrees
                Set TriggerCheck = True
                Hashtable - Save TriggerCheck as (Key Boolean) of (Key (Triggering unit)) in TriggerActivationHash
            Else - Actions
[/trigger]

Init the trigger with

[trigger]
        Hashtable - Create a hashtable
        Set TriggerActivationHash = (Last created hashtable)
[/trigger]

And when the unit dies

[trigger]
Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in TriggerActivationHash
[/trigger]

Or you can use unit's custom value if you're not using that for anything else.

Not sure what you mean by the passive ability thing...coukd you describe the spell a bit better?

You could use "unit takes damage" and then check if the level of the skill on that unit is greater than 0.
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
For the passive use
JASS:
    //    If the unit doesn'tthe ability it will not be executed, 
    //    as GetUnitAbilityLevel will return 0.
    if GetUnitAbilityLevel(u,'A000') != 0 then
    //
    //
    endif

As for the other thing, have a global Hashtable, and use

JASS:
    //    This for the check:
    local boolean bool =  LoadBoolean(HASHTABLE_NAME,GetHandleId(GetAttacker()),0)
    //    This when it runs, after the check:
    call SaveBoolean(HASHTABLE_NAME,GetHandleId(GetAttacker()),0,true)
 
Status
Not open for further replies.
Top