Spell not working: supposed to hit enemies in a line only once

eskimojoe_66

Member
Reaction score
2
Hi, I'm trying to make a spell that fires out a missile, hitting all enemies it passes through once per missile. Although the first missile works as expected, all subsequent casts cause the missiles to damage enemies it passes through multiple times.

For the life of me, I can't figure out what's going wrong! Maybe all I need is a fresh pair of eyes (see GUI code below).

Cast Trigger:
Code:
Events
    Unit - A unit Starts the effect of an ability
Conditions
    (Ability being cast) Equal to Reaper
Actions
    Set WPreaper_lochero = (Position of hero_unit)
    Set WPreaper_loccast = (Target point of ability being cast)
    Set WPreaper_anglecast = (Angle from WPreaper_lochero to WPreaper_loccast)
    Set WPreaper_locspawn = (WPreaper_lochero offset by 50.00 towards WPreaper_anglecast degrees)
    Unit - Create 1 missile reaper for Player 1 (Red) at WPreaper_locspawn facing WPreaper_anglecast degrees
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            WPreaper_intslots Greater than or equal to 5
        Then - Actions
            Set WPreaper_intslots = 1
        Else - Actions
            Set WPreaper_intslots = (WPreaper_intslots + 1)
    Unit - Set the custom value of (Last created unit) to WPreaper_intslots
    Unit Group - Add (Last created unit) to WPreaper_groupmissile
    Trigger - Turn on reaper move <gen>
    Custom script:  call RemoveLocation(udg_WPreaper_lochero)
    Custom script:  call RemoveLocation(udg_WPreaper_loccast)
    Custom script:  call RemoveLocation(udg_WPreaper_locspawn)

Missile Move/Damage Enemies Trigger:
Code:
Events
    Time - Every 0.01 seconds of game time
Conditions
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Number of units in WPreaper_groupmissile) Greater than 0
        Then - Actions
            Unit Group - Pick every unit in WPreaper_groupmissile and do (Actions)
                Loop - Actions
                    Set WPreaper_tempint = (Custom value of (Picked unit))
                    Set WPreaper_anglemove = (Facing of (Picked unit))
                    Set WPreaper_locstart = (Position of (Picked unit))
                    Set WPreaper_locend = (WPreaper_locstart offset by 7.00 towards WPreaper_anglemove degrees)
                    Unit - Move (Picked unit) instantly to WPreaper_locend
                    Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 7.00)
                    Unit Group - Remove all units from WPreaper_grouptarget
                    Set WPreaper_grouptarget = (Units within 85.00 of WPreaper_locend matching (((((Matching unit) is alive) Equal to True) and (((Matching unit) is in WPreaper_grouphit[(Custom value of (Picked unit))]) Equal to False)) and (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to
                    Unit Group - Pick every unit in WPreaper_grouptarget and do (Actions)
                        Loop - Actions
                            Unit Group - Add (Picked unit) to WPreaper_grouphit[WPreaper_tempint]
                            Unit - Cause hero_unit to damage (Picked unit), dealing 90.00 damage of attack type Spells and damage type Normal
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        If - Conditions
                            (Mana of (Picked unit)) Less than or equal to 0.00
                        Then - Actions
                            Unit - Kill (Picked unit)
                            Unit Group - Remove (Picked unit) from WPreaper_groupmissile
                        Else - Actions
                    Custom script:  call RemoveLocation(udg_WPreaper_locstart)
                    Custom script:  call RemoveLocation(udg_WPreaper_locend)
        Else - Actions
            Trigger - Turn off (This trigger)

Any help will be greatly appreciated!
 

eskimojoe_66

Member
Reaction score
2
hmmm... I've tweaked around with this spell and I'm fairly certain that there is no problem with my triggers, but a bug with unit arrays @@ it works with array number 1 (i.e. WPreaver_grouphit[1]) but not with 2 or above... is this a known problem?
 

Solu9

You can change this now in User CP.
Reaction score
216
Do all players WPreaver_grouphit[X] belong to an enemy of the casting hero?
 

eskimojoe_66

Member
Reaction score
2
yes, all enemies in grouptarget are moved into grouphit[x] so they can only be enemies.

I played around with the second trigger: it works when I change all instances of [x] to 1 but not when [x] is 2 or greater... weird

I figured out a compromise where i just created a separate unit group like this:
WPreaper_grouphit1
WPreaper_grouphit2...
But I'm still confused as to why unit group arrays aren't working for me...
 

Solu9

You can change this now in User CP.
Reaction score
216
I think it has something to do with the custom value. Can you tweak it to something like [Player Number (x-y)]?
 

eskimojoe_66

Member
Reaction score
2
Sorry i didn't make it clear! this is a single player map im making for myself, the only playable slot is player 1(red). The thing is this spell has no cooldown so at any time there can be as many as 3 missiles in play (all from the one hero). Enemies can be hit only once by each missile.

As I've said, I've created a workaround (so the spell works) but I'd still like to know the problem (in case I need to use a similar system in the future). Thanks for your input!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top