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

save system ?

Status
Not open for further replies.
Level 3
Joined
Sep 15, 2021
Messages
31
Greetings,
I've been making my new TD map and trying to make this system which is
when u won my TD map 1 time, u would get a certain point and u paly my td map next time, u can load the info(point) of ur previous game
and u get a nick name next to ur battle net ID.
For example, Player named MonkeyKing won my map 10 times and on its 11th time of playing this map, he loaded his previous data and he be shown as [Grand Master] MonkeyKing.

I found some RPG based save and load or codeless tools.. but seems they don't work for TD maps. am i wrong ?

plz help
 
Level 15
Joined
Sep 29, 2008
Messages
363
Save and load or codeless tools should work for any kind of map you want to keep data.
You need to learn the teory back the tool and full use of arrays and indexes.
At the end save codes stores mainly numbers, integer numbers, those can be amounts of materials or indexes from some array or points.
You can store names too,
Save codes uses push and pop functions to store numbers

for example, you have 10 different towers, they are indexed as tower type in an array with size equals to 10. The laser tower is located at position 5 of your array. arrays normally starts with index 0 then your laser tower gets index equals to 4 (5th position starting from 0)

to store this value you need to set a maximum value+1 (11) which represent all posibles positions in your array , then you push your position whitin.
A save object is required to keep all the data, in codeless its enabled via Savecode.create()

storing value should look "savecode.encode(4,11)"

a more readable version should be

local integer position = 4
local integer max_positions = 11
local Savecode savecode

call savecode.Create()
call savecode.encode(position,max_positions)

to retrieve data from savecode you need to pass the maximun size as argument to decode function

call savecode.decode(max_positions)

this should return 4.

Order of storing values is very important, always decode should be done in reverse order as encode order was done.

an encode order should be

call savecode.Create()
call savecode.encode(gold,max_gold)
call savecode.encode(points,max_points)
call savecode.encode(lumber,max_lumber)
call savecode.encode(position,max_positions)

decode in reverse order

call savecode.decode(max_positions)
call savecode.decode(max_lumber)
call savecode.decode(max_points)
call savecode.decode(max_gold)

that's as very basic insight
anyway I insist you need to learn the theory back the tool, if not there could appear bugs and errors you couldn't handle.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Greetings,
I've been making my new TD map and trying to make this system which is
when u won my TD map 1 time, u would get a certain point and u paly my td map next time, u can load the info(point) of ur previous game
and u get a nick name next to ur battle net ID.
For example, Player named MonkeyKing won my map 10 times and on its 11th time of playing this map, he loaded his previous data and he be shown as [Grand Master] MonkeyKing.

I found some RPG based save and load or codeless tools.. but seems they don't work for TD maps. am i wrong ?

plz help
You probably found this system:

Understand that the demo map that comes with that system is just an example of what the system can do. You don't need to do it like that, you can use the system to save any data you could possibly want in any way you'd like. It's all done in the form of Integers. An Integer can be used to represent anything if used correctly.

I attached an edited version of the Codeless save and load system that shows you how to save and load your Wins/Losses. It's also done in the form of autosaving/autoloading so the user doesn't have to type anything.

Important: Your Aerial Shackles ability must be exactly the same as the one in my demo map! I know it's a weird requirement but this is very important.
Also, you'll need to be on the latest patch to open my map.
 

Attachments

  • Save and Load Example.w3x
    149.3 KB · Views: 18
Level 3
Joined
Sep 15, 2021
Messages
31
I believe the links I posted here will help you. basically "caching" lets you save persistent data.

Thanks that post helped me understand how it works :)

Save and load or codeless tools should work for any kind of map you want to keep data.
You need to learn the teory back the tool and full use of arrays and indexes.
At the end save codes stores mainly numbers, integer numbers, those can be amounts of materials or indexes from some array or points.
You can store names too,
Save codes uses push and pop functions to store numbers

for example, you have 10 different towers, they are indexed as tower type in an array with size equals to 10. The laser tower is located at position 5 of your array. arrays normally starts with index 0 then your laser tower gets index equals to 4 (5th position starting from 0)

to store this value you need to set a maximum value+1 (11) which represent all posibles positions in your array , then you push your position whitin.
A save object is required to keep all the data, in codeless its enabled via Savecode.create()

storing value should look "savecode.encode(4,11)"

a more readable version should be

local integer position = 4
local integer max_positions = 11
local Savecode savecode

call savecode.Create()
call savecode.encode(position,max_positions)

to retrieve data from savecode you need to pass the maximun size as argument to decode function

call savecode.decode(max_positions)

this should return 4.

Order of storing values is very important, always decode should be done in reverse order as encode order was done.

an encode order should be

call savecode.Create()
call savecode.encode(gold,max_gold)
call savecode.encode(points,max_points)
call savecode.encode(lumber,max_lumber)
call savecode.encode(position,max_positions)

decode in reverse order

call savecode.decode(max_positions)
call savecode.decode(max_lumber)
call savecode.decode(max_points)
call savecode.decode(max_gold)

that's as very basic insight
anyway I insist you need to learn the theory back the tool, if not there could appear bugs and errors you couldn't handle.
Thanks for the good exmaple !

You probably found this system:

Understand that the demo map that comes with that system is just an example of what the system can do. You don't need to do it like that, you can use the system to save any data you could possibly want in any way you'd like. It's all done in the form of Integers. An Integer can be used to represent anything if used correctly.

I attached an edited version of the Codeless save and load system that shows you how to save and load your Wins/Losses. It's also done in the form of autosaving/autoloading so the user doesn't have to type anything.

Important: Your Aerial Shackles ability must be exactly the same as the one in my demo map! I know it's a weird requirement but this is very important.
Also, you'll need to be on the latest patch to open my map.
Thanks for the good explanation with ur demo!

#Uncle
Can i ask u one more thing?
I made my demo-save system with ur demo
but if i don't play Red(P1), like playing Blue(P2), Teal(P3) and so on.. this save system can't load my data
What else should i add in this below ?

  • base.gif
    Add Win
    • joinminus.gif
      events.gif
      Events
      • line.gif
        joinbottom.gif
        player.gif
        Player - Player 1 (Red) types a chat message containing -SAVE as An exact match
    • join.gif
      cond.gif
      Conditions
    • joinbottomminus.gif
      actions.gif
      Actions
      • empty.gif
        joinbottomminus.gif
        if.gif
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • empty.gif
          empty.gif
          joinminus.gif
          cond.gif
          If - Conditions
          • empty.gif
            empty.gif
            line.gif
            joinbottom.gif
            if.gif
            (Lives1 Greater than or equal to 1) and (pointer Greater than or equal to 56)
        • empty.gif
          empty.gif
          joinminus.gif
          actions.gif
          Then - Actions
          • empty.gif
            empty.gif
            line.gif
            join.gif
            set.gif
            Set VariableSet Wins[1] = (Wins[1] + 1)
          • empty.gif
            empty.gif
            line.gif
            join.gif
            game.gif
            Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: Added 1 Win to Play...
          • empty.gif
            empty.gif
            line.gif
            joinbottom.gif
            page.gif
            Trigger - Turn off (This trigger)
        • empty.gif
          empty.gif
          joinbottomminus.gif
          actions.gif
          Else - Actions
          • empty.gif
            empty.gif
            empty.gif
            joinbottom.gif
            page.gif
            Do nothing
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Wins/Losses are Array variables. In this case their [Index] represents the Player that they're associated with.
So Wins[1] goes with Player 1, Wins[2] goes with Player 2, Wins[3] with Player 3, etc...

You can get the Player number of a Player at any given time as long as you have reference to a Player.

So with that in mind you can make a trigger like this:
  • Events
    • Player - Player 1 (Red) types a chat message containing -Win as An exact match
    • Player - Player 2 (Blue) types a chat message containing -Win as An exact match
    • Player - Player 3 (Blue) types a chat message containing -Win as An exact match
    • Player - Player 4 (Blue) types a chat message containing -Win as An exact match
  • Conditions
  • Actions
    • Set Variable Wins[Player number of (Triggering player)] = (Wins[Player number of (Triggering player)] + 1)
(Triggering player) will be set to whoever typed the message. Their Wins[] will be increased by 1. This single trigger will work
for as many players as you'd like. Just don't put a Wait action in there unless you know what you're doing because it can complicate things.

The basic idea for most Win/Loss save systems would be something like this:

Right before Defeating a player (they must still be in the game when you save), you increase their Losses by 1.
Right before giving a player Victory (again, they must still be in the game), you increase their Wins by 1.
You usually add all of losing players to a Player group and all of your winning players to a Player group beforehand.
Then you can use the Pick Every Player action to easily give the Picked players +1 Win/Loss.
Once that's said and done, you run the Save system for each player, saving their new records.

The only flaw with this system is that players can leave early to avoid getting a loss since it's only recorded at the
end of the game. A solution to this problem is to give every player a loss at the start of the game and then save. Then at the
end of the game, when a team/player has won, you simply subtract a loss from the winners and give them a win. The result
will be that anyone that has left/lost the game will have been given 1 loss and anyone that won will have been given 1 win.

If I were you I would read up on triggers some more and get a better idea of how everything works before jumping right into a system
as complicated as this one.
 
Level 11
Joined
Jul 17, 2013
Messages
544
Wins/Losses are Array variables. In this case their [Index] represents the Player that they're associated with.
So Wins[1] goes with Player 1, Wins[2] goes with Player 2, Wins[3] with Player 3, etc...

You can get the Player number of a Player at any given time as long as you have reference to a Player.

So with that in mind you can make a trigger like this:
  • Events
    • Player - Player 1 (Red) types a chat message containing -Win as An exact match
    • Player - Player 2 (Blue) types a chat message containing -Win as An exact match
    • Player - Player 3 (Blue) types a chat message containing -Win as An exact match
    • Player - Player 4 (Blue) types a chat message containing -Win as An exact match
  • Conditions
  • Actions
    • Set Variable Wins[Player number of (Triggering player)] = (Wins[Player number of (Triggering player)] + 1)
(Triggering player) will be set to whoever typed the message. Their Wins[] will be increased by 1. This single trigger will work
for as many players as you'd like. Just don't put a Wait action in there unless you know what you're doing because it can complicate things.

The basic idea for most Win/Loss save systems would be something like this:

Right before Defeating a player (they must still be in the game when you save), you increase their Losses by 1.
Right before giving a player Victory (again, they must still be in the game), you increase their Wins by 1.
You usually add all of losing players to a Player group and all of your winning players to a Player group beforehand.
Then you can use the Pick Every Player action to easily give the Picked players +1 Win/Loss.
Once that's said and done, you run the Save system for each player, saving their new records.

The only flaw with this system is that players can leave early to avoid getting a loss since it's only recorded at the
end of the game. A solution to this problem is to give every player a loss at the start of the game and then save. Then at the
end of the game, when a team/player has won, you simply subtract a loss from the winners and give them a win. The result
will be that anyone that has left/lost the game will have been given 1 loss and anyone that won will have been given 1 win.

If I were you I would read up on triggers some more and get a better idea of how everything works before jumping right into a system
as complicated as this one.
i used version modyfited from you but sometimes people desync at start of game any reason by what it can be caused?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Is it actually related to the save/load system?

People usually desync at the start of the game because you're doing something bad during Map Initialization. Checking a Player's controller/slot status for example isn't safe until everyone has loaded into the game.
 
Level 11
Joined
Jul 17, 2013
Messages
544
Is it actually related to the save/load system?

People usually desync at the start of the game because you're doing something bad during Map Initialization. Checking a Player's controller/slot status for example isn't safe until everyone has loaded into the game.
actually im not sure its so far two days since im using it in my map i kinda got stressed because i hate whenever i hear about desync. also any idea why your example map dissapeared from this thread? i was sure i downloaded it few weeks ago and i cant see it there anymore. idk if it matters but i changed directory folder renamed it to my map instead CodeLessDemo, next thing i did is
1679678962292.png
i am using this trigger at map init i changed it to 0.01 second
 
Status
Not open for further replies.
Top