Name | Type | is_array | initial_value |
//TESH.scrollpos=19
//TESH.alwaysfold=0
scope test initializer setup
function setup takes nothing returns nothing
//!//////////////////////////////////////
//! First Gnoll Hut with Thiefes Spawn //
//!//////////////////////////////////////
local unit hut = gg_unit_ngnh_0005 // Thats the gnoll hut Placed on the map where units should spawn
local player p = Player(11) // Units spawn for this Player (Player 12, Brown)
local integer SpawnType = 'nban' // The Unittype which spawns (Burglars)
local real facing = 300 // The facing of the spawn (Faces a bit in the direction where the heroes will come from)
local real EnemyRange = 400 // Does only spawn with any enemy in rangee of 400 near the hut
local real SpawnInterval = 3.25 // If enemys are near every 3.25 seconds a unit Spawns
local integer MaxEnemys = 5 // Spawn Stops while there are 5 spawns
local real CountRange = 500 // Max amount of spawns is counted in this range near the hut
local string SpawnEffect = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" // Effect while a unit spawns
//Actually calls the function with the values set above which initializes the library for the hut
call AddSpawnToHut(hut,p,SpawnType,facing,EnemyRange,SpawnInterval,MaxEnemys,CountRange,SpawnEffect)
// Sure this can be inlined but to add any comments I used variables
//!//////////////////////////////////////////
//! The Tree Murloc huts with murloc Spawn //
//!//////////////////////////////////////////
// After the variables adescriped above ill inline the other calls to save space
// All three huts hot a normal spawn of small murlocs
call AddSpawnToHut(gg_unit_nmh0_0000,Player(11),'nmrl',45,600,5.5,8,600,"Abilities\\Weapons\\MurgulMagicMissile\\MurgulMagicMissile.mdl" )
call AddSpawnToHut(gg_unit_nmg1_0011,Player(11),'nmrl',45,600,5.5,8,600,"Abilities\\Weapons\\MurgulMagicMissile\\MurgulMagicMissile.mdl" )
call AddSpawnToHut(gg_unit_nmh0_0006,Player(11),'nmrl',45,600,5.5,8,600,"Abilities\\Weapons\\MurgulMagicMissile\\MurgulMagicMissile.mdl" )
// The third hut has also a bigger spawn
call AddSpawnToHut(gg_unit_nmg1_0011,Player(11),'nmrm',45,600,18,2,600,"Abilities\\Weapons\\MurgulMagicMissile\\MurgulMagicMissile.mdl" )
//!/////////////////////
//! Clockwork Factory //
//!/////////////////////
// FOR GERONIMO !! KAMIKAZE GOBLINS !!!11
call AddSpawnToHut(gg_unit_nfac_0003,Player(11),'ncg1',300,300,0.25,14,600,"Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" )
//!////////////////
//! Spider Queen //
//!////////////////
// If its a unit or Builder which will be the "Spawn Base" does not matter
call AddSpawnToHut(gg_unit_nsbm_0001,Player(11),'nspr',180,400,1.75,5,600,"Objects\\Spawnmodels\\Demon\\DemonSmallDeathExplode\\DemonSmallDeathExplode.mdl" )
//blablubb
set hut = null
set p = null
endfunction
endscope
//TESH.scrollpos=158
//TESH.alwaysfold=0
/////////////////////////////////////////////////////////////////////////////////////////////////
// Spawn Library 1.0
// Created by JonNny
//
// ° Mapmaking since 2006...
// °
// °
// °
// °°°ÛÜ
// °°X°ÛÛÛ ÛÛÛÛÛÛÛÛ ÿÜÛÛÛÛÛÛÛÛÜ
// °°XX° ÛÛÛ ßÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °XX ° ÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °XX ° ÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛß ßÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °°XXX°° ÛÛÛÛÛÛÜ ÛÛÛÜ ÛÛÛÛÛ ßÛÛÛÛÛ ßÛÛÛÛ ÛÛÛÛÛÛ
// °°°°°°°° ÛÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÜ
// ÛÛÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÜ ÛÛÛÛ
// °°°°°°°° ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛÜ ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÜ ÜÛÛÛÛÛÛ
// °°XXXXX° ÛÛÛÛ ÛÛÛÜ ÛÛÛÛÛ ÛÛÛÛÛÛÜ ßÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °°XXXXX °° ÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛ °°°ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ°°° ÛÛÛÛÛÛÛÛÛÛÛÛÛß
// ° XXXXX °°ÛÛÛÛÛ°°°°ÛÛÛÛÛÛÛÛ°°XX ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ XXX°°ÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛ
// °° XXXXX ÜÛÛÛÛÛÛ X ÛÛÛÛÛÛÛÛÛ XXX ÛÛÛÛÛÛÛÛÛÛÛ XXXXXX ÛÛÛÛÛÛÛ° ÛÛÛ
// °° XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°° °°°°
// °° XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°X°°
// °°° XXXXXXXXXX °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° XXXXXXXXXXXXXXXXX°°
// °°°°°°°°°°°°°°°° °°°°°°°° XXXXXXX °°°
// °°°°°° XX °°
// ...2009 and still moving on. °°°°°°°
// °°
//
// What you need to use this Library :
// - Jass New Gen Pack due it uses vJass
//
// How to use this Library :
// - The only thing you really need is the AddSpawnToHut function
// - For detailed information about each variable check the struct in line 143 or better take a look at the Test trigger added to this testmap
//
// Please give Credits when using
library SL initializer init
globals
private constant real TimerPeriod = 0.25
// The Interval all checks and spawns are executed
// Its also the min. Step of Spawn Intervals
endglobals
function AddSpawnToHut takes unit hut, player Owner, integer Spawn, real Facing, real EnemyRange, real SpawnInterval, integer MaxUnits, real CountRange, string SpawnEffect returns nothing
// This is the main Function of this system to be used
// It initializes the spawn of the hut
// Fo detailed information what each variable stands for look in the struct
call SL.create(hut,Owner,Spawn,Facing,EnemyRange,SpawnInterval,MaxUnits,CountRange,SpawnEffect)
endfunction
/////////////////////////////////////////////System Script////////////////////////////////////////
globals
// Systems Variables
private timer t = CreateTimer()
private group g = CreateGroup()
private boolexpr ufilter = null
endglobals
private function UnitFilter takes nothing returns boolean
// Any Units counted in range of the hut (enemy/Spawns) have to match this condition
return (GetWidgetLife(GetFilterUnit()) > 0.405)
endfunction
private function CountUnitsInRangeOfType takes unit hut, real Range, integer UnitType, boolean Enemy returns integer
// This functions counts all units in range
// If the boolean Enemys == false it counts all units of the unittype in range
// If the boolean Enemys == true it counts every Enemy unit in range
local integer i = 0
local unit u
call GroupEnumUnitsInRange(g, GetUnitX(hut), GetUnitY(hut),Range, ufilter)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
//Condition for counting, set up as described above
if (GetUnitTypeId(u) == UnitType and GetOwningPlayer(u) == GetOwningPlayer(hut) and Enemy == false ) or ( IsPlayerEnemy(GetOwningPlayer(u),GetOwningPlayer(hut)) == true and Enemy == true ) then
set i = i + 1
endif
endloop
set u = null
return i
endfunction
private function Callback takes nothing returns nothing
local integer i = 0
local unit u
local SL d
loop
//Looping through all structs
exitwhen i >= SL.Index
set d = SL.Data[i]
//Sure the hut or unit where all spawns are created shouldnt be dead
if GetWidgetLife(d.hut) >= 0.405 then
set d.Counter = d.Counter + TimerPeriod
//Checks if enemys are near to spawn and if the max. amount of spawns isn reached
if CountUnitsInRangeOfType(d.hut,d.CountRange, d.SpawnType,false) < d.MaxUnits and CountUnitsInRangeOfType(d.hut,d.EnemyRange, d.SpawnType,true) != 0 then
if d.Counter >= d.SpawnInterval then
set d.Counter = d.Counter - d.SpawnInterval
//Spawning the unit
set u = CreateUnit(d.Owner,d.SpawnType,GetUnitX(d.hut),GetUnitY(d.hut),d.Facing)
call DestroyEffect(AddSpecialEffect(d.SpawnEffect,GetUnitX(u),GetUnitY(u)))
endif
else
// Even if no enemys are near or the max amout of units is reached the hut "prepares" to spawn
// that if the conditions above are true and a unit should be spawned it is spaned directly
// because i think it useless if you get near a hut in range and then after the spawn interval the first unit spawns
if d.Counter >= d.SpawnInterval then
set d.Counter = d.SpawnInterval - TimerPeriod
endif
endif
set i = i + 1
else
// Hut is destroeyed, struct gets removed
set d.hut = null
set d.Owner = null
call SL.destroy(d)
set SL.Index = SL.Index - 1
set SL.Data[i] = SL.Data[SL.Index]
endif
endloop
if SL.Index == 0 then
call PauseTimer(t)
endif
set u = null
endfunction
struct SL
static integer Index = 0
static SL array Data
unit hut // Main building or unit where all spawns are created
player Owner // The owner of the Spawns (should be the owner of the Hut)
integer SpawnType // The units which Spawn
real Facing // Units Facing when spawning
real EnemyRange // Units do only Spawn if an enemy is in this range
real SpawnInterval // IThe interval in which units Spawn if enemys are near
integer MaxUnits // Maximum units spawned at the same time
real CountRange // Max. Amount of units near the hut is counted in this range
string SpawnEffect // Special Effect created when a unit Spawns
real Counter // Current Counter of the Spawn
static method create takes unit hut, player Owner, integer Spawn, real Facing, real EnemyRange, real SpawnInterval, integer MaxUnits, real CountRange, string SpawnEffect returns SL
local SL d = SL.allocate()
// Setting all Variables
set d.hut = hut
set d.Owner = Owner
set d.SpawnType = Spawn
set d.EnemyRange = EnemyRange
set d.SpawnInterval = SpawnInterval
set d.MaxUnits = MaxUnits
set d.CountRange = CountRange
set d.SpawnEffect = SpawnEffect
set d.Facing = d.Facing
set d.Counter = SpawnInterval - TimerPeriod
set SL.Data[SL.Index] = d
//Starting the timer if it isnt already
if d.Index == 0 then
call TimerStart(t, TimerPeriod, true, function Callback)
endif
set d.Index = d.Index + 1
return d
endmethod
endstruct
private function init takes nothing returns nothing
//Setting up the unit filter
set ufilter = Filter(function UnitFilter)
endfunction
endlibrary