Unit Finish Casting Issue

Naga'sShadow

Ultra Cool Member
Reaction score
49
I've got a spell that needs to detect after its finished casting. Except the data I need includes the target of the ability cast, not something included in the EVENT_PLAYER_UNIT_SPELL_FINISH. Right now I think that using structs would be the fastest way of getting this data from a trigger the stores the target on spell effect but I have no idea how to use structs and as I have it does not work. I'll post the code could someone tell me where I've gone wrong?

Main Trigger
JASS:

function BoW_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A004'
endfunction

function BoW_Actions takes nothing returns nothing
    local unit targ 
    local integer array spell 
    local integer level = GetUnitAbilityLevel(GetTriggerUnit(), 'A004')
    local player p = GetOwningPlayer(GetTransportUnit())
    local BattleTarget data = BattleTarget.create()
    
    set targ = data.targ
    set spell[1] = 'A00P'
    set spell[2] = 'A00Q'
    set spell[3] = 'A00R'
    set spell[4] = 'A00S'
    set spell[5] = 'A00T'
    
    call CasterCastAbility(p, spell[ level ], "doom", targ, false)
    
    set targ = null

endfunction
//=======================================================================
function InitTrig_Battle_of_Wits takes nothing returns nothing
    local trigger gg_trg_BoW
    set gg_trg_BoW = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BoW, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(gg_trg_BoW, Condition(function BoW_Conditions))
    call TriggerAddAction(gg_trg_BoW, function BoW_Actions)
    set gg_trg_BoW = null
endfunction

Secondary Trigger
JASS:

function BoW2_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A004'
endfunction

function BoW2_Actions takes nothing returns nothing
    local BattleTarget data = BattleTarget.create()
    set data.targ = GetSpellTargetUnit()
endfunction

//=======================================================================
function InitTrig_Battle_of_Wits2 takes nothing returns nothing
    local trigger gg_trg_BoW2
    set gg_trg_BoW2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_BoW2, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_BoW2, Condition(function BoW2_Conditions))
    call TriggerAddAction(gg_trg_BoW2, function BoW2_Actions)
    set gg_trg_BoW2 = null
endfunction

I've currently got the strut sitting in an otherwise empty library but due to the syntax checker going crazy whenever I attempt to use it I have no idea where it should go. Does in belong in either of these triggers?
 

Flare

Stops copies me!
Reaction score
662
local BattleTarget data = BattleTarget.create()
set targ = data.targ
There isn't (well, there shouldn't be) a value for data.targ, so how can you set targ to data.targ?

And which syntax checker are you going by? The one that appears when you click Save, or the one called Syntax Check in the Trigger Editor window?
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
The Secondary Trigger was supposed to set data.targ, and I'm referring to the syntax checker in the editor, it saves fine but does nothing.
 

Joker(Div)

Always Here..
Reaction score
86
Why do you need 2 triggers for this? Plus, where are you setting your struct? Also, why are you using structs, but nothing else from vJASS?
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
Why do you need 2 triggers for this? Plus, where are you setting your struct? Also, why are you using structs, but nothing else from vJASS?

Two triggers because the event unit finishes casting doesn't recall the targeted unit. The first trigger is to find the targeted unit on cast and give it to the second unit.

The struct is sitting in a library because I have no idea where it should be. As for why structs because I know nothing at all about VJass and all the tutorials on this page say that structs are the easiest way to transfer data between triggers without using globals.
 

Joker(Div)

Always Here..
Reaction score
86
Two triggers because the event unit finishes casting doesn't recall the targeted unit. The first trigger is to find the targeted unit on cast and give it to the second unit.
Um...I'm still not sure what your doing.

The struct is sitting in a library because I have no idea where it should be. As for why structs because I know nothing at all about VJass and all the tutorials on this page say that structs are the easiest way to transfer data between triggers without using globals.
Heres a basic vJASS template
JASS:
scope <NAME> initializer Init

//globals can be declared here, i.e.
//
//globals
//  private integer CD = 0
//endglobals

//structs would be declared here, i.e.
//
//  struct ABC
//      unit a
// 
//      method bla..
//  endstruct


//private prefixes are there so that these functions can only be used inside their declared scope
//you can use "public" prefixes if you want it declared outside the scope or you could use no
//prefix at all. When you use things when the public prefix outside the scope it is declared in,
//you need to declare it as: ScopeName_YourFunction/Global/Struct

private function Conditions takes nothing returns boolean
    return ...
endfunction

private function Actions takes nothing returns nothing
    Do stuff...
endfunction

private function Init takes nothing returns nothing //Your Init, obviously
    local trigger t = CreateTrigger()
    call TriggerRegister...
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    //you can null t if you want, I prefer not to
endfunction

endscope

Here's your 2 triggers in one.
JASS:
scope BattleOfWits initializer Init //I don't think your allowed underscores in scope names

private function BoW_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A004'
endfunction

private function BoW_Actions takes nothing returns nothing
    local unit targ = GetSpellTargetUnit()
    local integer array spell 
    local integer level = GetUnitAbilityLevel(GetTriggerUnit(), 'A004')
    local player p = GetOwningPlayer(GetTransportUnit())
    local BattleTarget data = BattleTarget.create()

    set spell[1] = 'A00P'
    set spell[2] = 'A00Q'
    set spell[3] = 'A00R'
    set spell[4] = 'A00S'
    set spell[5] = 'A00T'
    
    call CasterCastAbility(p, spell[ level ], "doom", targ, false)
    
    set targ = null

endfunction
//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    //set gg_trg_BoW = CreateTrigger()  We do not need this
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)  //Just use this event so that you can get the target unit
    call TriggerAddCondition(trig, Condition(function BoW_Conditions))
    call TriggerAddAction(trig, function BoW_Actions)
    set trig = null
endfunction

endscope
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
Thanks for the template but as for the spell, the spell is based of channel and has a casting time as part of the balance of a doom spell that targets heroes. But if you use any casting time the hero just stands there and doesn't play any animation. In other words doesn't place the large "stun me!" sign on his head i want him to. I'm going to just do the thing in Gui and not worry about it, thanks for all the help.
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Scopes need to have the same name as the trigger that they are in.
 

Artificial

Without Intelligence
Reaction score
326
> Scopes need to have the same name as the trigger that they are in.
No they don't, as long as you ain't using a public InitTrig and hoping for it to work. :p
Although it makes it easier to find them if they are named the same.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top