• 🏆 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!

[Trigger] Triggered Casting Time

Status
Not open for further replies.
Level 16
Joined
Feb 22, 2006
Messages
960
Hi there,
i have a problem, for my map i need a triggered casting system, that means the casttime should be decided by the trigger. Is there a way to do this?
Can be gui or jass i don't mind.
Would be nice if someone could help.

So i have it :p
here my solution

Update, added another trigger which sets a boolean true if the unit moves or something else.
the if construction cuts the rest of the trigger and clean leaks :)


JASS:
function cast_cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction


function cast_actions takes nothing returns nothing
  local unit dummy
  local unit caster = GetSpellAbilityUnit()
  local unit target = GetSpellTargetUnit()
  local integer tempint = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
  local location locunit = GetUnitLoc(caster)
  local timer t = CreateTimer()
  local real tleft
    set udg_casttime[tempint] = 2.20
    call TimerStart(t,udg_casttime[tempint],false,null)
    loop
        set tleft = TimerGetRemaining(t)
        exitwhen tleft == 0
        if udg_castboolean[tempint] == true then
            call IssueImmediateOrder(caster,"stop")
            call RemoveLocation(locunit)
            set caster = null
            set target = null
            set dummy = null
            set locunit = null
            set t = null
            return
        endif
        call TriggerSleepAction(0.02)
    endloop
    call IssueImmediateOrder(caster,"stop")
    set dummy = CreateUnitAtLoc(GetOwningPlayer(caster),'h000',locunit,0)
    call UnitAddAbility(dummy,'A003')
    call IssueTargetOrder(dummy,"thunderbolt",target)
    call UnitApplyTimedLife(dummy,'BTLF',2.0)    
  //clean up
  call RemoveLocation(locunit)
  set caster = null
  set target = null
  set dummy = null
  set locunit = null
  set t = null    
endfunction

function InitTrig_triggered_casting  takes nothing returns nothing
  local trigger casttrig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(casttrig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(casttrig,Condition(function cast_cond)) 
    call TriggerAddAction(casttrig,function cast_actions)
  set casttrig = null     
endfunction
 
Last edited:
Level 8
Joined
Jul 22, 2008
Messages
331
I think that that is impossible to do. you can create ability with 1000 levels with a diferent casting time. and then with a little help with triggers you set desired level when some event happen. I think I could help you a bit...
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Make it based on channel or some channeling ability with unlimited casting duration
and make real ability some dummy ability

Unit Starts Effect of Ability
if its the channeling one
Wait <custom casting time> seconds
Set OMFGBOOLEAN = True
Order Triggering Unit to Stop

Unit Stops Casting ability
if its the channeling one
if OMFGBOOLEAN is true
then create a dummy and order it to cast real ability
set OMFGBOOLEAN = False (outside of Then action)

And yes that would be MUI
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Its simple at thinking
Like someone channels an ability
If you stop it by yourself OMFGBOOLEAN will be false and we know that you stopped him
If its stopped by trigger OMFGBOOLEAN will be true and we will know that trigger stopped it after casting time

So if you stop it from casting nothing will happen
if trigger stopped it from casting a dummy will cast the real ability

Which Part you need information at making this ?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Id suggest life drain with no life drained per second and no lightning effect
Channel is not good for beginners
 
Status
Not open for further replies.
Top