• 🏆 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] Save/Load System (Ability Problem)

Status
Not open for further replies.
Level 11
Joined
Jul 9, 2009
Messages
926
I tried to make a save/load system from scratch and it works neatly, but when I tried to load an ability it did not seem to work.
  • Save Variable Set
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set Heroes Variable --------
      • Set HeroTypes[1] = Heavy Soldier
      • Set HeroTypesCoded[1] = 0A
      • Set HeroTypes[2] = Soldier
      • Set HeroTypesCoded[2] = 1S
      • Set HeroTypes[3] = Back-up
      • Set HeroTypesCoded[3] = 2J
      • Set HeroTypesLimit = 3
      • -------- Heroes Variable Finished --------
      • -------- Set Ability Variable --------
      • Set AbilityTypes[1] = Wooden Axe +0
      • Set AbilityCoded[1] = O1
      • Set AbilityLimit = 1
      • -------- Ability Variable Finished --------
  • Hero Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to HeroTypesLimit, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HeroTypes[(Integer A)] Equal to (Unit-type of (Picked unit))
                • Then - Actions
                  • Set Final_Code = (Final_Code + HeroTypesCoded[(Integer A)])
                  • For each (Integer A) from 1 to AbilityLimit, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of AbilityTypes[(Integer A)] for (Picked unit)) Equal to 1
                        • Then - Actions
                          • Set Final_Code = (Final_Code + AbilityCoded[(Integer A)])
                        • Else - Actions
                • Else - Actions
      • Game - Display to (Player group((Triggering player))) the text: Final_Code
  • Hero Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
      • (Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
    • Actions
      • Set Final_Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • For each (Integer A) from 1 to (Length of Final_Code), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to HeroTypesLimit, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(Final_Code, (Integer A), ((Integer A) + 1))) Equal to HeroTypesCoded[(Integer B)]
                • Then - Actions
                  • Unit - Create 1 HeroTypes[(Integer B)] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
                  • Set LoadedHero[(Player number of (Triggering player))] = (Last created unit)
                  • For each (Integer A) from 1 to AbilityLimit, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Substring(Final_Code, 9, 10)) Equal to AbilityCoded[(Integer A)]
                        • Then - Actions
                          • Unit - Add AbilityTypes[(Integer A)] to LoadedHero[(Player number of (Triggering player))]
                        • Else - Actions
                • Else - Actions
Does anyone know how to fix this ?

EDIT:
Figured it out already. Sorry for the bother :)
 
Last edited:
Level 11
Joined
Jul 9, 2009
Messages
926
I remember thanks :). I owe you a lot of rep xD

I fixed it. Can you please check if the leaks are fixed. :)

  • Hero Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set UnitGroupVar = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
      • Set TriggeringPlayer = (Player group((Triggering player)))
      • Unit Group - Pick every unit in UnitGroupVar and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to HeroTypesLimit, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HeroTypes[(Integer A)] Equal to (Unit-type of (Picked unit))
                • Then - Actions
                  • Set Final_Code = (Final_Code + (:D))
                  • For each (Integer A) from 1 to AbilityLimit, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of AbilityTypes[(Integer A)] for (Picked unit)) Equal to 1
                        • Then - Actions
                          • Set Final_Code = (Final_Code + (:D))
                        • Else - Actions
                • Else - Actions
      • Game - Display to TriggeringPlayer for 30.00 seconds the text: Final_Code
      • Game - Display to TriggeringPlayer for 30.00 seconds the text: |c004A4A4A---------...
      • Custom script: call DestroyGroup(udg_UnitGroupVar)
      • Custom script: call DestroyForce(udg_TriggeringPlayer)
  • Hero Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
      • (Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
    • Actions
      • Set Creation = ((Triggering player) start location)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Length of (Entered chat string)) Equal to 13
        • Then - Actions
          • Set Final_Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
          • For each (Integer A) from 1 to (Length of Final_Code), do (Actions)
            • Loop - Actions
              • For each (Integer B) from 1 to HeroTypesLimit, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(Final_Code, (Integer A), ((Integer A) + 1))) Equal to HeroTypesCoded[(Integer B)]
                    • Then - Actions
                      • Unit - Create 1 HeroTypes[(Integer B)] for (Triggering player) at Creation facing Default building facing degrees
                      • Set LoadedHero[(Player number of (Triggering player))] = (Last created unit)
                      • Custom script: call RemoveLocation(udg_Creation)
                    • Else - Actions
          • For each (Integer A) from 1 to (Length of Final_Code), do (Actions)
            • Loop - Actions
              • For each (Integer B) from 1 to AbilityLimit, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(Final_Code, (Integer A), ((Integer A) + 1))) Equal to AbilityCoded[(Integer B)]
                    • Then - Actions
                      • Unit - Add AbilityTypes[(Integer B)] to LoadedHero[(Player number of (Triggering player))]
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AbilityCoded[(Integer B)] Equal to AbilityCoded[1]
                        • Then - Actions
                          • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using Axe.mdx
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • AbilityCoded[(Integer B)] Equal to AbilityCoded[2]
                            • Then - Actions
                              • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using CrusaderSword.mdx
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • AbilityCoded[(Integer B)] Equal to AbilityCoded[3]
                                • Then - Actions
                                  • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using crsword.mdx
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • AbilityCoded[(Integer B)] Equal to AbilityCoded[4]
                                    • Then - Actions
                                      • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using OrcishRuneBlade.mdx
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • AbilityCoded[(Integer B)] Equal to AbilityCoded[5]
                                        • Then - Actions
                                          • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using Kitchen Knife by Sunchips.mdx
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • AbilityCoded[(Integer B)] Equal to AbilityCoded[6]
                                            • Then - Actions
                                              • Special Effect - Create a special effect attached to the right hand of LoadedHero[(Player number of (Triggering player))] using ClawRight.mdx
                                            • Else - Actions
                    • Else - Actions
        • Else - Actions
Thanks again for reminding :)
 
Note: There are a lot of cases in which conditions create leaks and since it's impossible to clear them in GUI (unless you're using some awesome hacks like in the below triggers), it's always better to use if/then/endif blocks and clear the leaks.

  • Hack
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
    • Conditions
    • Actions
      • Custom script: set udg_tempGroup = CreateGroup()
      • Custom script: call DestroyGroup(udg_tempGroup)
      • Custom script: if TriggerEvaluate(gg_trg_moarHacks) then
      • Custom script: call TriggerExecute(gg_trg_moarHacks)
      • Custom script: endif
  • moarHacks
    • Events
    • Conditions
      • (Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
    • Actions
      • Custom script: call DestroyGroup(udg_tempGroup)
      • -------- Actions here --------


But you shouldn't be doing this because it's crazy >:D
 
Level 11
Joined
Jul 9, 2009
Messages
926
@Maker
how can I remove the unit group leak ?
and I now have fixed the placing of the creation destroy leak.

@Magtheridon
I have never seen any kind of trigger like this before. Does it work and is it more efficient than the one I am using ? If it is I would want to be crazy >:D
 
Status
Not open for further replies.
Top