using corpses to attack

MasterOfRa

New Member
Reaction score
10
Is it possible to detect whether a meatwagon, or any unit with the ability to store corpses has any corpses, and if so, delete one? i would like to make meatwagons, use corpses to attack for something Im working on.
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
Try checking if they have the store corpses ability, then check their current cargo load. This is possible, seeming as the corpses are actually 'units,' just dead ones.
 

SanKakU

Member
Reaction score
21
try this

a unit is attacked

attaacking unit is the meat wagon...

create a dummy unit and have it cast a modified raise dead ability that raises another dummy unit

if there are other corpses around, those might rise to be the dummy unit instead...but if the unit really uses corpses to shoot maybe it should be able to use nearby corpses also instead of just the ones it's carrying.

a problem with this method is that it's a delayed reaction to remove the corpse. the ammo isn't removed until the target unit is attacked, instead of it being removed when the attacking unit attacks. so basically while the ammo is up in the air it's still in the inventory. once it hits, it's out. i guess in theory if the corpse missed perhpas the meat wagon would pick up the corpse to fire it again... heh, make of it what you will.
 

jwallstone

New Member
Reaction score
33
There is a Unit is Loaded event, which you can use to increment an integer representing the number of corpses in the meat wagon. Then just decrement the integer whenever a corpse is "used".
 

MasterOfRa

New Member
Reaction score
10
problem with that is how do you determine if the ability works, because the ability takes a short time to do, so it will not be able to stop the attack if you wait till its done to check if it worked
 

jwallstone

New Member
Reaction score
33
I assume it does, since a unit still has to be created and loaded by the game. I don't know what you meant in the previous post. Are you talking about the different spell events? Just use Unit Starts the Effect of an Ability, and that will trigger after the spell has just begun to work; i.e. mana is already deducted, target check is complete, spell has begun its effect.
 

MasterOfRa

New Member
Reaction score
10
here is my attempt

JASS:
library EnemyWaves initializer Init uses EnemyProperties, UnitProperties, Constants
globals
    private constant real PERIOD        = .1
    private constant integer WAVE_COUNT = 13
    private constant integer ENEMY_COUNT= 8
    
    private real POWER_MULT             = 1.0
    integer enemyQty                    = 0
    
    private real array UnitInfo[8][9]          // [enemyTypeNumber][whichStat]
    private real array WaveInfo[8][128]         // [enemyTypeNumber][waveAmount]
    private integer array UnitTypes             // 0th element is first unit type, 1th is second
    private real array TimeTillSpawn            // how many seconds till you can spawn one of this type

    private integer wave                = -1    // 0 is the first wave, 1 is second, ect
    private boolean isWaveOn            = false
    private timer t                     = null  // repeating timer, used for counting down time for spawns
    private timer waveTimer             = null
    private timerdialog tD              = null
endglobals
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function Spawn takes integer uid, real x, real y returns nothing
    local integer enemyCount
    local unit u
    local integer count = 0
    local EnemyProperties data
    local MeatWagon_Data meat
    local real iDamageMin       =       UnitInfo[uid][0] * POWER_MULT
    local real iDamageMax       =       UnitInfo[uid][1] * POWER_MULT
    local integer iCritChance   = R2I(  UnitInfo[uid][2] * POWER_MULT)
    local real iCritMult        =       UnitInfo[uid][3]
    local integer iHealthMax    = R2I(  UnitInfo[uid][4] * POWER_MULT)
    local integer iShield       = R2I(  UnitInfo[uid][5] * POWER_MULT)
    local integer iShieldGen    = R2I(  UnitInfo[uid][6] * POWER_MULT)
    local integer iMoveSpeed    = R2I(  UnitInfo[uid][7])
    local integer iBounty       = R2I(  UnitInfo[uid][8] * POWER_MULT)

    set u = CreateUnit(Player(11),UnitTypes[uid],x,y,0)
    if UnitTypes[uid] == UID_MEAT_WAGON then
        set meat = GetUnitIndex(u)
        set meat.owner = u
        loop
            exitwhen count >= 8
            set meat.stored[count] = null
            set count = count + 1
        endloop
        set MeatWagon_Data<u>  = meat
    endif
    set enemyQty = enemyQty + 1
    call CreateUnitProperties(u)
    call UnitSetMaxLife    (u,iHealthMax)
    call UnitSetMoveSpeed     (u,iMoveSpeed)
    set data = GetUnitIndex(u)
    set data.maxShield      = iShield
    set data.currentShield  = iShield
    set data.shieldGen      = iShieldGen
    set data.damageMin      = iDamageMin
    set data.damageMax      = iDamageMax
    set data.critChance     = iCritChance
    set data.critMult       = iCritMult
    set data.bounty         = iBounty
    set data.owner          = u
    set data.ttHealth       = CreateTextTag()
    set data.ttShield       = CreateTextTag()
    call SetTextTagPermanent(data.ttHealth, false)
    call SetTextTagPermanent(data.ttShield, false)
    if iShield != 0 then
        set data.isShieldOn = true
    else
        set data.isShieldOn = false
    endif
    set EnemyProperties<u>  = data
    set u = null

endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function SetPower takes nothing returns nothing
    local real amount = S2R(SubString(GetEventPlayerChatString(), 16, 30))
    local integer i = 0
    if (amount &gt;= 0.5) then
        loop
            call DisplayTimedTextToPlayer(Player(i), 0.52, -1.00,15,&quot;Difficulty set to &quot;+R2S(amount))
            set i = i + 1
            exitwhen i == bj_MAX_PLAYERS
        endloop
        set POWER_MULT = amount
    else
        call SimError(Player(0),&quot;Invalid Difficulty &quot;+R2S(amount))
    endif
    
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function GetPower takes nothing returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i), 0.52, -1.00,15,&quot;Difficulty is &quot;+R2S(POWER_MULT))
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function EndWave takes nothing returns nothing
    local integer count = 0
    call DisplayTextToPlayer(GetLocalPlayer(), 0.52, -1.00,&quot;Wave &quot;+I2S(wave + 1)+&quot; Finished!&quot;)
    set isWaveOn = false
    call DestroyTimerDialog(tD)
    set tD = null
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function StartWave takes nothing returns nothing
    local integer count
    if isWaveOn == false then
        if enemyQty == 0 then
            set wave = wave + 1
            if wave != WAVE_COUNT then
                set isWaveOn = true
                call DisplayTextToPlayer(GetLocalPlayer(), 0.52, -1.00,&quot;Starting Wave &quot;+I2S(wave + 1)+&quot;!&quot;)
                if wave == (WAVE_COUNT - 1) then
                    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.52, -1.00, 12,&quot;This is the Last Wave!&quot;) 
                    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.52, -1.00, 12,&quot;Not only does this wave last 5 minutes,&quot;) 
                    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.52, -1.00, 12,&quot;But monsters also spawn twice as fast as normal,&quot;)
                    call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.52, -1.00, 12,&quot;So get ready to Lose!&quot;)
                    call TimerStart(waveTimer,300.0,false,function EndWave)
                    call StopMusic( false )
                    call PlayMusic( gg_snd_Doom )
                else
                    call TimerStart(waveTimer,120.0,false,function EndWave)
                endif
                set tD = CreateTimerDialogBJ(waveTimer,&quot;Wave Ends In&quot;)
                loop
                    set TimeTillSpawn[count] = WaveInfo[count][wave]/((Players+.5) * 0.5)
                    set count = count + 1
                    exitwhen count &gt;= ENEMY_COUNT
                endloop
            else
                call DisplayTextToPlayer(GetLocalPlayer(), 0.52, -1.00,&quot;No Waves Left!&quot;)
            endif
        else
            call SimError(GetTriggerPlayer(),&quot;Error, cannot start wave while enemys exist!&quot;)
        endif
    else
        call SimError(GetTriggerPlayer(),&quot;Error, cannot start wave while in wave!&quot;)
    endif
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function WavePeriodic takes nothing returns nothing
    local integer count = 0
    local real x
    local real y
    if isWaveOn then
        loop
            if WaveInfo[count][wave] != 0 then
                set TimeTillSpawn[count] = TimeTillSpawn[count] - PERIOD
                if TimeTillSpawn[count] &lt;= 0 then
                    if enemyQty &lt; 12 then
                        set TimeTillSpawn[count] = WaveInfo[count][wave]/((Players+.5) * 0.5)
                        if GetRandomInt(0,1) == 1 then
                            if GetRandomInt(0,1) == 1 then
                                set x = 2000
                            else
                                set x = -2000
                            endif
                            set y = GetRandomInt(-2000,2000)
                        else
                            if GetRandomInt(0,1) == 1 then
                                set y = 2000
                            else
                                set y = -2000
                            endif
                            set x = GetRandomInt(-2000,2000)
                        endif
                        call Spawn(count,x,y)
                    endif
                endif
            endif
            set count = count + 1
            exitwhen count &gt;= ENEMY_COUNT
        endloop
    endif
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
function Init takes nothing returns nothing
    local trigger setPower      = CreateTrigger()
    local trigger getPower      = CreateTrigger()
    local trigger nextWave      = CreateTrigger()
    local integer count = 0
    
    set t = NewTimer()
    call TimerStart(t,PERIOD,true,function WavePeriodic)
    set waveTimer = NewTimer()
    
    set UnitTypes[count] = UID_GHOUL
    set UnitInfo [count][0]  =  10 // min damage
    set UnitInfo [count][1]  =  20 // max damage
    set UnitInfo [count][2]  =   5 // crit chance
    set UnitInfo [count][3]  =   2 // crit mult
    set UnitInfo [count][4]  =  25 // health
    set UnitInfo [count][5]  =   0 // shield
    set UnitInfo [count][6]  =   0 // shieldGen
    set UnitInfo [count][7]  = 250 // movement speed
    set UnitInfo [count][8]  =  50 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_ACOLYTE
    set UnitInfo [count][0]  =   0 // min damage
    set UnitInfo [count][1]  = 100 // max damage
    set UnitInfo [count][2]  =   2 // crit chance
    set UnitInfo [count][3]  =   2 // crit mult
    set UnitInfo [count][4]  =   5 // health
    set UnitInfo [count][5]  =  25 // shield
    set UnitInfo [count][6]  =   5 // shieldGen
    set UnitInfo [count][7]  = 325 // movement speed
    set UnitInfo [count][8]  =  30 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_ARCHER
    set UnitInfo [count][0]  =  10 // min damage
    set UnitInfo [count][1]  =  15 // max damage
    set UnitInfo [count][2]  =  10 // crit chance
    set UnitInfo [count][3]  =   4 // crit mult
    set UnitInfo [count][4]  =  75 // health
    set UnitInfo [count][5]  =   0 // shield
    set UnitInfo [count][6]  =   0 // shieldGen
    set UnitInfo [count][7]  = 200 // movement speed
    set UnitInfo [count][8]  =  75 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_ABOMINATION
    set UnitInfo [count][0]  =  25 // min damage
    set UnitInfo [count][1]  =  50 // max damage
    set UnitInfo [count][2]  =   5 // crit chance
    set UnitInfo [count][3]  =   3 // crit mult
    set UnitInfo [count][4]  = 300 // health
    set UnitInfo [count][5]  =   0 // shield
    set UnitInfo [count][6]  =   0 // shieldGen
    set UnitInfo [count][7]  = 185 // movement speed
    set UnitInfo [count][8]  = 150 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_MEAT_WAGON
    set UnitInfo [count][0]  =  75 // min damage
    set UnitInfo [count][1]  =  75 // max damage
    set UnitInfo [count][2]  =   5 // crit chance
    set UnitInfo [count][3]  =   1.5 // crit mult
    set UnitInfo [count][4]  = 100 // health
    set UnitInfo [count][5]  =   0 // shield
    set UnitInfo [count][6]  =   0 // shieldGen
    set UnitInfo [count][7]  = 100 // movement speed
    set UnitInfo [count][8]  = 100 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_SKELLY_WARRIOR
    set UnitInfo [count][0]  =   5 // min damage
    set UnitInfo [count][1]  =   8 // max damage
    set UnitInfo [count][2]  =  12 // crit chance
    set UnitInfo [count][3]  =   2 // crit mult
    set UnitInfo [count][4]  =  15 // health
    set UnitInfo [count][5]  =   0 // shield
    set UnitInfo [count][6]  =   0 // shieldGen
    set UnitInfo [count][7]  = 325 // movement speed
    set UnitInfo [count][8]  =  10 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_SKELLY_MAGE
    set UnitInfo [count][0]  =   5 // min damage
    set UnitInfo [count][1]  =   8 // max damage
    set UnitInfo [count][2]  =  12 // crit chance
    set UnitInfo [count][3]  =   2 // crit mult
    set UnitInfo [count][4]  =   5 // health
    set UnitInfo [count][5]  =  25 // shield
    set UnitInfo [count][6]  =   5 // shieldGen
    set UnitInfo [count][7]  = 325 // movement speed
    set UnitInfo [count][8]  =  20 // bounty
    
    set count = count + 1
    set UnitTypes[count] = UID_NECROMANCER
    set UnitInfo [count][0]  =  10 // min damage
    set UnitInfo [count][1]  =  15 // max damage
    set UnitInfo [count][2]  =  12 // crit chance
    set UnitInfo [count][3]  =   2 // crit mult
    set UnitInfo [count][4]  =  15 // health
    set UnitInfo [count][5]  = 150 // shield
    set UnitInfo [count][6]  =  15 // shieldGen
    set UnitInfo [count][7]  = 125 // movement speed
    set UnitInfo [count][8]  = 200 // bounty
    
    // Wave 1 [UnitId][WaveId]
    set count = 0
    set WaveInfo[0][count] =  4.0 // x means spawn one per x seconds
    set WaveInfo[1][count] =  0.0 // 0 means dont spawn it
    set WaveInfo[2][count] =  0.0
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 2
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  0.0
    set WaveInfo[2][count] =  0.0
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 3
    set count = count + 1
    set WaveInfo[0][count] =  4.0
    set WaveInfo[1][count] =  6.0 // Add acolyte
    set WaveInfo[2][count] =  0.0
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 4
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  4.8
    set WaveInfo[2][count] =  0.0
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 5
    set count = count + 1
    set WaveInfo[0][count] =  4.0
    set WaveInfo[1][count] =  6.0
    set WaveInfo[2][count] =  8.0 // Add Archer
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 6
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  4.8
    set WaveInfo[2][count] =  6.4
    set WaveInfo[3][count] =  0.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 7
    set count = count + 1
    set WaveInfo[0][count] =  4.0
    set WaveInfo[1][count] =  6.0
    set WaveInfo[2][count] =  8.0
    set WaveInfo[3][count] = 10.0 // Add Abomination
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 8
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  4.8
    set WaveInfo[2][count] =  6.4
    set WaveInfo[3][count] =  8.0
    set WaveInfo[4][count] =  0.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 9
    set count = count + 1
    set WaveInfo[0][count] =  4.0
    set WaveInfo[1][count] =  6.0
    set WaveInfo[2][count] =  8.0
    set WaveInfo[3][count] = 10.0
    set WaveInfo[4][count] = 12.0 // Add Meat Wagon
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 10
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  4.8
    set WaveInfo[2][count] =  6.4
    set WaveInfo[3][count] =  8.0
    set WaveInfo[4][count] =  9.6
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  0.0
    
    // Wave 11
    set count = count + 1
    set WaveInfo[0][count] =  4.0
    set WaveInfo[1][count] =  6.0
    set WaveInfo[2][count] =  8.0
    set WaveInfo[3][count] = 10.0
    set WaveInfo[4][count] = 12.0
    set WaveInfo[5][count] =  0.0 // Skip the unit the Necromancer summons
    set WaveInfo[6][count] =  0.0 // .... ... .... ... ........... .......
    set WaveInfo[7][count] = 14.0 // Add Necromancer
    
    // Wave 12
    set count = count + 1
    set WaveInfo[0][count] =  3.2
    set WaveInfo[1][count] =  4.8
    set WaveInfo[2][count] =  6.4
    set WaveInfo[3][count] =  8.0
    set WaveInfo[4][count] =  9.6
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] = 11.4
    
    // Wave 13
    set count = count + 1
    set WaveInfo[0][count] =  2.0 // make a wave, with all monsters spawning twice as fast as normal
    set WaveInfo[1][count] =  3.0
    set WaveInfo[2][count] =  4.0
    set WaveInfo[3][count] =  5.0
    set WaveInfo[4][count] =  6.0
    set WaveInfo[5][count] =  0.0
    set WaveInfo[6][count] =  0.0
    set WaveInfo[7][count] =  7.0
    
    
    call TriggerRegisterPlayerChatEvent( setPower    , Player(0), &quot;-enemy.setpower&quot;    , false )
    call TriggerRegisterPlayerChatEvent( getPower    , Player(0), &quot;-enemy.getpower&quot;    , false )
    
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.startwave&quot;    , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.wavestart&quot;    , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.wavenext&quot;     , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.nextwave&quot;     , true )
    
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.startlevel&quot;   , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.levelstart&quot;   , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.nextlevel&quot;    , true )
    call TriggerRegisterPlayerChatEvent( nextWave    , Player(0), &quot;-game.levelnext&quot;    , true )

    call TriggerAddAction( setPower    , function SetPower )
    call TriggerAddAction( getPower    , function GetPower )
    call TriggerAddAction( nextWave    , function StartWave )
    
    set setPower = null
    set getPower = null
    set nextWave = null
endfunction
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
//=======================================================================================================================
public function Restart takes nothing returns nothing
    set wave = -1
    set isWaveOn = false
    if tD != null then
        call DestroyTimerDialog(tD)
        set tD = null
    endif
    call PauseTimer(waveTimer)
endfunction
//=======================================================================================================================
endlibrary</u></u>
 
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