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

[vJASS] Problem: Temporary Unit Removal

Status
Not open for further replies.
Level 2
Joined
Apr 7, 2008
Messages
19
I am developing a spell that is intended to temporarily remove a unit from the game. That is, after casting the spell on a target, the target cannot perform any actions and cannot be observed by any player for a specified duration. Additional specifications include the target being unavailable for any other spell interactions until the duration passes and the unit is restored.

Using "ShowUnit(u, true/false)" is not sufficient as the unit u can still perform autoattacks and move around.

Using "DisableUnitTimed(u, real)" from Risking_DUsk's UnitStatus is problematic in that it will not work on a unit that is hidden via "ShowUnit(u, false)".

The brute force solution I have for this is to use "DisableUnitTimed(u, real)" and then use "ShowUnit(u, false)" after the passage of a small unit of time (ex. 1/16th of a second). This is not desirable.

A more elegant solution is desired. Does anyone have any ideas?
 
Level 2
Joined
Apr 7, 2008
Messages
19
There are too many side effects that pausing causes, primarily the extension of many ordinary melee spells. The context of the spell in question is a modded melee map.
 
Level 2
Joined
Apr 7, 2008
Messages
19
I've considered this, but I'm not sure if I can actually move units off of the playable map area (in which case, this would work relatively well).

I have been working on an invulnerability system to augment the current spell. As it is, it functions well enough, but if there is a really good method for this sort of effect, I am still looking.
 
Level 13
Joined
Nov 7, 2014
Messages
571
There's an ability called "Item Soul Theft" of an item called "Soul Gem" that does something like this but may have some side effects.

I've considered this, but I'm not sure if I can actually move units off of the playable map area (in which case, this would work relatively well).

Well if you can't do that then... you could remove the unit "for real", temporary of course =):

JASS:
globals
    gamecache cachy
endglobals

function cachy_init takes nothing returns nothing
    call FlushGameCache(InitGameCache("foo-bar.cache"))
    set cachy = InitGameCache("foo-bar.cache")
endfunction

// remove unit, temporary
...
call StoreUnit(cachy, "", "temporay-removed-unit", temporary_removed_unit)

// store the unit's current life, mana, user-data, etc., because those are not respected by RestoreUnit, if you care

call RemoveUnit(temporary_removed_unit)
set temporary_removed_unit = null
...

// restore
...
set temporary_removed_unit = RestoreUnit(cachy, "", "temporary-removed-unit", Player(...), x, y, facing)
...

RestoreUnit takes care of the hero's level, items and abilities, or at least it should... =)
 
Status
Not open for further replies.
Top