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

[Solved] Range checker ability updating with long rifles tech

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
Hello,

I have an issue with my trigger. Somehow i can't update the range shown of a tower via an ability.

My goal is to :

1. If no long rifles tech researched then show current acquisition range whenever the ability is activated to show tower's range.

2. If long rifles tech researched thenb update the range of the tower and also update it with the ability effect.

Problem is, if i research level 1, then the range got completely messed up and it increases by, maybe 400 range and not 75 as i want. So the range shown via the ability is completely wrong. How can i fix that?
Also i have to use default acquisition range instead of current one to make the special effect work...why?


Here are screenshots of my issue:


No long rifles research works fine...
1603634983-rangecheckbug1.jpg


Long rifles level 1 with current range updating...
1603635118-rangecheckbug2.jpg


Long rifles level 2 with default range updating... range shown with special effect is wrong, the tower cannot reach the unit.
1603635881-rangecheckbug3.jpg


  • Cast ability
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Show Range of Tower
    • Actions
      • Set VariableSet RangeCheck_UnitPos1 = (Position of (Triggering unit))
      • For each (Integer A) from 1 to 36, do (Actions)
        • Loop - Actions
          • Set VariableSet RangeCheck_UnitPos2 = (RangeCheck_UnitPos1 offset by (Current acquisition range of (Triggering unit)) towards ((Real((Integer A))) x 10.00) degrees.)
          • Special Effect - Create a special effect at RangeCheck_UnitPos2 using Objects\Spawnmodels\Other\IllidanFootprint\IllidanSpawnFootPrint0.mdl
          • Special Effect - Destroy (Last created special effect)
  • Updating acquisition range
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Long Rifles [|c00ffcc00Level 1|r]
    • Actions
      • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Triggering unit)).)
      • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 1
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 2
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3 (A HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 4
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 5
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 6
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 7
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 1
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 2
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 3
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 4
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 5
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 6
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 7
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 1
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 2
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 3
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 4
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 5
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 6
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 7
                  • (Unit-type of (Picked unit)) Equal to Range Tower 1
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2 (D HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Range Tower 3
                  • (Unit-type of (Picked unit)) Equal to Range Tower 4
                  • (Unit-type of (Picked unit)) Equal to Range Tower 5
                  • (Unit-type of (Picked unit)) Equal to Range Tower 6
                  • (Unit-type of (Picked unit)) Equal to Range Tower 7
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 1
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 2
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 3
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 4
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 5
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 6
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 7
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 1
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Triggering unit)) + 75.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 2
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Default acquisition range of (Triggering unit)) + 150.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 3
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Default acquisition range of (Triggering unit)) + 225.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 4
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Default acquisition range of (Triggering unit)) + 300.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 5
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Default acquisition range of (Triggering unit)) + 375.00)
                • Else - Actions
            • Else - Actions
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
Edit : I solved the problem alone ! no need for help anymore...
 
Last edited:
Level 6
Joined
Sep 24, 2015
Messages
174
Yeah sorry guys.

Here's the solution :D


Variables :

"RangeCheck_UnitPos1" is a "point" variable type without array.
"RangeCheck_UnitPos2" is a "point" variable type without array.

  • Cast ability
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Show Range of Tower
    • Actions
      • Set VariableSet RangeCheck_UnitPos1 = (Position of (Triggering unit))
      • For each (Integer A) from 1 to 36, do (Actions)
        • Loop - Actions
          • Set VariableSet RangeCheck_UnitPos2 = (RangeCheck_UnitPos1 offset by (Current acquisition range of (Triggering unit)) towards ((Real((Integer A))) x 10.00) degrees.)
          • Special Effect - Create a special effect at RangeCheck_UnitPos2 using Objects\Spawnmodels\Other\IllidanFootprint\IllidanSpawnFootPrint0.mdl
          • Special Effect - Destroy (Last created special effect)
  • Updating acquisition range
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Long Rifles [|c00ffcc00Level 1|r]
    • Actions
      • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Triggering unit)).)
      • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 1
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 2
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3 (A HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 4
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 5
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 6
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 7
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 1
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 2
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 3
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 4
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 5
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 6
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 7
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 1
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 2
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 3
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 4
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 5
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 6
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 7
                  • (Unit-type of (Picked unit)) Equal to Range Tower 1
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2 (D HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Range Tower 3
                  • (Unit-type of (Picked unit)) Equal to Range Tower 4
                  • (Unit-type of (Picked unit)) Equal to Range Tower 5
                  • (Unit-type of (Picked unit)) Equal to Range Tower 6
                  • (Unit-type of (Picked unit)) Equal to Range Tower 7
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 1
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 2
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 3
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 4
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 5
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 6
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 7
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 1
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + 75.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 2
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + 150.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 3
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + 225.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 4
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + 300.00)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Triggering unit))) Equal to 5
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + 375.00)
                • Else - Actions
            • Else - Actions
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Just some minor issues I noticed:
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)).) and do (Actions)
You aren't referencing tempUnitGroup, so you're leaking a unit group.

Also, for keeping the trigger nice and clean, something useful you can do in the future is create a hidden passive ability and use it as a "classification" for those Towers. Then add this ability to the Towers in the Object Editor.

Then you can have 1 single condition to handle it all:
  • (Level of Long Rifles (Classification Ability) for (Picked unit)) Greater than or equal to 1
Also, there's no need for a bunch of If Then Else statements in the Actions when you can use arithmetic to adjust the values in one line:
  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + (75.00 x (Real((Current research level of Long Rifles for (Owner of (Picked unit)))))))
And if that seems confusing then break it up using a variable:
  • Set VariableSet tempReal = (75.00 x (Real((Current research level of Long Rifles for (Owner of (Picked unit))))))
  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + tempReal)
Another thing, I'm pretty sure you want to adjust their Acquisition range so it's equal to their DEFAULT Acquisition range + the Long Rifles bonus. The way it's designed now, a tower can get increased Acquisition range multiple times like so.

Let's say our tower has 600 Acquisition range:
Lvl 1 Upgrade: 600 + 75
Lvl 2 Upgrade: 675 + 150
Lvl 3 Upgrade: 825 + 225
Lvl 4 Upgrade: 1050 + 300
Lvl 5 Upgrade: 1350 + 375
 
Last edited:
Level 6
Joined
Sep 24, 2015
Messages
174
Just some minor issues I noticed:
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)).) and do (Actions)
You aren't referencing tempUnitGroup, so you're leaking a unit group.

Also, for keeping the trigger nice and clean, something useful you can do in the future is create a hidden passive ability and use it as a "classification" for those Towers. Then add this ability to the Towers in the Object Editor.

Then you can have 1 single condition to handle it all:
  • (Level of Long Rifles (Classification Ability) for (Picked unit)) Greater than or equal to 1
Also, there's no need for a bunch of If Then Else statements in the Actions when you can use arithmetic to adjust the values in one line:
  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + (75.00 x (Real((Current research level of Long Rifles for (Owner of (Picked unit)))))))
And if that seems confusing then break it up using a variable:
  • Set VariableSet tempReal = (75.00 x (Real((Current research level of Long Rifles for (Owner of (Picked unit))))))
  • Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Picked unit)) + tempReal)
Another thing, I'm pretty sure you want to adjust their Acquisition range so it's equal to their DEFAULT Acquisition range + the Long Rifles bonus. The way it's designed now, a tower can get increased Acquisition range multiple times like so.

Let's say our tower has 600 Acquisition range:
Lvl 1 Upgrade: 600 + 75
Lvl 2 Upgrade: 675 + 150
Lvl 3 Upgrade: 825 + 225
Lvl 4 Upgrade: 1050 + 300
Lvl 5 Upgrade: 1350 + 375


Thank you for your reply Uncle. Did you mean like this?

  • Updating acquisition range
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Long Rifles [|c00ffcc00Level 1|r]
    • Actions
      • Set VariableSet tempUnitGroup = (Units owned by (Owner of (Triggering unit)).)
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 1
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 2
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 3 (A HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 4
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 5
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 6
                  • (Unit-type of (Picked unit)) Equal to Arrow Tower 7
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 1
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 2
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 3
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 4
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 5
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 6
                  • (Unit-type of (Picked unit)) Equal to Curse Tower 7
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 1
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 2
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 3
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 4
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 5
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 6
                  • (Unit-type of (Picked unit)) Equal to P.O.I.S.O.N tower 7
                  • (Unit-type of (Picked unit)) Equal to Range Tower 1
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2
                  • (Unit-type of (Picked unit)) Equal to Range Tower 2 (D HOTKEY ENTITY)
                  • (Unit-type of (Picked unit)) Equal to Range Tower 3
                  • (Unit-type of (Picked unit)) Equal to Range Tower 4
                  • (Unit-type of (Picked unit)) Equal to Range Tower 5
                  • (Unit-type of (Picked unit)) Equal to Range Tower 6
                  • (Unit-type of (Picked unit)) Equal to Range Tower 7
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 1
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 2
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 3
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 4
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 5
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 6
                  • (Unit-type of (Picked unit)) Equal to Spectral Tower 7
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Picked unit))) Greater than or equal to 1
                • Then - Actions
                  • Unit - Set (Picked unit) acquisition range to ((Default acquisition range of (Picked unit)) + (75.00 x (Real((Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Picked unit)))))))
                • Else - Actions
            • Else - Actions
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
Somehow level 1 doesn't do anything...

Edit : Okay problem solved :

  • (Current research level of Long Rifles [|c00ffcc00Level 1|r] for (Owner of (Picked unit))) Greater than 0
 
Last edited:
Status
Not open for further replies.
Top