How to make a ricochet unique?

That sounds complicated!
udg. I did some searching and found out that turning off auto-aim fixes everything. Anyway, thanks!
What is auto-aim? That doesn't sound like a mechanic in Warcraft 3.

Anyway, it's not that complicated:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (NextEnemyUnit is in I_Was_Already_Hit) Equal to False
    • Then - Actions
      • Unit Group - Add NextEnemyUnit to I_Was_Already_Hit
      • Unit - Deal 1000.00 damage to NextEnemyUnit...
    • Else - Actions
A Unit Group is just a container that holds Units. So it's like a bag, or a box, or a drawer. You can Add things to it (put them in the bag), you can Remove things from it (take them out of the bag), you can check if something is in the bag (like in my Condition above), and you can interact with everything inside of the bag (Pick every unit).

So Chain Lightning isn't that complicated to recreate yourself. Here are the basic steps:
1) Add nearby units to a temporary Unit Group.
2) Remove any units that are "bad" targets from this temporary Unit Group -> Allies, Structures, Units that were already hit, etc.
3) Now you're left with a Unit Group that contains only "good" targets. Pick one at random or pick the closest one (using distance checks).
4) Damage that picked unit and Add them to the "already hit" Unit Group. This Unit Group is going to be reused throughout the entire process.
5) Repeat this process X times, which is how many Bounces you want. You would clear the "already hit" Unit Group at the very end to reset things.
 
Last edited:
What is auto-aim? That doesn't sound like a mechanic in Warcraft 3.

Anyway, it's not that complicated:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (NextEnemyUnit is in I_Was_Already_Hit) Equal to False
    • Then - Actions
      • Unit Group - Add NextEnemyUnit to I_Was_Already_Hit
      • Unit - Deal 1000.00 damage to NextEnemyUnit...
    • Else - Actions
A Unit Group is just a container that holds Units. So it's like a bag, or a box, or a drawer. You can Add things to it (put them in the bag), you can Remove things from it (take them out of the bag), you can check if something is in the bag (like in my Condition above), and you can interact with everything inside of the bag (Pick every unit).

So Chain Lightning isn't that complicated to recreate yourself. Here are the basic steps:
1) Add nearby units to a temporary Unit Group.
2) Remove any units that are "bad" targets from this temporary Unit Group -> Allies, Structures, Units that were already hit, etc.
3) Now you're left with a Unit Group that contains only "good" targets. Pick one at random or pick the closest one (using distance checks).
4) Damage that picked unit and Add them to the "already hit" Unit Group.
5) Repeat this process X times, which is how many Bounces you have.
missile homing - yes/no.

This is in the unit editor. I have a very busy map with extra units, 500 towers and hundreds of mobs, so thankfully there's an in-game solution.

Anyway, thanks for the help.

By the way, do you know how to track a unit's deletion? For some reason, leaving the game map doesn't track it.
 
missile homing - yes/no.

This is in the unit editor. I have a very busy map with extra units, 500 towers and hundreds of mobs, so thankfully there's an in-game solution.

Anyway, thanks for the help.
I see.
By the way, do you know how to track a unit's deletion? For some reason, leaving the game map doesn't track it.
I'm not too sure what you mean. What are you trying to do exactly?
 
I see.

I'm not too sure what you mean. What are you trying to do exactly?

I want to make it so that when a player has 30 towers built, they unlock research that allows them to build a specific tower. But if they reach 29 (either through death or sale via deletion), the research is taken away, and construction is once again prohibited.


JASS:
function Trig_Enter_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer playerId = GetPlayerId(p)
    if (GetUnitTypeId(u) == 'h00C' and playerId >= 0 and playerId <= 5) then
        set udg_ArmageddonGuntowers[playerId] = udg_ArmageddonGuntowers[playerId] + 1
        if (udg_ArmageddonGuntowers[playerId] >= 30) then
            call SetPlayerTechResearched(p, 'R03A', 1)
        endif
    endif
    set u = null
    set p = null
endfunction






function InitTrig_Enter takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_UPGRADE_FINISH)
    call TriggerAddAction(t, function Trig_Enter_Actions)
    set t = null
endfunction







function Trig_Leave_Actions takes nothing returns nothing
    local unit u = GetDyingUnit()
    local player p = GetOwningPlayer(u)
    local integer playerId = GetPlayerId(p)
    if (GetUnitTypeId(u) == 'h00C' and playerId >= 0 and playerId <= 5) then
        set udg_ArmageddonGuntowers[playerId] = udg_ArmageddonGuntowers[playerId] - 1
        if (udg_ArmageddonGuntowers[playerId] < 30) then
            call SetPlayerTechResearched(p, 'R03A', 0)
        endif
    endif
    set u = null
    set p = null
endfunction




function InitTrig_Leave takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(t, function Trig_Leave_Actions)
    set t = null
endfunction

But I can't track the deletion (remove) of the unit...
udg. [General] - Unit being removed event interesting!
 
Last edited:
Removing a unit skips the "A unit Dies" event. If you want to use that Event then you need to actually Kill the unit first:
  • Actions
    • Unit - Kill (Triggering unit)
    • Unit - Remove (Triggering unit) from the game
Alternatively, you can just subtract 1 from ArmagedonGuntowers in your Sell trigger:
  • Sell Towers
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Sell Tower
    • Actions
      • Set Variable PN = (Player number of (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN Less than 6
          • Unit-type of (Triggering unit) Equal to Armageddon Gun Tower
        • Then - Actions
          • Set Variable ArmageddonGuntowers[PN] = (ArmageddonGuntowers[PN] - 1)
          • ...
        • Else - Actions
      • Unit - Remove (Triggering unit) from the game
 
Removing a unit skips the "A unit Dies" event. If you want to use that Event then you need to actually Kill the unit first:
  • Actions
    • Unit - Kill (Triggering unit)
    • Unit - Remove (Triggering unit) from the game
Alternatively, you can just subtract 1 from ArmagedonGuntowers in your Sell trigger:
  • Sell Towers
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Sell Tower
    • Actions
      • Set Variable PN = (Player number of (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN Less than 6
          • Unit-type of (Triggering unit) Equal to Armageddon Gun Tower
        • Then - Actions
          • Set Variable ArmageddonGuntowers[PN] = (ArmageddonGuntowers[PN] - 1)
          • ...
        • Else - Actions
      • Unit - Remove (Triggering unit) from the game

Yes, I think killing it first and then deleting it would solve everything. I was just wondering if there was a way to reduce the system load))
Thanks!
 
Back
Top