creeps

feistaghelm

New Member
Reaction score
2
I have a JASS code that I got from one of these posts that make creeps respawn as random creeps of the same level. Here tis...



function Trig_RespawnCreeps_Test takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) )
endfunction

function Trig_RespawnCreeps_Actions takes nothing returns nothing
local location Position = GetUnitLoc(GetDyingUnit())
local integer Level = GetUnitLevel(GetDyingUnit())
loop
call PolledWait( GetRandomReal(25.00, 55.00) )
exitwhen ( IsUnitGroupEmptyBJ(GetUnitsInRangeOfLocMatching(1536.00, Position, Condition(function Trig_RespawnCreeps_Test))) == true )
endloop
call CreateNUnitsAtLoc( 1, ChooseRandomCreepBJ(Level), Player(PLAYER_NEUTRAL_AGGRESSIVE), Position, bj_UNIT_FACING )
endfunction

function InitTrig_RespawnCreeps takes nothing returns nothing
set gg_trg_RespawnCreeps = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_RespawnCreeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_RespawnCreeps, function Trig_RespawnCreeps_Actions )
endfunction


Now my question is, how do I make the dead creep respawn as the same creep? I need it for quests mobs.

Thanks Tamisrah but I have no idea how to make your code work. I am horrible with JASS. Does anyone have a GUI code for respawning the same creep that died?

I got a great code for respawning the same creep that died. Took a little searching, which I am horrible at, but found it. here tis for anyone that needs it.


function Trig_Respawn5_Func_Test takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) )
endfunction

function Trig_Respawn5_Actions takes nothing returns nothing
local location tmpPoint = GetUnitLoc(GetDyingUnit())
local integer tmpUnit = GetUnitTypeId(GetDyingUnit())
loop
call PolledWait( GetRandomReal(240.00, 300.00) )
exitwhen ( IsUnitGroupEmptyBJ(GetUnitsInRangeOfLocMatching(1536.00, tmpPoint, Condition(function Trig_Respawn5_Func_Test))) )
endloop
call CreateNUnitsAtLoc( 1, tmpUnit, Player(PLAYER_NEUTRAL_AGGRESSIVE), tmpPoint, bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_Respawn5 takes nothing returns nothing
set gg_trg_Respawn5 = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Respawn5, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Respawn5, function Trig_Respawn5_Actions )
endfunction


Enjoy and thanks to AceHeart for both random and specific respawn codes.
 

Tamisrah

Active Member
Reaction score
16
JASS:
function RespawnCreeps_Filter takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) )
endfunction

function RespawnCreeps_Actions takes nothing returns nothing
    //============================================================
    // First store all information about the dead creep we need
    //===
    local unit u = GetDyingUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local integer id = GetUnitTypeId(u) // <- here we store the type of the dead creep so 
                                        //  we can create one of the same type later on
    local group g = CreateGroup()
    set u = null // clear the unit leak
    loop
        call TriggerSleepAction(GetRandomReal(25,55)) // after the unit died, wait a random amount of time
        //============================================================
        // this is IsUnitGroupEmptyBJ a bit more inlined
        // so we check if the area is clear of enemies
        //===
        bj_isUnitGroupEmptyResult = true
        call GroupEnumUnitsInRange(g,x,y,1536.,Filter(function RespawnCreeps_Filter))
        call ForGroup(, function IsUnitGroupEmptyBJEnum)
        // if we don't find any enemies within range, we can respawn the creep
        exitwhen (bj_isUnitGroupEmptyResult)
        call GroupClear(g) // make sure that the group is empty for the next test
    endloop
    // respawn the creep at the old location
    set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE),id,x,y,bj_UNIT_FACING)
    
    call DestroyGroup(g) // destroy our tempgroup
    g = null // clear the group leak
endfunction

function InitTrig_RespawnCreeps takes nothing returns nothing
    set gg_trg_RespawnCreeps = CreateTrigger()
    call TriggerRegisterPlayerUnitEvent(gg_trg_RespawnCreeps,Player(PLAYER_NEUTRAL_AGGRESSIVE),EVENT_PLAYER_UNIT_DEATH,null)
    call TriggerAddAction(gg_trg_RespawnCreeps,function RespawnCreeps_Actions)
endfunction
 

Skippy

Active Member
Reaction score
39
Thanks Tamisrah but I have no idea how to make your code work. I am horrible with JASS. Does anyone have a GUI code for respawning the same creep that died?
Just create trigger called RespawnCreeps, convert is to custom text and copy and paste Tamisrah's code.
 

feistaghelm

New Member
Reaction score
2
Error shows with this line:

call GroupEnumUnitsInRange(g,x,y,1536.,Filter(function RespawnCreeps_Filter))


But I got another that works. Thank you both for the codes and suggestions. +Rep
 
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