• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Create a system

Status
Not open for further replies.

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
I want to create a system which will stored all informations about a unit every seconds in the last 5 seconds. I mean it will store the HP, mana, position of the unit up to 5 seconds ago. If u still cannot understand what I really want, u should have a look through Dota Nerubian Weaver's Ultimate Time Warp. That ability allows Weaver to travel back to the position he was in 5 seconds ago, with his hp and mana like what he had 5 seconds ago.
I'm really sorry if many people cant understand my problem because of my terrible explanation but I have tried my best. If someone can explain it clearer, I'll glad if he/she post it. :D
 
Level 23
Joined
Oct 20, 2012
Messages
3,075
Every X time (something between 0.1 and 0.5 seconds seems the best imo), you save things in variables/hashtables. Let's say we make it 6seconds as you said, with a 0.5 periodic, you'll have 6/0,5 (12). So, you use only 12arrays/hashtable emplacments/variables. Every 0.5 seconds, for the values stored from 11 to 1, you save values to the next array/hashtable emplacment/variable (actual one + 1), and you save the actual ones at the array 1.
When your unit casts the spell, you give it the values saved in 12.

Also, for the unit's location, better to use coordonnates to avoid leaks.

Ninja_sheep said:
[Link to TheHelper.net thread]

okay, im actually not a dota player too, but i think i know how it works.
It safes every value (life, mana, gold, etc) in a variable with arrays every 0.01/2/3/4/5 seconds and if casting you get the older array and set the values (life, mana, gold, etc) to the value you ahve saved.

Here's a couple of solutions.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
if you want it MPI, make each variable array of size 12(or 15 for neutrals) (like for health, mana, positionX, positionY[X and Y to prevent leaks] and other stuff) and create periodic timer for like 0.1 sec(to not lag the game too much) and pick the unit of type whoever and store those values

if you want it MUI, just use some indexer and do the same as above(the size of array is undefined in that case, so you can keep it in 1 in gui)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Since u would be moving all units back u should use unit indexer by bribe. Every .1 seconds would be best. Then u use arrays and store all the into u need.

Pretty much wat edo said.

U will need a couple of arrays to store the different times. This will be a great system I made in vJass. GUI with the arrays will be a lot.
 
This is better put in hashtables rather than arrays considering the quantity of items that can possibly be saved...

Hmm... I thought systems could only be made MPI and not MUI... woah.

Of course they can be MUI... Where did you even get that idea? :)

For example: A missile system can be and needs to be MUI...
 
Last edited:

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Here is my current time system. It's pretty simple so if anyone thinks there will be problems with it, plz tell me so I can fix it.
  • Time Work
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Owner of (Matching unit)) controller) Equal to User)))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Set CV = (Custom value of (Picked unit))
          • Set TimePosition[CV] = (Position of (Picked unit))
          • Set TimeHP[CV] = (Life of (Picked unit))
          • Set TimeMana[CV] = (Mana of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeInteger[CV] Equal to 5
            • Then - Actions
              • Set TimeInteger[CV] = 1
            • Else - Actions
              • Set TimeInteger[CV] = (TimeInteger[CV] + 1)
          • Hashtable - Save TimeHP[CV] as TimeInteger[CV] of (Key (Picked unit)) in TimeHashtable
          • Hashtable - Save TimeMana[CV] as (TimeInteger[CV] x 10) of (Key (Picked unit)) in TimeHashtable
          • Hashtable - Save Handle OfTimePosition[CV] as (TimeInteger[CV] x 100) of (Key (Picked unit)) in TimeHashtable
          • Custom script: call RemoveLocation(udg_TimePosition[udg_CV])
Some explanation about how this will work: For example, I want to get my unit back 3s ago, then I'll check the TimeInteger, if it is less than 3, then set tempInt = 5 - TimeInteger, else set tempInt = TimeInteger - 3. Then based on the thing I want to get (HP = tempInt, Mana = tempInt x 10 and Position = tempInt x 100). Pretty simple, I think.
Some little question about the memory leaks:
Does Units in (playable area) leaks? The same question with (All Players)?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Unit group always leaks if not cleared
you should put one more custom script at the end(outside the group enumeration) so you destroy it

of you mean All Players as force(player group) then no that will not leak and you should mever destroy that one
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Well, guess I'll have to put it in :D. Oh, and MasterTrainer, if u dont think this system is too basic, too inefficency, then it's my pleasure to give it to ur map :D.
 
If I learned anything that deathismyfriend has showed me many times, I should tell you that it will be better if you stored (Picked Unit) and (Matching Unit) in a var and yes, (Units in (Playable Map Area)) does leak; leaks a loc.

Playable Map Area is not a loc; it is a rect. :wink:
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Yes. Dont want to touch the exp of that unit. :D. Travel back to time doesnt mean u get older or younger. It's just urself in the different time line. :D.
My purpose creating this system is my spell. It reverse the time in the targeted area back 5s.
 
Status
Not open for further replies.
Top