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

[Trigger] Saving custom hero

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2009
Messages
123
i'm making a campaign which there we can choose a hero that we will use until the end of the campaign
so i use trigger like this to save the hero
  • Chose Hero
    • Events
      • Player - Player 1 (Red) types a chat message containing ok as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Pick Sword <gen> contains TheChooser) Equal to True
        • Then - Actions
          • Game Cache - Create a game cache from Rise of Illidan.w3v
          • Unit - Remove TheChooser from the game
          • Unit - Create 1 Gilaras Bloodseeker for Player 1 (Red) at (Center of Choosing Start <gen>) facing Default building facing (270.0) degrees
          • Set ChosenHero = (Last created unit)
          • Game Cache - Store ChosenHero as BHero of Prologue in (Last created game cache)
          • Game Cache - Store Gilaras as BName of Prologue in (Last created game cache)
          • Game Cache - Save (Last created game cache)
          • Selection - Select (Last created unit) for Player 1 (Red)
          • Trigger - Run Retreat <gen> (ignoring conditions)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Pick Archer <gen> contains TheChooser) Equal to True
            • Then - Actions
              • Game Cache - Create a game cache from Rise of Illidan.w3v
              • Unit - Remove TheChooser from the game
              • Unit - Create 1 Victoria Hawkwing for Player 1 (Red) at (Center of Choosing Start <gen>) facing Default building facing (270.0) degrees
              • Set ChosenHero = (Last created unit)
              • Game Cache - Store ChosenHero as BHero of Prologue in (Last created game cache)
              • Game Cache - Store Victoria as BName of Prologue in (Last created game cache)
              • Game Cache - Save (Last created game cache)
              • Selection - Select (Last created unit) for Player 1 (Red)
              • Trigger - Run Retreat <gen> (ignoring conditions)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Pick Break <gen> contains TheChooser) Equal to True
                • Then - Actions
                  • Game Cache - Create a game cache from Rise of Illidan.w3v
                  • Unit - Remove TheChooser from the game
                  • Unit - Create 1 Eldin Sunchaser for Player 1 (Red) at (Center of Choosing Start <gen>) facing Default building facing (270.0) degrees
                  • Set ChosenHero = (Last created unit)
                  • Game Cache - Store ChosenHero as BHero of Prologue in (Last created game cache)
                  • Game Cache - Store Eldin as BName of Prologue in (Last created game cache)
                  • Game Cache - Save (Last created game cache)
                  • Selection - Select (Last created unit) for Player 1 (Red)
                  • Trigger - Run Retreat <gen> (ignoring conditions)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Pick Priest <gen> contains TheChooser) Equal to True
                    • Then - Actions
                      • Game Cache - Create a game cache from Rise of Illidan.w3v
                      • Unit - Remove TheChooser from the game
                      • Unit - Create 1 Tyoril Sunstrider for Player 1 (Red) at (Center of Choosing Start <gen>) facing Default building facing (270.0) degrees
                      • Set ChosenHero = (Last created unit)
                      • Game Cache - Store ChosenHero as BHero of Prologue in (Last created game cache)
                      • Game Cache - Store Tyoril as BName of Prologue in (Last created game cache)
                      • Game Cache - Save (Last created game cache)
                      • Selection - Select (Last created unit) for Player 1 (Red)
                      • Trigger - Run Retreat <gen> (ignoring conditions)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Pick Sorc <gen> contains TheChooser) Equal to True
                        • Then - Actions
                          • Game Cache - Create a game cache from Rise of Illidan.w3v
                          • Unit - Remove TheChooser from the game
                          • Unit - Create 1 Anaya Magefire for Player 1 (Red) at (Center of Choosing Start <gen>) facing Default building facing (270.0) degrees
                          • Set ChosenHero = (Last created unit)
                          • Game Cache - Store ChosenHero as BHero of Prologue in (Last created game cache)
                          • Game Cache - Store Anaya as BName of Prologue in (Last created game cache)
                          • Game Cache - Save (Last created game cache)
                          • Selection - Select (Last created unit) for Player 1 (Red)
                          • Trigger - Run Retreat <gen> (ignoring conditions)
                        • Else - Actions
                          • Cinematic - Send transmission to (All players) from No unit named |c0080FF00Hint|r: Play No sound and display Please stand on des.... Modify duration: Set to 4.00 seconds and Wait
now, what trigger i should use to load the hero on the next map?:vw_wtf:
thanks before
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Here is an example that you can use it in the map you want to restore the hero to:

  • Restore
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game Cache - Reload all game cache data from disk
      • Game Cache - Create a game cache from TestCashe.w3v
      • Game Cache - Restore BHero of Prologue from (Last created game cache) for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
      • Set Hero = (Last restored unit)
If you need further explanations for the triggers just post what you need to know.
 
Level 5
Joined
Feb 18, 2009
Messages
123
i do it like this on my trigger
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player - Change color of Player 2 (Blue) to Red, Changing color of existing units
      • Cinematic - Turn subtitle display override On
      • Game Cache - Reload all game cache data from disk
      • Game Cache - Create a game cache from Rise of Illidan.w3v
      • Trigger - Run Load Hero <gen> (ignoring conditions)
  • Load Hero
    • Events
    • Conditions
    • Actions
      • Game Cache - Restore BHero of Prologue from (Last created game cache) for Player 1 (Red) at (Center of Start place <gen>) facing (Position of Swordsman 0012 <gen>)
      • Set Hero = (Last restored unit)
      • Set HeroName = (Load BName of Prologue from (Last created game cache))
but the map crashes when it loading what sould i do?
 
Last edited:
Level 16
Joined
Mar 3, 2006
Messages
1,564
how about i send my campaign to you?

OK, no problem; I thought you didn't want to do that as some sort of protection.

<<< EDIT >>>

Before you upload your maps try the following:

- Don't leave spaces in the cache name; so instead of "Rise of Illidan" make it "RiseOfIllidan"
- Add this action before saving anything to the cache to prevent data overlapping
  • Game Cache - Clear all labels of Prologue in (Last created game cache)
<<< EDIT 2 >>>

Perhaps your map crashed because the name is too big; check this
 
Last edited:
Level 5
Joined
Feb 18, 2009
Messages
123
OK, no problem; I thought you didn't want to do that as some sort of protection.

<<< EDIT >>>

Before you upload your maps try the following:

- Don't leave spaces in the cache name; so instead of "Rise of Illidan" make it "RiseOfIllidan"
- Add this action before saving anything to the cache to prevent data overlapping
  • Game Cache - Clear all labels of Prologue in (Last created game cache)
<<< EDIT 2 >>>

Perhaps your map crashed because the name is too big; check this

i've change the cache name but it still crashes any way here is my campaign
 

Attachments

  • Rise of Illidan.w3n
    338.4 KB · Views: 44
Level 16
Joined
Mar 3, 2006
Messages
1,564
i've change the cache name but it still crashes any way here is my campaign

I checked something, see this:

  • Load Hero
    • Events
    • Conditions
    • Actions
      • Game Cache - Restore BHero of Prologue from (Last created game cache) for Player 1 (Red) at (Center of Start place <gen>) facing (Center of Start place <gen>)
      • Set Hero = (Last restored unit)
      • Set HeroName = (Load BName of Prologue from (Last created game cache))
      • If (Hero Equal to No unit) then do (Trigger - Run (This trigger) (ignoring conditions)) else do (Do nothing)
The last line might be what causing the problem.

Also there is something more simpler that what you are doing which is to save the player choice as an integer or a string and create the hero from scratch in the first map.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
  • Load Hero
    • Events
    • Conditions
    • Actions
      • Game Cache - Restore BHero of Prologue from (Last created game cache) for Player 1 (Red) at (Center of Start place <gen>) facing (Center of Start place <gen>)
      • Set Hero = (Last restored unit)
      • Set HeroName = (Load BName of Prologue from (Last created game cache))
      • If (Hero Equal to No unit) then do (Trigger - Run (This trigger) (ignoring conditions)) else do (Do nothing)
Indeed its the last line that is causing the problem; it creates an infinite loop if the cache returned null unit which is always happening in your campaign. (i.e. your saved unit can't be restored; don't know why yet but I guess it isn't saved in the prologue map)

I suggest this, use the Campaign Editor 'Custom Data' tab to ensure the unit is all the same all over the maps in this campaign.

Also, you don't need to save the hero name because Proper Names for heroes can't be changed.


Done and solved
 
Last edited:
Level 5
Joined
Feb 18, 2009
Messages
123
  • Load Hero
    • Events
    • Conditions
    • Actions
      • Game Cache - Restore BHero of Prologue from (Last created game cache) for Player 1 (Red) at (Center of Start place <gen>) facing (Center of Start place <gen>)
      • Set Hero = (Last restored unit)
      • Set HeroName = (Load BName of Prologue from (Last created game cache))
      • If (Hero Equal to No unit) then do (Trigger - Run (This trigger) (ignoring conditions)) else do (Do nothing)
Indeed its the last line that is causing the problem; it creates an infinite loop if the cache returned null unit which is always happening in your campaign. (i.e. your saved unit can't be restored; don't know why yet but I guess it isn't saved in the prologue map)

I suggest this, use the Campaign Editor 'Custom Data' tab to ensure the unit is all the same all over the maps in this campaign.

Also, you don't need to save the hero name because Proper Names for heroes can't be changed.


Done and solved

oh yeah i didn't see it
thanks now the crash problem is done

but it is Unsolved yet....

the remaining problem is why my unit not stored in the game cache
(i.e. i save the name of the hero for the unit name at cinematics)
 
Level 5
Joined
Feb 18, 2009
Messages
123
Because you didn't add this in your campaign maps:

  • Game Cache - Save (Last created game cache)
you just added it in this thread but when I checked your campaign it was not there.

oh yeah i forgot to put it back when i was experimenting and it worked now at last thank you very much:goblin_yeah: now it's really
Solved
 
Status
Not open for further replies.
Top