• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Make a trigger cast an ability automaticly.

Status
Not open for further replies.
Level 3
Joined
Jan 18, 2012
Messages
26
So i have an ability on a ward, that must be activated like 10 seconds after the ward is summoned.
the trigger unit-issue order ... doesnt have option to cast a custom spell.
basicly what i want to do: Make it so a player doesnt have to manually cast the spell when he wants to. so there must be a trigger doing it.
I hope its understood.
Looking forward for an answer, Thank You !
 
Level 3
Joined
Jan 18, 2012
Messages
26
an ability targeting an area(point) , like the 'cloud' of dragonhawk riders. ( area is -location of triggering unit- )
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
1) Create a group and add the unit that has been summoed to that group...
2) Make a 10/sec looping trigger, and pick every unit in that group and do actions...
3) Before the summoned cast the spell, you need to check the order of the ward by GetUnitCurrentOrder(yourward==ORDER_ID
coz it will cancel the spell every 10 seconds if not...

and that's the basic idea of it, I cant post triggers coz Im at work, you may PM me tonight if you need it...
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Here, I made it a system, it can cast all kinds of point spells...

JASS:
library SpellC

globals
    private hashtable HT = InitHashtable()
endglobals

native UnitAlive takes u returns boolean

struct SpellC
    unit c
    location w
    string o
    real i  
    real i2

    static method looper takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = LoadInteger(HT,GetHandleId(t),0)
        if UnitAlive(.c) then
            if .i > 0 then
                set .i = .i - 0.5
            else
                set .i = .i2
                call IssuePointOrderLoc(.c,.o,.w)
            endif           
        else
            call RemoveLocation(.w)
            set .w = null
            set .c = null
            call .destroy()
            call FlushChildHashtable(HT,GetHandleId(t))            
        endif     
        set t= null
    endmethod
    
    static method locCast takes unit caster, location where, string order, real interval returns nothing
        local thistype this = allocate()
        local timer t = CreateTimer()
        set .c = caster
        set .w = where
        set .o = order
        set .i = interval
        set .i2 = interval
        call SaveInteger(HT,GetHandleId(t),0,this)
        call TimerStart(t,0.5,true,function thistype.looper)    
        set t = null
    endmethod
endstruct

endlibrary

HOW TO USE?
- Just copy n paste the code above to your map and;
  • SpellC DEMO
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flame Strike
    • Actions
      • Set Loc = (Target point of ability being cast)
      • Custom script: call SpellC.locCast(GetTriggerUnit(), udg_Loc, "flamestrike", 10.)
- if it's summoned unit just replace the GetTriggerUnit() to GetSummonedUnit()
- Loc is a point variable
- "flamestrike" is the orderstring
- 10 is the interval of the spell casted
 
Level 3
Joined
Jan 18, 2012
Messages
26
Have you tried giving the ability a 10 second casting time.
When the ward is summoned(spawned) order it to cast the ability at the target point and because of the 10sec cast time it will cast it after 10 sec.

yes what i am trying to find out is .. how to order the unit to cast an ability at target point.. the 10 sec cast time is no problem..
 
Level 3
Joined
Jan 18, 2012
Messages
26
By the way . i am getting errors on both editors, original, and NewGen editor , after i copied your system.
JassHelper gives error: Out of Memory.
and original editor, just gives 1300 different errors in triggers
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
How to order unit to cast spells via Trigger Editor, that is your main question, isn't it ?
You should be clear at the first dude...

Well, there are basically 3 types of Target-type Spell; Instant-cast / Target-unit / AOE-target and extra additional target which is Unit/Point-target spell.

If your spell is instant such as Roar, you should use Unit - Issue Order With No Target

If your spell is target-unit such as Storm Bolt, you should use Unit - Issue Order Targeting A Unit

If your spell is AOE-target such as Flame Strike, you should use Unit - Issue Order Targeting A Point

All of these actions can be found in Trigger Editor - Actions

And 1 more thing, if your spell is based from certain spell, you should order that unit to cast its base order ID, such as if you base your spell from a Storm Bolt, you should;
  • Unit - Order (Triggering unit) to Human Mountain King - Storm Bolt (Target unit of ability being cast)
And if your spell is based from Banish, just find Banish in the action and use it.

Same applies to 2 other Target-type spell such as Instant and AOE.
 
Level 3
Joined
Jan 18, 2012
Messages
26
Thanks Defskull! So the Base spell order also works if i made a custom spell out of it? Great ! cant test it right now but thanks !
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Only Channel ability can have dynamic Base Order ID.
Not to confuse with Channeling spells, the spell name itself is Channel (search it in Object Editor -> Abilities Tab (CTRL + F)).

You would have to change the Data - Base Order ID and you're good to go.
 
Status
Not open for further replies.
Top