• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[vJASS] Detect auto cast orders of preplaced units with vJass

Status
Not open for further replies.
Level 29
Joined
Feb 2, 2006
Messages
1,691
Scenario: I have preplaced units which get calls like:
JASS:
call IssueImmediateOrder(u, "blackarrowon")
because they have Black Arrow abilities and I enabled auto cast for them.
However, this is done in the generated function main in CreateAllUnits before any module or struct initialization and hence before my trigger which detects issued orders is created/has its event etc.
Hence, I have tried to solve the detection these orders with a vJass hook.
Now I see that the hook is generated as prototype:
JASS:
//Struct method generated initializers/callers:
function sa___prototype15_BlackArrowSystem__IssueImmediateOrderHook takes nothing returns boolean
    call BlackArrowSystem__IssueImmediateOrderHook(f__arg_unit1,f__arg_string1)
    return true
endfunction

function jasshelper__initstructs320175859 takes nothing returns nothing
    set st___prototype15[1]=CreateTrigger()
    call TriggerAddAction(st___prototype15[1],function sa___prototype15_BlackArrowSystem__IssueImmediateOrderHook)
    call TriggerAddCondition(st___prototype15[1],Condition(function sa___prototype15_BlackArrowSystem__IssueImmediateOrderHook))

call ExecuteFunc("s__BlackArrowSystem__S_BlackArrowSystem__Init__onInit")

endfunction

I do not understand why this is done since the functions could be ordered in a way in which it is not necessary.

This is done AFTER the creation of the preplaced units (too late):
JASS:
function main takes nothing returns nothing
    call SetCameraBounds(- 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call CreateAllItems()
    call CreateAllUnits()
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs320175859")

    call InitGlobals()
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction
so I miss the orders once again.
How can I detect issued orders of preplaced units? I want to avoid the need for adding them manually.
Maybe I can somehow register the trigger event earlier? I do not want to inject the main function since I would have to call all the functions in it by myself and this is a system other people should use. I have attached the whole map script.
 

Attachments

Status
Not open for further replies.
Back
Top