Hello, I recently released a game, WmW X14. The problem is that in almost every game, people are experiencing a fatal error at random moments. I also experience the error. The fatal error reads as follows:
This application has encountered a critical error:
Not enough storage is available to process this command.
Program: c:\programfiles (x86)\warcraft iii\war3.exe
File: .\cmemblock.cpp
Line: 372
It isn't my ram or anything, I believe it's something in the map itself that's causing this fatal error.
Here are some triggers that I believe MAY be related to the error:
This application has encountered a critical error:
Not enough storage is available to process this command.
Program: c:\programfiles (x86)\warcraft iii\war3.exe
File: .\cmemblock.cpp
Line: 372
It isn't my ram or anything, I believe it's something in the map itself that's causing this fatal error.
Here are some triggers that I believe MAY be related to the error:
Code:
Build Unit Top
Events
Unit - A unit Sells a unit
Conditions
((Sold unit) is A giant) Equal to True
((Triggering player) is in TopPlayers) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SendLimit[(Player number of (Triggering player))] Greater than or equal to 240
Then - Actions
Custom script: set udg_UnitCost = GetUnitGoldCost(GetSoldUnit())
Player - Add UnitCost to (Triggering player) Current gold
Unit - Remove (Sold unit) from the game
Custom script: call SimError(GetTriggerPlayer(), "You may only have 240 units on the map at once.")
Multiboard - Set the text for MB[1] item in column 3, row ((Player number of (Triggering player)) + 2) to (String(IncomeMulti[(Player number of (Triggering player))]))
Else - Actions
Set IncomeMulti[(Player number of (Triggering player))] = (IncomeMulti[(Player number of (Triggering player))] + (Point-value of (Sold unit)))
Multiboard - Set the text for MB[1] item in column 3, row ((Player number of (Triggering player)) + 2) to (String(IncomeMulti[(Player number of (Triggering player))]))
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
Set Income[(Player number of (Triggering player))] = (Income[(Player number of (Triggering player))] + (Point-value of (Sold unit)))
Set SendLimit[(Player number of (Triggering player))] = (SendLimit[(Player number of (Triggering player))] + 2)
Set Pattern_1 = (Pattern_1 + 2)
If (Pattern_1 Equal to 13) then do (Set Pattern_1 = 7) else do (Do nothing)
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Left Unit --------
Set TempPoint = (Center of Middle Center Bottom Left <gen>)
Unit - Create 1 (Unit-type of (Sold unit)) for (Player(Pattern_1)) at TempPoint facing Default building facing (270.0) degrees
Set UnitLeft = (Last created unit)
Point - Remove TempPoint
Set TempPoint = (Center of BottomMiddleLeft <gen>)
Unit - Order UnitLeft to Move To TempPoint
Point - Remove TempPoint
Unit Group - Add UnitLeft to UnitsTopLeft[1]
Unit - Set the custom value of UnitLeft to (Player number of (Triggering player))
Unit - Change color of UnitLeft to (Color of (Triggering player))
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Right Unit --------
Set TempPoint = (Center of Middle Center Bottom Right <gen>)
Unit - Create 1 (Unit-type of (Sold unit)) for (Player(Pattern_1)) at TempPoint facing Default building facing (270.0) degrees
Set UnitRight = (Last created unit)
Unit Group - Add UnitRight to UnitsTopRight[1]
Point - Remove TempPoint
Set TempPoint = (Center of BottomMiddleRight <gen>)
Unit - Order UnitRight to Move To TempPoint
Point - Remove TempPoint
Unit - Set the custom value of UnitRight to (Player number of (Triggering player))
Unit - Change color of UnitRight to (Color of (Triggering player))
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Create the Creep Spells --------
Set SpellPlayer = (Triggering player)
Set SpellUnit = UnitLeft
Trigger - Run CreepSpellCheck <gen> (ignoring conditions)
Set SpellUnit = UnitRight
Trigger - Run CreepSpellCheck <gen> (ignoring conditions)
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
-------- He's no longer needed. --------
Unit - Remove (Sold unit) from the game
Code:
CreepSpellCheck
Events
Conditions
Actions
-------- Spell execute is used to know whether or not to create the creep spell based on whether or not the data was set up. --------
Set SpellExecute = False
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Creeps that cast spells immediately. End with "set udg_SpellType = Condition(function Creep_TargetSelf)" --------
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to God (Level 33)
(Unit-type of SpellUnit) Equal to God (Superspeed Level 33)
Then - Actions
Set SpellExecute = True
Set SpellAbility = NullAbility
Set SpellBuff = NullEffect
Set SpellOrder = divineshield
Set SpellRange = 550.00
Custom script: set udg_SpellType = Condition(function Creep_TargetSelf)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Earth Spirit (Level 51)
(Unit-type of SpellUnit) Equal to Earth Spirit (Superspeed Level 51)
Then - Actions
Set SpellExecute = True
Set SpellAbility = NullAbility
Set SpellBuff = NullEffect
Set SpellOrder = divineshield
Set SpellRange = 550.00
Custom script: set udg_SpellType = Condition(function Creep_TargetSelf)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Ogre Lord (Level 12) (Boss)
(Unit-type of SpellUnit) Equal to Ogre Lord (SuperSpeed12) (Boss)
Then - Actions
Set SpellExecute = True
Set SpellAbility = NullAbility
Set SpellBuff = NullEffect
Set SpellOrder = divineshield
Set SpellRange = 550.00
Custom script: set udg_SpellType = Condition(function Creep_TargetSelf)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Creeps that heal other creeps. End with "set udg_SpellType = Condition(function Creep_TargetHealing)" --------
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Lopsided. (Level 43)
(Unit-type of SpellUnit) Equal to Lopsided. (Superspeed Level 43)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Healing Wave (Creeps)(4500)
Set SpellBuff = NullEffect
Set SpellOrder = healingwave
Set SpellRange = 500.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Ice Troll (Level 8)
(Unit-type of SpellUnit) Equal to Ice Troll (SuperSpeed8)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Healing Wave (Creeps)(80)
Set SpellBuff = NullEffect
Set SpellOrder = healingwave
Set SpellRange = 500.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Unholy Knight (Level 21)
(Unit-type of SpellUnit) Equal to Unholy Knight (SuperSpeed21)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Holy Light (Creeps)(1200)
Set SpellBuff = NullEffect
Set SpellOrder = holybolt
Set SpellRange = 700.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Duke Wintermaul (SuperSpeed 28)
(Unit-type of SpellUnit) Equal to Duke Wintermaul (Level 28)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Holy Light (Creeps)(2200)
Set SpellBuff = NullEffect
Set SpellOrder = holybolt
Set SpellRange = 700.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Hitman_Cloud7 (Level 40)
(Unit-type of SpellUnit) Equal to Hitman_Cloud7 (Superspeed Level 40)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Holy Light (Creeps)(5000)
Set SpellBuff = NullEffect
Set SpellOrder = holybolt
Set SpellRange = 700.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Unholy Sorcerer (Level 50)
(Unit-type of SpellUnit) Equal to Unholy Sorcerer (Superspeed Level 50)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Unholy Darkness (Creeps)(32000)
Set SpellBuff = NullEffect
Set SpellOrder = holybolt
Set SpellRange = 700.00
Custom script: set udg_SpellType = Condition(function Creep_TargetHealing)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Creeps that target other creeps. End with "set udg_SpellType = Condition(function Creep_TargetCreep)" --------
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Crystal Mage (Level 22)
(Unit-type of SpellUnit) Equal to Crystal Mage (SuperSpeed22)
(Unit-type of SpellUnit) Equal to Mystical Tree (Level 34)
(Unit-type of SpellUnit) Equal to Mystical Tree (SuperSpeed 34)
(Unit-type of SpellUnit) Equal to Demon (Level 59)
(Unit-type of SpellUnit) Equal to Demon (Superspeed Level 59)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Anti-Magic Shell (Creeps)
Set SpellBuff = Anti-magic Shell
Set SpellOrder = antimagicshell
Set SpellRange = 700.00
Custom script: set udg_SpellType = Condition(function Creep_TargetCreep)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- Creeps that target towers. End with "set udg_SpellType = Condition(function Creep_TargetTower)" --------
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Stalker (Level 6)
(Unit-type of SpellUnit) Equal to Stalker (SuperSpeed6)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Curse (Creeps)(Stalker)
Set SpellBuff = Curse (Creeps)
Set SpellOrder = curse
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Web Spinner (SuperSpeed 32)
(Unit-type of SpellUnit) Equal to Web Spinner (Level 32)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Curse (Creeps)(Web Spinner)
Set SpellBuff = Curse (Creeps)
Set SpellOrder = curse
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to StRoNgFoE (Level 41)
(Unit-type of SpellUnit) Equal to StRoNgFoE (Superspeed Level 41)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Curse (Creeps)(MTL_Killer)
Set SpellBuff = Curse (Creeps)
Set SpellOrder = curse
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Chaos Orc (Level 58)
(Unit-type of SpellUnit) Equal to Chaos Orc (Superspeed Level 58)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Curse (Creeps)(Chaos Orc)
Set SpellBuff = Curse (Creeps)
Set SpellOrder = curse
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to ToxicNRG (Level 44)
(Unit-type of SpellUnit) Equal to ToxicNRG (Superspeed Level 44)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Slow (Creeps)(40%)
Set SpellBuff = Slow (Creeps)
Set SpellOrder = slow
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Undead KinG (SuperSpeed 26)
(Unit-type of SpellUnit) Equal to Undead KinG (Level 26)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Slow (Creeps)(25%)
Set SpellBuff = Slow (Creeps)
Set SpellOrder = slow
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Eternal Spirit (Level 17)
(Unit-type of SpellUnit) Equal to Eternal Spirit (SuperSpeed17)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Slow (Creeps)(15%)
Set SpellBuff = Slow (Creeps)
Set SpellOrder = slow
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Frozen Infernal (Level 23)
(Unit-type of SpellUnit) Equal to Frozen Infernal (SuperSpeed23)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Glacial Spike (Creeps)(5)
Set SpellBuff = Glacial Spike (Creeps)
Set SpellOrder = thunderbolt
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Mithril Golem (Level 52)
(Unit-type of SpellUnit) Equal to Mithril Golem (Superspeed Level 52)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Glacial Spike (Creeps)(8)
Set SpellBuff = Glacial Spike (Creeps)
Set SpellOrder = thunderbolt
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Hydralisk (Level 31)
(Unit-type of SpellUnit) Equal to Hydralisk (SuperSpeed 31)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Crippling Venom (Creeps)
Set SpellBuff = Crippling Venom
Set SpellOrder = innerfire
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ------------------------------------------------------------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Unit-type of SpellUnit) Equal to Panda (Level 54)
(Unit-type of SpellUnit) Equal to Panda (Superspeed Level 54)
Then - Actions
Set SpellExecute = True
Set SpellAbility = Debilitate (Creeps)
Set SpellBuff = Debilitate
Set SpellOrder = innerfire
Set SpellRange = 850.00
Custom script: set udg_SpellType = Condition(function Creep_TargetTower)
Else - Actions
-------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
-------- If a spell was created, execute it. Nothing here ever needs to be modified. --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SpellExecute Equal to True
Then - Actions
Custom script: call CreateSpell()
Else - Actions
Code:
library CreepSpellSystem initializer Init requires FunctionCalls
globals
group TEMPGROUP
boolean TEMPBOOL
integer TEMPINT
player TEMPPLAYER
integer CI
unit array CAST_TARGET
integer array CASTDATALIMIT
boolean Z_CREEPSPELLALLOW = true
endglobals
function Creep_TargetTower takes nothing returns boolean
local unit u = GetFilterUnit()
if ((GetUnitAbilityLevel(u, TEMPINT) == 0) and (IsUnitTower(u))) then
set CI = (CI + 1)
set CAST_TARGET[CI] = u
endif
set u = null
return false
endfunction
function Creep_TargetCreep takes nothing returns boolean
local unit u = GetFilterUnit()
if ((IsUnitType(u, UNIT_TYPE_GIANT) == true) and (GetUnitAbilityLevel(u, TEMPINT) == 0) and (IsUnitEnemy(u, TEMPPLAYER) == false)) then
set CI = (CI + 1)
set CAST_TARGET[CI] = u
endif
set u = null
return false
endfunction
function Creep_TargetHealing takes nothing returns boolean
local unit u = GetFilterUnit()
if ((IsUnitType(u, UNIT_TYPE_GIANT) == true) and (GetWidgetLife(u) / GetUnitState(u, UNIT_STATE_MAX_LIFE) * 100.0 <= 50.0)) then
set CI = (CI + 1)
set CAST_TARGET[CI] = u
endif
set u = null
return false
endfunction
function Creep_TargetSelf takes nothing returns boolean
local unit u = GetFilterUnit()
if ((IsUnitTower(u)) and (TEMPBOOL == false)) then
set TEMPBOOL = true
endif
set u = null
return false
endfunction
struct CreepSpell
unit creep
integer playerid
integer spellid
integer buffid
string spellorder
boolexpr spelltype
real spellrange
timer cycle
player play
static method create takes unit creep, integer playerid, integer spellid, integer buffid, string spellorder, real spellrange, boolexpr spelltype returns CreepSpell
local CreepSpell d = CreepSpell.allocate()
set d.creep = creep
set d.playerid = playerid
set d.spellid = spellid
set d.buffid = buffid
set d.spellorder = spellorder
set d.spellrange = spellrange
set d.spelltype = spelltype
set d.cycle = NewTimer()
set d.play = GetOwningPlayer(creep)
call SetTimerData(d.cycle, d)
set CASTDATALIMIT[playerid] = (CASTDATALIMIT[playerid] + 1)
if (spellid == 'A05S') then
call TimerStart(d.cycle, 4.75, false, function CreepSpell.ImmediateCast)
else
call TimerStart(d.cycle, 4.75, false, function CreepSpell.TargetCast)
endif
return d
endmethod
static method TargetCast takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit dummy = null
local unit target = null
local integer i = 0
local CreepSpell d = GetTimerData(t)
if (GetWidgetLife(d.creep) > 0) then
set CI = 0
if (GetUnitAbilityLevel(d.creep, 'BNsi') == 0) then
set TEMPINT = d.buffid
set TEMPPLAYER = d.play
call GroupEnumUnitsInRange(TEMPGROUP, GetUnitX(d.creep), GetUnitY(d.creep), d.spellrange, d.spelltype)
endif
if (CI > 0) then
set target = CAST_TARGET[GetRandomInt(1, CI)]
set dummy = CreateUnit(d.play, 'h062', GetUnitX(d.creep), GetUnitY(d.creep), 270.0)
call UnitAddAbility(dummy, d.spellid)
call IssueTargetOrder(dummy, d.spellorder, target)
call UnitApplyTimedLife(dummy, 'BTLF', 2)
call TimerStart(d.cycle, 8.0, false, function CreepSpell.TargetCast)
set dummy = null
set target = null
else
call TimerStart(d.cycle, 2.0, false, function CreepSpell.TargetCast)
endif
else
call d.destroy()
endif
set t = null
endmethod
static method ImmediateCast takes nothing returns nothing
local timer t = GetExpiredTimer()
local CreepSpell d = GetTimerData(t)
if (GetWidgetLife(d.creep) > 0.0) then
set TEMPBOOL = false
if (GetUnitAbilityLevel(d.creep, 'BNsi') == 0) then
call GroupEnumUnitsInRange(TEMPGROUP, GetUnitX(d.creep), GetUnitY(d.creep), d.spellrange, d.spelltype)
endif
if (TEMPBOOL) then
call IssueImmediateOrder(d.creep, d.spellorder)
call TimerStart(d.cycle, 8.00, false, function CreepSpell.ImmediateCast)
call Reorder.create(d.creep, 0.05)
else
call TimerStart(d.cycle, 2.00, false, function CreepSpell.ImmediateCast)
endif
else
call d.destroy()
endif
set t = null
endmethod
method onDestroy takes nothing returns nothing
call ReleaseTimer(.cycle)
set CASTDATALIMIT[.playerid] = (CASTDATALIMIT[.playerid] - 1)
if (CASTDATALIMIT[.playerid] < 0) then
set CASTDATALIMIT[.playerid] = 0
endif
endmethod
endstruct
function CreateSpell takes nothing returns nothing
local integer i = GetPlayerId(udg_SpellPlayer) + 1
local integer id = GetUnitTypeId(udg_SpellUnit)
local CreepSpell data
if ((CASTDATALIMIT[i] <= 40) and (Z_CREEPSPELLALLOW)) then
set data = CreepSpell.create(udg_SpellUnit, i, udg_SpellAbility, udg_SpellBuff, udg_SpellOrder, udg_SpellRange, udg_SpellType)
endif
endfunction
private function Init takes nothing returns nothing
local integer x = 1
set TEMPGROUP = CreateGroup()
loop
exitwhen x > 6
set CASTDATALIMIT[x] = 0
set x = x + 1
endloop
endfunction
endlibrary
Code:
library FunctionCalls requires TimerUtils, GroupUtils
//-----------------------------------------------------------------------------------------------------------------
// -- Function to check if a unit has an ability. (Shortcut instead of always GetUnitAbilityLevel != 0.)
function UnitHasAbility takes unit u, integer i returns boolean
return (GetUnitAbilityLevel(u, i) != 0)
endfunction
//-----------------------------------------------------------------------------------------------------------------
// -- Function to display text to all players. (Replaces local code in DisplayTimedTextToForce.)
function DisplayMessageTop takes real duration, string message returns nothing
local integer i = 0
loop
exitwhen i >= 2
call DisplayTimedTextToPlayer(Player (i), 0, 0, duration, message)
set i = i + 1
endloop
endfunction
function DisplayMessageBottom takes real duration, string message returns nothing
local integer i = 3
loop
exitwhen i >= 5
call DisplayTimedTextToPlayer(Player (i), 0, 0, duration, message)
set i = i + 1
endloop
endfunction
//-----------------------------------------------------------------------------------------------------------------
// Checks to see if a unit is a tower.
function IsUnitTower takes unit u returns boolean
return (IsUnitType(u, UNIT_TYPE_MECHANICAL) == true) or (IsUnitType(u, UNIT_TYPE_ANCIENT) == true)
endfunction
//-----------------------------------------------------------------------------------------------------------------
// Creates hovering text over a unit.
function CreateFadeTextOnUnit takes unit target, string message, integer Xoffset, integer Yoffset, integer Hoffset, integer red, integer green, integer blue, real duration returns nothing
local texttag t = CreateTextTag()
local real x = GetUnitX(target)
local real y = GetUnitY(target)
local real xv = 0.044375 * Cos(90 * bj_DEGTORAD)
local real yv = 0.044375 * Sin(90 * bj_DEGTORAD)
call SetTextTagText(t, message, 0.0220) //0.0184
call SetTextTagPos(t, x + Xoffset, y + Yoffset, Hoffset)
call SetTextTagColor(t, red, green, blue, 255)
call SetTextTagVelocity(t, xv, yv)
call SetTextTagVisibility(t, true)
call SetTextTagPermanent(t, false)
call SetTextTagLifespan(t, duration)
call SetTextTagFadepoint(t, 1)
set t = null
endfunction
// Simplifier function to use less paramters than the original.
function CreateHoverText takes unit target, string message, integer Red, integer Green, integer Blue returns nothing
call CreateFadeTextOnUnit(target, message, -25, 0, 10, Red, Green, Blue, 1.60)
endfunction
//-----------------------------------------------------------------------------------------------------------------
// Simulates an error message like the game console.
function SimError takes player p, string s returns nothing
set s = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+s+"|r"
if (GetTriggerPlayer() == p) then
call ClearTextMessages()
call DisplayTimedTextToPlayer(p, 0.52, 0.96, 2.0, s)
call StartSound( gg_snd_Error )
endif
endfunction
//-----------------------------------------------------------------------------------------------------------------
// SetResourceState is a function to set the player's resource state with arithmetic functions.
globals
constant playerstate GOLD = ConvertPlayerState(1) // Alternative to using the Blizzard functions.
constant playerstate LUMB = ConvertPlayerState(2) // Alternavite to using the Blizzard functions.
constant integer ADD = 0 // Used when calling function to add.
constant integer SUB = 1 // Used when calling function to subtract.
constant integer MPL = 2 // Used when calling function to multiply.
constant integer DIV = 3 // Used when calling function to divide.
constant integer SET = 4 // Used when calling function to set the value manually.
endglobals
function SetResourceState takes player p, playerstate state, integer sign, integer newnumber returns nothing
if (sign == 0) then
call SetPlayerState(p, state, GetPlayerState(p, state) + newnumber)
elseif (sign == 1) then
call SetPlayerState(p, state, GetPlayerState(p, state) - newnumber)
elseif (sign == 2) then
call SetPlayerState(p, state, GetPlayerState(p, state) * newnumber)
elseif (sign == 3) then
call SetPlayerState(p, state, GetPlayerState(p, state) / newnumber)
elseif (sign == 4) then
call SetPlayerState(p, state, newnumber)
endif
endfunction
//-----------------------------------------------------------------------------------------------------------------
// This function is used to get the gold cost of a unit.
function XRemoveX takes nothing returns nothing
local unit u = GetSoldUnit()
call RemoveUnit(u)
set u = null
endfunction
function GetUnitGoldCost takes unit z returns integer
local trigger t = CreateTrigger()
local integer d = GetUnitTypeId(z)
local unit u = CreateUnit(Player(15), 'nshf', GetRectCenterX(gg_rct_Path), GetRectCenterY(gg_rct_Path), 270.0)
call UnitAddAbility(u, 'Asud')
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_SELL)
call TriggerAddAction(t, function XRemoveX)
call SetResourceState(Player(15), GOLD, SET, 1000000)
call SetResourceState(Player(15), LUMB, SET, 1000000)
call SetPlayerState(Player(15), PLAYER_STATE_RESOURCE_FOOD_CAP, 200)
call AddUnitToStock(u, d, 1, 1)
call IssueImmediateOrderById(u, d)
call RemoveUnit(u)
call DestroyTrigger(t)
set u = null
set t = null
return (1000000 - GetPlayerState(Player(15), PLAYER_STATE_RESOURCE_GOLD))
endfunction
//*****************************************************************************************************************
// -- Universal struct to move a unit based on the group it's currently in.
// -- Struct to reorder a unit after a given amount of time, takes the unit and how long to wait til moving it again.
struct Reorder
unit u
timer t
static method create takes unit toMove, real moveTime returns Reorder
local Reorder data = Reorder.allocate()
set data.u = toMove
set data.t = NewTimer()
call SetTimerData(data.t, data)
call TimerStart(data.t, moveTime, false, function Reorder.StartMove)
return data
endmethod
static method StartMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local Reorder data = GetTimerData(t)
if (GetWidgetLife(data.u) > 0.00) then
call Reorder.CreepMove(data.u)
endif
call data.destroy()
set t = null
endmethod
static method CreepMove takes unit u returns nothing
if (IsUnitInGroup(u, udg_UnitsTopLeft[1])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomMiddleLeft), GetRectCenterY(gg_rct_BottomMiddleLeft))
elseif (IsUnitInGroup(u, udg_UnitsTopLeft[2])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))
elseif (IsUnitInGroup(u, udg_UnitsTopLeft[3])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomCenter), GetRectCenterY(gg_rct_BottomCenter))
elseif (IsUnitInGroup(u, udg_UnitsTopRight[1])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomMiddleRight), GetRectCenterY(gg_rct_BottomMiddleRight))
elseif (IsUnitInGroup(u, udg_UnitsTopRight[2])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))
elseif (IsUnitInGroup(u, udg_UnitsTopRight[3])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomCenter), GetRectCenterY(gg_rct_BottomCenter))
elseif (IsUnitInGroup(u, udg_UnitsTopShip)) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_BottomShip), GetRectCenterY(gg_rct_BottomShip))
elseif (IsUnitInGroup(u, udg_UnitsBottomLeft[1])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopMiddleLeft), GetRectCenterY(gg_rct_TopMiddleLeft))
elseif (IsUnitInGroup(u, udg_UnitsBottomLeft[2])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))
elseif (IsUnitInGroup(u, udg_UnitsBottomLeft[3])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopCenter), GetRectCenterY(gg_rct_TopCenter))
elseif (IsUnitInGroup(u, udg_UnitsBottomRight[1])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopMiddleRight), GetRectCenterY(gg_rct_TopMiddleRight))
elseif (IsUnitInGroup(u, udg_UnitsBottomRight[2])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))
elseif (IsUnitInGroup(u, udg_UnitsBottomRight[3])) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopCenter), GetRectCenterY(gg_rct_TopCenter))
elseif (IsUnitInGroup(u, udg_UnitsBottomShip)) then
call IssuePointOrder(u, "move", GetRectCenterX(gg_rct_TopShip), GetRectCenterY(gg_rct_TopShip))
endif
endmethod
method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
endstruct
//*****************************************************************************************************************
// -- Used to add a creep to a specific unit group.
function GroupSetup takes unit u, group g returns nothing
call GroupRemoveUnit(udg_UnitsTopLeft[1], u)
call GroupRemoveUnit(udg_UnitsTopLeft[2], u)
call GroupRemoveUnit(udg_UnitsTopLeft[3], u)
call GroupRemoveUnit(udg_UnitsTopRight[1], u)
call GroupRemoveUnit(udg_UnitsTopRight[2], u)
call GroupRemoveUnit(udg_UnitsTopRight[3], u)
call GroupRemoveUnit(udg_UnitsTopShip, u)
call GroupRemoveUnit(udg_UnitsBottomLeft[1], u)
call GroupRemoveUnit(udg_UnitsBottomLeft[2], u)
call GroupRemoveUnit(udg_UnitsBottomLeft[3], u)
call GroupRemoveUnit(udg_UnitsBottomRight[1], u)
call GroupRemoveUnit(udg_UnitsBottomRight[2], u)
call GroupRemoveUnit(udg_UnitsBottomRight[3], u)
call GroupRemoveUnit(udg_UnitsBottomShip, u)
call GroupAddUnit(g, u)
endfunction
//*****************************************************************************************************************
// Text functions to clear all text from the screen.
function ClearAllTextForce1 takes nothing returns nothing
local integer i = 1
loop
exitwhen (i > 22)
call DisplayMessageTop(0.01, " ")
set i = i + 1
endloop
endfunction
function ClearAllTextForce2 takes nothing returns nothing
local integer i = 1
loop
exitwhen (i > 22)
call DisplayMessageBottom(0.01, " ")
set i = i + 1
endloop
endfunction
//*****************************************************************************************************************
//Function to play sounds when player upgrades units.
function UpgradeSounds takes nothing returns nothing
if GetLocalPlayer() == Player(0) then
call StartSound (gg_snd_KnightUpgradeComplete1)
elseif GetLocalPlayer() == Player(1) then
call StartSound (gg_snd_KnightUpgradeComplete1)
elseif GetLocalPlayer() == Player(2) then
call StartSound (gg_snd_KnightUpgradeComplete1)
elseif GetLocalPlayer()==Player(3) then
call StartSound (gg_snd_KnightUpgradeComplete1)
elseif GetLocalPlayer()==Player(4) then
call StartSound (gg_snd_KnightUpgradeComplete1)
elseif GetLocalPlayer()==Player(5) then
call StartSound (gg_snd_KnightUpgradeComplete1)
endif
endfunction
endlibrary