• 🏆 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] Issue with sell ability

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
332
The problem is when I upgrade my towers and click on the sell ability, the refund does not work! (I mean it works until I upgrade them).
For example: If a tower is newly built, it will sell for 100%, until the next round starts, otherwise it will sell 50%.
  • Sell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sell 50%
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Boolean_InRound Equal to False
        • Then - Actions
          • For each (Integer B) from 1 to Integer_Towers, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Casting unit)) Equal to UnitTypes_Towers[(Integer B)]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Casting unit) is in UnitGroup_TowersNewlyBuilt.) Equal to True
                    • Then - Actions
                      • Set VariableSet Integer_Temp = ((Point-value of (Casting unit)) x 1)
                    • Else - Actions
                      • Set VariableSet Integer_Temp = (Integer(((Real((Point-value of (Casting unit)))) x 0.50)))
                  • Game - Display to (Player group((Owner of (Casting unit)))) for 10.00 seconds the text: ((You sold a + ((Name of (Casting unit)) + for |cffffcc00)) + ((String(Integer_Temp)) + |r gold.))
                  • Player - Add Integer_Temp to (Owner of (Casting unit)).Current gold
                  • Player - Set (Owner of (Casting unit)).Total gold gathered to (((Owner of (Casting unit)) Total gold gathered) - Integer_Temp)
                  • Set VariableSet Integer_Temp2 = (Point-value of (Casting unit))
                  • Set VariableSet Integer_Temp3 = (Integer_Temp2 - Integer_Temp)
                  • Player - Set (Owner of (Casting unit)).Total gold gathered to (((Owner of (Casting unit)) Total gold gathered) - Integer_Temp3)
                  • Set VariableSet Integers_TotalGold[(Player number of (Owner of (Casting unit)))] = (Integers_TotalGold[(Player number of (Owner of (Casting unit)))] - Integer_Temp3)
                  • Set VariableSet Temp_Player = (Owner of (Casting unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Integer_Temp Greater than 0
                    • Then - Actions
                      • Custom script: call showUnitTextPlayer (GetSpellAbilityUnit(), "+" + I2S(udg_Integer_Temp), 100.00, 77.00, 0.00, udg_Temp_Player)
                    • Else - Actions
                  • Unit Group - Remove (Casting unit) from UnitGroups_TowersSelected[(Player number of (Owner of (Casting unit)))].
                  • Unit Group - Remove (Casting unit) from UnitGroup_Towers.
                  • Unit - Remove (Casting unit) from the game
                  • Set VariableSet Point_Temp = (Position of (Casting unit))
                  • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Other\Transmute\PileofGold.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call RemoveLocation(udg_Point_Temp)
                  • Trigger - Run Fighters Value <gen> (ignoring conditions)
                • Else - Actions
        • Else - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 10.00 seconds the text: |cffff0000Couldn't ...
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
What doesn't work about it?

Here's some things I would change just for efficiency and avoiding possible issues:
- Change your For Loop to use a new Integer variable instead of (Integer B)
- Change (Owner of (Casting unit)) to Triggering Player (this is the same thing, just faster)
- You don't need the Temp_Player variable as far as I can tell. I only see it used in the custom script which can be changed to not need it -> Custom script: call showUnitTextPlayer (GetSpellAbilityUnit(), "+" + I2S(udg_Integer_Temp), 100.00, 77.00, 0.00, GetTriggerPlayer())

Two possible issues that come to mind, the upgraded tower is not setup in the UnitTypes_Towers array, and/or it gets removed from Unit Groups when it upgrades.
 
Level 10
Joined
Jun 20, 2017
Messages
332
What doesn't work about it?

Here's some things I would change just for efficiency and avoiding possible issues:
- Change your For Loop to use a new Integer variable instead of (Integer B)
- Change (Owner of (Casting unit)) to Triggering Player (this is the same thing, just faster)
- You don't need the Temp_Player variable as far as I can tell. I only see it used in the custom script which can be changed to not need it -> Custom script: call showUnitTextPlayer (GetSpellAbilityUnit(), "+" + I2S(udg_Integer_Temp), 100.00, 77.00, 0.00, GetTriggerPlayer())

Two possible issues that come to mind, the upgraded tower is not setup in the UnitTypes_Towers array, and/or it gets removed from Unit Groups when it upgrades.
Yes, I forgot to set the upgraded tower in the UnitTypes_Towers array. Thanks.
 
Status
Not open for further replies.
Top