- Joined
- Sep 19, 2006
- Messages
- 152
Just wanted you pros to take a gander over the following trigger and alert me to any inefficiencies. Thanks!
JASS:
function CreepsItemCreator 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 CreepsDeath_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_unitD = GetUnitUserData (trig_unit)
local integer trig_unitE
local itempool I
local integer C
local integer P
local integer P_CWu
// Determine Killing Player
if kill_unitQ == 0 or kill_unitQ == 14 then
if trig_unitD > 3999 then
call GroupRemoveUnit (udg_TrollGroup [trig_unitD], trig_unit)
elseif trig_unitD == 80 then
call GroupRemoveUnit (udg_CaveGroup, trig_unit)
elseif trig_unitD == 100 then
call GroupRemoveUnit (udg_EliteGroup, trig_unit)
endif
set trig_unit = null
set kill_unit = null
return
elseif kill_unitQ == 15 then
set P = 1
loop
exitwhen P == 12
if kill_unit == udg_PlayerMerc or kill_unit == udg_PlayerCompan then
set kill_unitQ = P
set P = 12
else
set P = P + 1
endif
endloop
endif
// Scoring and Gold
set trig_unitE = GetUnitLevel (trig_unit)
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
if trig_unitD > 3999 then
call GroupRemoveUnit (udg_TrollGroup [trig_unitD], trig_unit)
elseif trig_unitD == 80 then
call GroupRemoveUnit (udg_CaveGroup, trig_unit)
elseif trig_unitD == 100 then
call GroupRemoveUnit (udg_EliteGroup, trig_unit)
endif
set trig_unit = null
set kill_unit = null
return
endif
// Create Items
set C = 0
if trig_unitD > 3999 then
call GroupRemoveUnit (udg_TrollGroup [trig_unitD], trig_unit)
set P_CWu = udg_PlayerItemUsed_CrstWater [kill_unitQ]
if P_CWu > 0 then
set udg_PlayerItemUsed_CrstWater [kill_unitQ] = P_CWu - 1
call CreepsItemCreator (trig_unit, trig_unitE, udg_PlayerChance_ItemBoost [kill_unitQ])
elseif udg_RealArray [kill_unitQ + 100] > GetRandomReal (0.00, 99.00) then
call CreepsItemCreator (trig_unit, trig_unitE, udg_PlayerChance_ItemBoost [kill_unitQ])
endif
elseif trig_unitD == 80 then
call GroupRemoveUnit (udg_CaveGroup, trig_unit)
set P_CWu = udg_PlayerItemUsed_CrstWater [kill_unitQ]
if P_CWu > 0 then
set udg_PlayerItemUsed_CrstWater [kill_unitQ] = P_CWu - 1
call CreepsItemCreator (trig_unit, trig_unitE, udg_PlayerChance_ItemBoost [kill_unitQ])
elseif udg_RealArray [kill_unitQ + 100] > GetRandomReal (0.00, 99.00) then
call CreepsItemCreator (trig_unit, trig_unitE, udg_PlayerChance_ItemBoost [kill_unitQ])
endif
elseif trig_unitD == 100 then
call GroupRemoveUnit (udg_EliteGroup, trig_unit)
call RemoveUnit (trig_unit)
if GetRandomInt (1, 2500) < trig_unitE and udg_UniqueIsAvail == true then
set udg_UniqueIsAvail = false
set I = CreateItemPool ()
call ItemPoolAddItemType (I, 'sehr', 1) // Crimson Cape of Evading
call ItemPoolAddItemType (I, 'gold', 1) // The Death Knell
call ItemPoolAddItemType (I, 'shhn', 1) // Pegasus Plate
call ItemPoolAddItemType (I, 'glsk', 1) // Pharaoh Band
call ItemPoolAddItemType (I, 'shea', 1) // Phoenix Gloves
call ItemPoolAddItemType (I, 'ratf', 1) // Ring of Perception
call ItemPoolAddItemType (I, 'spsh', 1) // Ring of Sevens
call ItemPoolAddItemType (I, 'ratf', 1) // Ring Of Perception
call ItemPoolAddItemType (I, 'infs', 1) // Scroll of Barkskin
call ItemPoolAddItemType (I, 'ledg', 1) // Scroll of Perfect Harmony
call ItemPoolAddItemType (I, 'rdis', 1) // Scroll of Serenity
call ItemPoolAddItemType (I, 'pmna', 1) // Stone Idol
call ItemPoolAddItemType (I, 'fwss', 1) // Vivacio
call PlaceRandomItem (I, GetUnitX (trig_unit), GetUnitY (trig_unit))
call DestroyItemPool (I)
set I = null
endif
set C = GetRandomInt (0, 3) + GetRandomInt (1, 4)
loop
exitwhen C == 0
call CreepsItemCreator (trig_unit, trig_unitE, udg_PlayerChance_ItemBoost [kill_unitQ])
set C = C - 1
endloop
endif
set trig_unit = null
set kill_unit = null
endfunction
function InitTrig_CreepsDeath takes nothing returns nothing
set gg_trg_CreepsDeath = CreateTrigger ()
call TriggerRegisterPlayerUnitEvent (gg_trg_CreepsDeath, Player (12), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddAction (gg_trg_CreepsDeath, function CreepsDeath_Action01)
endfunction