- Joined
- Sep 19, 2006
- Messages
- 152
Just wanted an extra set of eyes over this trigger, for the purposes of efficiency and leakage. One point to consider however: the undead units have a negative regeneration in daylight and therefore die (thus the != null condition).
JASS:
function CreepsDeathUndead_Condition01 takes nothing returns boolean
return GetKillingUnit () != null
endfunction
function UndeadItemCreator takes unit trig_unit, integer trig_unitE, integer P_CIB returns nothing
local item drop_item
local integer drop_itemE
local integer drop_itemJ
if GetRandomInt (1, 10) > P_CIB then
set drop_itemE = GetRandomInt (0, trig_unitE / 8)
elseif GetRandomInt (1, 50) > P_CIB then
set drop_itemE = GetRandomInt (0, trig_unitE / 8) + 1
else
set drop_itemE = GetRandomInt (0, trig_unitE / 8) + 2
endif
if drop_itemE > 9 then
set drop_itemE = GetRandomInt (2, 9)
endif
set drop_item = CreateItem (ChooseRandomItem (drop_itemE), GetUnitX (trig_unit), GetUnitY (trig_unit))
set drop_itemJ = GetItemTypeId (drop_item)
if drop_itemJ == 'mgtk' or drop_itemJ == 'srrc' or drop_itemJ == 'mcri' or drop_itemJ == 'sres' then
call SetItemInvulnerable (drop_item, true)
call SetItemUserData (drop_item, 200)
endif
call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", drop_item, "origin"))
set drop_item = null
endfunction
function CreepsDeathUndead_Action01 takes nothing returns nothing
local unit kill_unit = GetKillingUnit ()
local integer kill_unitQ = GetPlayerId (GetOwningPlayer (kill_unit))
local unit trig_unit = GetDyingUnit ()
local integer trig_unitE = GetUnitLevel (trig_unit)
local integer q
local integer P_CWu
local item drop_item
local itempool I
// Determine Killing Player
if kill_unitQ == 15 then
set q = 1
loop
exitwhen q == 12
if kill_unit == udg_PlayerMerc [q] then
set kill_unitQ = q
set q = 12
elseif kill_unit == udg_PlayerFamiliar [q] then
set kill_unitQ = q
set q = 12
else
set q = q + 1
endif
endloop
if kill_unitQ == 15 then
set trig_unit = null
set kill_unit = null
return
endif
endif
// Scoring and Gold
set udg_PlayerKills [kill_unitQ] = udg_PlayerKills [kill_unitQ] + 1
set udg_PlayerKillsLevels [kill_unitQ] = udg_PlayerKillsLevels [kill_unitQ] + trig_unitE
// Filter Computer Hero
if udg_PlayerTypeIsHuman [kill_unitQ] == false then
set trig_unit = null
set kill_unit = null
return
endif
// Create Items (Undead-specific)
set P_CWu = udg_PlayerItemUsed_CrstWater [kill_unitQ]
if P_CWu > 0 then
set udg_PlayerItemUsed_CrstWater [kill_unitQ] = P_CWu - 1
call UndeadItemCreator (trig_unit, trig_unitE, udg_PlayerChanceItemBoost [kill_unitQ])
elseif udg_RealArray [kill_unitQ + 100] + udg_RealArray [kill_unitQ + 160] > GetRandomReal (0.00, 99.00) then
call UndeadItemCreator (trig_unit, trig_unitE, udg_PlayerChanceItemBoost [kill_unitQ])
elseif GetRandomInt (1, 35) == 1 then
set I = CreateItemPool ()
if GetRandomInt (1, 10) == 1 then
call ItemPoolAddItemType (I, 'I05J', 1) // Bone Powder
call ItemPoolAddItemType (I, 'I05F', 1) // Crypt Wand
call ItemPoolAddItemType (I, 'I05E', 1) // Grave Wand
call ItemPoolAddItemType (I, 'I05D', 1) // Tomb Relic
call ItemPoolAddItemType (I, 'I05N', 1) // Vial of Evolution
set drop_item = PlaceRandomItem (I, GetUnitX (trig_unit), GetUnitY (trig_unit))
else
call ItemPoolAddItemType (I, 'I05M', 4) // Black Zombie Hide
call ItemPoolAddItemType (I, 'I05R', 4) // Carrion Bird Wing
call ItemPoolAddItemType (I, 'I05Q', 4) // Grey Zombie Hide
call ItemPoolAddItemType (I, 'I05O', 2) // Mossy Skull
call ItemPoolAddItemType (I, 'I05G', 4) // Rotted Limb
call ItemPoolAddItemType (I, 'I05S', 4) // Skull
call ItemPoolAddItemType (I, 'I05P', 5) // Slime
call ItemPoolAddItemType (I, 'I05K', 1) // Specter Soul
call ItemPoolAddItemType (I, 'I05I', 1) // Wraith Soul
call ItemPoolAddItemType (I, 'I05H', 4) // Yellow Zombie Hide
call ItemPoolAddItemType (I, 'I05T', 2) // Zombie Heart
set drop_item = PlaceRandomItem (I, GetUnitX (trig_unit), GetUnitY (trig_unit))
call SetItemUserData (drop_item, 210)
endif
call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", drop_item, "origin"))
call DestroyItemPool (I)
set I = null
set drop_item = null
endif
set trig_unit = null
set kill_unit = null
endfunction
function InitTrig_CreepsDeathUndead takes nothing returns nothing
set gg_trg_CreepsDeathUndead = CreateTrigger ()
call TriggerRegisterPlayerUnitEvent (gg_trg_CreepsDeathUndead, Player (14), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition (gg_trg_CreepsDeathUndead, Condition (function CreepsDeathUndead_Condition01))
call TriggerAddAction (gg_trg_CreepsDeathUndead, function CreepsDeathUndead_Action01)
endfunction