| 05-19-2004, 10:45 PM | #1 |
It's been a long while since Ive messed with editing this game, but now a friend and I are starting a one map, singleplayer RPG. In it we have a "Time Mage". Here's the problem, we have come up with an idea to allow respawning of the Time Mage, an "ability" (although its not really, just triggering) that makes it so that when the Mage dies, time is "reset". I myself don't have extensive enough trigger knowledge to make this work, but I was hoping that one of you might. The original hope was that when the Time Mage dies, time goes back 30 seconds or so (doesnt need to be exact). Can anyone think of an efficient way to make checks when the hero dies against the position and status of units 30 seconds ago? It sounds impossible to me, but on a small scale one of you might be able to figure it out. If this isn't possible, do you have any other ideas as to how we could make a system based on manipulation of time for reviving the hero? |
| 05-19-2004, 11:36 PM | #2 |
Short of having 30 separate arrays, a custom value on EVERY unit that is different, and a semi-complex arithmatic sequence, no, this is not possible. It -MIGHT- be possible, but it would probably be very laggy and/or a hell of a lot of triggering. |
| 05-19-2004, 11:50 PM | #3 |
It wouldn't be too hard to just store a snapshot of the position, angle, HP, and mana of every unit. So you make a snapshot every 20 seconds, and keep a copy of the next oldest snapshot which will be between 20 and 40 seconds ago, then you always use the old one so that time will be rolled back by 30 seconds +/- 10 seconds. Get that? The main stuff that cannot be restored are current buffs/debuffs and cooldowns of nearly any type, ability cooldowns, attack cooldowns, corpse decay, blood stains, creep item drops (unless you make your own drop system), summoned unit life duration remaining (possible but hard!!). If your happy with just having units location, angle, hitpoints and mana reset then doable. Items can be reset, doodads technically possible but thats really sucking up resources, hero experience can be reset, and skills too if your a sucker for punishment. Might want to restore live/dead status too. The easiest way, something of a comprimise, would be to reset only units. Items dont get reset either on the ground or in inventory, this way you avoid problems with creep drops getting lost or duplicated. hero experience, skills are retained and the hero zoomed back to his old location, prehaps with his HP and mana reset too. All buffs and summoned units are destroyed and ability cooldowns reset, explained as the time-shift destroys all magic effects. My creep respawn system uses arrays to store a snapshot of all units on the map when the game starts, exactly the same principle could be used to store a snapshot every 20 seconds, but it's going to be more complicated ofcourse. Then when it comes to rollback time the trigger does this: Iterate over every unit in the array. If the picked unit is still alive, just restore it's location, hp, mana, reset it's ability cooldowns and clear all buffs. If it's dead now, destroy the old corpse (may have already been consumed by raise dead), and make a new unit, at the location with the old hp,mana. If it was dead at the time of snapshot, destroy the old corpse (may have already been consumed by raise dead) and create a new corpse of that unit type. That should give you a basic idea of what will be involved. |
| 05-20-2004, 12:25 AM | #4 |
Ok, so it is possible, will it lag the game beyond reason? (and really we were mostly thinking just units anyways) |
| 05-20-2004, 01:37 AM | #5 | |
Quote:
Done badly it could easily cause a lot of lag (due to memory leaks), but an effecient implementation should cause no noticable lag. And if the map is quite large it would only be nessecary to update the unit information for units in about a 20,000 radius of the hero (if the maps are small and chained together then it would be fine to update all the units on the map) |
