creep revival system

icond3maker

New Member
Reaction score
6
once again, I have a problem... when I kill a unit and kill another one...
Sometimes they exchange places o_O
Example.
Legends :
o~ = rat
>~ = wolf

o~

>~

Becomes this :

>~

o~

It exchanges places with the other unit died also. Here is my trigger :
JASS:
function Trig_Creep_Reviving_Func009001 takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction

function Trig_Creep_Reviving_Func009002 takes nothing returns boolean
    return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) != true )
endfunction

function Trig_Creep_Reviving_Conditions takes nothing returns boolean
    if ( not GetBooleanAnd( Trig_Creep_Reviving_Func009001(), Trig_Creep_Reviving_Func009002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Creep_Reviving_Actions takes nothing returns nothing
    local integer utype = GetUnitTypeId(GetTriggerUnit())
    set udg_Temp_Type = utype
    call CreateEffectLoc( OffsetLocation(GetRectCenter(GetEntireMapRect()), udg_CREEPX[GetUnitUserData(GetTriggerUnit())], udg_CREEPY[GetUnitUserData(GetTriggerUnit())]), "Abilities\\Spells\\NightElf\\TrueshotAura\\TrueshotAura.mdl", 30.00 )
    call TriggerSleepAction( 30.00 )
    call CreateNUnitsAtLoc( 1, udg_Temp_Type, Player(PLAYER_NEUTRAL_AGGRESSIVE), OffsetLocation(GetRectCenter(GetEntireMapRect()), udg_CREEPX[GetUnitUserData(GetTriggerUnit())], udg_CREEPY[GetUnitUserData(GetTriggerUnit())]), GetUnitFacing(GetTriggerUnit()) )
    call SetUnitUserData( GetLastCreatedUnit(), GetUnitUserData(GetTriggerUnit()))
endfunction

//===========================================================================
function InitTrig_Creep_Reviving takes nothing returns nothing
    set gg_trg_Creep_Reviving = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Creep_Reviving, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Creep_Reviving, Condition( function Trig_Creep_Reviving_Conditions ) )
    call TriggerAddAction( gg_trg_Creep_Reviving, function Trig_Creep_Reviving_Actions )
endfunction

Any answer to my problem?
 

Dirac

22710180
Reaction score
147
Your system fails, it would only revive the unit on the place it died, so if a player decides to kite it around would cause problems.

I recomend you storing every unit that enters the game belongin to hostiles in a hashtable with the position where it was placed, if the unit dies just look for it's index and respawn after x seconds in the location... Requires MUI knowledge
 

tooltiperror

Super Moderator
Reaction score
231
Dirac, of course, you could use GUI AIDS for that. I love indexers.

JASS:

 //globals
 //udg_XArray[8191]
 //udg_YArray[8191]
 //endglobals
 function IsCreep takes unit whichUnit returns nothing
     if GetOwningPlayer(whichUnit)==bj_ALLIANCE_NEUTRAL then
       return true
       // Of course, you can always add more to this.
     endif
     return false
 endfunction
 function onDeath takes nothing returns nothing
     local unit u=GetTriggerUnit()
     local integer index=GetUnitUserData(u) // Is this the native?  I forget.
       if IsCreep(u) then
           call CreateUnit(Player(11),'rawc',udg_XArray[index],udg_YArray[index],270.0)
       endif
 endfunction
 function onEnter takes nothing returns nothing
     local unit u=GetTriggerUnit()
     local integer index=GetUnitUserData(u)
     set udg_XArray[index]=GetUnitX(u)
     set udg_YArray[index]=GetUnitY(u)
 endfunction
 function onInit takes nothing returns nothing
     //pretend I register on-death event for onDeath
     //and onEnter event for onEnter.
 endfunction
 

Azylaminaz

Vox Populi
Reaction score
91
JASS:
function respawnCreep_Condition takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) == false and GetOwningPlayer(GetTriggerUnit()) == Player(12)
endfunction

function respawnCreep_Actions takes nothing returns nothing
    local integer uType = GetUnitTypeId(GetDyingUnit())
    local real x = GetUnitX(GetDyingUnit())
    local real y = GetUnitY(GetDyingUnit())
    local real f = GetUnitFacing(GetDyingUnit())
    local integer uData = GetUnitUserData(GetDyingUnit())
    local effect e = AddSpecialEffect("Abilities\\Spells\\NightElf\\TrueshotAura\\TrueshotAura.mdl", x, y)
    call TriggerSleepAction(30)
    call SetUnitUserData(CreateUnit(Player(12), uType, x, y, f), uData)
    call DestroyEffect(e)
    set e = null
endfunction

//===========================================================================
function InitTrig_respawnCreep takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t, function respawnCreep_Condition)
    call TriggerAddAction(t, function respawnCreep_Actions)
endfunction

Looks like you just converted your trigger to JASS to post it, not sure. CreatEffectLoc isn't even a call.. IDK, know nothing about BJ functions. :p

If you did mean JASS, you're in the wrong forum.

The CREEPY/CREEPX are confusing. Not sure what you are trying to do there...
 

icond3maker

New Member
Reaction score
6
Your system fails, it would only revive the unit on the place it died, so if a player decides to kite it around would cause problems.

I recomend you storing every unit that enters the game belongin to hostiles in a hashtable with the position where it was placed, if the unit dies just look for it's index and respawn after x seconds in the location... Requires MUI knowledge

not really , i just forgot to post the trigger that sets the custom value to the creature. It revives in its own position ( not the place where he died ).
I'll just fix some things and i hope it will work
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top