time travel

Moridin

Snow Leopard
Reaction score
144
Hey guys. A small request from me. I'm looking into time travel effects and I was wondering if you could help me out.

Firstly, by time travel I mean:

A unit/All units of a player/All units of all players , backtracking to a certain point in time, and obtaining past values, including health, mana, items, gold, etc.

Now, the term game cache came up somewhere, so What I Want is this:

1) If someone could either explain game cache to me (what it is, how it works, how to use it) or point out a tutorial doing the same.

2) Any suggestions as to how to go about this would also be helpful.

Thanks.
 

crazyfanatic

New Member
Reaction score
20
For now i cant make a tutorial, but i can tell you, that you must set variables that are same count as the max back traveling. When you start the ability restore the variables captured X secs ago.
 

LightChaosma

New Member
Reaction score
60
2 thing that comes to mind...
lag...
impossible

if you have to store all the data of all units, evry X seconds...

if a unit dies, you cannot revive it, so all saved data regarding that unit is lost

game cache i dont know... i would think of hashtables....
 

Moridin

Snow Leopard
Reaction score
144
Well. It seems impossible, but I know that it has been partly done in Dota (to some extent). A hero in Dota has the ability to go back in time 5 seconds, regaining past life and mana (not cooldowns though).

I do understand that what they do there ^ is a pretty simple life/mana variable setting and calling. I wanted to know if it could be a bit more extensive.
 

N(O.O)B

New Member
Reaction score
27
Well. It seems impossible, but I know that it has been partly done in Dota (to some extent). A hero in Dota has the ability to go back in time 5 seconds, regaining past life and mana (not cooldowns though).

I do understand that what they do there ^ is a pretty simple life/mana variable setting and calling. I wanted to know if it could be a bit more extensive.

You can try storing the unit in a Game Cache every half a second or so (I don't think that laggs); that automatically saves health/mana/items/experience, though I'm not sure if it also saves cooldowns (probably not, it'll probably reset them), and you'd have to store points/facing individually

Edit: A Game Cache is basically a "Cache" (yea) in which you can store values, such as units, integers, reals, and it will *duplicate* them inside the Cache, so you can withdraw them later. It's actually primarily used in campaigns as you can transfer data from Map to Map using them (items/experience are all saved), though you could use them for time travel. They're pretty simple to operate:

First create a Game Cache:
Trigger:
  • Events
    • Map Initialization
    • Conditions
    • Actions
      • Game Cache - Create a game cache from TimeTravel.w3v
      • Set GameCache = (Last created game cache)

Then Store the Unit:
Trigger:
  • Events
    • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Game Cache - Store <unit> as <string> of <string> in GameCache

Then load it
Trigger:
  • Events
    • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Time Travel
    • Actions
      • Game Cache - Restore <string> of <string> from GameCache for (Owner of TimeTravel) at <point> facing <angle>


So if you would want to be able to go back 5 seconds in time you could use the following actions:
Trigger:
  • Events
    • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TimeTravel Less than 10
        • Then - Actions
          • Set TimeTravel = (TimeTravel + 1)
        • Else - Actions
          • Set TimeTravel = 1
      • Game Cache - Store TimeTravelUnit as (Time + (String(TimeTravel))) of Time in Game Cache
      • Set TimeTravelPoint[TimeTravel] = (Position of (TimeTravelUnit))
      • Set TimeTravelAngle[TimeTravel] = (Facing of (TimeTravelUnit))

Then load the values
Trigger:
  • Events
    • Unit - A unit Finishes casting an Ability
    • Conditions
      • (Ability Being Cast) Equal To Time Travel
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TimeTravel Equal to 10
        • Then - Actions
          • Set TimeTravelTemp = 1
        • Else - Actions
          • Set TimeTravelTemp = (TimeTravel + 1)
      • Unit - Remove (Casting unit) from the game
      • Game Cache - Restore (Time + (String(TimeTravelTemp)) of Time from GameCache for (Owner of (Casting unit)) at TimeTravelPoint[TimeTravelTemp] facing TimeTravelAngle[TimeTravelTemp]
      • Camera - Pan camera for (Owner of (Casting unit)) to TimeTravelPoint[TimeTravelTemp] over 0.00 seconds
      • Selection - Add (Last restored unit) to selection for (Owner of (Casting unit))


That should work, though I'm not sure if it maintains the proper cooldowns (probably not, WC3 is very strict about cooldowns, you cannot alter them in any way)

This would only be usable on one single unit though, using this system on all units of a player would completely destroy the game because of lagg. If you're looking to create this sort of thing in a campaign or something, try using Check Points instead, in which you store the data of all units owned by the player
 

LightChaosma

New Member
Reaction score
60
u can use hashtables for that... problem is hashtables have only 2 indices...

you can store the locatio, mana, life.... ehm... facing angle... the target of him at that point...pretty mach anything...

you could accoplish this by using 1 hashtable per second you want to go back.

every 1 second of the game
copy the values of hashtable timetogoback-1 to hashtable timetogoback
.
.
.
copy the values of hashtable 2 to hashtable 3
copy the values of hashtable 1 to hashtable 2
set the values of the hashtable in hashtable 1



abilty execute
load vbalues from table



seeing you are helping others quitte well, i guess you can fill in the rest

P.S. it could be that game cashe is far more effiecent, but i never used tgat
 

Moridin

Snow Leopard
Reaction score
144
Hmm...Thanks for the idea LightChaosma. Will try out a few things based on that and test it out.

@N.O.O.B: You seem to have some experience with game cache. Could you explain how it works and what it does? If you're a little busy, then you can also point the way to a tutorial, etc that I could read.
 

N(O.O)B

New Member
Reaction score
27
Hmm...Thanks for the idea LightChaosma. Will try out a few things based on that and test it out.

@N.O.O.B: You seem to have some experience with game cache. Could you explain how it works and what it does? If you're a little busy, then you can also point the way to a tutorial, etc that I could read.

A Game Cache is just a sort of "extended variable" in which you can store values (you can store integers, reals, booleans, strings and units), though you can store integers, reals, booleans and strings in real variables too, Game Caches handle "units" a little differently, as rather than linking a variable with a unit (the variable is the unit) the game cache creates a duplicate of the unit and stores that, which you can recall later. It stores the following characteristics of a unit:
Current Life, Current Mana, Current Experience, Current Items Carried, All Skills the Unit has (or has learned for Heroes), Hero Skill Points; it basically stores everything except for Cooldowns, Location and Angle (which you will have to store seperately, except for cooldowns which cannot be stored), refer to my post above to learn how to use Game Caches
 

Moridin

Snow Leopard
Reaction score
144
Wow. Very detailed description, thank you. Will do a bit more research and then play around with it until I get it done right.

Thanks to everyone who replied. Again, a link to a tutorial (if there is one / if one might be necessary) that will help me learn the extents of game cache would be appreciated.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top