H
Hanester
Guest
wow it almost seems too simple
SaveLoad Save All
Events
Player - Player 1 (Red) types a chat message containing -save as An exact match
Player - Player 2 (Blue) types a chat message containing -save as An exact match
Player - Player 3 (Teal) types a chat message containing -save as An exact match
Player - Player 4 (Purple) types a chat message containing -save as An exact match
Conditions
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveCount = 0
-------- Player's Gold --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = ((Triggering player) Current gold)
-------- Take all Heroes --------
Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of units in UnitGroup)
Unit Group - Pick every unit in UnitGroup and do (Actions)
Loop - Actions
-------- Save the Hero --------
Set SaveCount = (SaveCount + 1)
Set TempUnit = (Picked unit)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
-------- Hero Experience --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Hero experience of (Picked unit))
-------- Hero Position X --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
-------- Hero Position Y --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
-------- How many items does he carry --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of items carried by (Picked unit))
-------- Add all items --------
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
Then - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
-------- The number of charges it has --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
Else - Actions
-------- Add all abilities --------
For each (Integer A) from 1 to SaveLoad_Abilities_LastIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of SaveLoad_Abilities[(Integer A)] for (Picked unit)) Greater than 0
Then - Actions
-------- The actual ability --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer A)
-------- Its level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Level of SaveLoad_Abilities[(Integer A)] for (Picked unit))
Else - Actions
-------- Turn values into code --------
Custom script: set udg_Code = SaveLoad_Encode()
-------- Show code to player --------
Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
SaveLoad Load All
Events
Player - Player 1 (Red) types a chat message containing -load as A substring
Player - Player 2 (Blue) types a chat message containing -load as A substring
Player - Player 3 (Teal) types a chat message containing -load as A substring
Player - Player 4 (Purple) types a chat message containing -load as A substring
Conditions
(Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
(Length of (Entered chat string)) Greater than 6
Actions
-------- Try to decode what was typed --------
Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Validate Equal to False
Then - Actions
-------- Invalid code --------
Game - Display to (Player group((Triggering player))) the text: There's some error ...
Skip remaining actions
Else - Actions
-------- It worked, let's do something with it --------
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
Unit - Remove (Picked unit) from the game
Set SaveCount = 1
-------- Restore Gold --------
Player - Set (Triggering player) Current gold to Save[SaveCount]
-------- For "number of Heroes", do --------
Set SaveCount = (SaveCount + 1)
For each (Integer B) from 1 to Save[SaveCount], do (Actions)
Loop - Actions
-------- Restore Hero --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
-------- Set Experience --------
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
-------- Move to saved position --------
Set SaveCount = (SaveCount + 1)
Unit - Move (Last created unit) instantly to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)]))))
Set SaveCount = (SaveCount + 1)
-------- Recreate all items --------
Set SaveCount = (SaveCount + 1)
For each (Integer A) from 1 to Save[SaveCount], do (Actions)
Loop - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- Number of charges --------
Set SaveCount = (SaveCount + 1)
Item - Set charges remaining in (Last created item) to Save[SaveCount]
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
Unit - Remove (Picked unit) from the game
Set TempInteger = SaveCount
Set SaveCount = 1
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) Hero-level to Save[SaveCount], Hide level-up graphics
For each (Integer SaveCount) from (SaveCount + 1) to TempInteger, do (Actions)
Loop - Actions
For each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
Loop - Actions
Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
Set SaveCount = (SaveCount + 1)
<your trigger >
function Trig_SaveLoad_Save_test_Func010001002 takes nothing returns boolean
return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction
function Trig_SaveLoad_Save_test_Func010Func021Func001C takes nothing returns boolean
if ( not ( IsItemOwned(UnitItemInSlotBJ(GetEnumUnit(), GetForLoopIndexA())) == true ) ) then
return false
endif
return true
endfunction
function Trig_SaveLoad_Save_test_Func010A takes nothing returns nothing
// Save the Hero
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempUnit = GetEnumUnit()
set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
// Hero Experience
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetHeroXP(GetEnumUnit())
// Hero Str
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetHeroStatBJ(bj_HEROSTAT_STR, GetEnumUnit(), false)
// Hero Agi
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetHeroStatBJ(bj_HEROSTAT_AGI, GetEnumUnit(), false)
// Hero Int
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetHeroStatBJ(bj_HEROSTAT_INT, GetEnumUnit(), false)
// How many items does he carry
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = UnitInventoryCount(GetEnumUnit())
// Add all items
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_SaveLoad_Save_test_Func010Func021Func001C() ) then
// The actual item
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempItem = UnitItemInSlotBJ(GetEnumUnit(), GetForLoopIndexA())
set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
// The number of charges it has
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetItemCharges(UnitItemInSlotBJ(GetEnumUnit(), GetForLoopIndexA()))
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
function Trig_SaveLoad_Save_test_Func015Func001C takes nothing returns boolean
if ( not ( IsItemOwned(UnitItemInSlotBJ(gg_unit_hpea_0016, GetForLoopIndexA())) == true ) ) then
return false
endif
return true
endfunction
function Trig_SaveLoad_Save_test_Actions takes nothing returns nothing
// Prepare the save array with this player's Hero
set udg_SaveCount = 0
// Player's Gold
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD)
// Player's Lumber
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER)
// Take all Heroes (assumes there is only one)
call ForGroupBJ( GetUnitsOfPlayerMatching(GetTriggerPlayer(), Condition(function Trig_SaveLoad_Save_test_Func010001002)), function Trig_SaveLoad_Save_test_Func010A )
// How many items does he carry
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = UnitInventoryCount(gg_unit_hpea_0016)
// Add all items
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_SaveLoad_Save_test_Func015Func001C() ) then
// The actual item
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempItem = UnitItemInSlotBJ(gg_unit_hpea_0016, GetForLoopIndexA())
set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
// The number of charges it has
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_Save[udg_SaveCount] = GetItemCharges(UnitItemInSlotBJ(gg_unit_hpea_0016, GetForLoopIndexA()))
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set udg_Code = SaveLoad_Encode()
// Show code to player
call QuestMessageBJ( GetForceOfPlayer(GetTriggerPlayer()), bj_QUESTMESSAGE_SECRET, "TRIGSTR_030" )
call DisplayTimedTextToForce( GetForceOfPlayer(GetTriggerPlayer()), 300.00, udg_Code )
endfunction
//===========================================================================
function InitTrig_SaveLoad_Save_test takes nothing returns nothing
set gg_trg_SaveLoad_Save_test = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Save_test, Player(0), "-save", true )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Save_test, Player(1), "-save", true )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Save_test, Player(2), "-save", true )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Save_test, Player(3), "-save", true )
call TriggerAddAction( gg_trg_SaveLoad_Save_test, function Trig_SaveLoad_Save_test_Actions )
endfunction
function Trig_SaveLoad_Load_test_Conditions takes nothing returns boolean
if ( not ( SubStringBJ(GetEventPlayerChatString(), 1, 6) == GetEventPlayerChatStringMatched() ) ) then
return false
endif
if ( not ( StringLength(GetEventPlayerChatString()) > 6 ) ) then
return false
endif
return true
endfunction
function Trig_SaveLoad_Load_test_Func004C takes nothing returns boolean
if ( not ( udg_Validate == false ) ) then
return false
endif
return true
endfunction
function Trig_SaveLoad_Load_test_Func006001002 takes nothing returns boolean
return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction
function Trig_SaveLoad_Load_test_Func006A takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction
function Trig_SaveLoad_Load_test_Actions takes nothing returns nothing
// Try to decode what was typed
set udg_Code = SubStringBJ(GetEventPlayerChatString(), 7, StringLength(GetEventPlayerChatString()))
set udg_Validate = SaveLoad_Decode( udg_Code )
if ( Trig_SaveLoad_Load_test_Func004C() ) then
// Invalid code
call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "TRIGSTR_029" )
return
else
endif
// It worked, let's do something with it
call ForGroupBJ( GetUnitsOfPlayerMatching(GetTriggerPlayer(), Condition(function Trig_SaveLoad_Load_test_Func006001002)), function Trig_SaveLoad_Load_test_Func006A )
set udg_SaveCount = 1
// Restore Gold
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, udg_Save[udg_SaveCount] )
// Restore Lumber
set udg_SaveCount = ( udg_SaveCount + 1 )
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER, udg_Save[udg_SaveCount] )
// Restore Hero
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
call CreateNUnitsAtLoc( 1, udg_TempUnitType, GetTriggerPlayer(), GetPlayerStartLocationLoc(GetTriggerPlayer()), bj_UNIT_FACING )
// Set Experience
set udg_SaveCount = ( udg_SaveCount + 1 )
call SetHeroXP( GetLastCreatedUnit(), udg_Save[udg_SaveCount], false )
// Set Str
set udg_SaveCount = ( udg_SaveCount + 1 )
call ModifyHeroStat( bj_HEROSTAT_STR, GetLastCreatedUnit(), bj_MODIFYMETHOD_SET, udg_Save[udg_SaveCount] )
// Set Agi
set udg_SaveCount = ( udg_SaveCount + 1 )
call ModifyHeroStat( bj_HEROSTAT_AGI, GetLastCreatedUnit(), bj_MODIFYMETHOD_SET, udg_Save[udg_SaveCount] )
// Set Int
set udg_SaveCount = ( udg_SaveCount + 1 )
call ModifyHeroStat( bj_HEROSTAT_INT, GetLastCreatedUnit(), bj_MODIFYMETHOD_SET, udg_Save[udg_SaveCount] )
set udg_SaveCount = ( udg_SaveCount + 1 )
// Recreate all items
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = udg_Save[udg_SaveCount]
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
// The actual item
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
call UnitAddItemByIdSwapped( udg_TempItemType, GetLastCreatedUnit() )
// Number of charges
set udg_SaveCount = ( udg_SaveCount + 1 )
call SetItemCharges( GetLastCreatedItem(), udg_Save[udg_SaveCount] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
// Recreate all items
set udg_SaveCount = ( udg_SaveCount + 1 )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = udg_Save[udg_SaveCount]
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
// The actual item
set udg_SaveCount = ( udg_SaveCount + 1 )
set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
call UnitAddItemByIdSwapped( udg_TempItemType, gg_unit_hpea_0016 )
// Number of charges
set udg_SaveCount = ( udg_SaveCount + 1 )
call SetItemCharges( GetLastCreatedItem(), udg_Save[udg_SaveCount] )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
//===========================================================================
function InitTrig_SaveLoad_Load_test takes nothing returns nothing
set gg_trg_SaveLoad_Load_test = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Load_test, Player(0), "-load ", false )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Load_test, Player(1), "-load ", false )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Load_test, Player(2), "-load ", false )
call TriggerRegisterPlayerChatEvent( gg_trg_SaveLoad_Load_test, Player(3), "-load ", false )
call TriggerAddCondition( gg_trg_SaveLoad_Load_test, Condition( function Trig_SaveLoad_Load_test_Conditions ) )
call TriggerAddAction( gg_trg_SaveLoad_Load_test, function Trig_SaveLoad_Load_test_Actions )
endfunction
SaveLoad Save All
Events
Player - Player 1 (Red) types a chat message containing -save as An exact match
Player - Player 2 (Blue) types a chat message containing -save as An exact match
Player - Player 3 (Teal) types a chat message containing -save as An exact match
Player - Player 4 (Purple) types a chat message containing -save as An exact match
Conditions
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveCount = 0
-------- Player's Gold --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = ((Triggering player) Current gold)
-------- Take all Heroes --------
Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of units in UnitGroup)
Unit Group - Pick every unit in UnitGroup and do (Actions)
Loop - Actions
-------- Save the Hero --------
Set SaveCount = (SaveCount + 1)
Set TempUnit = (Picked unit)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
-------- Hero Experience --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Hero experience of (Picked unit))
-------- Hero Position X --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
-------- Hero Position Y --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
-------- How many items does he carry --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of items carried by (Picked unit))
-------- Add all items --------
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
Then - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
-------- The number of charges it has --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
Else - Actions
-------- Add all abilities --------
For each (Integer A) from 1 to SaveLoad_Abilities_LastIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of SaveLoad_Abilities[(Integer A)] for (Picked unit)) Greater than 0
Then - Actions
-------- The actual ability --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer A)
-------- Its level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Level of SaveLoad_Abilities[(Integer A)] for (Picked unit))
Else - Actions
-------- Turn values into code --------
Custom script: set udg_Code = SaveLoad_Encode()
-------- Show code to player --------
Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
SaveLoad Load All
Events
Player - Player 1 (Red) types a chat message containing -load as A substring
Player - Player 2 (Blue) types a chat message containing -load as A substring
Player - Player 3 (Teal) types a chat message containing -load as A substring
Player - Player 4 (Purple) types a chat message containing -load as A substring
Conditions
(Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
(Length of (Entered chat string)) Greater than 6
Actions
-------- Try to decode what was typed --------
Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Validate Equal to False
Then - Actions
-------- Invalid code --------
Game - Display to (Player group((Triggering player))) the text: There's some error ...
Skip remaining actions
Else - Actions
-------- It worked, let's do something with it --------
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
Unit - Remove (Picked unit) from the game
Set SaveCount = 1
-------- Restore Gold --------
Player - Set (Triggering player) Current gold to Save[SaveCount]
-------- For "number of Heroes", do --------
Set SaveCount = (SaveCount + 1)
For each (Integer B) from 1 to Save[SaveCount], do (Actions)
Loop - Actions
-------- Restore Hero --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
-------- Set Experience --------
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
-------- Move to saved position --------
Set SaveCount = (SaveCount + 1)
Unit - Move (Last created unit) instantly to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)]))))
Set SaveCount = (SaveCount + 1)
-------- Recreate all items --------
Set SaveCount = (SaveCount + 1)
For each (Integer A) from 1 to Save[SaveCount], do (Actions)
Loop - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- Number of charges --------
Set SaveCount = (SaveCount + 1)
Item - Set charges remaining in (Last created item) to Save[SaveCount]
For each (Integer SaveCount) from (SaveCount + 1) to TempInteger, do (Actions)
Loop - Actions
For each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
Loop - Actions
Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
Set SaveCount = (SaveCount + 1)
Actions
-------- List of Heroes --------
Set SaveLoad_Heroes[1] = Paladin
Set SaveLoad_Heroes[2] = Archmage
Set SaveLoad_Heroes[3] = Mountain King
Set SaveLoad_Heroes[4] = Blood Mage
-------- Number of Heroes --------
Set SaveLoad_Heroes_LastIndex = 4
-------- List of Items --------
Set SaveLoad_Items[1] = Claws of Attack +15
Set SaveLoad_Items[2] = Cheese
Set SaveLoad_Items[3] = Wand of Lightning Shield
Set SaveLoad_Items[4] = Magic Key Chain
-------- Number of Items --------
Set SaveLoad_Items_LastIndex = 4
-------- List of Abilities --------
Set SaveLoad_Abilities[1] = Banish
Set SaveLoad_Abilities[2] = Flame Strike
Set SaveLoad_Abilities[3] = Phoenix
Set SaveLoad_Abilities[4] = Siphon Mana
-------- Number of Abilities --------
Set SaveLoad_Abilities_LastIndex = 4
-------- Encryption ^)^ --------
Set Alphabet[1] = abcjkl$%&mwxyNOPQRSzABCDM456TUVWnopqrstuvXYZ012EFGHIJKL3789@#<>?defghi=+~\
Set Alphabet[2] = @%fx1B&<0C>?=+~\abc#$deyzDAEvwF6789Gghijklm2345nopqrstuHIJKLMNOPQRSTUVWXYZ
Set Alphabet[3] = $%&=+~\a<>?ghiCDjkl01ef2634mOPQnKopqzbcd57uvy89BA@#ErstFGXHIJLMNRwxSTUVWYZ
Set Alphabet[4] = U+~\Ya<?4ghDjkl0EtFr5pf3=mOeoQT>1iCqZPzbc%d7uvyW89nV2KB$&A@#s6GXHIJLMNRwxS
Set Alphabet[5] = eMDjkl\0Etbc%7uvy2KB$U+hr5pf3=m1iC4g&A@#s6~GXHOYa<?NFqZPzRwoQT>dIJLW89nVxS
Set Alphabet[6] = RwoQT>5pf3=mA@#s6~1iC4g&GXHOYac%7uvy2<?NFqZetbKB$U+hrPzdIJLW89nVxSMDjkl\0E
Set Alphabet[8] = =T>#5mAp@sCy?42\0EgoQHVxS6~1Gvw<U+%NbKFtWBR7f3XOuDjkqZeYac$hrPzdIJL89nliM&
Set basemax = 8
Set SaveLoad_CaseSensitive = True
Set SaveLoad_UsePlayername = True
-------- Required: false --------
Set SaveLoad_Initialized = False
-------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
Set Code = AceHart
Set Save[1] = 0
Set SaveCount = 1
Set Validate = False
Set SaveLoad_Compress[1] = 0
Set SaveLoad_Uncompress[1] = 0
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveLoad_UsePlayername = False
Set SaveCount = 1
Set base = (Random integer number between 1 and basemax)
Set base2 = base
Set Save[SaveCount] = base
Set base = (Random integer number between 1 and basemax)
Custom script: set udg_Code = SaveLoad_Encode()
Set Save[SaveCount] = base
Set base = basemax
Custom script: set udg_Code = udg_Code + SaveLoad_Encode() + "-"
Set SaveLoad_UsePlayername = True
Set SaveCount = 0
-------- Gold/Lumber/Variables --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = ((Triggering player) Current gold)
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = ((Triggering player) Current lumber)
-------- Take all Heroes (assumes there is only one) --------
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
-------- Save the Hero --------
Set SaveCount = (SaveCount + 1)
Set TempUnit = (Picked unit)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
-------- Hero level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Hero level of (Picked unit))
-------- How many items does he carry --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of items carried by (Picked unit))
-------- Add all items --------
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
Then - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
-------- The number of charges it has --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
Else - Actions
-------- Add all abilities --------
For each (Integer A) from 1 to SaveLoad_Abilities_LastIndex, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of SaveLoad_Abilities[(Integer A)] for (Picked unit)) Greater than 0
Then - Actions
-------- The actual ability --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Integer A)
-------- Its level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Level of SaveLoad_Abilities[(Integer A)] for (Picked unit))
Else - Actions
-------- Turn values into code --------
Set base = base2
Custom script: set udg_Code = udg_Code + SaveLoad_Encode()
-------- Show code to player --------
Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
Actions
-------- Try to decode what was typed --------
Set SaveLoad_UsePlayername = False
Set base = basemax
Set Code = (Substring((Entered chat string), 7, 8))
Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
Set SaveLoad_UsePlayername = True
Set base = (Integer(Code))
Set Code = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Validate Equal to False
Then - Actions
-------- Invalid code --------
Game - Display to (Player group((Triggering player))) the text: There's some error ...
Skip remaining actions
Else - Actions
-------- It worked, let's do something with it --------
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
Unit - Remove (Picked unit) from the game
Set TempInteger = SaveCount
Set SaveCount = 1
Player - Set (Triggering player) Current gold to Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Player - Set (Triggering player) Current lumber to Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) Hero-level to Save[SaveCount], Hide level-up graphics
Set SaveCount = (SaveCount + 1)
For each (Integer A) from 1 to Save[SaveCount], do (Actions)
Loop - Actions
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
Set SaveCount = (SaveCount + 1)
Item - Set charges remaining in (Last created item) to Save[SaveCount]
For each (Integer SaveCount) from (SaveCount + 1) to TempInteger, do (Actions)
Loop - Actions
For each (Integer A) from 1 to Save[(SaveCount + 1)], do (Actions)
Loop - Actions
Custom script: call SelectHeroSkill( GetLastCreatedUnit(), udg_SaveLoad_Abilities[ udg_Save[ udg_SaveCount ] ] )
Set SaveCount = (SaveCount + 1)
QqCj-GBD3-NlMG-9bFU-3wig-frX5-qKg1-Qp29-9rBT-jIVi-3KLl-1Pd7-XqzR-Rfnm-n0