• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Kill and Replace...

Status
Not open for further replies.
SOLVED!


The ReplaceUnitBJ function has so many callings, now in order to simplify this, it can be...

JASS:
local unit tar = LoadUnitHandle(udg_HASH, metkey, 2)
local unit newunit
call UnitApplyTimedLife(tar, 'BTLF', 0.03)
call ShowUnit(tar, false) //Is this necessary?...
call RemoveUnit(tar)
if random==1 then
   set newunit = CreateUnit(GetOwningPlayer(tar), MET_WARLOCK(), GetUnitX(tar), GetUnitY(tar), 0)   
endif

Now forget about the 'random' coz its in another function...also forget about the statelife and mana coz Im not applying it yet...

My questions are;
1. Does the RemoveUnit leak?...
2. What's the use of bj_lastReplacedUnit?...
3. Is this the simplified setup?, well I know that there's better...
 
Last edited:
Level 20
Joined
Jul 6, 2009
Messages
1,885
1. According to some people, yes. To clear it, you would need to explode the unit instead of removing it ExplodeUnitBJ
2. It's a global variable that gets the replaced unit assigned as value after ReplaceUnitBJ
3. I'm not sure what you mean but your example wouldn't work since you're removing the old unit and then trying to retrieve it's owner and coordinates; you have to save those values before removing the unit.
 
1. Ok, when exploding, does it play it's death animation? coz if it does
then it's no good...ReplaceUnitBJ has also "call RemoveUnit(oldUnit)",
but before that, it kills the old unit first...

3. The 'saving' was already done in another function so no need to worry
about it and I already tested and it worked, as you can see, I already
Load the 'tar' unit...
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
1. Ok, when exploding, does it play it's death animation? coz if it does
then it's no good...ReplaceUnitBJ has also "call RemoveUnit(oldUnit)",
but before that, it kills the old unit first...
I'm not sure if exploding the unit causes it to play some animation; test it and if it does, you can hide it first then explode it.
3. The 'saving' was already done in another function so no need to worry
about it and I already tested and it worked, as you can see, I already
Load the 'tar' unit...
If you assign a unit to a variable, it will just point to that unit so if the unit is removed, you can't retrieve it's information.
Are you sure that your trigger worked?

Just tested it and strangely it worked ;o
 
Status
Not open for further replies.
Top