[Trigger] Codeless save/load, help needed

Level 12
Joined
Jun 11, 2018
Messages
177
Hello. I really could use some help. I'm using TriggerHappy's codeless save/load and it works. It saves everone's hero and it will load the hero in another game. Good. However, there's another thing. The heroes in my map are Pokemon, like Pikachu etc., and of course Pokemon do evolve. To achieve this, I used the "Unit - replace"-action. The problem I have is that it will not save the new replacing hero. I do get a message saying it is being saved, but when I load, it will load the old hero. So for example, if I save Pikachu at lvl 10 - play further and evolve (replace) to Raichu then save, it will load Pikachu lvl 10. Do I make sense?

So what I need is the system to continue saving the replacing hero and, basicly, continue to overwrite the save file so that whichever new hero is replacing is the one that is loaded.

Here is the trigger from when a Player picks their hero aka Pokemon:

  • Yellow Selects Pokemon
    • Events
      • Unit - A unit owned by Player 5 (Yellow) Sells a unit
    • Conditions
    • Actions
      • Unit - Remove (Sold unit) from the game
      • -------- Local files check --------
      • Custom script: if not (File.ReadEnabled) then
      • Custom script: call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000, udg_LocalFiles_WarningMessage)
      • Custom script: endif
      • -------- Create hero --------
      • Player Group - Pick every player in Player Group - Player 5 (Yellow) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Sold unit)) Equal to Bulbasaur
                • Then - Actions
                  • Custom script: set udg_SaveTempInt = 1
                  • Unit - Create 1 SaveUnitType[SaveTempInt] for (Picked player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                  • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                  • Selection - Select (Last created unit) for (Picked player)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Sold unit)) Equal to Charmander
                    • Then - Actions
                      • Unit - Remove (Sold unit) from the game
                      • Custom script: set udg_SaveTempInt = 2
                      • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                      • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                      • Selection - Select (Last created unit) for (Triggering player)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Sold unit)) Equal to Squirtle
                        • Then - Actions
                          • Unit - Remove (Sold unit) from the game
                          • Custom script: set udg_SaveTempInt = 3
                          • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                          • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                          • Selection - Select (Last created unit) for (Triggering player)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Unit-type of (Sold unit)) Equal to Caterpie
                            • Then - Actions
                              • Unit - Remove (Sold unit) from the game
                              • Custom script: set udg_SaveTempInt = 4
                              • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                              • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                              • Selection - Select (Last created unit) for (Triggering player)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Unit-type of (Sold unit)) Equal to Weedle
                                • Then - Actions
                                  • Unit - Remove (Sold unit) from the game
                                  • Custom script: set udg_SaveTempInt = 5
                                  • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                  • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                  • Selection - Select (Last created unit) for (Triggering player)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Unit-type of (Sold unit)) Equal to Pidgey
                                    • Then - Actions
                                      • Unit - Remove (Sold unit) from the game
                                      • Custom script: set udg_SaveTempInt = 6
                                      • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                      • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                      • Selection - Select (Last created unit) for (Triggering player)
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Unit-type of (Sold unit)) Equal to Rattata
                                        • Then - Actions
                                          • Unit - Remove (Sold unit) from the game
                                          • Custom script: set udg_SaveTempInt = 7
                                          • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                          • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                          • Selection - Select (Last created unit) for (Triggering player)
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Unit-type of (Sold unit)) Equal to Spearow
                                            • Then - Actions
                                              • Unit - Remove (Sold unit) from the game
                                              • Custom script: set udg_SaveTempInt = 8
                                              • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                              • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                              • Selection - Select (Last created unit) for (Triggering player)
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • (Unit-type of (Sold unit)) Equal to Ekans
                                                • Then - Actions
                                                  • Unit - Remove (Sold unit) from the game
                                                  • Custom script: set udg_SaveTempInt = 9
                                                  • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                                  • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                                  • Selection - Select (Last created unit) for (Triggering player)
                                                • Else - Actions
                                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    • If - Conditions
                                                      • (Unit-type of (Sold unit)) Equal to Pikachu
                                                    • Then - Actions
                                                      • Unit - Remove (Sold unit) from the game
                                                      • Custom script: set udg_SaveTempInt = 10
                                                      • Unit - Create 1 SaveUnitType[SaveTempInt] for (Triggering player) at (Random point in Region 183 <gen>) facing 90.00 degrees
                                                      • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastCreatedUnit
                                                      • Selection - Select (Last created unit) for (Triggering player)
                                                    • Else - Actions
            • Else - Actions
      • Unit - Remove Pokeball 0044 <gen> from the game
Here is the trigger that evolves the Pokemon, aka replaces the hero with the new hero:
  • Pikachu Evolve
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Pikachu
      • (Item-type of (Item being manipulated)) Equal to Thunderstone
    • Actions
      • Item - Remove (Item being manipulated)
      • Special Effect - Create a special effect at (Position of (Hero manipulating item)) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
      • Unit - Replace (Hero manipulating item) with a Raichu using The old unit's relative life and mana
      • Custom script: set udg_SaveTempInt = 28
      • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastReplacedUnit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • Set VariableSet PokemonYellow = (Last replaced unit)
          • Selection - Select PokemonYellow for Player 5 (Yellow)
        • Else - Actions
 
The issue is likely this line in "Pikachu Evolve":
  • Custom script: set udg_SavePlayerHero[GetPlayerId(GetEnumPlayer())] = bj_lastReplacedUnit
GetEnumPlayer() only works in the "Player Group - Pick every player in <Player Group>..." context. ;)

You'll want to use GetTriggerPlayer() instead (which is the equivalent of "Triggering Player").
  • Custom script: set udg_SavePlayerHero[GetPlayerId(GetTriggerPlayer())] = bj_lastReplacedUnit
 
Top