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

Getting time left on timed life

Status
Not open for further replies.
Level 7
Joined
Dec 9, 2014
Messages
89
Hi,

When a unit is spawned in my map I give it an expiration timer of 120 seconds. However when the unit reaches a region I am using 'replace unit using the old unit's relative life and mana' (ship turns to land unit) and the replaced unit does not have the expiration timer.

How can I detect and transfer over the remaining expiration time, is there any way to do this? I thought about using timers for each unit that updates the remaining time in a hashtable for each but that seems demanding since there will be 100s of units on the map at any one time. Is there an alternative where I can replace the units model and keep the timer?
 
Level 12
Joined
Nov 3, 2013
Messages
989
You could do the same thing, but with a periodic event instead of timer.


I remember seeing new natives regarding timed life and such Producer Update: Natives List but after a quick glance I haven't been able to spot one which checks for current elapsed time.

However I did see this:

function GetUnitBuffElapsed takes unit u, integer rawcode returns real and function GetUnitBuffRemaining takes unit u, integer rawcode returns real

Though they don't appear to be listed under the already added section. (But the post hasn't been updated since march, so maybe it's been added by now idk)
 
Level 39
Joined
Feb 27, 2007
Messages
5,008
Is there an alternative where I can replace the units model and keep the timer?
With a custom model with 2 geosets with different animation tags :D

Don't know it will work but did you try both Chaos and passive Bear Form morph? Hero passive transformation

It might be worth trying UnitMakeAbilityPermanent() on the rawcode of the timed life you used before attempting the morph. It sounds real dumb but... who knows, maybe that would actually do something.
 
Status
Not open for further replies.
Top