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

[vJASS] spell with triggered casting time

Status
Not open for further replies.
Level 7
Joined
Mar 22, 2010
Messages
228
JASS:
scope Purge initializer onInit

globals
    private constant integer MY_SPELL = 'Csp0'
    private constant real CAST_TIME = 2.0

endglobals

private function actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real time = 2.0
    local real i = 0.0
    local real acc = 0.0
    local boolean end = false
    
            debug call BJDebugMsg("actions work") //good and working
            
    call SetUnitAcquireRange(caster, acc) //making the unit not to attack
    
    loop //checking unit's current order every 0.01 second
        call SetUnitAnimation(caster, "channel")//chances unit's animation
        call IssueImmediateOrder(caster, "holdposition")//making the unit to stand still
        set i = i + 0.01
        
        if GetUnitCurrentOrder(caster) != String2OrderIdBJ("holdposition") then //stops the loop when the unit's current order changes
            debug call BJDebugMsg(OrderId2String(GetUnitCurrentOrder(caster)))//this noob says (null), but it should be "holdposition" coz i issued an order before the IF
            set i = time//makes the loop exit
            set end = true //boolean for actionsABC to work
            debug call BJDebugMsg("loop stop")//tells if the loop is stopped
            
        endif
        
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //                                                                                                                              //
        // for no reason the DebugMsg says the unit's current order is (null) when the loop is On making the actionsABC not to follow   //
        //                                                                                                                              //
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        
        call TriggerSleepAction(0.01)
        exitwhen i == time
    endloop
    
    if end == false then //<--- i call this actionsABC for no reason
                                //actions should be done here
        debug call BJDebugMsg("actions good") 
    endif
    
endfunction

private function conditions takes nothing returns boolean
            debug call BJDebugMsg("conditions good") //good and working
    return GetSpellAbilityId() == MY_SPELL
endfunction

private function onInit takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction(t, function actions)
    call TriggerAddCondition(t, Condition(function conditions))
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    debug call BJDebugMsg("initialize good") //good and working
endfunction

endscope

problems:
1.) it says (in-game) that the current order of caster is null
JASS:
debug call BJDebugMsg(OrderId2String(GetUnitCurrentOrder(caster)))
2.) read number 1 problem
3.) cant find solutions for problem 1
 
You had better use EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER and its components and check the order with GetIssuedOrderId() function. Then, you can fire a timer, which will expire when the ability has been cast. To combine abilities and orders, either get the ability's id (it still counts as an order) and by Id I don't mean 'A000', but something like 10032002 or save via a hashtable or index the order id's (e.g. 852762) to the abilities' raw ids (now I speak of 'A000').
 
Level 7
Joined
Mar 22, 2010
Messages
228
i think you got it wrong..

this is a spell that has cast time..within the cast time(loop) the unit's current order must be equal to holdposition or else the loop will end and no actions will be executed..


or you meant something i didnt understand


EDIT: with response to your edit:
sorry i cant catch up
 
You can try to use Anitarf's Casting System so that you won't have to replicate your casting codes for all of your spells that needs casting time...

btw, if you ordered him to do holdposition, the debug message isn't even supposed to show since its inside an if in which the condition is that the current order should not be equal to holdposition...
JASS:
debug call BJDebugMsg(OrderId2String(GetUnitCurrentOrder(caster)))//this noob says (null), but it should be "holdposition" coz i issued an order before the IF

/*
 that line... how would it return holdposition when its only called if the order isn't holdposition???
*/

and also, TSA cannot be taken below .27 seconds... even if you put a number below .27 (like in your code, you used .01), it will be changed in-game... and TSA is pretty inaccurate to use for this kind of thing...
 
Status
Not open for further replies.
Top