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

Create Corpse

Status
Not open for further replies.
Of the several methods to create a corpse none is stranger than the way to literally create a corpse; native CreateCorpse takes player whichPlayer, integer unitid, real x, real y, real face returns unit. However, if you want to create a permanent corpse you need;
JASS:
function CreatePermanentCorpseLocBJ takes integer style, integer unitid, player whichPlayer, location loc, real facing returns unit
    set bj_lastCreatedUnit = CreateCorpse(whichPlayer, unitid, GetLocationX(loc), GetLocationY(loc), facing)
    call SetUnitBlendTime(bj_lastCreatedUnit, 0)

    if (style == bj_CORPSETYPE_FLESH) then
        call SetUnitAnimation(bj_lastCreatedUnit, "decay flesh")
        call GroupAddUnit(bj_suspendDecayFleshGroup, bj_lastCreatedUnit)
    elseif (style == bj_CORPSETYPE_BONE) then
        call SetUnitAnimation(bj_lastCreatedUnit, "decay bone")
        call GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit)
    else
        // Unknown decay style - treat as skeletal.
        call SetUnitAnimation(bj_lastCreatedUnit, "decay bone")
        call GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit)
    endif

    call TimerStart(bj_delayedSuspendDecayTimer, 0.05, false, null)
    return bj_lastCreatedUnit
endfunction
What is so special about the started time, the unit group, and the blend time? What if i want a permanent corpse that doesn't go away, but works with Raise Dead, Animate Death, Resurrection, Cannibalize, and Pick Up Corpse?
What if i wanted to remove the corpse later from the game? What special things do i need to do to not cause errors?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
function CreateCorpsePerm takes player p, integer unitid, real x, real y, real facing returns unit
    local unit u = CreateCorpse(p, unitid, x, y, facing)

    call UnitSuspendDecay(u, true)
    call SetUnitBlendTime(u, 0)
    call SetUnitAnimation(u, "decay bone")

    set udg_u = u
    
    set u = null
    
    return udg_u
endfunction
 
Status
Not open for further replies.
Top