- Joined
- Sep 19, 2006
- Messages
- 152
The following trigger has the "smell" of inefficiency, but I can't seem to pin it down. Any suggestions?
JASS:
function EliteMonsterCreator takes unit creep_unit, integer PointsTotal returns nothing
local integer PointsPossible
local integer PointsCurrent
set udg_NumberOfElites = udg_NumberOfElites + 1
call SetUnitUserData (creep_unit, 100)
call SetUnitColor (creep_unit, PLAYER_COLOR_RED)
call SetUnitVertexColor (creep_unit, 150, 150, 150, 255)
call SetUnitScalePercent (creep_unit, 140.00, 140.00, 140.00)
call GroupAddUnit (udg_EliteGroup, creep_unit)
// Elite Monster Resistances
if PointsTotal > 4 then
set PointsPossible = 4
else
set PointsPossible = PointsTotal
endif
set PointsCurrent = GetRandomInt (0, PointsPossible)
set PointsTotal = PointsTotal - PointsCurrent
call UnitAddAbility (creep_unit, udg_EliteMonsterStat [PointsCurrent])
// Elite Monster Damage
if PointsTotal > 5 then
set PointsPossible = 5
else
set PointsPossible = PointsTotal
endif
set PointsCurrent = GetRandomInt (5, PointsPossible + 5)
call UnitAddAbility (creep_unit, udg_EliteMonsterStat [PointsCurrent])
// Elite Monster Life
if PointsTotal > 8 then
set PointsPossible = 8
else
set PointsPossible = PointsTotal
endif
set PointsCurrent = GetRandomInt (11, PointsPossible + 11)
call UnitAddAbility (creep_unit, udg_EliteMonsterStat [PointsCurrent])
// Elite Ability
if GetRandomInt (1, 4) == 4 then
call UnitAddAbility (creep_unit, 'A084')
if GetRandomInt (1, 4) == 4 then
call UnitAddAbility (creep_unit, 'A084')
endif
endif
if GetRandomInt (1, 10) == 10 then
call UnitAddAbility (creep_unit, 'Apig')
endif
endfunction
function CreepsCreation_Action01 takes nothing returns nothing
local integer n_LQualX25 = udg_LevelQualifier * 25
local integer n_CaveCount = udg_NumberOfCaveMonsters
local integer n_HutNumb = udg_HutNumber
local integer n_HutNumb_max = n_HutNumb + 2
local integer n_MonsterCap = udg_MonsterQuantity
local integer n_EliteCount = CountUnitsInGroup (udg_EliteGroup)
local integer n_TrollCount
local unit creep_spawn
local real creep_spawnX
local real creep_spawnY
local unit creep_unit
local integer creep_unitE
local integer R
// Create Monsters (Cave)
if n_CaveCount < 40 then
set R = (GetRandomInt (0, n_LQualX25) / 5) + 200
set creep_unit = CreateUnit (Player (12), udg_Monster [R], GetRandomReal (-3500.00, 5000.00), GetRandomReal (-11500.00, -10000.00), 0.00)
call RemoveGuardPosition (creep_unit)
// ** Create Elite Monster (Cave) **
if GetRandomInt (1, 30) == 30 then
set creep_unitE = GetUnitLevel (creep_unit)
if creep_unitE > 24 and n_EliteCount < 5 then
call EliteMonsterCreator (creep_unit, creep_unitE / 5)
endif
else
set udg_NumberOfCaveMonsters = n_CaveCount + 1
call SetUnitUserData (creep_unit, 80)
call SetUnitVertexColor (creep_unit, 150, 150, 150, 255)
endif
endif
// Create Monsters (Troll)
loop
exitwhen n_HutNumb == n_HutNumb_max
set n_TrollCount = CountUnitsInGroup (udg_TrollGroup [n_HutNumb])
if n_TrollCount < n_MonsterCap then
set creep_spawn = udg_TrollHut [n_HutNumb]
set creep_spawnX = GetUnitX (creep_spawn)
set creep_spawnY = GetUnitY (creep_spawn)
loop
exitwhen n_TrollCount == n_MonsterCap
set R = GetRandomInt (0, n_LQualX25) / 5
set creep_unit = CreateUnit (Player (12), udg_Monster [R], creep_spawnX, creep_spawnY, 0.00)
call SetUnitUserData (creep_unit, n_HutNumb)
call RemoveGuardPosition (creep_unit)
call SetUnitVertexColor (creep_unit, 150, 150, 150, 255)
call GroupAddUnit (udg_TrollGroup [n_HutNumb], creep_unit)
set n_TrollCount = n_TrollCount + 1
endloop
// ** Create Elite Monster (Troll) **
if GetRandomInt (1, 50) == 50 then
set creep_unitE = GetUnitLevel (creep_unit)
if GetUnitLevel (creep_unit) > 24 and n_EliteCount < 5 then
call EliteMonsterCreator (creep_unit, creep_unitE / 5)
endif
endif
endif
if n_HutNumb == 4080 then
set n_HutNumb = 4001
set n_HutNumb_max = 4001
else
set n_HutNumb = n_HutNumb + 1
endif
endloop
set udg_HutNumber = n_HutNumb
set creep_unit = null
set creep_spawn = null
endfunction
function InitTrig_CreepsCreation takes nothing returns nothing
set gg_trg_CreepsCreation = CreateTrigger ()
call TriggerAddAction (gg_trg_CreepsCreation, function CreepsCreation_Action01)
endfunction