Name | Type | is_array | initial_value |
AB_DLS | string | No | |
AB_lastCreatedAB | string | No | |
abilityHash | hashtable | No | |
ABUnit | unit | No | |
AF_artifactText | string | No | |
AF_effectText | string | Yes | |
AF_methodText | string | No | |
aFLoc | location | No | |
AIPaused | boolean | No | |
ArcaneForge_B_A2Main | button | No | |
ArcaneForge_B_Accept | button | No | |
ArcaneForge_B_Artifact | button | No | |
ArcaneForge_B_ArtifactMenu | button | No | |
ArcaneForge_B_Effect | button | Yes | |
ArcaneForge_B_Method | button | No | |
ArcaneForge_B_NextCharacter | button | No | |
ArcaneForge_B_Quit | button | No | |
ArcaneForge_B_U2Main | button | No | |
ArcaneForge_B_UpgradeMenu | button | No | |
ArcaneForgeCharacter_MB | multiboard | No | |
ArcaneForgeMenu_Artifact | dialog | No | |
ArcaneForgeMenu_Main | dialog | No | |
ArcaneForgeMenu_MB | multiboard | No | |
ArcaneForgeMenu_Upgrade | dialog | No | |
ArcaneForgeNext | button | No | |
ArcaneForgeSC_Index | integer | No | |
ArcaneForgeSelectedCharacter | unit | Yes | |
ArtifactSelected | integer | No | |
assignmentData | hashtable | No | |
assignmentDataParent | integer | No | |
assignmentDataPlayerInt | integer | No | |
battlegolem | integer | No | |
Beacon01 | unit | No | |
Beacon02 | unit | No | |
Beacon03 | unit | No | |
Beacon04 | unit | No | |
Beacons | group | No | |
BronzeDragon | unit | No | |
BronzeDragons | group | No | |
CameraFocusIndex_CurrentCamera | integer | No | |
camlockunit | unit | No | |
ChildOfAir | unit | No | |
ChildOfAirDefeated | boolean | No | |
ChildOfAirGroup | group | No | |
CineCam | unit | No | |
CineEric | unit | No | |
CineHerodin | unit | No | |
CineKael | unit | No | |
CineLilith | unit | No | |
CinematicGroup | group | No | |
CinematicGroup01 | group | No | |
CinematicGroup02 | group | No | |
CinematicModeOn | boolean | No | |
CinematicTimer | timer | No | |
CinematicTransmissionTime | boolean | No | |
CinematicTransmissionTimer | timer | No | |
CineMyrax | unit | No | |
CineSaira | unit | No | |
CineUnit | unit | No | |
CineWell | unit | No | |
const_trainingQueueSize | integer | No | 5 |
cryptfiend | integer | No | |
CurrentMusicList | string | No | |
DarkRangerLilith | unit | No | |
DarkTroll | unit | No | |
DeathKnight | unit | No | |
DeathKnightGroup | group | No | |
demon1 | integer | No | |
Dhjeri | unit | No | |
Dragon | unit | No | |
DragonIDS | string | No | |
DragonMomIDS | string | No | |
Dreadlord | unit | No | |
dT_trackingData | hashtable | No | |
DwarfBridgeDefenders | group | No | |
EarthKing | unit | No | |
EarthKingDefeated | boolean | No | |
Eclipsa | unit | No | |
EffectSelected | trigger | Yes | |
Eric_Dest | location | No | |
Eric_Group | group | No | |
Eric_HomeDefense | group | No | |
Eric_ImproveParty | boolean | No | |
Eric_MainTown | rect | No | |
Eric_NeedUnits | boolean | No | |
Eric_Outposts | group | No | |
Eric_PartyHealthQuotient | real | No | |
Eric_PartyNumWanted | integer | No | 6 |
Eric_PartyReady | boolean | No | |
Eric_PartyRemainingHealth | real | No | |
Eric_PartyStartingHealth | real | No | |
Eric_PartyStartingNumbers | integer | No | |
Eric_Point01 | location | No | |
Eric_Point02 | location | No | |
Eric_ReturnHome | boolean | No | |
Eric_ScoutMode | boolean | No | true |
Eric_Timer01 | timer | No | |
Eric_Timer02 | timer | No | |
Eric_Timer03 | timer | No | |
Eric_Workers | group | No | |
ericFirstTH | unit | No | |
ericPlayerID | integer | No | 3 |
EricsForces_Wave_Level | integer | No | |
EternityWorm | unit | No | |
Ethereal | unit | No | |
execTrainingFuncHash | hashtable | No | |
felhound1 | integer | No | |
FireElementals | group | No | |
FireOgre | unit | No | |
fireOgre_firstAttack | boolean | No | true |
fireOgre_vis | rect | No | |
FireOgreDefeated | boolean | No | |
fO_tauntText | texttag | No | |
fxDragon | effect | No | |
fxs_dispel | string | No | |
g_attackSound | sound | No | |
G_FText | texttag | No | |
GaleDefeated | boolean | No | |
GaleWinterFreeze | unit | No | |
gameloop | real | No | 0.06 |
gameloop_fx | real | No | 0.06 |
gameloop_x2 | real | No | 0.06 |
generalHash | hashtable | No | |
GFight_Heroes | group | No | |
giantSkeleton | integer | No | |
gravityZ | real | No | -0.10 |
Gustivus | unit | No | |
Gustivus_RestartOn | boolean | No | |
Herodin | unit | No | |
Herodin_Dest | location | No | |
Herodin_Group | group | No | |
Herodin_HomeDefense | group | No | |
Herodin_ImproveParty | boolean | No | |
Herodin_MainTown | rect | No | |
Herodin_NeedUnits | boolean | No | |
Herodin_Outposts | group | No | |
Herodin_PartyHealthQuotient | real | No | |
Herodin_PartyNumWanted | integer | No | 6 |
Herodin_PartyReady | boolean | No | |
Herodin_PartyRemainingHealth | real | No | |
Herodin_PartyStartingHealth | real | No | |
Herodin_PartyStartingNumbers | integer | No | |
Herodin_Point01 | location | No | |
Herodin_Point02 | location | No | |
Herodin_ReturnHome | boolean | No | |
Herodin_ScoutMode | boolean | No | true |
Herodin_Timer01 | timer | No | |
Herodin_Timer02 | timer | No | |
Herodin_Timer03 | timer | No | |
Herodin_Workers | group | No | |
herodinFirstTH | unit | No | |
herodinPlayerID | integer | No | 3 |
HeroGroup | group | No | |
HoldingDown | boolean | No | |
HoldingLeft | boolean | No | |
HoldingRight | boolean | No | |
HoldingUp | boolean | No | |
HOMLevel | integer | No | |
HxNumOfRiflemen | integer | No | |
hydra | integer | No | |
iceTroll | integer | No | |
iceTrollP | integer | No | |
IDautospell | integer | No | |
Kael | unit | No | |
lastCDLS | string | No | |
lastCHash | hashtable | No | |
lastCheckedCondition | string | No | |
lastCPassed | boolean | No | |
lastCreatedObjectIDS | string | No | |
LastCreatedOrderHashT | hashtable | No | |
LastCreatedOrderID | integer | No | |
LastCreatedOrderParentPath | string | No | |
LastCreatedOrderPath | string | No | |
LastCreatedOrderPlayerID | integer | No | |
LastCreatedTownChildPath | integer | No | |
LastCreatedTownHash | hashtable | No | |
LastCreatedTownInt | integer | No | |
LastCreatedTownParentPath | integer | No | |
lastCreatedTownPlayerIndex | integer | Yes | |
LastCreatedVUnitHashT | hashtable | No | |
LastCreatedVUnitParentPath | string | No | |
LastCreatedVUnitPath | string | No | |
LastCreatedWarPartyInt | integer | No | |
lastOrderDLS | string | No | |
lastOrderHash | hashtable | No | |
lastPLS | string | No | |
LastSavedParameterHash | hashtable | No | |
LastSavedParameterNameS | string | No | |
LastSavedParameterParentS | string | No | |
lastSPart | unit | No | |
lastUsedAddDataHashIndex | integer | No | |
lastUsedAddDataRootName | string | No | |
lilithArmy | group | No | |
LilithHasInfiniteGem | boolean | No | |
LilithMinion | unit | Yes | |
lilithSpawnWait | real | No | 120.00 |
LordEricPaladin | unit | No | |
MacroAbilities | button | No | |
MacroAbilitiesDialog | dialog | No | |
MagicStatues | group | No | |
MaleRanger | unit | No | |
MeetDreadlord | boolean | No | |
MeetDreadlord_Complete | boolean | No | |
MethodSelected | trigger | No | |
MinionSelected | integer | No | |
monsterTypeCount | integer | No | |
MouseLastPos | location | No | |
MousePos | location | No | |
Move | boolean | No | |
mudgolem | integer | No | |
Name_Alucard | string | No | Alucard |
Name_AlucardInfernalForm | string | No | Infernal |
Name_Dhjeri | string | No | Dhjeri |
Name_Dragonblight | string | No | Dragonblight |
name_Gustivus | string | No | Gustivus the Cyclope |
Name_Herodin | string | No | Herodin Mountainkiller |
Name_Kael | string | No | Kael |
Name_LilithDarkRanger | string | No | Lilith |
Name_LordEricPaladin | string | No | Lord Eric the Mighty |
Name_PitlordSauresh | string | No | Sauresh the Divider of Brothers |
Name_Saira | string | No | Saira |
Name_Scout1 | string | No | Elven Scout |
numSheep | integer | No | |
numSheep_Eaten | integer | No | |
numSheep_Goal | integer | No | 10 |
objectI | integer | No | |
OTSxDragonWhelp | string | No | |
paramString_building | string | No | _building_ |
paramString_Units | string | No | Units_ |
PitlordKagreshCleaver | unit | No | |
PlayerAI | hashtable | Yes | |
PlayerConstructionWorkers | group | Yes | |
PlayerFightingWorkers | group | Yes | |
PlayerGoldWorkers | group | Yes | |
PlayerIdleWorkers | group | Yes | |
PlayerLumberWorkers | group | Yes | |
portal | integer | No | |
PortalMonster_Max | integer | No | 40 |
PortalMonsters | group | No | |
Portals | group | No | |
PrinceAlucard | unit | No | |
PrinceAlucardInfernal | unit | No | |
QuestSheep | quest | No | |
QuitCinematic | boolean | No | |
ReachEternitysEnd | boolean | No | |
ReachEternitysEnd_Complete | boolean | No | |
ReportPosts | group | No | |
resourceMB | multiboard | No | |
Return_Eric | location | No | |
Return_Kael | location | No | |
Return_Saira | location | No | |
ReturnHeroes | boolean | No | |
rocks | group | No | |
sAI_g | group | No | |
sAI_g_count | integer | No | |
sAI_g_count2 | integer | No | |
sAI_g_i | integer | No | |
sAI_g_iC | integer | No | |
sAI_HashLocationData | hashtable | No | |
sAI_lastCreatedBaseID | integer | No | |
sAIClaimedGoldMines | group | Yes | |
Saira | unit | No | |
SairaEscorts | boolean | No | |
savedCam | camerasetup | No | |
SavedCameraPosition | integer | No | |
savedSairaMain | unit | No | |
Scout1 | unit | No | |
sheepCreated | boolean | No | |
skeletonA | integer | No | |
skeletonW | integer | No | |
SkipTrigger | trigger | No | |
Skull | unit | No | |
Skull_Group | group | No | |
snakehead | unit | No | |
snakeheadfx | effect | No | |
snakeRise | boolean | No | true |
spider1 | integer | No | |
spider2 | integer | No | |
SpiderQueen | unit | No | |
SpiderQueen_Dest | location | No | |
SpiderQueen_EmergeTimer | timer | No | |
SpiderQueen_Enemies | boolean | No | |
SpiderQueen_HasHammer | boolean | No | |
SpiderQueen_Hidden | boolean | No | |
SpiderQueen_Impatience | timer | No | |
SpiderQueen_LaunchFX | effect | No | |
SpiderQueen_Rocks | integer | No | 4 |
SpiderQueen_RockTimer | timer | No | |
SpiderQueen_Spell | string | No | |
SpiderQueen_SpellFinished | boolean | No | |
SpiderQueen_SpiderSpawn | integer | No | 3 |
StatueLevel | integer | No | |
str_attack | string | No | attack |
str_emerge | string | No | retreat |
str_ensnare | string | No | ensnare |
str_getHammer | string | No | gethammer |
str_laser | string | No | laser |
str_move | string | No | move |
str_musicAlucard | string | No | musicAlucard |
str_musicAlucardMega | string | No | musicAlucard |
str_musicMain | string | No | musicMain |
str_retreat | string | No | retreat |
str_returnStart | string | No | returnstart |
str_rockFall | string | No | rockfall |
str_spawnSpiders | string | No | spawnspiders |
str_throwHammer | string | No | throwhammer |
string_harvestGoldMineTarget | string | No | harvestGoldMineTarget |
SummonedDragonBlight | unit | No | |
TeleportationStoneActive | boolean | No | |
TeleportStoneSiteLimit | integer | No | 3 |
temp_real_global | real | No | |
temp_real_global_dividend | real | No | |
temp_real_global_mod | real | No | |
tempAvailableGoldMines | group | No | |
tempBoolean | boolean | No | |
tempDestructable | destructable | No | |
tempEffect | effect | No | |
tempGroup | group | No | |
tempGroup2 | group | No | |
tempHash | hashtable | No | |
tempHashData | hashtable | No | |
tempHighestReal | real | No | |
tempInt | integer | No | |
tempInt2 | integer | No | |
tempLightning | lightning | No | |
tempLoc | location | No | |
tempLoc2 | location | No | |
tempLoc_clear | boolean | No | |
tempOrder | ordercode | No | |
tempParentString | string | No | |
tempPlayerInt | integer | No | |
tempReal | real | No | |
tempReal2 | real | No | |
tempRegion | rect | No | |
tempRootName | string | No | |
tempRPosX | real | No | |
tempRPosY | real | No | |
tempRPosZ | real | No | |
tempString | string | No | |
tempTextTag | texttag | No | |
tempTimer | timer | No | |
tempTrigger | trigger | No | |
tempTriggerUnit | unit | No | |
tempUnit | unit | No | |
tempUnit2 | unit | No | |
tempX | integer | No | |
tempY | integer | No | |
tempZ | integer | No | |
Terms | hashtable | Yes | |
testdls | string | No | |
time | timer | No | |
townIndex | integer | No | |
TrainingQueues | hashtable | Yes | |
TransmissionFinished | boolean | No | |
TransmissionTimerStarted | boolean | No | |
uAI_aOUnit | unit | No | |
uAI_oDLS | string | No | |
uAI_uIS | string | No | |
uAI_Unit | unit | No | |
undeadBluePlayerID | integer | No | 3 |
undeadGreyPlayerID | integer | No | 3 |
undeadVioletPlayerID | integer | No | 3 |
UnitAI | hashtable | No | |
Waygate | unit | No | |
WaygateDest | rect | No | |
WaygateRegion | rect | No | |
Yeorn | unit | No | |
zoetropeT | timer | No | |
zT_ang | real | No | |
zT_dist | real | No | |
zT_endLoc | location | No | |
zT_environmentG | group | No | |
zT_ghosts | group | No | |
zT_on | boolean | No | |
zT_on2 | boolean | No | true |
zT_speed | real | No | |
zT_startLoc | location | No | |
zT_unitGroup | group | No | |
zT_wallEnd | location | Yes | |
zT_wallStart | location | Yes | |
zTAFCreated | boolean | No | |
zTAFSwitch | destructable | No | |
zTAutospellGroup | group | No | |
zTDistCovered | real | Yes | |
zTDistMin | real | Yes | |
zTDistToStart | real | No | |
zTMaxAutospells | integer | No | |
zTMaxDist | real | No | |
zTxCreateGroup | integer | No | |
zTxCreateGroup_num | integer | No | 8 |
function cs_CameraFocus takes real p_startingfocaltarget, real p_startingfocusspread, real p_focaltarget, real p_focusspread, real p_time returns nothing
local integer i = 1
local real focaldiff = p_focaltarget - p_startingfocaltarget
local real DOPscalediff = p_focusspread - p_startingfocusspread
local real focalincrement = 0
local real DOPincrement = 0
local real currentFocalDist = 0
local real currentDOPScale = 0
local real increments = 0
local real lv_fps = 8.00
local real lv_waittime = 0
set increments = focaldiff / p_time * lv_fps
set lv_waittime = 1 / focaldiff / p_time
// 1 second divided into the amount of frames every second. It should be 1/8, I think.
set focalincrement = focaldiff / increments
set DOPincrement = DOPscalediff / increments
call CameraSetFocalDistance( p_startingfocaltarget )
call CameraSetDepthOfFieldScale( p_startingfocusspread )
loop
exitwhen i >= increments
set currentFocalDist = currentFocalDist + focalincrement
set currentDOPScale = currentDOPScale + DOPincrement
call CameraSetFocalDistance( currentFocalDist )
call CameraSetDepthOfFieldScale( currentDOPScale )
call PolledWait( 1/lv_fps )
//this is probably dicey, it could be inaccurate at certain levels, so make sure it's simple (in fact, just change it to timer, sir)
set i = i + 1
endloop
set i = 0
set focaldiff = 0
set DOPscalediff = 0
set focalincrement = 0
set DOPincrement = 0
set currentFocalDist = 0
set currentDOPScale = 0
set increments = 0
set lv_fps = 0
set lv_waittime = 0
endfunction
function cs_CameraFocus takes real p_startingfocaltarget, real p_startingfocusspread, real p_focaltarget, real p_focusspread, real p_time returns nothing
local integer i = 1
local real focaldiff = p_focaltarget - p_startingfocaltarget
local real DOPscalediff = p_focusspread - p_startingfocusspread
local real focalincrement = 0
local real DOPincrement = 0
local real currentFocalDist = 0
local real currentDOPScale = 0
local real increments = 0
local real lv_fps = 8.00
local real lv_waittime = 0
set increments = focaldiff / p_time * lv_fps
set lv_waittime = 1 / focaldiff / p_time
// 1 second divided into the amount of frames every second. It should be 1/8, I think.
set focalincrement = focaldiff / increments
set DOPincrement = DOPscalediff / increments
call CameraSetFocalDistance( p_startingfocaltarget )
call CameraSetDepthOfFieldScale( p_startingfocusspread )
loop
exitwhen i >= increments
set currentFocalDist = currentFocalDist + focalincrement
set currentDOPScale = currentDOPScale + DOPincrement
call CameraSetFocalDistance( currentFocalDist )
call CameraSetDepthOfFieldScale( currentDOPScale )
call PolledWait( 1/lv_fps )
//this is probably dicey, it could be inaccurate at certain levels, so make sure it's simple
set i = i + 1
endloop
set i = 0
set focaldiff = 0
set DOPscalediff = 0
set focalincrement = 0
set DOPincrement = 0
set currentFocalDist = 0
set currentDOPScale = 0
set increments = 0
set lv_fps = 0
set lv_waittime = 0
endfunction
function sAI_sairaMBStunExpire takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandleBJ(0, StringHashBJ(I2S(GetHandleId(t)) + "_unit"), udg_tempHash )
//MAIN PART
if (udg_CinematicModeOn == false) then
call PauseUnitBJ( false, u)
endif
call FlushChildHashtableBJ( StringHashBJ(I2S(GetHandleId(t)) + "_unit"), udg_tempHash )
call DestroyTimer(t)
//PLUG LEAKS
set t = null
set u = null
endfunction
function sAI_animationReset takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tID = GetHandleId(t)
local unit u = LoadUnitHandleBJ(0, StringHashBJ(I2S(tID) + "_unit"), udg_tempHash)
// MAIN PART
call ResetUnitAnimation( u )
call FlushChildHashtableBJ( StringHashBJ(I2S(tID) + "_unit"), udg_tempHash )
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tID = 0
set u = null
endfunction
constant native GetUnitX takes unit whichUnit returns real
constant native GetUnitY takes unit whichUnit returns real
native IssueTargetOrder takes unit whichUnit, string order, widget targetWidget returns boolean
native GetUnitCurrentOrder takes unit whichUnit returns integer
native GetResourceAmount takes unit whichUnit returns integer
native IssueInstantPointOrder takes unit whichUnit, string order, real x, real y, widget instantTargetWidget returns boolean
native IssueInstantPointOrderById takes unit whichUnit, integer order, real x, real y, widget instantTargetWidget returns boolean
native IssueInstantTargetOrder takes unit whichUnit, string order, widget targetWidget, widget instantTargetWidget returns boolean
native IssueInstantTargetOrderById takes unit whichUnit, integer order, widget targetWidget, widget instantTargetWidget returns boolean
native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing
native IssueImmediateOrder takes unit whichUnit, string order returns boolean
native IssueImmediateOrderById takes unit whichUnit, integer order returns boolean
native IssuePointOrder takes unit whichUnit, string order, real x, real y returns boolean
native IssuePointOrderLoc takes unit whichUnit, string order, location whichLocation returns boolean
native IssuePointOrderById takes unit whichUnit, integer order, real x, real y returns boolean
native IssuePointOrderByIdLoc takes unit whichUnit, integer order, location whichLocation returns boolean
native IssueTargetOrder takes unit whichUnit, string order, widget targetWidget returns boolean
native IssueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean
native IssueInstantPointOrder takes unit whichUnit, string order, real x, real y, widget instantTargetWidget returns boolean
native IssueInstantPointOrderById takes unit whichUnit, integer order, real x, real y, widget instantTargetWidget returns boolean
native IssueInstantTargetOrder takes unit whichUnit, string order, widget targetWidget, widget instantTargetWidget returns boolean
native IssueInstantTargetOrderById takes unit whichUnit, integer order, widget targetWidget, widget instantTargetWidget returns boolean
native IssueBuildOrder takes unit whichPeon, string unitToBuild, real x, real y returns boolean
native IssueBuildOrderById takes unit whichPeon, integer unitId, real x, real y returns boolean
native GetUnitCurrentOrder takes unit whichUnit returns integer
BlzGetUnitAbilityByIndex takes unit whichUnit, integer index returns ability // will just have to loop until it returns nothing
//========================================================================================
globals
hashtable udg_TypeCastHashtable = InitHashtable()
endglobals
library TypeCasting
function Widget2Handle takes widget i returns handle
return i
endfunction
function Agent2Handle takes agent i returns handle
return i
endfunction
function Integer2BooleanExpr takes integer i returns boolexpr
call SaveFogStateHandle(udg_TypeCastHashtable, 0, 0, ConvertFogState(i))
return LoadBooleanExprHandle(udg_TypeCastHashtable, 0, 0)
endfunction
function Handle2BooleanExpr takes handle h returns boolexpr
return Integer2BooleanExpr(GetHandleId(h))
endfunction
function BooleanExpr2Handle takes boolexpr b returns handle
return b
endfunction
endlibrary
scope Example
globals
private hashtable hashData = InitHashtable()
endglobals
struct s_data
unit u = null
unit t = null
real x
real y
integer i
endstruct
function MCADelayed takes nothing returns nothing
local timer t=GetExpiredTimer()
local s_data d=s_data(LoadInteger(hashData, GetHandleId(t), 1))
local player p=GetOwningPlayer(d.u)
local unit u
loop
exitwhen (d.i==0)
set u=CreateUnit(p, 'nmrl', d.x, d.y, 0)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl",u,"overhead"))
call IssueTargetOrder(u, "attack", d.t)
set d.i=d.i-1
endloop
call RemoveSavedInteger(hashData, GetHandleId(t), 1)
call d.destroy()
set p=null
set u=null
set t=null
endfunction
endscope
function sAI_saveStringParameter takes string data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveStringBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("string", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addStringParameter takes string data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveStringBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("string", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("string", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveRealParameter takes real data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveRealBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("real", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addRealParameter takes real data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveRealBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types - Honestly, I'm not certain what to save an add name as, doesn't even matter I guess
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("real", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("real", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveIntegerParameter takes integer data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveIntegerBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("integer", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addIntegerParameter takes integer data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveIntegerBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("integer", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("integer", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveDestructibleParameter takes destructable data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveDestructableHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("destructible", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addDestructibleParameter takes destructable data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveDestructableHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("unit", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("destructible", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveBooleanParameter takes boolean data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveBooleanBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("boolean", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addBooleanParameter takes boolean data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveBooleanBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("integer", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("boolean", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveUnitParameter takes unit data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveUnitHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("unit", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addUnitParameter takes unit data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveUnitHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("unit", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("unit", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveLocationParameter takes location data, string lp_addName, string lp_parentString, hashtable ht returns nothing
// The Child key is a function of indexing and that's all. Always 0 in SaveParameter.
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveLocationHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("location", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addLocationParameter takes location data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveLocationHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("location", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("location", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveGroupParameter takes group data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveGroupHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("group", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addGroupParameter takes group data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveGroupHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("group", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("group", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveRegionParameter takes region data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveRegionHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("region", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addRegionParameter takes region data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveRegionHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("region", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("region", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveRectParameter takes rect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveRectHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("rect", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addRectParameter takes rect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveRectHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("rect", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("rect", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveTimerParameter takes timer data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveTimerHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("timer", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addTimerParameter takes timer data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveTimerHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("timer", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("timer", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveEffectParameter takes effect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveEffectHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("effect", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addEffectParameter takes effect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveEffectHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("effect", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("effect", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveLightningParameter takes lightning data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveLightningHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("lightning", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addLightningParameter takes lightning data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveLightningHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("lightning", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("lightning", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveTriggerParameter takes trigger data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveTriggerHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("trigger", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addTriggerParameter takes trigger data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveTriggerHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("trigger", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("trigger", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveWeatherParameter takes weathereffect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveIntegerBJ(GetHandleId(data), 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("weather", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addWeatherParameter takes weathereffect data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveIntegerBJ(GetHandleId(data), 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("weather", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("weather", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_saveTextTagParameter takes texttag data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
call SaveTextTagHandleBJ(data, 0, StringHashBJ(parentString), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then // check if the name alreadyexists
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("texttag", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_addTextTagParameter takes texttag data, string lp_addName, string lp_parentString, hashtable ht returns nothing
local string addName = ""
local string parentString = ""
local integer metaI = 0
local integer metaIC = 0
local integer i = 0
local integer iC = 0
local string iS = ""
local boolean nameAlreadyExists = false
//==================================
//===================================================================================
//ZHULI DO THE THING
//===================================================================================
if (lp_addName != "") then
set addName = "_" + lp_addName
endif
set parentString = lp_parentString + addName
//Indexing Part//===========
set iC = LoadIntegerBJ(0, StringHashBJ(parentString + "_indexCount"), ht)
set iC = iC + 1
set iS = I2S(iC)
call SaveIntegerBJ(iC, 0, StringHashBJ(parentString + "_indexCount"), ht)
//===========================
call SaveTextTagHandleBJ(data, 0, StringHashBJ(parentString + "_" + iS), ht)
//===================================================================================
//ADD META
//===================================================================================
if (HaveSavedValue(0, bj_HASHTABLE_STRING, StringHashBJ(parentString + "_dataName"), ht)) then // hopefully this doesn't create any issues w different types
set nameAlreadyExists = true
endif
if ((lp_addName != "") and (nameAlreadyExists == false)) then
set metaIC = LoadIntegerBJ(0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
set metaIC = metaIC + 1
call SaveIntegerBJ(metaIC, 0, StringHashBJ(lp_parentString + "_metaList_indexCount"), ht)
call SaveStringBJ(lp_addName, 0, StringHashBJ(lp_parentString + "_metaList_" + I2S(metaIC)), ht)
call SaveStringBJ(I2S(metaIC), 0, StringHashBJ(lp_parentString + "_metaList_" + lp_addName), ht) // The double naming thing. Also we I2S because that's what we need for that.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_dataName"), ht)
call SaveStringBJ("texttag", 0, StringHashBJ(parentString + "_dataType"), ht)
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_rootDir"), ht)
endif
//There is always an index.
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_dataName"), ht) // hopefully no flush conflicts
call SaveStringBJ("texttag", 0, StringHashBJ(parentString + "_" + iS + "_dataType"), ht)
if (lp_addName != "") then
call SaveStringBJ(lp_addName, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
else
call SaveStringBJ(lp_parentString, 0, StringHashBJ(parentString + "_" + iS + "_rootDir"), ht)
endif
set parentString = parentString + "_" + iS //this is so it adds the index name
// Save Last Created/Added/Saved Parameter
set udg_lastPLS = parentString
set udg_LastSavedParameterNameS = lp_addName
set udg_LastSavedParameterParentS = lp_parentString
set udg_LastSavedParameterHash = ht
endfunction
function sAI_convertUnitAbilitiesToHashKnowledge takes integer lp_playerID, unit lp_unit returns nothing
local integer i = 0
local integer lv_indexCount = 0
local ability lv_abil = null
local string lv_abilString = ""
loop
exitwhen i > lv_indexCount
set lv_abil = BlzGetUnitAbilityByIndex(lp_unit, i)
set lv_abilString = I2S(GetHandleIdBJ(lv_abil))
call sAI_addStringParameterToHash("", "PlayerAI_terms", "ability", lv_abilString, udg_PlayerAI[lp_playerID])
endloop
endfunction
function sAI_deleteDataTree takes string targetLocString, hashtable ht returns nothing
local integer indexI = 0
local integer indexIC = 0
local integer metaI = 0
local integer metaIC = 0
local string rootString = ""
local string name = ""
local string str = ""
local string fieldString = ""
local string prefix = ""
local boolean processingIndex = false
//================
local hashtable dT_trackingData = udg_dT_trackingData
local integer dT_i = 0
local string dT_targetLocString = ""
local string dT_iString = ""
local string dT_prefix = ""
local integer dT_iC = 0
//================
local integer targetLocStringIC = 0
local integer dT_fieldI = 0
local string dT_fieldIString = ""
local integer dT_fieldIC = 0
local integer dT_fieldMetaI = 0
local integer dT_fieldMetaIC = 0
local string dT_fieldMetaIString = ""
local string dT_fieldMetaNameString = ""
local integer targetLocStringMIC = 0
//================
local string dT_rootName = ""
local string dT_saveRootName = ""
local string dT_name = ""
local string dT_saveName = ""
local string dT_addName = ""
local boolean processFinished = false
local boolean backstep = false
local boolean hitLastEntry = false
local boolean transfer = false
local integer deleteSL = 0
local integer i = 0
local string iS = ""
local string filterString = ""
local boolean isIndexed = false
local boolean forward = false
local integer entriesDeleted = 0
local integer debugInt = 0
local integer childKey = 0
local string addName = ""
local string dataType = ""
//============================================
//MAIN PART
//============================================
//=====================================
//=====================================
set processFinished = false
//=====================================
set dT_rootName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_rootDir"), ht)
set dT_targetLocString = targetLocString
//==========================================
//==========================================
//==========================================
//==========================================
//MAIN FUNCTION
loop
exitwhen (processFinished == true)
set dT_fieldIC = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_indexCount"), ht)
set dT_fieldMetaIC = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_metaList_indexCount"), ht)
set dT_fieldI = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_currentIndex"), dT_trackingData)
set dT_fieldMetaI = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_currentMetaIndex"), dT_trackingData)
//==========================================
// ACTUAL TRANSFER PROCESS
//==========================================
if (dT_targetLocString == targetLocString) then // This is the stop function, so it doesn't delete prior to target locString
elseif (LoadBooleanBJ(0, StringHashBJ(dT_targetLocString + "_transferred"), dT_trackingData) != true) then
call SaveBooleanBJ(true, 0, StringHashBJ( dT_targetLocString + "_transferred"), dT_trackingData) // still need this
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//ACTUAL PROCESS
//DELETE DATA HERE (REMOVE MEMORY LEAKS)
if (dataType == "group") then
call DestroyGroup(LoadGroupHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "location") then
call RemoveLocation(LoadLocationHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "region") then
call RemoveRegion(LoadRegionHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "rect") then
call RemoveRect(LoadRectHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "effect") then
call DestroyEffect(LoadEffectHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "timer") then
call DestroyTimer(LoadTimerHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "group") then
call DestroyGroup(LoadGroupHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
//call DisplayTextToForce(GetPlayersAll(), "deleted: " + dT_targetLocString )
// I think I do need to read type, actually, if I save memory using things like locations i need to destroy before flushing hash.
// At the moment I just have string parameters so no big, I'm pretty sure.
// Key memory leaks are taken care of by Flush.
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//FLUSH DATA HASHTABLE
set addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_dataName"), ht )
set dataType = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_dataType"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString), ht ) // might not need the previous , flushing an entire index should be fine
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_indexCount"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_dataName"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_dataType"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_rootDir"), ht )
//might add these to a generalHash list to loop apply
//And delete all the in-built and all the meta, too.
// I think this checks off everything.
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_metaList_" + LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + addName), ht) ), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_metaList_" + addName), ht )
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
set entriesDeleted = entriesDeleted + 1
else
set backstep = false
endif
//ITERATION
if ( ( (LoadIntegerBJ(0, StringHashBJ(dT_targetLocString + "_indexCount"), ht) == 0) and (LoadIntegerBJ(0, StringHashBJ(dT_targetLocString + "_metaList_indexCount"), ht) == 0) ) or ((dT_fieldI >= dT_fieldIC) and (dT_fieldMetaI >= dT_fieldMetaIC)) ) then
set backstep = true
else
set dT_rootName = dT_targetLocString
if (dT_fieldI < dT_fieldIC) then
set dT_fieldI = dT_fieldI + 1
set dT_fieldIString = (I2S(dT_fieldI))
set dT_addName = dT_fieldIString
else
if (dT_fieldMetaI < dT_fieldMetaIC) then
set dT_fieldMetaI = dT_fieldMetaI + 1
set dT_fieldMetaIString = (I2S(dT_fieldMetaI))
set dT_addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + dT_fieldMetaIString), ht)
else
set dT_fieldMetaIString = (I2S(dT_fieldMetaI))
set dT_addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + dT_fieldMetaIString), ht)
endif
endif
endif
call SaveIntegerBJ(dT_fieldI, 0, StringHashBJ(dT_targetLocString + "_currentIndex"), dT_trackingData)
call SaveIntegerBJ(dT_fieldMetaI, 0, StringHashBJ(dT_targetLocString + "_currentMetaIndex"), dT_trackingData)
//==================================
//==================================
//TRACKING - FORWARD OR BACKWARDS
//==================================
//==================================
if (((dT_targetLocString == "") or ( dT_targetLocString == targetLocString)) and (backstep == true)) then
set processFinished = true
elseif (debugInt > 100) then
set processFinished = true
else
set debugInt = debugInt + 1
endif
//=====================================
//=====================================
//=====================================
if (backstep == true) then
set dT_targetLocString = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_rootDir"), ht)
else
set dT_targetLocString = dT_rootName + "_" + dT_addName
endif
endloop
call FlushParentHashtableBJ(dT_trackingData)
//============================================
//PLUG LEAKS
//============================================
set indexI = 0
set indexIC = 0
set metaI = 0
set metaIC = 0
set rootString = ""
set name = ""
set str = ""
set fieldString = ""
set prefix = ""
set processingIndex = false
//================
set dT_trackingData = null
set dT_i = 0
set dT_targetLocString = ""
set dT_iString = ""
set dT_prefix = ""
set dT_iC = 0
//================
set targetLocStringIC = 0
set dT_fieldI = 0
set dT_fieldIString = ""
set dT_fieldIC = 0
set dT_fieldMetaI = 0
set dT_fieldMetaIC = 0
set dT_fieldMetaIString = ""
set dT_fieldMetaNameString = ""
set targetLocStringMIC = 0
//================
set dT_rootName = ""
set dT_saveRootName = ""
set dT_name = ""
set dT_saveName = ""
set dT_addName = ""
set processFinished = false
set backstep = false
set hitLastEntry = false
set transfer = false
set deleteSL = 0
set i = 0
set iS = ""
set filterString = ""
set isIndexed = false
set forward = false
set entriesDeleted = 0
set debugInt = 0
set childKey = 0
set addName = ""
set dataType = ""
endfunction
function sAI_copyDataTree takes string targetLocString, hashtable ht returns nothing
local integer indexI = 0
local integer indexIC = 0
local integer metaI = 0
local integer metaIC = 0
local string rootString = ""
local string name = ""
local string str = ""
local string fieldString = ""
local string prefix = ""
local boolean processingIndex = false
//================
local hashtable dT_trackingData = udg_dT_trackingData
local integer dT_i = 0
local string dT_targetLocString = ""
local string dT_iString = ""
local string dT_prefix = ""
local integer dT_iC = 0
//================
local integer targetLocStringIC = 0
local integer dT_fieldI = 0
local string dT_fieldIString = ""
local integer dT_fieldIC = 0
local integer dT_fieldMetaI = 0
local integer dT_fieldMetaIC = 0
local string dT_fieldMetaIString = ""
local string dT_fieldMetaNameString = ""
local integer targetLocStringMIC = 0
//================
local string dT_rootName = ""
local string dT_saveRootName = ""
local string dT_name = ""
local string dT_saveName = ""
local string dT_addName = ""
local boolean processFinished = false
local boolean backstep = false
local boolean hitLastEntry = false
local boolean transfer = false
local integer deleteSL = 0
local integer i = 0
local string iS = ""
local string filterString = ""
local boolean isIndexed = false
local boolean forward = false
local integer entriesDeleted = 0
local integer debugInt = 0
local integer childKey = 0
local string addName = ""
local string dataType = ""
//============================================
//MAIN PART
//============================================
//=====================================
//=====================================
set processFinished = false
//=====================================
set dT_rootName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_rootDir"), ht)
set dT_targetLocString = targetLocString
//==========================================
//==========================================
//==========================================
//==========================================
//MAIN FUNCTION
loop
exitwhen (processFinished == true)
set dT_fieldIC = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_indexCount"), ht)
set dT_fieldMetaIC = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_metaList_indexCount"), ht)
set dT_fieldI = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_currentIndex"), dT_trackingData)
set dT_fieldMetaI = LoadIntegerBJ( 0, StringHashBJ(dT_targetLocString + "_currentMetaIndex"), dT_trackingData)
//==========================================
// ACTUAL TRANSFER PROCESS
//==========================================
if (dT_targetLocString == targetLocString) then // This is the stop function, so it doesn't delete prior to target locString
elseif (LoadBooleanBJ(0, StringHashBJ(dT_targetLocString + "_transferred"), dT_trackingData) != true) then
call SaveBooleanBJ(true, 0, StringHashBJ( dT_targetLocString + "_transferred"), dT_trackingData) // still need this
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//ACTUAL PROCESS
//DELETE DATA HERE (REMOVE MEMORY LEAKS)
if (dataType == "group") then
call DestroyGroup(LoadGroupHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "location") then
call RemoveLocation(LoadLocationHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "region") then
call RemoveRegion(LoadRegionHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "rect") then
call RemoveRect(LoadRectHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "effect") then
call DestroyEffect(LoadEffectHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "timer") then
call DestroyTimer(LoadTimerHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
if (dataType == "group") then
call DestroyGroup(LoadGroupHandleBJ(0, StringHashBJ(dT_targetLocString), ht))
endif
// I think I do need to read type, actually, if I save memory using things like locations i need to destroy before flushing hash.
// At the moment I just have string parameters so no big, I'm pretty sure.
// Key memory leaks are taken care of by Flush.
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//FLUSH DATA HASHTABLE
set addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_dataName"), ht )
set dataType = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_dataType"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString), ht ) // might not need the previous , flushing an entire index should be fine
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_indexCount"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_dataName"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_dataType"), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_rootDir"), ht )
//might add these to a generalHash list to loop apply
//And delete all the in-built and all the meta, too.
// I think this checks off everything.
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_metaList_" + LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + addName), ht) ), ht )
call FlushChildHashtableBJ( StringHashBJ(dT_targetLocString + "_metaList_" + addName), ht )
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
//==========================================
set entriesDeleted = entriesDeleted + 1
else
set backstep = false
endif
//ITERATION
if ( ( (LoadIntegerBJ(0, StringHashBJ(dT_targetLocString + "_indexCount"), ht) == 0) and (LoadIntegerBJ(0, StringHashBJ(dT_targetLocString + "_metaList_indexCount"), ht) == 0) ) or ((dT_fieldI >= dT_fieldIC) and (dT_fieldMetaI >= dT_fieldMetaIC)) ) then
set backstep = true
else
set dT_rootName = dT_targetLocString
if (dT_fieldI < dT_fieldIC) then
set dT_fieldI = dT_fieldI + 1
set dT_fieldIString = (I2S(dT_fieldI))
set dT_addName = dT_fieldIString
else
if (dT_fieldMetaI < dT_fieldMetaIC) then
set dT_fieldMetaI = dT_fieldMetaI + 1
set dT_fieldMetaIString = (I2S(dT_fieldMetaI))
set dT_addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + dT_fieldMetaIString), ht)
else
set dT_fieldMetaIString = (I2S(dT_fieldMetaI))
set dT_addName = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_metaList_" + dT_fieldMetaIString), ht)
endif
endif
endif
call SaveIntegerBJ(dT_fieldI, 0, StringHashBJ(dT_targetLocString + "_currentIndex"), dT_trackingData)
call SaveIntegerBJ(dT_fieldMetaI, 0, StringHashBJ(dT_targetLocString + "_currentMetaIndex"), dT_trackingData)
//==================================
//==================================
//TRACKING - FORWARD OR BACKWARDS
//==================================
//==================================
if (((dT_targetLocString == "") or ( dT_targetLocString == targetLocString)) and (backstep == true)) then
set processFinished = true
elseif (debugInt > 100) then
set processFinished = true
else
set debugInt = debugInt + 1
endif
//=====================================
//=====================================
//=====================================
if (backstep == true) then
set dT_targetLocString = LoadStringBJ(0, StringHashBJ(dT_targetLocString + "_rootDir"), ht)
else
set dT_targetLocString = dT_rootName + "_" + dT_addName
endif
endloop
call FlushParentHashtableBJ(dT_trackingData)
//============================================
//PLUG LEAKS
//============================================
set indexI = 0
set indexIC = 0
set metaI = 0
set metaIC = 0
set rootString = ""
set name = ""
set str = ""
set fieldString = ""
set prefix = ""
set processingIndex = false
//================
set dT_trackingData = null
set dT_i = 0
set dT_targetLocString = ""
set dT_iString = ""
set dT_prefix = ""
set dT_iC = 0
//================
set targetLocStringIC = 0
set dT_fieldI = 0
set dT_fieldIString = ""
set dT_fieldIC = 0
set dT_fieldMetaI = 0
set dT_fieldMetaIC = 0
set dT_fieldMetaIString = ""
set dT_fieldMetaNameString = ""
set targetLocStringMIC = 0
//================
set dT_rootName = ""
set dT_saveRootName = ""
set dT_name = ""
set dT_saveName = ""
set dT_addName = ""
set processFinished = false
set backstep = false
set hitLastEntry = false
set transfer = false
set deleteSL = 0
set i = 0
set iS = ""
set filterString = ""
set isIndexed = false
set forward = false
set entriesDeleted = 0
set debugInt = 0
set childKey = 0
set addName = ""
set dataType = ""
endfunction
function sAI_iDLS takes string dls, string parent returns nothing
// searches for "_" within the given dls and creates the appropriate yggdrasilling
endfunction
function d_tL takes nothing returns nothing
call RemoveLocation(udg_tempLoc)
set udg_tempLoc = null
endfunction
function s_tDL_s takes location data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveLocationParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDG_s takes group data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveGroupParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDU_s takes unit data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveUnitParameter(data, path, tIS, udg_tempHash)
//PLUG LEAKS
set data = null
set s = ""
set tIS = ""
set path = ""
//RETURN
endfunction
function s_tDI_s takes integer data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveIntegerParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = 0
//RETURN
endfunction
function s_tDR_s takes real data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveRealParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = 0
//RETURN
endfunction
function s_tDS_s takes string data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveStringParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = ""
//RETURN
endfunction
function s_tDB_s takes boolean data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveBooleanParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = false
//RETURN
endfunction
function s_tDLE_s takes lightning data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveLightningParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDE_s takes effect data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveEffectParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDT_s takes timer data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveTimerParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDTR_s takes trigger data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveTriggerParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDTT_s takes texttag data, string tIS, string path returns nothing
local string s = ""
//MAIN PART
call sAI_saveTextTagParameter(data, path , tIS, udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
set data = null
//RETURN
endfunction
function s_tDL takes string tIS, string path returns location
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempLoc = LoadLocationHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempLoc
endfunction
function s_tDG takes string tIS, string path returns group
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempGroup = LoadGroupHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempGroup
endfunction
function s_tDU takes string tIS, string path returns unit
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempUnit = LoadUnitHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempUnit
endfunction
function s_tDI takes string tIS, string path returns integer
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempInt = LoadIntegerBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempInt
endfunction
function s_tDR takes string tIS, string path returns real
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempReal = LoadRealBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempReal
endfunction
function s_tDS takes string tIS, string path returns string
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempString = LoadStringBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempString
endfunction
function s_tDB takes string tIS, string path returns boolean
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempBoolean = LoadBooleanBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempBoolean
endfunction
function s_tDLE takes string tIS, string path returns lightning
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempLightning = LoadLightningHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempLightning
endfunction
function s_tDE takes string tIS, string path returns effect
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempEffect = LoadEffectHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempEffect
endfunction
function s_tDT takes string tIS, string path returns timer
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempTimer = LoadTimerHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempTimer
endfunction
function s_tDTR takes string tIS, string path returns trigger
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempTrigger = LoadTriggerHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempTrigger
endfunction
function s_tDTT takes string tIS, string path returns texttag
local string s = ""
//MAIN PART
if (path != "") then
set s = "_" + path
else
set s = ""
endif
set udg_tempTextTag = LoadTextTagHandleBJ(0, StringHashBJ(tIS + s), udg_tempHash)
//PLUG LEAKS
set s = ""
set tIS = ""
set path = ""
//RETURN
return udg_tempTextTag
endfunction
function s_uDL takes unit u, string s returns location
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempLoc = LoadLocationHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempLoc
endfunction
function s_uDG takes unit u, string s returns group
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempGroup = LoadGroupHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempGroup
endfunction
function s_uDU takes unit u, string s returns unit
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempUnit = LoadUnitHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempUnit
endfunction
function s_uDI takes unit u, string s returns integer
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempInt = LoadIntegerBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempInt
endfunction
function s_uDR takes unit u, string s returns real
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempReal = LoadRealBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempReal
endfunction
function s_uDS takes unit u, string s returns string
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempString = LoadStringBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempString
endfunction
function s_uDB takes unit u, string s returns boolean
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempBoolean = LoadBooleanBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempBoolean
endfunction
function s_uDLE takes unit u, string s returns lightning
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempLightning = LoadLightningHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempLightning
endfunction
function s_uDE takes unit u, string s returns effect
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempEffect = LoadEffectHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempEffect
endfunction
function s_uDT takes unit u, string s returns timer
local string uIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempTimer = LoadTimerHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempTimer
endfunction
function s_uDTR takes unit u, string s returns trigger
local integer uI = GetHandleId(u)
local string uIDS = I2S(uI)
//MAIN PART
set udg_tempTrigger = LoadTriggerHandleBJ(0, StringHashBJ("Units_" + uIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set uI = 0
set uIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempTrigger
endfunction
function s_uDDE takes unit u, string s returns destructable
local string dIDS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempDestructable = LoadDestructableHandleBJ(0, StringHashBJ("Units_" + dIDS + "_" + s), udg_UnitAI)
//PLUG LEAKS
set dIDS = ""
set s = ""
set u = null
//RETURN
return udg_tempDestructable
endfunction
function s_uDL_s takes location data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveLocationParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDG_s takes group data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveGroupParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDU_s takes unit data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveUnitParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDI_s takes integer data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveIntegerParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = 0
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDR_s takes real data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveRealParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = 0
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDS_s takes string data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveStringParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = ""
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDB_s takes boolean data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveBooleanParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = false
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDLE_s takes lightning data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveLightningParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDE_s takes effect data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveEffectParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDT_s takes timer data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveTimerParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDTR_s takes trigger data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveTriggerParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDDE_s takes destructable data, string uIS, string path returns nothing
//MAIN PART
call sAI_saveDestructibleParameter(data, path, "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set data = null
set uIS = ""
set path = ""
//RETURN
endfunction
function s_uDI_i takes integer i, unit u, string name, string parent returns nothing
local string s = ""
//MAIN PART
if (parent == "") then
//
else
set s = parent
endif
if (name == "") then
//
elseif (parent != "") then
set s = s + "_" + name
else
set s = name
endif
call sAI_saveIntegerParameter(s_uDI(u, s) + i, name, parent, udg_UnitAI)
//PLUG LEAKS
set s = ""
set i = 0
set u = null
set name = ""
set parent = ""
endfunction
function s_uDR_i takes real r, unit u, string name, string parent returns nothing
local string s = ""
//MAIN PART
if (parent == "") then
//
else
set s = parent
endif
if (name == "") then
//
elseif (parent != "") then
set s = s + "_" + name
else
set s = name
endif
call sAI_saveRealParameter(s_uDR(u, s) + r, name, parent, udg_UnitAI)
//PLUG LEAKS
set s = ""
set r = 0
set u = null
set name = ""
set parent = ""
endfunction
function s_sTimer takes timer t, string tIS returns nothing
call sAI_saveTimerParameter(t, "", tIS, udg_tempHash)
endfunction
function s_stunExpire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = LoadUnitHandleBJ(0, StringHashBJ(tIS + "_unit"), udg_tempHash)
local integer stunStack = 0
//MAIN PART
call s_uDI_i(-1, u, "stun", "state")
set stunStack = s_uDI(u, "state_stun")
if ((stunStack <= 0)) then
call PauseUnitBJ( false, u )
endif
call DestroyEffectBJ( s_tDE(tIS, "effect") )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set stunStack = 0
set u = null
set tIS = ""
set u = null
endfunction
function s_stun takes unit u, real time returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call s_uDI_i(1, u, "stun", "state")
call TimerStart(t, time, false, function s_stunExpire)
call s_tDU_s(u, tIS, "unit")
call PauseUnitBJ( true, u )
call AddSpecialEffectTargetUnitBJ( "overhead", u, "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl" )
call s_tDE_s(bj_lastCreatedEffect, tIS, "effect")
//PLUG LEAKS
set t = null
set u = null
set tIS = ""
set u = null
set time = 0
endfunction
function s_clearOrders takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call sAI_deleteDataTree(("Units_" + uIS + "_order"), udg_UnitAI)
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function s_addOrder takes unit u, string s, trigger t, location l, boolean terminated returns nothing
local string uIS = I2S(GetHandleId(u))
local string oDLS = ""
local integer oI = 0
local integer oIC = 0
//MAIN PART
call sAI_addStringParameter(s, "order", "Units_" + uIS, udg_UnitAI)
set oDLS = udg_lastPLS
call sAI_addTriggerParameter(t, "trigger", oDLS, udg_UnitAI) // this saves to "order_[X]_trigger", not the order name which is also seperate
call sAI_saveBooleanParameter(terminated, "terminated", oDLS, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "added order")
//call DisplayTextToForce(GetPlayersAll(), I2S(LoadIntegerBJ(0, StringHash("Units_" + uIS + "_order_indexCount"), udg_UnitAI)))
//call DisplayTextToForce(GetPlayersAll(), "odls: " + oDLS)
//call DisplayTextToForce(GetPlayersAll(), "trig count: " + I2S(LoadIntegerBJ(0, StringHash(oDLS + "_trigger_indexCount"), udg_UnitAI)))
//GLOBAL VARS
set udg_lastOrderDLS = oDLS
set udg_lastOrderHash = udg_UnitAI
//PLUG LEAKS
set u = null
set s = ""
set t = null
set l = null
set terminated = false
set oDLS = ""
set oI = 0
set oIC = 0
set uIS = ""
endfunction
//additional triggers
function s_addOrderTrigger takes unit u, string oDLS, trigger t returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call sAI_addTriggerParameter(t, "trigger", oDLS, udg_UnitAI)
//PLUG LEAKS
set u = null
set t = null
set oDLS = ""
set uIS = ""
endfunction
function sP_addOrder takes integer pI, string s, trigger t, location l, boolean terminated returns nothing
local string pIS = I2S(pI)
local string oDLS = ""
local integer oI = 0
local integer oIC = 0
//MAIN PART
call sAI_addStringParameter(s, "order", "Player_" + pIS, udg_PlayerAI[pI])
set oDLS = udg_lastPLS
call sAI_addTriggerParameter(t, "trigger", oDLS, udg_PlayerAI[pI]) // this saves to "order_[X]_trigger", not the order name which is also seperate
call sAI_saveBooleanParameter(terminated, "terminated", oDLS, udg_PlayerAI[pI])
call sAI_saveLocationParameter(l, "loc", oDLS, udg_PlayerAI[pI]) // prob not needed here
//GLOBAL VARS
set udg_lastOrderDLS = oDLS
set udg_lastOrderHash = udg_PlayerAI[pI]
//PLUG LEAKS
set pI = 0
set s = ""
set t = null
set l = null
set terminated = false
set pIS = ""
set oDLS = ""
set oI = 0
set oIC = 0
endfunction
function sP_addOrderTrigger takes integer pI, string oDLS, trigger t returns nothing
//MAIN PART
call sAI_addTriggerParameter(t, "trigger", oDLS, udg_PlayerAI[pI]) // this saves to "order_[X]_trigger", not the order name which is also seperate
//PLUG LEAKS
set pI = 0
set t = null
set oDLS = ""
endfunction
function sP_addCondition takes integer pI, string s, trigger t returns nothing
local string pIS = I2S(pI)
local string cDLS = ""
local integer cI = 0
local integer cIC = 0
//MAIN PART
call sAI_addStringParameter(s, "condition", "Player_" + pIS, udg_PlayerAI[pI])
set cDLS = udg_lastPLS
call sAI_saveTriggerParameter(t, "trigger", cDLS, udg_PlayerAI[pI]) // this saves to "order_[X]_trigger", not the order name which is also seperate
//GLOBAL VARS
set udg_lastCDLS = cDLS
set udg_lastCHash = udg_PlayerAI[pI]
//PLUG LEAKS
set pI = 0
set s = ""
set t = null
set pIS = ""
set cDLS = ""
set cI = 0
set cIC = 0
endfunction
function sAI_Condition_timeElapsed takes real lp_time returns nothing
// just takes current game time, checks the difference, and returns if yea
endfunction
function sC_checkArmyRangeCentre takes nothing returns real
local string dLS = udg_tempString
local unit u = null
local string uIS = I2S(GetHandleId(u))
//
local group g = null
local location l = null
//
local real tRange = 0
local real nUnits = 0
local real aRange = 0
local group g2 = CreateGroup()
local unit eU = null
local location eUL = null
//MAIN PART
call GroupAddGroup(g2, g)
set eU = FirstOfGroup(g2)
set eUL = GetUnitLoc(eU)
loop
exitwhen (eU == null)
set tRange = tRange + (DistanceBetweenPoints(eUL, l))
set nUnits = nUnits + 1
call GroupRemoveUnit(g2, eU)
call RemoveLocation(eUL)
set eU = FirstOfGroup(g2)
set eUL = GetUnitLoc(eU)
endloop
set udg_tempReal = tRange / nUnits
//PLUG LEAKS
call DestroyGroup(g2)
set l = null
set g = null
set u = null
set uIS = ""
//RETURN
return udg_tempReal
endfunction
function sC_checkRangeCentre takes nothing returns real
local string dLS = udg_tempString
local unit u = udg_tempUnit
local string uIS = I2S(GetHandleId(u))
//
local group g = null
local location l = udg_tempLoc
//
local real tRange = 0
local real nUnits = 0
local real aRange = 0
local group g2 = CreateGroup()
local unit eU = null
local location eUL = null
//MAIN PART
call GroupAddGroup(g2, g)
set eU = FirstOfGroup(g2)
set eUL = GetUnitLoc(eU)
loop
exitwhen (eU == null)
set tRange = tRange + (DistanceBetweenPoints(eUL, l))
set nUnits = nUnits + 1
call GroupRemoveUnit(g2, eU)
call RemoveLocation(eUL)
set eU = FirstOfGroup(g2)
set eUL = GetUnitLoc(eU)
endloop
set udg_tempReal = tRange / nUnits
//PLUG LEAKS
call DestroyGroup(g2)
set l = null
set g = null
set u = null
set uIS = ""
//RETURN
return udg_tempReal
endfunction
function s_conditionAdd_range takes string s, group g, location l, real r, boolean b returns nothing
local string oDLS = s
local hashtable ht = udg_lastOrderHash
//
local string cDLS = ""
local integer cI = 0
local integer cIC = 0
local trigger tR = gg_trg_sC_x_Check_Range
//MAIN PART
//
set cIC = LoadIntegerBJ(0, StringHashBJ(oDLS + "_condition_indexCount"), ht)
set cIC = cIC + 1
call SaveIntegerBJ(cIC, 0, StringHashBJ(oDLS + "_condition_indexCount"), ht) // we use these because they ARE meta, they don't create it (assumed in the system)
set cDLS = oDLS + "_condition_" + I2S(cIC)
//
call sAI_saveStringParameter("range", "", cDLS, ht) // just autofills this
call sAI_addTriggerParameter(tR, "trigger", cDLS, ht)
call sAI_saveRealParameter(r, "range", cDLS, ht)
call sAI_saveBooleanParameter(b, "if", cDLS, ht)
//PLUG LEAKS
set oDLS = ""
set ht = null
endfunction
function s_conditionAdd_state takes string dls, string data, boolean b returns nothing
local string oDLS = dls
local hashtable ht = udg_lastOrderHash
//
local string cDLS = ""
local integer cI = 0
local integer cIC = 0
//MAIN PART
//
set cIC = LoadIntegerBJ(0, StringHashBJ(oDLS + "_condition_indexCount"), ht)
set cIC = cIC + 1
call SaveIntegerBJ(cIC, 0, StringHashBJ(oDLS + "_condition_indexCount"), ht)
set cDLS = oDLS + "_condition_" + I2S(cIC)
//
call sAI_saveStringParameter(data, "", cDLS, ht)
call sAI_saveBooleanParameter(b, "if", cDLS, ht)
//PLUG LEAKS
set oDLS = ""
set ht = null
endfunction
function s_conditionAdd_timer takes string dls, real data, boolean b returns nothing
local string oDLS = dls
local hashtable ht = udg_lastOrderHash
//
local string cDLS = ""
local integer cI = 0
local integer cIC = 0
//MAIN PART
//
set cIC = LoadIntegerBJ(0, StringHashBJ(oDLS + "_condition_indexCount"), ht)
set cIC = cIC + 1
call SaveIntegerBJ(cIC, 0, StringHashBJ(oDLS + "_condition_indexCount"), ht)
set cDLS = oDLS + "_condition_" + I2S(cIC)
//
call sAI_saveRealParameter(data, "time", cDLS, ht)
call sAI_saveTimerParameter(CreateTimer(), "timer", cDLS, ht)
call sAI_saveBooleanParameter(b, "if", cDLS, ht)
//PLUG LEAKS
set oDLS = ""
set ht = null
endfunction
//=======================================================================================
//=======================================================================================
//=======================================================================================
//=======================================================================================
//=======================================================================================
//=======================================================================================
function sAI_unitDetectUnits takes unit u, real r returns nothing
local real radius = 900
local integer i = GetHandleIdBJ(u)
local string unitIDString = I2S(i)
local integer dls_i = 0
local hashtable ht = udg_UnitAI
local group sortGroup = GetUnitsInRangeOfLocAll(200.00, GetUnitLoc(u))
local unit enumUnit = null
local integer num = 0
//MAIN PART
// add a condition for visibility, set rad to unit sight range
set enumUnit = FirstOfGroup(sortGroup)
loop
exitwhen (enumUnit == null)
if (IsPlayerEnemy(GetOwningPlayer(enumUnit), (GetOwningPlayer(u))) == true) then
if (IsUnitType(enumUnit, UNIT_TYPE_STRUCTURE) == false ) then
set num = num + 1
endif
endif
call GroupRemoveUnitSimple(enumUnit, sortGroup)
set enumUnit = FirstOfGroup(sortGroup)
endloop
set dls_i = S2I("Units_" + unitIDString + "_detectedUnits_count")
call SaveIntegerBJ(num, 0, dls_i, ht)
//PLUG LEAKS
set u = null
set i = 0
set unitIDString = ""
set dls_i = 0
set ht = null
set radius = 0
call DestroyGroup(sortGroup)
set enumUnit = null
set num = 0
endfunction
function sP_queueMoveArmy_slow takes integer pI, string dLS, group g, location l returns nothing
local string pIS = I2S(pI)
local string tS = dLS
//MAIN PART
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", dLS, udg_PlayerAI[pI])
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_PlayerAI[pI])
call sAI_saveLocationParameter(l, "loc", tS, udg_PlayerAI[pI])
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
//=======================
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", dLS, udg_PlayerAI[pI])
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
//PLUG LEAKS
set pI = 0
set pIS = ""
set l = null
set g = null
endfunction
function s_findWord takes string s, string word returns integer
local string eS = ""
local integer i = 0
local integer i2 = 0
local integer sL = StringLength(s)
// MAIN PART
set udg_tempInt = -1 // if nowhere
loop
exitwhen ((i > sL) or (udg_tempInt != -1))
set eS = SubStringBJ(s, i, i2)
if (eS == word) then
set udg_tempInt = i
endif
set i2 = i2 + 1
if (i2 > sL) then
set i2 = 1
set i = i + 1
endif
endloop
//PLUG LEAKS
set eS = ""
set i = 0
set i2 = 0
set s = ""
set word = ""
// RETURN
return udg_tempInt
endfunction
function s_findWord takes string s, hashtable ht returns integer
local string word = ""
local string eS = ""
local integer i = 0
local integer i2 = 0
local integer sL = StringLength(s)
// MAIN PART
set udg_tempInt = -1 // if nowhere
loop
exitwhen ((i > sL) or (udg_tempInt != -1))
set eS = SubStringBJ(s, i, i2)
if (eS == word) then
set udg_tempInt = i
endif
set i2 = i2 + 1
if (i2 > sL) then
set i2 = 1
set i = i + 1
endif
endloop
//PLUG LEAKS
set eS = ""
set i = 0
set i2 = 0
set s = ""
set word = ""
// RETURN
return udg_tempInt
endfunction
function s_basicGroupOrderLoc takes group g, string s, location l returns nothing
local group g2 = CreateGroup()
local unit eU = FirstOfGroup(g)
//MAIN PART
call GroupAddGroup(g2, g)
loop
exitwhen (eU == null)
call IssuePointOrderLoc(eU, s, l)
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
//PLUG LEAKS
call DestroyGroup(g2)
set g2 = null
set g = null
set l = null
set s = ""
set eU = null
endfunction
function s_groupOrderLoc takes boolean clear, group g, string s, trigger t, location l, boolean b returns nothing
local group g2 = CreateGroup()
local unit eU = FirstOfGroup(g)
//MAIN PART
call GroupAddGroup(g2, g)
loop
exitwhen (eU == null)
if (clear == true) then
call s_clearOrders(eU)
endif
call s_addOrder(eU, s, t, l, b)
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
//PLUG LEAKS
call DestroyGroup(g2)
set g2 = null
set g = null
set l = null
set s = ""
set eU = null
endfunction
function pA_sendArmy takes nothing returns nothing
local string oIS = udg_tempString
local string oS = LoadStringBJ(0, StringHashBJ(oIS + "_order"), udg_UnitAI) // easy to create a generic order func wid dis
local unit u = LoadUnitHandleBJ(0, StringHashBJ(oIS + "_unit"), udg_UnitAI)
local string uIS = I2S(GetHandleId(u))
//
local integer pI = udg_tempInt
local location l = null
local group g = LoadGroupHandleBJ(0, StringHashBJ(oIS + "_group"), udg_PlayerAI[pI])
//
local integer lCount = 0
local integer cI = 0
local string s = ""
local string cDLS = "" // condition dls
local boolean conditionsPassed = false
//MAIN PART
set s = oIS
set l = LoadLocationHandleBJ(0, StringHashBJ(s + "_targetLoc"), udg_PlayerAI[pI])
set lCount = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_indexCount"), udg_PlayerAI[pI])
set cI = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
call s_basicGroupOrderLoc(g, "move", l)
set udg_tempGroup = g // can probably still put these into parameters
set udg_tempLoc = l
call SaveIntegerBJ(cI, 0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set oIS = ""
set oS = ""
set lCount = 0
set cI = 0
set s = ""
set cDLS = ""
set conditionsPassed = false
endfunction
function pA_armyGuard_area takes nothing returns nothing
local string oIS = udg_tempString
local string oS = LoadStringBJ(0, StringHashBJ(oIS + "_order"), udg_UnitAI) // easy to create a generic order func wid dis
local unit u = LoadUnitHandleBJ(0, StringHashBJ(oIS + "_unit"), udg_UnitAI)
local string uIS = I2S(GetHandleId(u))
//
local integer pI = udg_tempInt
local location l = null
local group g = LoadGroupHandleBJ(0, StringHashBJ(oIS + "_group"), udg_PlayerAI[pI])
//
local integer lCount = 0
local integer cI = 0
local string s = ""
local string cDLS = "" // condition dls
local boolean conditionsPassed = false
//MAIN PART
set s = oIS
set l = LoadLocationHandleBJ(0, StringHashBJ(s + "_targetLoc"), udg_PlayerAI[pI])
set lCount = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_indexCount"), udg_PlayerAI[pI])
set cI = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
call s_basicGroupOrderLoc(g, "move", l)
set udg_tempGroup = g // can probably still put these into parameters
set udg_tempLoc = l
call SaveIntegerBJ(cI, 0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set oIS = ""
set oS = ""
set lCount = 0
set cI = 0
set s = ""
set cDLS = ""
set conditionsPassed = false
endfunction
function pA_sendArmy takes nothing returns nothing
local string oIS = udg_tempString
local string oS = LoadStringBJ(0, StringHashBJ(oIS + "_order"), udg_UnitAI) // easy to create a generic order func wid dis
local unit u = LoadUnitHandleBJ(0, StringHashBJ(oIS + "_unit"), udg_UnitAI)
local string uIS = I2S(GetHandleId(u))
//
local integer pI = udg_tempInt
local location l = null
local group g = LoadGroupHandleBJ(0, StringHashBJ(oIS + "_group"), udg_PlayerAI[pI])
//
local integer lCount = 0
local integer cI = 0
local string s = ""
local string cDLS = "" // condition dls
local boolean conditionsPassed = false
//MAIN PART
set s = oIS
set l = LoadLocationHandleBJ(0, StringHashBJ(s + "_targetLoc"), udg_PlayerAI[pI])
set lCount = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_indexCount"), udg_PlayerAI[pI])
set cI = LoadIntegerBJ(0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
call s_basicGroupOrderLoc(g, "move", l)
set udg_tempGroup = g // can probably still put these into parameters
set udg_tempLoc = l
call SaveIntegerBJ(cI, 0, StringHashBJ(s + "_targetLoc_currentIndex"), udg_PlayerAI[pI])
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set oIS = ""
set oS = ""
set lCount = 0
set cI = 0
set s = ""
set cDLS = ""
set conditionsPassed = false
endfunction
function uA_moveTo takes nothing returns nothing
local string oIS = udg_tempString
local string oS = LoadStringBJ(0, StringHashBJ(oIS + "_order"), udg_UnitAI) // easy to create a generic order func wid dis
local unit u = LoadUnitHandleBJ(0, StringHashBJ(oIS + "_unit"), udg_UnitAI)
local string uIS = I2S(GetHandleId(u))
local location l = null
local group g = null
//
local integer lCount = 0
local integer cI = 0
local string s = ""
local string cDLS = "" // condition dls
local boolean conditionsPassed = false
//MAIN PART
// this should probably actually be pulling from orders
// can run a condition check trigger
set s = oIS
set l = s_uDL(u, s + "_targetLoc")
set lCount = s_uDI(u, s + "_targetLoc_indexCount")
set cI = s_uDI(u, s + "_targetLoc_currentIndex")
call IssuePointOrderLoc(u, "move", l)
set cI = cI + 1
if (cI > lCount) then
if (s_uDB(u, s + "_loop") == true) then
set cI = 1
endif
endif
call s_uDI_s(cI, uIS, s + "_targetLoc_currentIndex")
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set oIS = ""
set oS = ""
set lCount = 0
set cI = 0
set s = ""
set cDLS = ""
set conditionsPassed = false
endfunction
function s_checkConditions takes string dLS returns boolean
local trigger t = null
//
local string cDLS = dLS + "_condition"
local boolean b = true
local boolean b2 = false
local integer cI = 1
local integer cIC = LoadIntegerBJ(0, StringHashBJ(dLS + "_condition_indexCount"), udg_UnitAI)
local string cIS = ""
//MAIN PART
set udg_tempLoc = LoadLocationHandleBJ(0, StringHashBJ(dLS + "_loc"), udg_UnitAI)
set udg_tempString = dLS
//These should be available for use, as the containing Order function should already have collected its info.
set cIC = LoadIntegerBJ(0, StringHashBJ(dLS + "_condition_indexCount"), udg_UnitAI)
loop
exitwhen (cI > cIC)
set cDLS = dLS + "_condition_" + cIS
set t = LoadTriggerHandleBJ(0, StringHashBJ(cDLS + "_trigger"), udg_UnitAI)
call TriggerExecute(t)
set cI = cI + 1
set cIS = I2S(cI)
endloop
//PLUG LEAKS
set dLS = ""
set b = false
set b2 = false
set cI = 0
set cIC = 0
set cIS = ""
set cDLS = ""
//RETURN
return udg_tempBoolean
endfunction
function u_orderStart takes unit u, string oIS returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDB_s(true, uIS, oIS + "_currentlyExecuting")
//PLUG LEAKS
set u = null
set oIS = ""
set uIS = ""
endfunction
function u_orderFinish takes unit u, string oIS returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDB_s(false, uIS, oIS + "_currentlyExecuting")
//PLUG LEAKS
set u = null
set oIS = ""
set uIS = ""
endfunction
function u_orderCheckExec takes unit u, string oDLS returns boolean
local string uIS = I2S(GetHandleId(u))
//MAIN PART
set udg_tempBoolean = s_uDB(u, oDLS + "_currentlyExecuting")
//PLUG LEAKS
set u = null
set oDLS = ""
set uIS = ""
//RETURN
return udg_tempBoolean
endfunction
function sU_executeOrder takes unit u, string oDLS returns nothing
local trigger t = null
local string oS = LoadStringBJ(0, StringHashBJ(oDLS), udg_UnitAI)
local integer sI = StringHash(oDLS + "_trigger_indexCount")
local integer tRI = 1
local integer tRIC = LoadIntegerBJ(0, sI, udg_UnitAI)
local string tRIS = I2S(tRI)
local boolean cReturn = false
local boolean cWanted = false
//MAIN PART
set udg_uAI_Unit = u
set udg_uAI_uIS = I2S(GetHandleId(u))
// set udg_uAI_oDLS = oDLS //this needs to link to base order data
set udg_uAI_oDLS = LoadStringBJ(0, StringHash(oDLS + "_orderDataLink"), udg_UnitAI)
set udg_tempLoc = LoadLocationHandleBJ(0, StringHashBJ(oDLS + "_loc"), udg_UnitAI)
set udg_tempString = oDLS
//call DisplayTextToForce(GetPlayersAll(), "executing order 1")
//call DisplayTextToForce(GetPlayersAll(), I2S(tRIC))
//call DisplayTextToForce(GetPlayersAll(), "odls: " + oDLS)
loop
exitwhen (tRI > tRIC)
set sI = StringHash(oDLS + "_trigger_" + tRIS)
set t = LoadTriggerHandleBJ(0, sI, udg_UnitAI)
//set cWanted = LoadBooleanBJ(0, StringHash(oDLS + "_trigger_" + tRIS + "_if"), udg_UnitAI)
//set cReturn = s_checkConditions(oDLS + "_trigger_" + tRIS + "_if")
//if (cReturn == cWanted) then
//call DisplayTextToForce(GetPlayersAll(), "executing trigger")
call TriggerExecute(t)
//endif
set tRI = tRI + 1
set tRIS = I2S(tRI)
endloop
//PLUG LEAKS
set u = null
set oDLS = ""
set sI = 0
set t = null
set oS = ""
set tRI = 0
set tRIC = 0
set tRIS = ""
set cReturn = false
set cWanted = false
endfunction
function sP_executeOrder takes integer pI, string oDLS returns nothing
local trigger t = null
local string oS = LoadStringBJ(0, StringHashBJ(oDLS + "_order"), udg_UnitAI)
local integer tRI = 1
local integer tRIC = LoadIntegerBJ(0, StringHashBJ(oDLS + "_trigger_indexCount"), udg_UnitAI)
local string tRIS = I2S(tRI)
local boolean cReturn = false
local boolean cWanted = false
//MAIN PART
set udg_tempInt = pI
set udg_tempLoc = LoadLocationHandleBJ(0, StringHashBJ(oDLS + "_loc"), udg_UnitAI)
set udg_tempString = oDLS
loop
exitwhen (tRI > tRIC)
set t = LoadTriggerHandleBJ(0, StringHashBJ(oDLS + "_trigger_" + tRIS), udg_UnitAI)
//
set cWanted = LoadBooleanBJ(0, StringHashBJ(oDLS + "_trigger_" + tRIS + "_if"), udg_UnitAI)
set cReturn = s_checkConditions(oDLS + "_trigger_" + tRIS + "_if")
if (cReturn == cWanted) then
call TriggerExecute(t)
endif
set tRI = tRI + 1
set tRIS = I2S(tRI)
endloop
//PLUG LEAKS
set pI = 0
set oDLS = ""
endfunction
function sU_executeAllOrders takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
local string oS = ""
local integer sI = StringHash("Units_" + uIS + "_order_indexCount")
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, sI, udg_UnitAI)
local string oIS = I2S(oI)
local integer cI = s_uDI(u, "order_currentIndex")
local boolean break = false
//MAIN PART
set udg_uAI_Unit = u
//call DisplayTextToForce(GetPlayersAll(), "a unit executing orders")
//call DisplayTextToForce( GetPlayersAll(), "loop" )
//call DisplayTextToForce( GetPlayersAll(), uIS )
//call DisplayTextToForce( GetPlayersAll(), R2S(GetTimeOfDay()) )
if oIC > 0 then
//call DisplayTextToForce(GetPlayersAll(), I2S(oIC))
endif
loop
exitwhen (oI > oIC) or break == true
//call DisplayTextToForce(GetPlayersAll(), "a unit executing order")
call s_uDI_s(oI, uIS, "order_currentIndex")
set oS = "Units_" + uIS + "_order_" + oIS
// s check
//call u_orderStart(u, oS)
call sU_executeOrder(u, oS)
//if (u_orderCheckExec(u, oS)) == true then
//set break = true
//endif
set oI = oI + 1
set oIS = I2S(oI)
endloop
//PLUG LEAKS
set u = null
set uIS = ""
set oS = ""
set sI = 0
set oI = 0
set oIC = 0
set oIS = ""
set cI = 0
set break = false
endfunction
function sP_executeAllOrders takes integer pI returns nothing
local string pIS = I2S(pI)
local string oS = ""
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, StringHashBJ("Player_" + pIS + "_order_indexCount"), udg_UnitAI)
local string oIS = I2S(oI)
//MAIN PART
set udg_tempInt = pI
loop
exitwhen (oI > oIC)
set oS = LoadStringBJ(0, StringHashBJ("Player_" + pIS + "_order_" + oIS), udg_UnitAI)
// s check
call sP_executeOrder(pI, oS)
set oI = oI + 1
set oIS = I2S(oI)
endloop
//PLUG LEAKS
set pI = 0
set pIS = ""
set oS = ""
set oI = 0
set oIC = 0
set oIS = ""
endfunction
function sP_lilithOrderArmy takes integer pI, group g returns nothing
local string pIS = I2S(pI)
local string oS = ""
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, StringHashBJ("Player_" + pIS + "_order_indexCount"), udg_PlayerAI[pI])
local string oIS = I2S(oI)
local location l = GetRectCenter(gg_rct_KaelTH)
local string tS = ""
//MAIN PART
//to add a waiting period to this, we add a trigger to the order, and create condition ifs to switch
set l = GetRectCenter(gg_rct_LilithArmy01)
// conditions == false it immediately terminates, THEN starts next trigger/order?
call sP_addOrder(pI, "attack", gg_trg_sP_x_sendArmy, l, true) // "true" means when it reaches the end it does not loop
call sAI_saveGroupParameter(g, "group", udg_lastOrderDLS, udg_lastOrderHash)
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_LilithArmy02)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_LilithArmy03)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_KaelTH)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//PLUG LEAKS
set pI = 0
set pIS = ""
set oS = ""
set oI = 0
set oIC = 0
set oIS = ""
call RemoveLocation(l)
set l = null
endfunction
function sP_elementalsOrderArmy takes integer pI, group g returns nothing
local string pIS = I2S(pI)
local string oS = ""
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, StringHashBJ("Player_" + pIS + "_order_indexCount"), udg_PlayerAI[pI])
local string oIS = I2S(oI)
local location l = GetRectCenter(gg_rct_KaelTH)
local string tS = ""
//MAIN PART
//to add a waiting period to this, we add a trigger to the order, and create condition ifs to switch
set l = GetRectCenter(gg_rct_LilithArmy01)
// conditions == false it immediately terminates, THEN starts next trigger/order?
call sP_addOrder(pI, "attack", gg_trg_sP_x_sendArmy, l, true) // "true" means when it reaches the end it does not loop
call sAI_saveGroupParameter(g, "group", udg_lastOrderDLS, udg_lastOrderHash)
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_LilithArmy02)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_LilithArmy03)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_KaelTH)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//PLUG LEAKS
set pI = 0
set pIS = ""
set oS = ""
set oI = 0
set oIC = 0
set oIS = ""
call RemoveLocation(l)
set l = null
endfunction
function sP_stormWyrmsOrderArmy takes integer pI, group g returns nothing
local string pIS = I2S(pI)
local string oS = ""
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, StringHashBJ("Player_" + pIS + "_order_indexCount"), udg_PlayerAI[pI])
local string oIS = I2S(oI)
local location l = GetRectCenter(gg_rct_KaelTH)
local string tS = ""
//MAIN PART
set l = GetRectCenter(gg_rct_StormWyrms_Path_01)
call sP_addOrder(pI, "attack", gg_trg_sP_x_sendArmy, l, true) // "true" means when it reaches the end it does not loop
call sAI_saveGroupParameter(g, "group", udg_lastOrderDLS, udg_lastOrderHash)
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_StormWyrms_Path_02)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
//PLUG LEAKS
set pI = 0
set pIS = ""
set oS = ""
set oI = 0
set oIC = 0
set oIS = ""
call RemoveLocation(l)
set l = null
endfunction
function sP_stormWyrmsOrderArmy takes integer pI, group g returns nothing
local string pIS = I2S(pI)
local string oS = ""
local integer oI = 1
local integer oIC = LoadIntegerBJ(0, StringHashBJ("Player_" + pIS + "_order_indexCount"), udg_PlayerAI[pI])
local string oIS = I2S(oI)
local location l = GetRectCenter(gg_rct_KaelTH)
local string tS = ""
//MAIN PART
set l = GetRectCenter(gg_rct_StormWyrms_Path_01)
call sP_addOrder(pI, "attack", gg_trg_sP_x_sendArmy, l, true) // "true" means when it reaches the end it does not loop
call sAI_saveGroupParameter(g, "group", udg_lastOrderDLS, udg_lastOrderHash)
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
set l = GetRectCenter(gg_rct_StormWyrms_Path_02)
call sAI_addTriggerParameter(gg_trg_sP_x_sendArmy, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call sAI_saveGroupParameter(g, "group", tS, udg_lastOrderHash)
call sAI_saveLocationParameter(l, "loc", tS, udg_lastOrderHash)
call s_conditionAdd_range(tS, g, l, 200, false) // add to trigger, false should mean this activates until timer expires
call sAI_addTriggerParameter(gg_trg_sP_x_armyGuardArea, "trigger", udg_lastOrderDLS, udg_lastOrderHash)
set tS = udg_lastPLS
call s_conditionAdd_timer(tS, 15, false) // add to trigger, false should mean this activates until timer expires
call RemoveLocation(l)
//=======================
//PLUG LEAKS
set pI = 0
set pIS = ""
set oS = ""
set oI = 0
set oIC = 0
set oIS = ""
call RemoveLocation(l)
set l = null
endfunction
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
function udf_playerCanAffordUnit takes integer unitid, integer p returns boolean
local integer goldCost = GetUnitGoldCost(unitid)
local integer lumberCost = GetUnitWoodCost(unitid)
local integer currentGold = GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_GOLD)
local integer currentLumber = GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_LUMBER)
local integer foodRemaining = (GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_FOOD_CAP) - GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_FOOD_USED))
local integer foodCost = GetFoodUsed(unitid)
if (goldCost < currentGold) and (lumberCost < currentLumber) and (foodCost < foodRemaining) then
return true
else
return false
endif
endfunction
function sAI_setDataNameMetaType takes string dataType, string dls, hashtable ht returns nothing
call sAI_saveStringParameter(dataType, "nameMetaType", dls, ht)
endfunction
function sAI_baseRemoveUnit takes integer p, integer b, unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
local string str = ""
local integer dls_i = 0
local string playerIDString = I2S(p)
local string baseIString = I2S(b)
local integer currentB = 0
local integer baseIC = 0
local region baseR = null
local boolean baseFound = false
local group baseGroup = null
local integer count = 0
local string uTS = UnitId2StringBJ(GetUnitTypeId(u))
local string eUTS = "" // enumUTS
local integer subtract = 0
local string sDataType = ""
local integer i = 0
local integer mIC = 0
//MAIN PART
call sAI_deleteDataTree("Units_" + unitIDString + "_baseID", udg_UnitAI) // this will remove it? (to make it clean- although i dunno if it affects the data search when null)
//call SaveIntegerBJ(0, 0, StringHashBJ("Units_" + unitIDString + "_baseID"), udg_UnitAI )
//call FlushChildHashtableBJ( StringHashBJ("Units_" + unitIDString + "_baseID"), udg_UnitAI )
set str = "Player_" + playerIDString + "_base_" + baseIString
set baseGroup = LoadGroupHandleBJ(0, StringHashBJ(str + "_group"), udg_PlayerAI[p])
call GroupRemoveUnit(baseGroup, u)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_workers"), udg_PlayerAI[p]), u)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_workers_idle"), udg_PlayerAI[p]), u)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_army"), udg_PlayerAI[p]), u)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_structures"), udg_PlayerAI[p]), u)
//quick cheese because these are the only types to currently exist
set str = "Player_" + playerIDString + "_base_" + baseIString
set str = str + "_has_" + UnitId2StringBJ(GetUnitTypeId(u)) + "_count"
set count = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
set count = count - 1
call SaveIntegerBJ(count, 0, StringHashBJ(str), udg_PlayerAI[p]) // update to params later
//UPDATE BASE TRAINING
set str = "Units_" + unitIDString + "_training"
set mIC = LoadIntegerBJ(0, StringHashBJ(str + "_metaList_indexCount"), udg_UnitAI)
loop
exitwhen (i > mIC)
set str = "Units_" + unitIDString + "_training"
set eUTS = LoadStringBJ(0, StringHashBJ(str + "_metaList_" + I2S(i)), udg_UnitAI)
if (LoadStringBJ(0, StringHashBJ(str + "_" + eUTS + "_nameMetaType"), udg_UnitAI) == "unitTypeString") then
set subtract = LoadIntegerBJ(0, StringHashBJ(str + "_" + eUTS + "_count"), udg_UnitAI)
call sAI_saveIntegerParameter(0, "count", str + "_training_" + eUTS , udg_PlayerAI[p])
set str = "Player_" + playerIDString + "_base_" + baseIString
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + eUTS + "_count"), udg_UnitAI)
set count = count - subtract
endif
set i = i + 1
endloop
//===============
//PLUG LEAKS
set unitIDString = ""
set str = ""
set dls_i = 0
set playerIDString = ""
set currentB = 0
set baseIString = ""
set baseIC = 0
set baseR = null
set baseFound = false
set baseGroup = null
set count = 0
set uTS = ""
set eUTS = ""
set subtract = 0
set sDataType = ""
set i = 0
set mIC = 0
//params
set p = 0
set b = 0
set u = null
endfunction
function sAI_baseAddUnit takes integer p, integer b, unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
local string str = ""
local integer dls_i = 0
local string playerIDString = I2S(p)
local string baseIString = I2S(b)
local integer currentB = 0
local integer baseIC = 0
local group baseGroup = null
local integer count = 0
//MAIN PART
set str = "Player_" + playerIDString + "_base_" + baseIString
set baseGroup = LoadGroupHandleBJ(0, StringHashBJ(str + "_group"), udg_PlayerAI[p])
set str = "Units_" + unitIDString + "_baseID"
if (HaveSavedValue(0, bj_HASHTABLE_INTEGER, StringHashBJ(str), udg_UnitAI) == false) then
call sAI_saveIntegerParameter(b, "baseID", "Units_" + unitIDString, udg_UnitAI)
call GroupAddUnitSimple(u, baseGroup)
set str = "Player_" + playerIDString + "_base_" + baseIString
call sAI_saveBooleanParameter(true, UnitId2StringBJ(GetUnitTypeId(u)), str + "_has", udg_PlayerAI[p])
set str = str + "_has_" + UnitId2StringBJ(GetUnitTypeId(u))
set count = LoadIntegerBJ(0, StringHashBJ(str + "_count"), udg_PlayerAI[p])
set count = count + 1
call sAI_saveIntegerParameter(count, "count", str, udg_PlayerAI[p])
//call SetUnitColor( u, GetPlayerColor(Player(1)) ) //debug
endif
//ADD TO GROUPS
if (IsUnitType(u, UNIT_TYPE_PEON) == true) then
set str = "Player_" + playerIDString + "_base_" + baseIString
set str = str + "_workers"
call GroupAddUnit(LoadGroupHandleBJ(0, StringHashBJ(str), udg_UnitAI), u)
set str = "Player_" + playerIDString + "_base_" + baseIString
set str = str + "_workers_idle"
call GroupAddUnit(LoadGroupHandleBJ(0, StringHashBJ(str), udg_UnitAI), u)
endif
if (IsUnitType(u, UNIT_TYPE_STRUCTURE) == true) then
set str = "Player_" + playerIDString + "_base_" + baseIString
set str = str + "_structures"
call GroupAddUnit(LoadGroupHandleBJ(0, StringHashBJ(str), udg_UnitAI), u)
endif
if ((IsUnitType(u, UNIT_TYPE_PEON) == false) and (IsUnitType(u, UNIT_TYPE_STRUCTURE) == false)) then
set str = "Player_" + playerIDString + "_base_" + baseIString
set str = str + "_army"
call GroupAddUnit(LoadGroupHandleBJ(0, StringHashBJ(str), udg_UnitAI), u)
endif
//===============
//PLUG LEAKS
set unitIDString = ""
set str = ""
set dls_i = 0
set playerIDString = ""
set currentB = 0
set baseIString = ""
set baseIC = 0
set baseGroup = null
set count = 0
//params
set p = 0
set b = 0
set u = null
endfunction
function sAI_assignBaseToUnit takes integer p, integer b, unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
local string str = ""
local integer dls_i = 0
local string playerIDString = I2S(p)
local string baseIString = I2S(b)
local integer currentB = 0
local integer baseIC = 0
local region baseR = null
local boolean baseFound = false
local group baseGroup = null
local integer count = 0
//MAIN PART
//===============
//REMOVE FROM CURRENT BASE
set str = "Units_" + unitIDString + "_baseID"
set currentB = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
set baseIString = I2S(currentB)
if (HaveSavedValue(0, bj_HASHTABLE_INTEGER, StringHashBJ(str), udg_UnitAI) == true) then
call sAI_baseRemoveUnit(p,b,u)
endif
//ADD TO NEW BASE
set str = "Units_" + unitIDString + "_baseID"
set currentB = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
set baseIString = I2S(currentB)
call sAI_baseAddUnit(p,b,u)
//===============
//PLUG LEAKS
set unitIDString = ""
set str = ""
set dls_i = 0
set playerIDString = ""
set currentB = 0
set baseIString = ""
set baseIC = 0
set baseR = null
set baseFound = false
set baseGroup = null
set count = 0
//params
set p = 0
set b = 0
set u = null
endfunction
function sAI_assignNearbyBaseToUnit takes integer p, unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
local string str = ""
local integer dls_i = 0
local string playerIDString = I2S(p)
local integer baseI = 0
local string baseIString = ""
local integer baseIC = 0
local region baseR = null
local boolean baseFound = false
local group baseGroup = null
//MAIN PART
set str = "Player_" + playerIDString + "_base_indexCount"
set baseIC = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
//REMOVE FROM CURRENT BASE IF ANY
set str = "Units_" + unitIDString + "_baseID"
set baseI = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
if (HaveSavedValue(0, bj_HASHTABLE_INTEGER, StringHashBJ(str), udg_UnitAI) == true) then
call sAI_baseRemoveUnit(p, baseI, u)
endif
//========================================
set baseI = 1
loop
exitwhen ((baseI > baseIC) or (baseFound == true))
set baseIString = I2S(baseI)
set str = "Player_" + playerIDString + "_base_" + baseIString
set baseR = LoadRegionHandleBJ(0, StringHashBJ(str + "_region"), udg_PlayerAI[p])
if (IsUnitInRegion(baseR, u) == true) then
set baseFound = true
call sAI_baseAddUnit(p, baseI, u)
//call SetUnitColor( u, GetPlayerColor(Player(1)) ) //debug
endif
set baseI = baseI + 1
endloop
if (baseFound == false) then
//call sAI_baseAddUnit(p, 0, u) //if a base is not found nearby, assigns them to 0 "base" which basically means no base
endif
//PLUG LEAKS
set unitIDString = ""
set str = ""
set dls_i = 0
set playerIDString = ""
set baseI = 0
set baseIString = ""
set baseIC = 0
set baseR = null
set baseFound = false
set baseGroup = null
//params
set p = 0
set u = null
endfunction
function sAI_addBase takes integer p, unit townhall returns nothing
local integer dls_i = 0
local string playerIDString = I2S(p)
local integer indexCount = 0
local string str = ""
local string pS = I2S(p)
local integer index = 0
local string iS = ""
local integer numNeeded = 0
local integer currentlyBuildingCount = 0
local string prefix = ""
local group sortGroup = CreateGroup()
local group sortGroup2 = CreateGroup()
local group alreadySorted = CreateGroup()
local group saveGroup = CreateGroup()
local string baseType = ""
local real range = 1000
local unit enumUnit = null
local region baseR = CreateRegion()
local rect baseRect = null
local string baseIString = ""
local location unitLoc = null
local integer base = 0
local integer bIC = 0
//new
local boolean alreadyAssigned = false
local location townHallLoc = null
//MAIN PART
//Create new base
set str = "Player_" + I2S(p)
call sAI_addBooleanParameter( true, "base", str, udg_PlayerAI[p])
//GET BASE ID
set str = "Player_" + playerIDString + "_base"
set bIC = LoadIntegerBJ(0, StringHashBJ(str +"_indexCount"), udg_PlayerAI[p])
//set bIC = 1 //debug
set base = bIC
set udg_sAI_lastCreatedBaseID = bIC
set baseIString = I2S(base)
//PREEMPTIVELY CREATE/SAVE GROUP
set str = "Player_" + playerIDString + "_base_" + baseIString
call sAI_saveGroupParameter( saveGroup, "group", str, udg_PlayerAI[p])
// GET GROUP
// doing a chain jump adding structures to given base data structure
set unitLoc = GetUnitLoc(townhall)
call GroupAddGroup( GetUnitsInRangeOfLocAll(range, unitLoc), sortGroup )
set enumUnit = FirstOfGroup(sortGroup)
call RemoveLocation(unitLoc)
//======================
loop
exitwhen (enumUnit == null)
if (HaveSavedValue(0, bj_HASHTABLE_INTEGER, StringHashBJ("Units_" + I2S(GetHandleIdBJ(enumUnit)) + "_baseID"), udg_UnitAI) == false) then
if ( (GetConvertedPlayerId(GetOwningPlayer(enumUnit)) == p ) and (IsUnitIdType(GetUnitTypeId(enumUnit), UNIT_TYPE_STRUCTURE) == true )) then // i think units are added somewhere else also i don't think it matters
//call SetUnitColor( enumUnit, GetPlayerColor(Player(2)) ) //debug
if (IsUnitInGroup(enumUnit, alreadySorted) == true) then
//Do nothing, it'll be eliminated. I think the exponent growth should be fine.
else
call GroupAddGroup( GetUnitsInRangeOfLocAll(range, GetUnitLoc(enumUnit)), sortGroup )
call GroupAddUnitSimple(enumUnit, saveGroup)
call sAI_assignBaseToUnit(p,base,enumUnit)
call RemoveLocation(unitLoc)
set unitLoc = GetUnitLoc(enumUnit)
set baseRect = RectFromCenterSizeBJ(unitLoc, range, range)
call RegionAddRect(baseR, baseRect)
call RemoveRect(baseRect)
call RemoveLocation(unitLoc)
endif
endif
endif
call GroupRemoveUnit(sortGroup, enumUnit)
call GroupAddUnitSimple(enumUnit, alreadySorted)
set enumUnit = FirstOfGroup(sortGroup)
endloop
//SAVE GROUP TO BASE
set baseIString = I2S(bIC)
set str = "Player_" + playerIDString + "_base_" + baseIString
//call sAI_saveGroupParameter( saveGroup, "group", str, udg_PlayerAI[p]) //shouldn't need this
call sAI_saveRegionParameter( baseR, "region", str, udg_PlayerAI[p])
call sAI_saveRectParameter( RectFromCenterSizeBJ(GetUnitLoc(townhall), range, range), "rect", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "workers", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "workers_idle", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "army", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "builders", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "harvesters", str, udg_PlayerAI[p])
call sAI_saveGroupParameter( CreateGroup() , "isBuilding", str, udg_PlayerAI[p])
//This should be an entirely new base, so this should be clean.
//PLUG LEAKS
call RemoveRect(baseRect)
call RemoveLocation(unitLoc)
call DestroyGroup(sortGroup)
call DestroyGroup(sortGroup2)
call DestroyGroup(alreadySorted)
set dls_i = 0
set playerIDString = ""
set indexCount = 0
set str = ""
set pS = ""
set index = 0
set iS = ""
set numNeeded = 0
set currentlyBuildingCount = 0
set prefix = ""
set sortGroup = null
set sortGroup2 = null
set alreadySorted = null
set saveGroup = null
set baseType = ""
set range = 0
set enumUnit = null
set baseR = null
set baseRect = null
set baseIString = ""
set unitLoc = null
set base = 0
set bIC = 0
endfunction
function sAI_base_addWant_unit takes integer p, integer baseI, string uTS, integer count returns nothing
local integer dls_i = 0
local integer indexCount = 0
local string str = ""
local integer index = 0
local string iS = ""
local integer numNeeded = 0
local integer currentlyBuildingCount = 0
local string prefix = ""
local group sortGroup = CreateGroup()
local string meta_DLS = ""
local integer mDLSI = 0
local integer currentNumWanted = 0
local integer mL_indexCount = 0
local string newMIS = ""
//MAIN PART
set str = "Player_" + I2S(p) + "_base_" + I2S(baseI)
set str = str + "_wants"
set prefix = str
set str = str + "_" + uTS + "_count"
set dls_i = StringHashBJ(str)
set currentNumWanted = LoadIntegerBJ(0, dls_i, udg_PlayerAI[p])
set currentNumWanted = currentNumWanted + count
call sAI_saveBooleanParameter(true, uTS, prefix, udg_PlayerAI[p])
call sAI_saveIntegerParameter(currentNumWanted, "count", prefix + "_" + uTS, udg_PlayerAI[p])
//PLUG LEAKS
set dls_i = 0
set indexCount = 0
set str = ""
set index = 0
set iS = ""
set numNeeded = 0
set currentlyBuildingCount = 0
set prefix = ""
call DestroyGroup(sortGroup)
set sortGroup = null
set meta_DLS = ""
set mDLSI = 0
set currentNumWanted = 0
set mL_indexCount = 0
set newMIS = ""
//params
set p = 0
set baseI = 0
set uTS = ""
set count = 0
endfunction
//===================================================
function sAI_addUnitTrainingKnowledge takes integer p, string trainerString, string trainedString returns nothing // Are these id strings or unit type strings? prob latter
local string str = ""
local integer dls_i = 0
local integer i = 0
local integer iC = 0
//MAIN PART
// SAVE TERM KNOWLEDGE
//I'm treating Terms much the same as normal data atm, but do want a faster system with less mem use.
set str = trainedString + "_built_by"
call sAI_addBooleanParameter( true, trainerString , str ,udg_Terms[p])
set str = trainerString + "_can_build"
call sAI_addBooleanParameter( true, trainedString , str ,udg_Terms[p]) //This isn't a duplication. It's slightly different from the super-fast access Term use.
//PLUG LEAKS
set str = ""
set dls_i = 0
set i = 0
set iC = 0
//PARAMS
set p = 0
set trainerString = ""
set trainedString = ""
endfunction
//===================================================
//===================================================
function sAI_base_AI takes integer p, integer baseI returns nothing
//it checks it's "wants", trains
// also directs home defense and signals for help
local string uTS = ""
local integer dls_i = 0
local integer indexCount = 0
local string str = ""
local integer index = 0
local string iS = ""
local integer numNeeded = 0
local integer currentlyHave = 0
local integer currentlyBuilding = 0
local group sortGroup = CreateGroup()
local group baseGroup = null
local string str2 = ""
local string prefix = ""
local string prefix2 = ""
local integer count = 0
local integer addCount = 0
local integer i = 0
local integer iEnd = 0
local boolean processFinished = false
local real goldRequired = 0
local real gold = GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_GOLD)
local real woodRequired = 0
local real wood = GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_LUMBER)
local real foodRequired = 0
local real food = (GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_FOOD_CAP) - GetPlayerState(Player(p), PLAYER_STATE_RESOURCE_FOOD_USED))
local integer previousCount = 0
local integer newUnitsQueued = 0
local unit enumUnit = null
local boolean newLoop = false
local integer unitsInGroup = 0
//GetPlayerState(Player(0), PLAYER_STATE_FOOD_CAP_CEILING)
// NEW VARIABLES (REQUIRE LEAKS PLUGGED)
local string reqUTS = "" //requirement for unit, creating a one-off type deal, being needed for a single purpose (creating a unit)
local location l = null
local rect baseRect = null
local region baseR = null
local integer reqI = 0
local integer reqIC = 0
local string reqS = ""
local string prefixBase = ""
local string dataType = ""
local integer mIC = 0
local integer mI = 0
local string cBIS = "" //building id string
//=========================================================================================
//MAIN PART
//=========================================================================================
set str = "Player_" + I2S(p) + "_base_" + I2S(baseI)
set dls_i = StringHashBJ(str + "_group")
set baseGroup = LoadGroupHandleBJ(0, dls_i, udg_PlayerAI[p])
call GroupAddGroup(baseGroup, sortGroup)
set unitsInGroup = CountUnitsInGroup(sortGroup) //this would do nothing, sortGroup is empty at this stage
set str = "Player_" + I2S(p) + "_base_" + I2S(baseI) + "_region"
set baseRect = LoadRectHandleBJ(0, StringHashBJ("Player_" + I2S(p) + "_base_" + I2S(baseI) + "_rect"), udg_PlayerAI[p])
//set baseR = LoadRegionHandleBJ(0, StringHashBJ(str), udg_PlayerAI[p]) //just doesn't work
set l = GetRandomLocInRect(baseRect) // this will need to be changed to just randomly picking a building in group and then offset from it
set str = "Player_" + I2S(p) + "_base_" + I2S(baseI) + "_wants"
set prefix = str
set str = str + "_indexCount"
set dls_i = StringHashBJ(str)
set indexCount = LoadIntegerBJ(0, dls_i, udg_PlayerAI[p]) // this should actually be 0, but fix later
set mIC = LoadIntegerBJ(0, StringHashBJ(prefix + "_metaList_indexCount"), udg_PlayerAI[p]) // this should not get dataName because that shouldn't be in meta, it's inbuilt
set prefix2 = "Player_" + I2S(p) + "_base_" + I2S(baseI) + "_has"
set prefixBase = "Player_" + I2S(p) + "_base_" + I2S(baseI)
/*
if (p == udg_herodinPlayerID) then
call DisplayTextToForce( GetPlayersAll(), "baseAI begun" )
call DisplayTextToForce( GetPlayersAll(), "player: " + I2S(p) )
call DisplayTextToForce( GetPlayersAll(), "base: " + I2S(baseI) )
endif
*/
//=========================================================================================
set index = 1
loop
exitwhen (index > mIC)
if (p == udg_herodinPlayerID) then
//call DisplayTextToForce( GetPlayersAll(), "started loop" )
//call DisplayTextToForce( GetPlayersAll(), "unitsInGroup: " + I2S(unitsInGroup) )
endif
set iS = I2S(index)
set str = prefix + "_metaList_" + iS // it's doing it here
set dls_i = StringHashBJ(str)
set uTS = LoadStringBJ(0, dls_i, udg_PlayerAI[p])
set str = prefix2 + "_" + uTS + "_count"
set currentlyHave = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
set str = prefix2 + "_building_" + uTS + "_count"
set currentlyBuilding = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
set str = prefix + "_" + uTS + "_count"
set count = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p]) // how much wanted
set addCount = count - currentlyHave - currentlyBuilding
if (p == udg_herodinPlayerID) then
/*
call DisplayTextToForce( GetPlayersAll(), "dls: " + prefix2 + "_building_" + uTS + "_count" )
call DisplayTextToForce( GetPlayersAll(), "uTS: " + uTS )
call DisplayTextToForce( GetPlayersAll(), "addCount: " + I2S(addCount) )
call DisplayTextToForce( GetPlayersAll(), "currentlyBuilding: " + I2S(currentlyBuilding) )
call DisplayTextToForce( GetPlayersAll(), "currentlyHave: " + I2S(currentlyHave) )
*/
endif
set i = 1
set iEnd = 250 // just temp blocker atm, I'll plug everything later :3
set enumUnit = FirstOfGroup(sortGroup)
loop
exitwhen ((processFinished == true) or (enumUnit == null))
//add all units that can train unit in here
set previousCount = addCount
set str = prefix2 + "_" + uTS + "_count"
set currentlyHave = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
set str = prefix2 + "_building_" + uTS + "_count"
set currentlyBuilding = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p])
set str = prefix + "_" + uTS + "_count"
set count = LoadIntegerBJ(0, StringHashBJ(str), udg_PlayerAI[p]) // how much wanted
set addCount = count - currentlyHave - currentlyBuilding
//================================
//TRAIN UNIT PART
//================================
if (IsUnitInGroup(enumUnit, LoadGroupHandleBJ(0, StringHashBJ(prefixBase + "_builders"), udg_PlayerAI[p])) == false) then
if (IsUnitIdType(String2UnitIdBJ(uTS), UNIT_TYPE_STRUCTURE) == false ) then
call IssueTrainOrderByIdBJ(enumUnit, String2UnitIdBJ(uTS))
else
call IssueBuildOrderByIdLocBJ( enumUnit, String2UnitIdBJ(uTS), l)
endif
//================================
//REQS
//================================
set str = "UnitType_" + uTS + "_req_indexCount" // data from Terms, what the Player understands (information can be manually set)
set dls_i = StringHashBJ(str)
set reqIC = LoadIntegerBJ(0, dls_i, udg_Terms[p])
set reqI = 1
loop
exitwhen (reqI > reqIC)
set reqS = LoadStringBJ(0, StringHashBJ("UnitType_" + uTS + "_req_" + I2S(reqI)), udg_Terms[p]) // this gives us the req unit type string
// this all needs to be checked, it seems wonky
set str = prefix2 + "_" + reqS + "_count"
set dls_i = StringHashBJ(str)
set currentlyHave = LoadIntegerBJ(0, dls_i, udg_PlayerAI[p])
set str = prefix2 + "_building_" + reqS + "_count"
set dls_i = StringHashBJ(str)
set currentlyBuilding = LoadIntegerBJ(0, dls_i, udg_PlayerAI[p])
set dls_i = StringHashBJ(reqS)
if ((currentlyHave - currentlyBuilding) > 0 ) then // quick cheese, it just needs to make a minimum of one in all cases
if (IsUnitIdType(String2UnitIdBJ(reqS), UNIT_TYPE_STRUCTURE) == false ) then
call IssueTrainOrderByIdBJ(enumUnit, String2UnitIdBJ(uTS))
else
call IssueBuildOrderByIdLocBJ( enumUnit, String2UnitIdBJ(uTS), l) // this is covered by a issued order trigger
endif
//call DisplayTextToForce( GetPlayersAll(), "should have started building req" )
endif
//checking the queue count for the req units too
set reqI = reqI + 1
endloop
endif
//===============================================
set newUnitsQueued = previousCount - addCount // this gets the difference in units wanted between cycles, if it hasn't changed since last then it's stuck
//check this
if (newUnitsQueued <= 0) then
if (newLoop == true) then
set processFinished = true
endif
endif
if (addCount <= 0) then
set processFinished = true
endif
if (i > iEnd) then
set processFinished = true
endif
if(udf_playerCanAffordUnit(String2UnitIdBJ(uTS), p) == false) then
//set processFinished = true
endif
//===============================================
//cycle, remove unit, new unit, group loop, etc
// in its best life just adds a train order one at a time to individual trainers until it's queued up enough
//===============================================
call GroupRemoveUnitSimple(enumUnit,sortGroup)
set enumUnit = FirstOfGroup(sortGroup)
//===============================================
// if sortGroup becomes empty it's time for a new loop
if (newLoop == true) then
set newLoop = false
endif
if (enumUnit == null) then
call GroupAddGroup(baseGroup, sortGroup)
set enumUnit = FirstOfGroup(sortGroup)
set newLoop = true
endif
//===============================================
set i = i + 1
endloop
call GroupAddGroup(baseGroup, sortGroup) // resets group
// just keep rechecking number being trained
// add all units capable of training to the sortGroup, and check when they're all full and can't train anymore
// and also that economic requirements are met
// and add an arbitrary limiter just in case
set index = index + 1
endloop
// Construction will be covered in the train unit parts. Sometimes units are required to be upgraded to as well.
//=========================================================================================
//PLUG LEAKS
//=========================================================================================
set uTS = ""
set dls_i = 0
set indexCount = 0
set str = ""
set index = 0
set iS = ""
set numNeeded = 0
set currentlyHave = 0
set currentlyBuilding = 0
call DestroyGroup(sortGroup)
set sortGroup = null
set baseGroup = null
set str2 = ""
set prefix = ""
set prefix2 = ""
set count = 0
set addCount = 0
set i = 0
set iEnd = 0
set goldRequired = 0
set gold = 0
set woodRequired = 0
set wood = 0
set foodRequired = 0
set food = 0
set previousCount = 0
set newUnitsQueued = 0
set enumUnit = null
set newLoop = false
set processFinished = false
endfunction
function Trig_test_x_gets_ids_of_unit_Actions takes nothing returns nothing
local integer b = 0
local group g = GetUnitsSelectedAll(GetTriggerPlayer())
local unit u = FirstOfGroup(g)
//MAIN PART
set b = LoadIntegerBJ(0, StringHashBJ("Units_" + I2S(GetHandleIdBJ(u)) + "_baseID"), udg_UnitAI)
call DisplayTextToForce( GetPlayersAll(), "unitID: " + I2S(GetHandleIdBJ(u)) )
call DisplayTextToForce( GetPlayersAll(), "playerID: " + I2S(GetConvertedPlayerId(GetOwningPlayer(u))) )
call DisplayTextToForce( GetPlayersAll(), "baseID: " + I2S(b) )
//PLUG LEAKS
call DestroyGroup(g)
set g = null
set u = null
set b = 0
endfunction
//===========================================================================
function InitTrig_test_x_gets_ids_of_unit takes nothing returns nothing
set gg_trg_test_x_gets_ids_of_unit = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_test_x_gets_ids_of_unit, Player(0), "1", true )
call TriggerAddAction( gg_trg_test_x_gets_ids_of_unit, function Trig_test_x_gets_ids_of_unit_Actions )
endfunction
function udf_calculateEricPartyStats takes group lp_g returns nothing
local real lv_partyOriginalHealth = udg_Eric_PartyStartingHealth
local real lv_partyOriginalNumbers = I2R(udg_Eric_PartyStartingNumbers)
local real lv_baseTotalHealth = 0
local real lv_remainingTotalHealth = 0
local group lv_sortGroupAlt = CreateGroup()
local unit lv_enumUnit = null
local integer lv_numRemaining = 0
call GroupAddGroup( udg_Eric_Group, lv_sortGroupAlt)
set lv_numRemaining = CountUnitsInGroup(lv_sortGroupAlt)
set udg_Eric_PartyStartingNumbers = lv_numRemaining
loop
exitwhen (lv_numRemaining <= 0)
set lv_enumUnit = FirstOfGroup(lv_sortGroupAlt)
set lv_remainingTotalHealth = lv_remainingTotalHealth + GetUnitStateSwap(UNIT_STATE_LIFE, lv_enumUnit)
set lv_baseTotalHealth = lv_baseTotalHealth + GetUnitStateSwap(UNIT_STATE_MAX_LIFE, lv_enumUnit)
set lv_numRemaining = lv_numRemaining -1
call GroupRemoveUnitSimple(lv_enumUnit, lv_sortGroupAlt) //i'm assuming this doesn't remove from original unit, and the groups are copies
endloop
set udg_Eric_PartyStartingHealth = lv_baseTotalHealth
if (lv_baseTotalHealth > 0) then
set udg_Eric_PartyHealthQuotient = lv_remainingTotalHealth / lv_baseTotalHealth
endif
set udg_Eric_PartyHealthQuotient = udg_Eric_PartyHealthQuotient * (udg_Eric_PartyStartingNumbers - lv_numRemaining)
//this should work fine
set udg_Eric_PartyRemainingHealth = lv_remainingTotalHealth
//PLUG LEAKS
call DestroyGroup (lv_sortGroupAlt)
set lv_baseTotalHealth = 0
set lv_remainingTotalHealth = 0
set lv_partyOriginalHealth = 0
set lv_partyOriginalNumbers = 0
set lv_enumUnit = null
set lv_numRemaining = 0
//PARAMS
set lp_g = null // i assume this group is actually a udg, so don't destroy it
endfunction
function sAI_addUnitToEricParty takes unit u returns nothing
local integer lv_numRemaining = CountUnitsInGroup(udg_Eric_Group)
local integer p = GetPlayerId(GetOwningPlayer(u))
local integer b = 0
local string unitIDString = I2S(GetHandleIdBJ(u))
//MAIN PART
set b = LoadIntegerBJ(0, StringHashBJ("Units_" + unitIDString + "_baseID"), udg_UnitAI)
set udg_Eric_PartyStartingHealth = udg_Eric_PartyStartingHealth + GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)
set udg_Eric_PartyRemainingHealth = udg_Eric_PartyRemainingHealth + GetUnitStateSwap(UNIT_STATE_LIFE, u)
set lv_numRemaining = lv_numRemaining + 1
call sAI_baseRemoveUnit(p, b, u) //hopefully no errors occur with this, like unit not being properly added to a returned default 0
call GroupAddUnitSimple(u, udg_Eric_Group)
if (udg_Eric_PartyStartingHealth > 0) then
set udg_Eric_PartyHealthQuotient = udg_Eric_PartyRemainingHealth / udg_Eric_PartyStartingHealth
else
set udg_Herodin_PartyStartingHealth = 0
endif
//PLUG LEAKS
set lv_numRemaining = 0
set p = 0
set b = 0
set unitIDString = ""
//PARAMS
set u = null
endfunction
function sAI_removeUnitFromEricParty takes unit u returns nothing
local integer lv_numRemaining = CountUnitsInGroup(udg_Eric_Group)
//MAIN PART
set udg_Eric_PartyStartingHealth = udg_Eric_PartyStartingHealth - GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)
set udg_Eric_PartyRemainingHealth = udg_Eric_PartyRemainingHealth - GetUnitStateSwap(UNIT_STATE_LIFE, u)
set udg_Eric_PartyStartingNumbers = udg_Eric_PartyStartingNumbers - 1
call GroupRemoveUnit(udg_Eric_Group, u)
if (udg_Eric_PartyStartingHealth > 0) then
set udg_Eric_PartyHealthQuotient = udg_Eric_PartyRemainingHealth / udg_Eric_PartyStartingHealth
else
set udg_Eric_PartyStartingHealth = 0
endif
//PLUG LEAKS
set lv_numRemaining = 0
//PARAMS
set u = null
endfunction
function sAI_testUnitForTrainAbility takes integer p, unit u returns nothing
//use this later for the ai to generate its own data, learning etc
endfunction
function sAI_cycleUnitAbilitiesAndReturn takes integer p, unit u returns nothing
// a sort of enum function, to help AI test its abilities and what each unit can do
// hopefully there is actually a way to cycle abilities other than manually writing each one down and then testing the entire list
set udg_tempString = ""
endfunction
//==========================================================================
function sAI_playerAI_pregenReqs takes integer p returns nothing
local string prefix = ""
local string str = ""
local string dls = ""
local integer dls_i = 0
local string uTS = ""
local integer reqI = 0
local string reqS = ""
//========================================================================
//HUMAN ALLIANCE
//========================================================================
//HUMAN FOOTMAN
set uTS = UnitId2StringBJ('hfoo')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN VETERAN
set uTS = UnitId2StringBJ('h00N')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN KNIGHT
set reqI = 1
set uTS = UnitId2StringBJ('hkni')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//========
set reqI = reqI + 1
set reqS = UnitId2StringBJ('hbla')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//========
set reqI = reqI + 1
set reqS = UnitId2StringBJ('hcas')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN HUNTER
set reqI = 1
set uTS = UnitId2StringBJ('n006')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN PEASANT
set uTS = UnitId2StringBJ('hpea')
set reqS = UnitId2StringBJ('htow')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN GUARD TOWER
set uTS = UnitId2StringBJ('hgtw') // human guard tower
set reqS = UnitId2StringBJ('hwtw') //normal scout tower which is required for it to upgrade
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//HUMAN CANNON TOWER
set uTS = UnitId2StringBJ('hgtw')
set reqS = UnitId2StringBJ('hwtw')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//ALLIANCE ARCANE TOWER
set uTS = UnitId2StringBJ('hgtw')
set reqS = UnitId2StringBJ('hwtw')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//ALLIANCE BARRACKS
set uTS = UnitId2StringBJ('hbar')
set reqS = UnitId2StringBJ('htow')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//ALLIANCE BLACKSMITH
set uTS = UnitId2StringBJ('hbla')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//ALLIANCE KEEP
set uTS = "hkee"
set reqS = "htow"
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//ALLIANCE CASTLE
set uTS = UnitId2StringBJ('hcas')
set reqS = UnitId2StringBJ('hkee')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//========================================================================
//DWARVES
//========================================================================
//RIFLEMAN
set reqI = 1
set uTS = UnitId2StringBJ('hrif')
set reqS = UnitId2StringBJ('hbar')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//DWARF WORKER
set reqI = 1
set uTS = UnitId2StringBJ('h014')
set reqS = UnitId2StringBJ('h00S')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//========================================================================
//UNDEAD
//========================================================================
//UNDEAD SPIRIT TOWER
set uTS = UnitId2StringBJ('uzg1')
set reqS = UnitId2StringBJ('uzig')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//UNDEAD NERUBIAN TOWER
set uTS = UnitId2StringBJ('uzg2')
set reqS = UnitId2StringBJ('uzig')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
//UNDEAD HAUNTED GOLD MINE
set uTS = UnitId2StringBJ('ugol')
set reqS = UnitId2StringBJ('ngol')
set str = "UnitType_" + uTS + "_req_" + I2S(reqI)
set dls_i = StringHashBJ(str)
call SaveStringBJ(str, 0, dls_i, udg_Terms[p])
endfunction
function sAI_ericPlayerAI_init takes nothing returns nothing
local unit townhall = udg_ericFirstTH
local integer p = udg_ericPlayerID
local integer base = 1
call sAI_addBase(p, townhall)
set base = udg_sAI_lastCreatedBaseID
//Veterans
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h00N'), 3)
//Footmen
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hfoo'), 6)
//Hunters
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('n006'), 4)
//Peasants
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hpea'), 8)
//buildings
//Guard Tower
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hgtw'), 4)
//Town Hall
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hcas'), 1)
//Barracks
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hbar'), 2)
//Lumber Mill
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hlum'), 1)
//Blacksmith
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hbla'), 1)
//Altar of Kings
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('halt'), 1)
//Farms
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hhou'),10)
//PLUG LEAKS
set townhall = null
set p = 0
set base = 0
endfunction
function sAI_undeadGreyPlayerAI_init takes nothing returns nothing
local unit townhall = udg_undeadGreyFirstTH
local integer p = udg_undeadGreyPlayerID
local integer base = 1
call sAI_addBase(p, townhall)
//Ghouls
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('ugol'), 6) // how does this work with duplicated names?
//Child of Gro'dar
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('u001'), 6)
//Crypt Fiends
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('ucry'), 3)
//Carrion Beetles
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('u009'), 4)
//Acolytes
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('uaco'), 5)
//buildings
//Spirit Tower
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('uzg1'), 6)
//Black Citadel
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('unp2'), 1)
//Graveyard
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('ugrv'), 1)
//Crypt
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('usep'), 1)
//Slaughterhouse
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('uslh'), 1)
//PLUG LEAKS
set townhall = null
set p = 0
set base = 0
endfunction
function udf_calculateHerodinPartyStats takes group lp_g returns nothing
local real lv_partyOriginalHealth = udg_Herodin_PartyStartingHealth
local real lv_partyOriginalNumbers = I2R(udg_Herodin_PartyStartingNumbers)
local real lv_baseTotalHealth = 0
local real lv_remainingTotalHealth = 0
local group lv_sortGroupAlt = CreateGroup()
local unit lv_enumUnit = null
local integer lv_numRemaining = 0
call GroupAddGroup( udg_Herodin_Group, lv_sortGroupAlt)
set lv_numRemaining = CountUnitsInGroup(lv_sortGroupAlt)
set udg_Herodin_PartyStartingNumbers = lv_numRemaining
loop
exitwhen (lv_numRemaining <= 0)
set lv_enumUnit = FirstOfGroup(lv_sortGroupAlt)
set lv_remainingTotalHealth = lv_remainingTotalHealth + GetUnitStateSwap(UNIT_STATE_LIFE, lv_enumUnit)
set lv_baseTotalHealth = lv_baseTotalHealth + GetUnitStateSwap(UNIT_STATE_MAX_LIFE, lv_enumUnit)
set lv_numRemaining = lv_numRemaining -1
call GroupRemoveUnitSimple(lv_enumUnit, lv_sortGroupAlt)
endloop
set udg_Herodin_PartyStartingHealth = lv_baseTotalHealth
if (lv_baseTotalHealth > 0) then
set udg_Herodin_PartyHealthQuotient = lv_remainingTotalHealth / lv_baseTotalHealth
endif
set udg_Herodin_PartyHealthQuotient = udg_Herodin_PartyHealthQuotient * (udg_Herodin_PartyStartingNumbers - lv_numRemaining)
//this should work fine
set udg_Herodin_PartyRemainingHealth = lv_remainingTotalHealth
//PLUG LEAKS
call DestroyGroup (lv_sortGroupAlt)
set lv_baseTotalHealth = 0
set lv_remainingTotalHealth = 0
set lv_partyOriginalHealth = 0
set lv_partyOriginalNumbers = 0
set lv_enumUnit = null
set lv_numRemaining = 0
endfunction
function sAI_addUnitToHerodinParty takes unit u returns nothing
local integer lv_numRemaining = CountUnitsInGroup(udg_Herodin_Group)
local integer p = GetPlayerId(GetOwningPlayer(u))
local integer b = 0
local string unitIDString = I2S(GetHandleIdBJ(u))
//MAIN PART
set b = LoadIntegerBJ(0, StringHashBJ("Units_" + unitIDString + "_baseID"), udg_UnitAI)
set udg_Herodin_PartyStartingHealth = udg_Herodin_PartyStartingHealth + GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)
set udg_Herodin_PartyRemainingHealth = udg_Herodin_PartyRemainingHealth + GetUnitStateSwap(UNIT_STATE_LIFE, u)
set lv_numRemaining = lv_numRemaining + 1
call sAI_baseRemoveUnit(p, b, u) //hopefully no errors occur with this, like unit not being properly added to a returned default 0
call GroupAddUnitSimple(u, udg_Herodin_Group)
if (udg_Herodin_PartyStartingHealth > 0) then
set udg_Herodin_PartyHealthQuotient = udg_Herodin_PartyRemainingHealth / udg_Herodin_PartyStartingHealth
else
set udg_Herodin_PartyStartingHealth = 0
endif
//maybe should make this recalculate cleanly somehow to avoid errors, that shouldn't be an issue
// add all remaining life and incl new unit
// and update numbers, so we know if there's replacement or whatev if need to count dat
//PLUG LEAKS
set lv_numRemaining = 0
set p = 0
set b = 0
set unitIDString = ""
endfunction
function sAI_removeUnitFromHerodinParty takes unit u returns nothing
local integer lv_numRemaining = CountUnitsInGroup(udg_Herodin_Group)
//MAIN PART
set udg_Herodin_PartyStartingHealth = udg_Herodin_PartyStartingHealth - GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)
set udg_Herodin_PartyRemainingHealth = udg_Herodin_PartyRemainingHealth - GetUnitStateSwap(UNIT_STATE_LIFE, u)
set udg_Herodin_PartyStartingNumbers = udg_Herodin_PartyStartingNumbers - 1
call GroupRemoveUnit(udg_Herodin_Group, u)
if (udg_Herodin_PartyStartingHealth > 0) then
set udg_Herodin_PartyHealthQuotient = udg_Herodin_PartyRemainingHealth / udg_Herodin_PartyStartingHealth
else
set udg_Herodin_PartyStartingHealth = 0
endif
//PLUG LEAKS
set lv_numRemaining = 0
endfunction
function Herodin_createGuardPositions takes nothing returns nothing
endfunction
function loAI_addPatrolLocation takes location lp_loc, string lp_patrolType returns nothing
endfunction
function udf_rootToLastLock takes nothing returns nothing
local hashtable lv_hash = udg_hashTablePathHash
local integer lv_index = 0
local string lv_saveName = udg_lastUsedRootName
local integer lv_parent = StringHashBJ("rootName")
//========================================
set lv_index = LoadIntegerBJ(StringHashBJ("indexCount"), lv_parent, lv_hash)
set lv_index = lv_index + 1
call SaveStringBJ(lv_saveName, StringHashBJ(I2S(lv_index)), lv_parent, lv_hash)
call SaveIntegerBJ(lv_index, StringHashBJ("indexCount"), lv_parent, lv_hash)
set udg_lockedRootName = lv_saveName
set udg_lockedRootNamePathInt = lv_index
endfunction
function udg_rootToLastUnlock takes nothing returns nothing
local hashtable lv_hash = udg_hashTablePathHash
local integer lv_parent = StringHashBJ("rootName")
local integer lv_index = LoadIntegerBJ(StringHashBJ("indexCount"), lv_parent, lv_hash)
local string lv_saveName = LoadStringBJ(StringHashBJ(I2S(lv_index)), lv_parent, lv_hash)
//========================================
call SaveStringBJ(null, StringHashBJ(I2S(lv_index)), lv_parent, lv_hash)
set lv_index = lv_index - 1
call SaveIntegerBJ(lv_index, StringHashBJ("indexCount"), lv_parent, lv_hash)
set udg_lockedRootName = ""
set udg_lockedRootNamePathInt = 0
endfunction
function loAI_addGuardPosition takes location lp_loc, integer lp_unitTypeInt, string lp_patrolRoute returns nothing
local integer lv_pathInt = 0
local integer lv_indexCount = 0
local integer lv_parent = StringHashBJ("guardPosition")
local hashtable lv_hash = udg_herodinGuardForceHash
set udg_tempHash = lv_hash
set udg_tempParent = lv_parent
set udg_tempRootName = ""
//=============================================================
// Add unit data to the hash
//=============================================================
call sAI_addDataToHashLocation_UT(lp_playerInt, lp_location)
call sAI_addDataToHashString_UT(lp_playerInt,"unit", "") // creates an empty for a unit - auto added to last, waiting for fill
call udf_rootToLastLock() // locks the temp root name, cannot be changed, so next addDatas will be set to this root name
call sAI_addDataToHashInteger_UT(lp_playerInt, lp_unitTypeInt)
call sAI_addDataToHashString_UT(lp_playerInt,"behavior", "guard") // need a field state add?
call udf_rootToLastUnlock()
//=============================================================
//=============================================================
endfunction
function loAI_setGuardsPeriodicCheck takes nothing returns nothing
local integer lv_herodinAIInt = udg_herodinAIInt
//these strings need to be proper unit type ids
if udg_HDxNumOfRiflemen < udg_HDxNumOfRiflemenNeeded[udg_bridgeDefenderLevel] then
udf_createHerodinDefenders("riflemen", udg_HDxNumOfRiflemenNeeded[udg_bridgeDefenderLevel] - udg_HDxNumOfRiflemen)
endif
if udg_HDxNumOfMortarTeams < udg_HDxNumOfMortarTeamsNeeded[udg_bridgeDefenderLevel] then
udf_createHerodinDefenders("mortarteam", udg_HDxNumOfMortarTeamsNeeded[udg_bridgeDefenderLevel] - udg_HDxNumOfMortarTeams)
endif
if udg_HDxNumOfWorkers < udg_HDxNumOfWorkersNeeded[udg_bridgeDefenderLevel] then
udf_createHerodinDefenders("dwarvenworker", udg_HDxNumOfWorkersNeeded[udg_bridgeDefenderLevel] - udg_HDxNumOfWorkers)
endif
// if positions are filled up, then the reinforcement just picks a unit to go stand by
// loops guard position and also sees if assigned unit is there, if unit is alive but not there, attack move to
// new unit just stands close by, unassigned until a slot opens up
if then
elseif then
else
endif
endfunction
function sAI_herodinSpells takes nothing returns nothing
local unit u = udg_Herodin
local integer closeEnemyCount = 0
local group sortGroup = CreateGroup()
local boolean processFinished = false
local unit enumUnit = null
//MAIN PART
set sortGroup = GetUnitsInRangeOfLocAll(200.00, GetUnitLoc(u))
set enumUnit = FirstOfGroup(sortGroup)
loop
exitwhen (enumUnit == null)
if (IsPlayerEnemy(GetOwningPlayer(enumUnit), (GetOwningPlayer(u))) == true) then
if (IsUnitType(enumUnit, UNIT_TYPE_STRUCTURE) == false ) then
set closeEnemyCount = closeEnemyCount + 1
endif
endif
call GroupRemoveUnitSimple(enumUnit, sortGroup)
set enumUnit = FirstOfGroup(sortGroup)
endloop
if (closeEnemyCount >= 3) then
call IssueImmediateOrderBJ( u, "thunderclap" )
endif
//PLUG LEAKS
set u = null
set closeEnemyCount = 0
call DestroyGroup(sortGroup)
set sortGroup = null
set processFinished = false
set enumUnit = null
endfunction
function sAI_herodinPlayerAI_init takes nothing returns nothing
local unit townhall = udg_herodinFirstTH
local integer p = udg_herodinPlayerID
local integer base = 1
//MAIN PART
call sAI_addBase(p, townhall)
set base = udg_sAI_lastCreatedBaseID
//Rifleman
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h019'), 9)
//Skybarge prob
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('n00q'), 2)
//Dwarven Worker
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h00K'), 6)
//buildings
//Dwarven Rifleman Tower (bottom piece - fix later)
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h018'), 1)
//Dwarven AA Tower
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h017'), 1)
//Dwarven Town Hall
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h00S'), 1)
//Barracks
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h00F'), 1)
//D Smithy
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('h00E'), 1)
//Altar of Kings
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('halt'), 1)
//Farm
call sAI_base_addWant_unit(p, base, UnitId2StringBJ('hhou'),8)
//PLUG LEAKS
set townhall = null
set p = 0
set base = 0
endfunction
function sAI_hunterDog takes unit u returns nothing
local integer unitID = GetHandleIdBJ(u)
local string unitIDString = I2S(unitID)
local unit hunter = LoadUnitHandleBJ(0, StringHashBJ("Units_" + unitIDString + "_hunter"), udg_UnitAI)
local string hunterIDString = I2S(GetHandleIdBJ(hunter))
local unit hunterTarget = LoadUnitHandleBJ(0, StringHashBJ("Units_" + hunterIDString + "_currentTarget"), udg_UnitAI) // this requires some attack input
local location dogAttackPoint = GetUnitLoc(hunterTarget)
local location randPoint = PolarProjectionBJ(GetUnitLoc(hunter), 256, GetRandomDirectionDeg())
//local timer dogDecisionWait = null
if (hunterTarget != null) then
call IssueTargetOrderBJ( u, "attack", hunterTarget )
else
call IssuePointOrderLocBJ( u, "attack", dogAttackPoint )
endif
//PLUG LEAKS
set unitID = 0
set unitIDString = ""
set hunter = null
set hunterIDString = ""
set hunterTarget = null
call RemoveLocation(dogAttackPoint)
set dogAttackPoint = null
call RemoveLocation(randPoint)
set randPoint = null
endfunction
function Trig_Hunter_Dies_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetDyingUnit()) == 'n006' ) ) then
return false
endif
return true
endfunction
function Trig_Hunter_Dies_Actions takes nothing returns nothing
local string hunterIDString = I2S(GetHandleIdBJ(GetDyingUnit()))
local integer dls_i = StringHashBJ("Units_" + hunterIDString + "_hunter")
local unit pet = LoadUnitHandleBJ(0, dls_i, udg_UnitAI)
//==============================================
//MAIN PART
//==============================================
call KillUnit(pet)
//==============================================
//PLUG LEAKS
//==============================================
set hunterIDString = ""
set dls_i = 0
set pet = null
endfunction
//===========================================================================
function InitTrig_Hunter_Dies takes nothing returns nothing
set gg_trg_Hunter_Dies = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hunter_Dies, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Hunter_Dies, Condition( function Trig_Hunter_Dies_Conditions ) )
call TriggerAddAction( gg_trg_Hunter_Dies, function Trig_Hunter_Dies_Actions )
endfunction
function Trig_Unit_Acquires_Target_x_General_Actions takes nothing returns nothing
local unit u = GetOrderedUnit()
local string unitIDString = I2S(GetHandleIdBJ(u))
local integer dls_i = StringHashBJ("Units_" + unitIDString + "_currentTarget")
//MAIN PART
call SaveUnitHandleBJ(GetOrderTargetUnit(), 0, dls_i, udg_UnitAI)
//PLUG LEAKS
set u = null
set unitIDString = ""
set dls_i = 0
endfunction
//===========================================================================
function InitTrig_Unit_Acquires_Target_x_General takes nothing returns nothing
set gg_trg_Unit_Acquires_Target_x_General = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Acquires_Target_x_General, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddAction( gg_trg_Unit_Acquires_Target_x_General, function Trig_Unit_Acquires_Target_x_General_Actions )
endfunction
function Trig_Unit_Unacquires_Target_x_General_Actions takes nothing returns nothing
local unit u = GetOrderedUnit()
local string unitIDString = I2S(GetHandleIdBJ(u))
local integer dls_i = StringHashBJ("Units_" + unitIDString + "_currentTarget")
//MAIN PART
call SaveUnitHandleBJ(null, 0, dls_i, udg_UnitAI)
//PLUG LEAKS
set u = null
set unitIDString = ""
set dls_i = 0
endfunction
//===========================================================================
function InitTrig_Unit_Unacquires_Target_x_General takes nothing returns nothing
set gg_trg_Unit_Unacquires_Target_x_General = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Unacquires_Target_x_General, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Unacquires_Target_x_General, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddAction( gg_trg_Unit_Unacquires_Target_x_General, function Trig_Unit_Unacquires_Target_x_General_Actions )
endfunction
function sAI_saveUnitToHash takes unit u returns nothing
local string uIS = I2S(GetHandleIdBJ(u))
//MAIN PART
call sAI_saveUnitParameter(u, "unit", "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set uIS = ""
endfunction
function sAI_unitStopBuilding takes unit u returns nothing
local unit trainer = u
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
local string cBIS = ""
local unit cB = null // currently building
local string cBTS = ""
local string bOrdString = null
//MAIN PART
//GET ID VARIABLES
set baseIDString = I2S(LoadIntegerBJ(0, StringHashBJ("Units_" + trainerIDString + "_baseID"), udg_UnitAI))
set cB = LoadUnitHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_unit"), udg_UnitAI)
set cBTS = LoadStringBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_unitType"), udg_UnitAI) // maybe update to "unitTypeString"
//call IssueImmediateOrderBJ(u, "stop")
call sAI_saveUnitParameter(null, "currentlyBuilding_unit", "Units_" + trainerIDString, udg_UnitAI)
call sAI_saveLocationParameter(null, "currentlyBuilding_location", "Units_" + trainerIDString, udg_UnitAI)
call sAI_saveStringParameter("", "currentlyBuilding_unitType", "Units_" + trainerIDString, udg_UnitAI)
set str = "Player_" + playerIDString + "_base_" + baseIDString
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_builders"), udg_PlayerAI[p]), trainer)
call GroupAddUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_workers_idle"), udg_PlayerAI[p]), trainer)
set str = "Player_" + playerIDString + "_base_" + baseIDString
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + cBTS + "_count"), udg_PlayerAI[p])
set count = count - 1
call SaveIntegerBJ(count, 0, StringHashBJ(str + "_has_building_" + cBTS + "_count"), udg_PlayerAI[p])
//"has building" applies even to a structure that has begun construction, they are not considered "has" until complete
//PLUG LEAKS
set trainer = null
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
set cBIS = ""
set cB = null
set cBTS = ""
set bOrdString = null
endfunction
function sAI_cancelConstruction takes unit u returns nothing
call IssueImmediateOrderById(u, 851976)
endfunction
function sAI_startException takes unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
//MAIN PART
call sAI_saveBooleanParameter(true, "loopException", "Units_" + unitIDString, udg_UnitAI)
//PLUG LEAKS
set unitIDString = ""
endfunction
function sAI_endException takes unit u returns nothing
local string unitIDString = I2S(GetHandleIdBJ(u))
//MAIN PART
call sAI_saveBooleanParameter(false, "loopException", "Units_" + unitIDString, udg_UnitAI)
//PLUG LEAKS
set unitIDString = ""
endfunction
function Trig_PlayerAI_x_Base_Attacked_Actions takes nothing returns nothing
local string unitIDString = I2S(GetHandleId(GetAttackedUnitBJ()))
local integer p = GetConvertedPlayerId(GetOwningPlayer(GetAttackedUnitBJ()))
local string playerIDString = I2S(p)
local string bIS = I2S(LoadIntegerBJ(0, StringHashBJ("Units_" + unitIDString + "_baseID"), udg_UnitAI))
local group g = CreateGroup()
local unit enumUnit = null
local location loc = GetUnitLoc(GetAttackedUnitBJ())
//======================================================
if (IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_STRUCTURE) == true) then
set udg_tempGroup = LoadGroupHandleBJ(0, StringHashBJ("Player_" + playerIDString + "_base_" + bIS + "_army"), udg_PlayerAI[p])
call sAI_saveUnitParameter(GetAttackedUnitBJ(), "lastAttackedBuilding", "Player_" + playerIDString + "_base_" + bIS, udg_PlayerAI[p])
call GroupAddGroup(udg_tempGroup, g)
set enumUnit = FirstOfGroup(g)
loop
exitwhen (enumUnit == null)
call IssuePointOrderLoc(enumUnit, "attack", loc)
call GroupRemoveUnit(g, enumUnit)
set enumUnit = FirstOfGroup(g)
endloop
endif
// //======================================================
call DestroyGroup(g)
call RemoveLocation(loc)
set g = null
set unitIDString = ""
set p = 0
set playerIDString = ""
set bIS = ""
set enumUnit = null
set loc = null
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Base_Attacked takes nothing returns nothing
set gg_trg_PlayerAI_x_Base_Attacked = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Base_Attacked, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_PlayerAI_x_Base_Attacked, function Trig_PlayerAI_x_Base_Attacked_Actions )
endfunction
function Trig_PlayerAI_x_Construction_Finishes_Actions takes nothing returns nothing
local unit trainer = GetTriggerUnit() //invalid i tink
local unit u = GetConstructedStructure()
local string unitIDString = I2S(GetHandleIdBJ(u))
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer))
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train indec string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local group baseArmy = null
local integer count = 0
local string uTS = UnitId2StringBJ(GetUnitTypeId(u))
//new
local group sortGroup = CreateGroup()
//MAIN PART
//call AddSpecialEffectLocBJ( GetUnitLoc(trainer), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
//call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call sAI_saveUnitParameter(null, "currentlyBuilding_unit", "Units_" + trainerIDString, udg_UnitAI)
call sAI_saveLocationParameter(null, "currentlyBuilding_location", "Units_" + trainerIDString, udg_UnitAI)
call sAI_saveStringParameter("", "currentlyBuilding_unitType", "Units_" + trainerIDString, udg_UnitAI)
// ASSIGN BASE
call sAI_assignNearbyBaseToUnit(p, u) // Just whatever zone it's actually built in. Otherwise default to 0.
//call sAI_baseAddUnit(p, baseID, u)
// don't need to add terms
//GET BASE ID
set str = "Units_" + unitIDString + "_baseID"
set baseID = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
set baseIDString = I2S(baseID)
//GET BUILDERS
// UPDATE TRAINING COUNT
set str = "Player_" + playerIDString + "_base_" + baseIDString
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_builders"), udg_PlayerAI[p]), trainer)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_isBuilding"), udg_UnitAI), u)
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + uTS + "_count"), udg_PlayerAI[p])
set count = count - 1
call SaveIntegerBJ(count, 0, StringHashBJ(str + "_has_building_" + uTS + "_count"), udg_PlayerAI[p])
//PLUG LEAKS
set trainer = null
set u = null
set unitIDString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set baseArmy = null
set count = 0
set uTS = ""
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Construction_Finishes takes nothing returns nothing
set gg_trg_PlayerAI_x_Construction_Finishes = CreateTrigger( )
call DisableTrigger( gg_trg_PlayerAI_x_Construction_Finishes )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Construction_Finishes, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_PlayerAI_x_Construction_Finishes, function Trig_PlayerAI_x_Construction_Finishes_Actions )
endfunction
function Trig_PlayerAI_x_Construction_Queued_2_Conditions takes nothing returns boolean
if ( not ( IsUnitIdType(String2UnitIdBJ(OrderId2StringBJ(GetIssuedOrderIdBJ())), UNIT_TYPE_STRUCTURE) == true ) ) then
return false
endif
if ( not ( String2UnitIdBJ(OrderId2StringBJ(GetIssuedOrderIdBJ())) != 0 ) ) then
return false
endif
return true
endfunction
function Trig_PlayerAI_x_Construction_Queued_2_Actions takes nothing returns nothing
local integer ord = GetIssuedOrderIdBJ()
//
local unit trainer = GetOrderedUnit()
local string orderString = OrderId2StringBJ(GetIssuedOrderIdBJ())
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
//new
local location orderLoc = GetOrderPointLoc()
local timer newTimer = LoadTimerHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_timer"), udg_UnitAI)
//MAIN PART
//call AddSpecialEffectLocBJ( GetUnitLoc(trainer), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
//call DestroyEffectBJ( GetLastCreatedEffectBJ() )
//call DisplayTextToForce( GetPlayersAll(), "queued" )
set trainerIDString = I2S(GetHandleIdBJ(trainer))
//Get Base Id
set str = "Units_" + trainerIDString + "_baseID"
set dls_i = StringHashBJ(str)
set baseID = LoadIntegerBJ(0, dls_i, udg_UnitAI)
set baseIDString = I2S(baseID)
//Save Unit Type Being Constructed
call sAI_saveStringParameter(orderString, "currentlyBuilding_unitType", "Units_" + trainerIDString, udg_UnitAI)
call sAI_saveLocationParameter(orderLoc, "currentlyBuilding_location", "Units_" + trainerIDString, udg_UnitAI)
if (newTimer == null) then
set newTimer = CreateTimer()
endif
call sAI_saveTimerParameter(newTimer, "currentlyBuilding_timer", "Units_" + trainerIDString, udg_UnitAI)
if (TimerGetRemaining(newTimer) <= 0.0) then
call StartTimerBJ(newTimer, false, 20)
endif
set str = "Player_" + playerIDString + "_base_" + baseIDString
call GroupAddUnitSimple(trainer, LoadGroupHandleBJ(0, StringHashBJ(str + "_builders"), udg_PlayerAI[p]))
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_harvesters"), udg_PlayerAI[p]), trainer)
// the following adds Terms
//call sAI_addUnitTrainingKnowledge(GetConvertedPlayerId(GetOwningPlayer(trainer)), UnitId2StringBJ(GetUnitTypeId(trainer)), orderString)
// update training count
call sAI_saveBooleanParameter(true, orderString, str + "_has_building", udg_PlayerAI[p])
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + orderString + "_count"), udg_PlayerAI[p])
set count = count + 1
call sAI_saveIntegerParameter(count, "count", str + "_has_building_" + orderString, udg_PlayerAI[p])
//PLUG LEAKS
set ord = 0
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
set orderLoc = null //it's being saved to data
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Construction_Queued_2 takes nothing returns nothing
set gg_trg_PlayerAI_x_Construction_Queued_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Construction_Queued_2, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Construction_Queued_2, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_PlayerAI_x_Construction_Queued_2, Condition( function Trig_PlayerAI_x_Construction_Queued_2_Conditions ) )
call TriggerAddAction( gg_trg_PlayerAI_x_Construction_Queued_2, function Trig_PlayerAI_x_Construction_Queued_2_Actions )
endfunction
function Trig_PlayerAI_x_Construction_Starts_Conditions takes nothing returns boolean
return true
endfunction
function Trig_PlayerAI_x_Construction_Starts_Actions takes nothing returns nothing
local integer ord = GetIssuedOrderIdBJ()
//
local unit trainer = GetTriggerUnit()
local unit u = GetConstructingStructure()
local string orderString = OrderId2StringBJ(GetIssuedOrderIdBJ())
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
//new
local location orderLoc = GetOrderPointLoc()
local string cBIS = ""
local unit cB = null // currently building
//MAIN PART
//call AddSpecialEffectLocBJ( GetUnitLoc(trainer), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
//call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call sAI_saveUnitToHash(u)
call sAI_saveUnitParameter(u, "currentlyBuilding_unit", "Units_" + trainerIDString, udg_UnitAI)
call GroupAddUnitSimple(u, LoadGroupHandleBJ(0, StringHashBJ("Player_" + playerIDString + "_base_" + baseIDString + "_isBuilding"), udg_UnitAI))
call GroupAddUnitSimple(u, LoadGroupHandleBJ(0, StringHashBJ("Player_" + playerIDString + "_base_" + baseIDString + "_group"), udg_UnitAI))
//PLUG LEAKS
set ord = 0
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
set orderLoc = null //it's being save to data
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Construction_Starts takes nothing returns nothing
set gg_trg_PlayerAI_x_Construction_Starts = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Construction_Starts, EVENT_PLAYER_UNIT_CONSTRUCT_START )
call TriggerAddCondition( gg_trg_PlayerAI_x_Construction_Starts, Condition( function Trig_PlayerAI_x_Construction_Starts_Conditions ) )
call TriggerAddAction( gg_trg_PlayerAI_x_Construction_Starts, function Trig_PlayerAI_x_Construction_Starts_Actions )
endfunction
function Trig_Player_x_Construction_Unqueued_Conditions takes nothing returns boolean
if ( ( String2UnitIdBJ(OrderId2StringBJ(GetIssuedOrderIdBJ())) != 0 ) ) then
return false
endif
return true
endfunction
function Trig_Player_x_Construction_Unqueued_Actions takes nothing returns nothing
local integer ord = GetIssuedOrderIdBJ()
//
local unit trainer = GetOrderedUnit()
local string orderString = OrderId2StringBJ(GetIssuedOrderIdBJ())
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
//new
local location orderLoc = GetOrderPointLoc()
local string cBIS = ""
local unit cB = null // currently building
local string cBTS = ""
local string bOrdString = null
local location loc = null
local timer t = LoadTimerHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_timer"), udg_UnitAI)
local unit transport = LoadUnitHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_timer"), udg_UnitAI)
local boolean unitIsBuilding = false
local boolean loopException = false
local unit targetUnit = GetOrderTargetUnit()
//MAIN PART
if (orderString == "repair" ) then
call sAI_saveUnitParameter(targetUnit, "currentlyBuilding_unit", "Units_" + trainerIDString, udg_UnitAI)
//integrate this with next part so building will remove it from its b group if this is a new building it's instructed to build
endif
//GET ID VARIABLES
set baseIDString = I2S(LoadIntegerBJ(0, StringHashBJ("Units_" + trainerIDString + "_baseID"), udg_UnitAI))
set cB = LoadUnitHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_unit"), udg_UnitAI)
set cBTS = LoadStringBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_unitType"), udg_UnitAI) // maybe update to "unitTypeString"
set loc = LoadLocationHandleBJ(0, StringHashBJ("Units_" + trainerIDString + "_currentlyBuilding_location"), udg_UnitAI)
set loopException = LoadBooleanBJ(0, StringHashBJ("Units_" + trainerIDString + "_loopException"), udg_UnitAI)
set str = "Player_" + playerIDString + "_base_" + baseIDString
if ((IsUnitInGroup(trainer, LoadGroupHandleBJ(0, StringHashBJ(str + "_builders"), udg_PlayerAI[p])) == true) and (loopException == false)) then
if (TimerGetRemaining(t) <= 0.0) then
if (cB != null) then
//call StartTimerBJ(t, false, 20.0)
//call IssuePointOrderLocBJ( trainer, "move", loc) // avoid infinite murozond loop, might need another timer
//call sAI_cancelConstruction(cB)
else
call sAI_unitStopBuilding(trainer)
endif
else
if (cBTS != "") then
if (cB != null) then
//call IssueTargetOrder(trainer, "smart", cB) // actually need it to repair, not build new unit, maybe this smart commands it?
call sAI_startException(trainer)
//call IssueTargetOrder(trainer, "repair", cB) // test // does this create infinite loop? i think it does
call sAI_endException(trainer)
//call sAI_cancelConstruction(cB)
//call DisplayTextToForce( GetPlayersAll(), "requeue" )
else
set str = "Player_" + playerIDString + "_base_" + baseIDString
//set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + cBTS + "_count"), udg_PlayerAI[p])
//set count = count - 1
//call SaveIntegerBJ(count, 0, StringHashBJ(str + "_has_building_" + cBTS + "_count"), udg_PlayerAI[p])
//because it reissues and +counts
// test
call sAI_startException(trainer)
//call IssuePointOrderLocBJ( trainer, cBTS, loc)
call sAI_endException(trainer)
//call DisplayTextToForce( GetPlayersAll(), "requeue" )
endif
endif
endif
endif // Of Unit Is Builder
//PLUG LEAKS
set ord = 0
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
set orderLoc = null //it's being saved to data
endfunction
//===========================================================================
function InitTrig_Player_x_Construction_Unqueued takes nothing returns nothing
set gg_trg_Player_x_Construction_Unqueued = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_x_Construction_Unqueued, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_x_Construction_Unqueued, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_x_Construction_Unqueued, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_Player_x_Construction_Unqueued, Condition( function Trig_Player_x_Construction_Unqueued_Conditions ) )
call TriggerAddAction( gg_trg_Player_x_Construction_Unqueued, function Trig_Player_x_Construction_Unqueued_Actions )
endfunction
function Trig_PlayerAI_x_Construction_Cancelled_2_Actions takes nothing returns nothing
local unit trainer = GetTriggerUnit()
local string orderString = UnitId2StringBJ(GetUnitTypeId(GetCancelledStructure()))
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
local unit u = GetCancelledStructure()
local string unitIDString = I2S(GetHandleIdBJ(u))
local group builderGroup = LoadGroupHandleBJ(0, StringHashBJ("Units_" + unitIDString + "_builderGroup"), udg_UnitAI)
local group sortGroup = CreateGroup()
local unit enumUnit = null
//MAIN PART
call sAI_saveUnitParameter(null, "currentlyBuilding_unit", "Units_" + trainerIDString, udg_UnitAI)
//Get Base Id
set str = "Units_" + trainerIDString + "_baseID"
set dls_i = StringHashBJ(str)
set baseID = LoadIntegerBJ(0, dls_i, udg_UnitAI)
set baseIDString = I2S(baseID)
//STOP ALL WORKERS
call GroupAddGroup(builderGroup, sortGroup)
set enumUnit = FirstOfGroup(sortGroup)
loop
exitwhen (enumUnit == null)
//call sAI_unitStopBuilding // removes all its building data
call GroupRemoveUnit(sortGroup, enumUnit)
set enumUnit = FirstOfGroup(sortGroup)
endloop
//I think builder group gets automatically cleared by delete data func, at least it SHOULD
//REMOVE CANCELLED BUILDING FROM GROUP (Redundant?)
call GroupRemoveUnit(LoadGroupHandleBJ(0, StringHashBJ(str + "_isBuilding"), udg_PlayerAI[p]), u)
// UPDATE BUILDING COUNT
set str = "Player_" + playerIDString + "_base_" + baseIDString
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + orderString + "_count"), udg_PlayerAI[p])
set count = count - 1
call SaveIntegerBJ(count, 0, StringHashBJ(str + "_has_building_" + orderString + "_count"), udg_PlayerAI[p])
//PLUG LEAKS
call DestroyGroup(sortGroup)
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
set u = null
set unitIDString = ""
set builderGroup = null
set sortGroup = null
set enumUnit = null
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Construction_Cancelled_2 takes nothing returns nothing
set gg_trg_PlayerAI_x_Construction_Cancelled_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Construction_Cancelled_2, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL )
call TriggerAddAction( gg_trg_PlayerAI_x_Construction_Cancelled_2, function Trig_PlayerAI_x_Construction_Cancelled_2_Actions )
endfunction
function Trig_PlayerAI_x_Building_Queues_Training_Conditions takes nothing returns boolean
if ( String2UnitIdBJ(OrderId2StringBJ(GetIssuedOrderIdBJ())) != 0 ) then
return true
endif
return false
endfunction
//==============================================================================================
function Trig_PlayerAI_x_Building_Queues_Training_Actions takes nothing returns nothing
local unit trainer = GetOrderedUnit()
local string orderString = OrderId2StringBJ(GetIssuedOrderIdBJ())
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer))
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(p)
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
//MAIN PART
if (p == udg_herodinPlayerID) then
//call DisplayTextToForce( GetPlayersAll(), "training queue order: " + orderString )
endif
//debug
// call AddSpecialEffectLocBJ( GetUnitLoc(trainer), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
// call DestroyEffectBJ( GetLastCreatedEffectBJ() )
//Get Base Id
set str = "Units_" + trainerIDString + "_baseID"
set baseID = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
//set baseID = 1 //debug
set baseIDString = I2S(baseID)
set str = "Player_" + playerIDString + "_base_" + baseIDString
// the following adds Terms
//call sAI_addUnitTrainingKnowledge(GetConvertedPlayerId(GetOwningPlayer(trainer)), UnitId2StringBJ(GetUnitTypeId(trainer)), orderString)
// update training count
call sAI_saveBooleanParameter(true, orderString, str + "_has_building", udg_PlayerAI[p])
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + orderString + "_count"), udg_PlayerAI[p])
set count = count + 1
call sAI_saveIntegerParameter(count, "count", str + "_has_building_" + orderString, udg_PlayerAI[p])
if (p == udg_herodinPlayerID) then
//call DisplayTextToForce( GetPlayersAll(), "training queue count: " + I2S(count) )
//call DisplayTextToForce( GetPlayersAll(), "queued unit: " + orderString )
//call DisplayTextToForce( GetPlayersAll(), "dls: " + str + "_has_building_" + orderString + "_count" )
endif
//UPDATE TRAINER INFO
set str = "Units_" + trainerIDString
call sAI_saveBooleanParameter(true, "isTrainer", str, udg_PlayerAI[p])
call sAI_saveBooleanParameter(true, "training", str, udg_PlayerAI[p])
call sAI_saveBooleanParameter(true, orderString, str + "_training", udg_PlayerAI[p])
call sAI_setDataNameMetaType("unitTypeString", udg_lastPLS, udg_PlayerAI[p])
set count = LoadIntegerBJ(0, StringHashBJ(str + "_training_" + orderString + "_count"), udg_PlayerAI[p])
set count = count + 1
call sAI_saveIntegerParameter(count, "count", str + "_training_" + orderString, udg_PlayerAI[p])
//PLUG LEAKS
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
endfunction
//===========================================================================
//TRIGGER INIT
//===========================================================================
function InitTrig_PlayerAI_x_Building_Queues_Training takes nothing returns nothing
set gg_trg_PlayerAI_x_Building_Queues_Training = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Building_Queues_Training, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_PlayerAI_x_Building_Queues_Training, Condition( function Trig_PlayerAI_x_Building_Queues_Training_Conditions ) )
call TriggerAddAction( gg_trg_PlayerAI_x_Building_Queues_Training, function Trig_PlayerAI_x_Building_Queues_Training_Actions )
endfunction
function Trig_PlayerAI_x_Building_Finishes_Training_2_Actions takes nothing returns nothing
local unit trainer = GetTriggerUnit()
local unit u = GetTrainedUnit()
local string unitIDString = I2S(GetHandleIdBJ(u))
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer))
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train indec string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(GetConvertedPlayerId(GetOwningPlayer(trainer)))
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local group baseArmy = null
local integer count = 0
local string uTS = UnitId2StringBJ(GetUnitTypeId(u))
//MAIN PART
//debug
//call AddSpecialEffectLocBJ( GetUnitLoc(trainer), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
//call DestroyEffectBJ( GetLastCreatedEffectBJ() )
//SAVE UNIT ID
call sAI_saveUnitToHash(u)
//GET BASE ID
set str = "Units_" + trainerIDString + "_baseID"
set baseID = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
set baseIDString = I2S(baseID)
// ASSIGN BASE
call sAI_assignBaseToUnit(p, baseID, u)
// don't need to add terms
// UPDATE TRAINING COUNT
set str = "Player_" + playerIDString + "_base_" + baseIDString
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + uTS + "_count"), udg_PlayerAI[p])
set count = count - 1
call sAI_saveIntegerParameter(count, "count", str + "_has_building_" + uTS, udg_PlayerAI[p])
//If it's in baseID 0, then training data was still added and needs to be removed.
//UPDATE TRAINER INFO
set str = "Units_" + trainerIDString
call sAI_saveBooleanParameter(true, "training", str, udg_PlayerAI[p])
call sAI_saveBooleanParameter(true, uTS, str + "_training", udg_PlayerAI[p])
set count = LoadIntegerBJ(0, StringHashBJ(str + "_training_" + uTS + "_count"), udg_PlayerAI[p])
set count = count - 1
call sAI_saveIntegerParameter(count, "count", str + "_training_" + uTS, udg_PlayerAI[p])
//PLUG LEAKS
set trainer = null
set u = null
set unitIDString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set baseArmy = null
set count = 0
set uTS = ""
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Building_Finishes_Training_2 takes nothing returns nothing
set gg_trg_PlayerAI_x_Building_Finishes_Training_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Building_Finishes_Training_2, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddAction( gg_trg_PlayerAI_x_Building_Finishes_Training_2, function Trig_PlayerAI_x_Building_Finishes_Training_2_Actions )
endfunction
function Trig_PlayerAI_x_Building_Cancels_Training_2_Actions takes nothing returns nothing
local string unitIDString = ""
local unit trainer = GetTriggerUnit()
local string orderString = UnitId2StringBJ(GetTrainedUnitType())
local string trainerTypeS = UnitId2StringBJ(GetUnitTypeId(trainer)) // As opposed to a handle which doesn't exist cos it's a unit type, not a unit.
local string trainerIDString = I2S(GetHandleIdBJ(trainer))
local string str = ""
local integer dls_i = 0
local string tIS = "" // train index string
local integer trainIndex = 0
local integer tIC = 0
local integer p = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string playerIDString = I2S(GetConvertedPlayerId(GetOwningPlayer(trainer)))
local integer baseID = 0 //get from trainer
local string baseIDString = ""
local integer count = 0
//MAIN PART
//Get Base Id
set str = "Units_" + unitIDString + "_baseID"
set dls_i = StringHashBJ(str)
set baseID = LoadIntegerBJ(0, dls_i, udg_UnitAI)
set baseIDString = I2S(baseID)
set str = "Player_" + playerIDString + "_base_" + baseIDString
//UPDATE BASE TRAINING COUNT
set count = LoadIntegerBJ(0, StringHashBJ(str + "_has_building_" + orderString + "_count"), udg_PlayerAI[p])
set count = count - 1
call sAI_saveIntegerParameter(count, "count", str + "_has_building_" + orderString, udg_PlayerAI[p])
//UPDATE SPECIFIC UNIT TRAINING COUNT
set str = "Units_" + trainerIDString
call sAI_saveBooleanParameter(true, "training", str, udg_PlayerAI[p])
call sAI_saveBooleanParameter(true, orderString, str + "_training", udg_PlayerAI[p])
set count = LoadIntegerBJ(0, StringHashBJ(str + "_training_" + orderString + "_count"), udg_PlayerAI[p])
set count = count - 1
call sAI_saveIntegerParameter(count, "count", str + "_training_" + orderString , udg_PlayerAI[p])
//PLUG LEAKS
set unitIDString = ""
set trainer = null
set orderString = ""
set trainerTypeS = ""
set trainerIDString = ""
set str = ""
set dls_i = 0
set tIS = ""
set trainIndex = 0
set tIC = 0
set p = 0
set playerIDString = ""
set baseID = 0
set baseIDString = ""
set count = 0
endfunction
//===========================================================================
function InitTrig_PlayerAI_x_Building_Cancels_Training_2 takes nothing returns nothing
set gg_trg_PlayerAI_x_Building_Cancels_Training_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PlayerAI_x_Building_Cancels_Training_2, EVENT_PLAYER_UNIT_TRAIN_CANCEL )
call TriggerAddAction( gg_trg_PlayerAI_x_Building_Cancels_Training_2, function Trig_PlayerAI_x_Building_Cancels_Training_2_Actions )
endfunction
function Trig_Unit_Changes_Owner_Actions takes nothing returns nothing
local integer pPlayer = GetConvertedPlayerId(GetChangingUnitPrevOwner())
local integer p = GetConvertedPlayerId(GetTriggerPlayer())
local integer b = 0
local unit u = GetChangingUnit()
local string str = ""
//MAIN PART
set str = "Units_" + I2S(GetHandleIdBJ(u)) + "_baseID"
set b = LoadIntegerBJ(0, StringHashBJ(str), udg_UnitAI)
call sAI_baseRemoveUnit(pPlayer, b, u)
call sAI_assignNearbyBaseToUnit(p, u) // just use this (if something else is needed, I assume the appropriate function will cover it)
//PLUG LEAKS
set pPlayer = 0
set p = 0
set b = 0
set u = null
set str = ""
endfunction
//===========================================================================
function InitTrig_Unit_Changes_Owner takes nothing returns nothing
set gg_trg_Unit_Changes_Owner = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Changes_Owner, EVENT_PLAYER_UNIT_CHANGE_OWNER )
call TriggerAddAction( gg_trg_Unit_Changes_Owner, function Trig_Unit_Changes_Owner_Actions )
endfunction
function s_isUnitControlled takes unit u returns boolean
local integer i = s_uDI(u, "controlAI_indexCount")
//MAIN PART
if (i > 0) then
set udg_tempBoolean = true
else
set udg_tempBoolean = false
endif
//PLUG LEAKS
set i = 0
//RETURN
return udg_tempBoolean
endfunction
function s_filterUnits_uncontrolled takes group g returns nothing
local integer i = 1
local integer iC = CountUnitsInGroup(g)
local unit eU = null
local group g2 = CreateGroup()
//MAIN PART
call GroupAddGroup(g, g2)
loop
exitwhen (eU == null)
if (s_isUnitControlled(eU) == true) then
call GroupRemoveUnit(g, eU)
endif
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
//PLUG LEAKS
set i = 0
set iC = 0
set eU = null
set g = null
call DestroyGroup(g2)
set g2 = null
endfunction
function s_filterUnits_stormWyrmsNoAI takes group g returns nothing
local integer i = 1
local integer iC = CountUnitsInGroup(g)
local unit eU = null
local group g2 = CreateGroup()
local integer uT = 0
//MAIN PART
call GroupAddGroup(g, g2)
set eU = FirstOfGroup(g2)
loop
exitwhen (eU == null)
set uT = GetUnitTypeId(eU)
if ((s_isUnitControlled(eU) == true) and (( uT == 'nstw' ) or ( uT == 'nthl' ) or ( uT == 'nltl'))) then
call GroupRemoveUnit(g, eU)
endif
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
//PLUG LEAKS
set i = 0
set iC = 0
set eU = null
set g = null
call DestroyGroup(g2)
set g2 = null
set uT = 0
endfunction
function sAI_findEnemyClosestStructure takes integer p, unit u returns unit
endfunction
function sAI_findEnemyRandomStructure takes integer p, unit u returns unit
endfunction
function sAI_cAbility takes nothing returns nothing
// ability added whole sale to unit ai data sheet?
//DATA TO ADD
local string s = ""
//MAIN PART
endfunction
function fx_warningIndicator takes string eS, location l, real time returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = null
local string uIS = I2S(GetHandleId(u))
local group g = null
//MAIN PART
call AddSpecialEffectLoc(eS, l)
call s_destroyEffect_main(bj_lastCreatedEffect, time)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set tIS = ""
set eS = ""
endfunction
function fx_warningIndicator takes string eS, location l, real time returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = null
local string uIS = I2S(GetHandleId(u))
local group g = null
//MAIN PART
call AddSpecialEffectLoc(eS, l)
call s_destroyEffect_main(bj_lastCreatedEffect, time)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set tIS = ""
set eS = ""
endfunction
function s_newUnitAI takes nothing returns nothing
local string iS = ""
//MAIN PART
call CreateNUnitsAtLoc( 1, 'h01Q', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
set iS = I2S(GetHandleId(bj_lastCreatedUnit))
//create ai here so that it is executed regardless of being "dead"
call sAI_saveStringParameter("", iS, "", udg_UnitAI)
call sAI_saveBooleanParameter(true, "noUnit", iS, udg_UnitAI)
call RemoveUnit(bj_lastCreatedUnit)
//PLUG LEAKS
set iS = ""
endfunction
function sAI_playerCamInRange takes location l, real dist returns boolean
local location l1 = GetCameraTargetPositionLoc()
local real r = DistanceBetweenPoints(l, l1)
if (r <= dist) then
set udg_tempBoolean = true
else
set udg_tempBoolean = false
endif
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l1)
set l = null
set l1 = null
set r = 0
set dist = 0
//RETURN
return udg_tempBoolean
endfunction
function s_destroyEffect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local effect e = s_tDE(tIS, "effect")
//MAIN PART
call DestroyEffect(e)
call sAI_deleteDataTree(tIS, udg_tempHash) // in theory wipes all leaks
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
set e = null
endfunction
function s_destroyEffect_main takes effect e, real time returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call s_tDE_s(e, tIS, "effect")
call TimerStart(t, time, false, function s_destroyEffect)
//PLUG LEAKS
set t = null
set tIS = ""
set e = null
set time = 0
endfunction
function s_projectile_effect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location l = LoadLocationHandleBJ(0, StringHashBJ(tIS + "_impactLoc"), udg_tempHash)
local group g = GetUnitsInRangeOfLocAll(512, l)
local unit u = s_tDU(tIS, "unit")
local integer pID = s_uDI(u, "owner")
local unit eU = null
local real hp = 0
local real dmg = s_tDR(tIS, "damage")
//MAIN PART
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
if ((BlzIsUnitInvulnerable(eU) == false ) and ( GetConvertedPlayerId(GetOwningPlayer(eU)) != pID )) then // won't hurt caster
call UnitDamageTargetBJ( u, eU, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endif
endloop
call KillUnit(u)
//call DisplayTextToForce( GetPlayersAll(), "boop" )
//call PlaySoundAtPointBJ( gg_snd_ThunderBoltMissileDeath, 100, uL, 0 )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
call DestroyTimer(t)
set t = null
set u = null
set tIS = ""
set pID = 0
set eU = null
set hp = 0
set dmg = 0
endfunction
function fx_delayedEffect_expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location l = s_tDL(tIS, "loc")
local real delay = s_tDR(tIS, "delay")
local string e = s_tDS(tIS, "effect")
//MAIN PART
call AddSpecialEffectLoc(e, l)
call s_tDE_s(bj_lastCreatedEffect, tIS, "effect")
call TimerStart(t, delay, false, function s_destroyEffect)
//Delete hash in expiry.
//call DisplayTextToForce( GetPlayersAll(), "expired effect activated" )
//PLUG LEAKS
set l = null
set t = null
set tIS = ""
set delay = 0
set e = null
endfunction
function fx_delayedEffect takes string eS, location l, real delayEffect, real delayExpire returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
//call AddSpecialEffectLoc(eS, l)
//
call s_tDS_s(eS, tIS, "effect")
call s_tDR_s(delayExpire, tIS, "delay")
call s_tDL_s(l, tIS, "loc")
call TimerStart(t, delayEffect, false, function fx_delayedEffect_expire)
//PLUG LEAKS
set l = null
set t = null
set tIS = ""
set eS = ""
set delayEffect = 0
set delayExpire = 0
endfunction
function s_effect takes string eS, location l, real delayExpire returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = null
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call AddSpecialEffectLoc(eS, l)
call s_destroyEffect_main(bj_lastCreatedEffect, delayExpire)
//call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
//call RemoveLocation(l)
set l = null
//call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set tIS = ""
set eS = ""
endfunction
function s_ability_finishCasting_t takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local string abilityString = s_tDS(tIS, "abilityString")
//MAIN PART
call s_uDI_i(-1, u, "stack", "ability_" + abilityString + "_casting" )
if(s_uDI(u, "ability_" + abilityString + "_casting_stack") <=0) then
call s_uDB_s(false, uIS, "ability_" + abilityString + "_casting")
call s_uDB_s(false, uIS, "ability_" + abilityString + "_currentlyExecuting")
endif
// might also check state
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set tIS = ""
endfunction
function s_ability_startCasting takes unit u, string aS returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDI_i(1, u, "stack", "ability_" + aS + "_casting")
call s_uDB_s(true, uIS, "ability_" + aS + "_casting")
call s_uDB_s(true, uIS, "ability_" + aS + "_currentlyExecuting")
//PLUG LEAKS
set u = null
set uIS = ""
set aS = ""
endfunction
function s_g_headMissileXYOffset takes nothing returns location
local unit u = udg_Gustivus
local location l = GetUnitLoc(u)
local real ang = GetUnitFacing(u)
local real dist = 400
//MAIN PART
set udg_tempLoc = PolarProjectionBJ(l, dist, ang) // have to make sure this gets cleaned in all uses
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
set ang = 0
set dist = 0
//RETURN
return udg_tempLoc
endfunction
function s_g_setLightningOffset takes nothing returns location
local unit u = udg_Gustivus
local location l = GetUnitLoc(u)
local real ang = GetUnitFacing(u)
local real dist = 400
local real x = 0
local real y = 0
local real z = 0
//MAIN PART
set udg_tempLoc = PolarProjectionBJ(l, dist, ang) // have to make sure this gets cleaned in all uses
set x = GetLocationX(udg_tempLoc)
set y = GetLocationY(udg_tempLoc)
set z = GetLocationZ(udg_tempLoc)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
set ang = 0
set dist = 0
//RETURN
return udg_tempLoc
endfunction
function s_g_headMissileOffset takes nothing returns location
local unit u = udg_Gustivus
local location l = GetUnitLoc(u)
local real ang = GetUnitFacing(u)
local real dist = 400
local location dLoc = null
//Lightning origin co-ordinates to target
local real lOX = 0
local real lOY = 0
local real lOZ = 0
local real lTX = 0
local real lTY = 0
local real lTZ = 0
//MAIN PART
//set udg_tempLoc = PolarProjectionBJ(l, dist, ang) // have to make sure this gets cleaned in all uses
call AddLightningLoc( "CLPB", GetUnitLoc(GetTriggerUnit()), GetRectCenter(GetPlayableMapRect()) )
call SetLightningColorBJ( GetLastCreatedLightningBJ(), 255.00, 1.00, 1, 1 )
set bj_lastCreatedLightning = AddLightningEx(
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
set ang = 0
set dist = 0
//RETURN
return udg_tempLoc
endfunction
function sAI_scaleEffectOverTime_effect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local effect e = s_tDE(tIS, "effect")
local real inc = s_tDR(tIS, "inc")
local real s = s_tDR(tIS, "scale")
local real tS = s_tDR(tIS, "targetScale")
local string str = ""
//MAIN PART
//timer based loop
if s<tS then
call BlzSetSpecialEffectScale( e, s + inc )
call sAI_saveRealParameter(s + inc, "scale", tIS, udg_tempHash)
call TimerStart(t, udg_gameloop_fx, false, function sAI_scaleEffectOverTime_effect)
//set str = R2S(TimerGetElapsed(udg_time))
//call StartTimerBJ(udg_time, false, 10)
//call DisplayTextToForce(GetPlayersAll(), "scale update")
//call DisplayTextToForce(GetPlayersAll(), str)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
set t = null
set tIS = ""
set e = null
set inc = 0
set s = 0
set tS = 0
set str = ""
endfunction
function sAI_scaleEffectOverTime takes effect e, real scale_start, real scale_end, real time returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local real inc = 0
//MAIN PART
call s_tDE_s(e, tIS, "effect")
call s_tDR_s(scale_end, tIS, "targetScale")
if time > 0 then
set inc = ((scale_end - scale_start) / time) * udg_gameloop_fx
else
set inc = scale_end - scale_start
endif
call s_tDR_s(inc, tIS, "inc")
call s_tDR_s(scale_start, tIS, "scale")
call TimerStart(t, 0, false, function sAI_scaleEffectOverTime_effect)
//PLUG LEAKS
set e = null
set scale_end = 0
set scale_start = 0
set time = 0
set t = null
set tIS = ""
set inc = 0
endfunction
function s_removeUnit takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call sAI_deleteDataTree(uIS, udg_UnitAI)
call RemoveUnit(u)
//PLUG LEAKS
set uIS = ""
set u = null
endfunction
function sAI_playerAIUpdate takes integer p returns nothing
local integer numBases = 0
local integer i = 1
local integer iC = 0
local string prefix = ""
local string str = ""
local integer dls_i = 0
//MAIN PART
set prefix = "Player_" + I2S(p) + "_base"
set str = prefix + "_indexCount"
set dls_i = StringHashBJ(str)
set numBases = LoadIntegerBJ(0, dls_i, udg_PlayerAI[p])
loop
exitwhen (i > numBases)
call sAI_base_AI(p, i)
set i = i + 1
endloop
//PLUG LEAKS
set numBases = 0
set i = 0
set iC = 0
set prefix = ""
set str = ""
set dls_i = 0
endfunction
function pF_reportPost takes unit u returns nothing
local player p = GetOwningPlayer(u)
local integer pI = GetConvertedPlayerId(p)
local string s = "gather_troops"
local trigger t = gg_trg_uA_x_Gather_Supply_Units
local location l = null
local boolean terminated = false
//MAIN PART
//GATHER TROOPS
call s_addOrder(u, s, t, l, terminated) // this is it right here
//GOVERN TROOPS
call s_addOrder(u, "govern_troops", gg_trg_uA_x_Govern_Guards, l, terminated)
//PLUG LEAKS
set p = null
set pI = 0
set s = ""
set t = null
set l = null
set terminated = false
endfunction
function pF_trainer takes unit u returns nothing
local player p = GetOwningPlayer(u)
local integer pI = GetConvertedPlayerId(p)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string s = "train"
local trigger t = gg_trg_uA_x_Train_Requests
local location l = null
local boolean terminated = false
//MAIN PART
call s_uDB_s(true, uIS, "isTrainer")
//TRAINER
call s_addOrder(u, s, t, l, terminated) // this is it right here
//PLUG LEAKS
set p = null
set pI = 0
set s = ""
set t = null
set l = null
set terminated = false
set uI = 0
set uIS = ""
endfunction
function s_runPrefabs takes nothing returns nothing
local rect rct = GetPlayableMapRect()
local group g = GetUnitsInRectAll(rct)
local unit eU = null
local integer eUI = 0
local string uTS = ""
local string eUTS = ""
local string s = ""
//MAIN PART
set eU = FirstOfGroup(g)
set s = UnitId2String('h01R')
//call DisplayTextToForce(GetPlayersAll(), "running prefab data")
loop
exitwhen eU == null
set eUI = GetUnitTypeId(eU)
set eUTS = UnitId2String(eUI)
if eUTS == s then
call pF_reportPost(eU)
//call DisplayTextToForce(GetPlayersAll(), "rP prefab added")
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//call DisplayTextToForce(GetPlayersAll(), "ran prefab data")
//PLUG LEAKS
call DestroyGroup(g)
set rct = null
set g = null
set eU = null
set eUI = 0
set uTS = ""
set eUTS = ""
endfunction
function sAI_initAI takes nothing returns nothing
local group lv_group = GetUnitsInRectAll(GetPlayableMapRect())
local integer lv_numOfUnits = CountUnitsInGroup(lv_group)
local integer i = 1
local unit lv_evalUnit = null
//======================================
//========================================
//Prefab Player Term Knowledge
//========================================
//call write_sAI_TermsForAll()
//call sAI_addGoldMinesToPlayerKnowledge()
loop
exitwhen i > 28
//call sAI_addPlayerKnowledgeSet1(i)
call sAI_playerAI_pregenReqs(i)
set i = i + 1
endloop
set i = 1
//========================================
// Assign AI to Units
//========================================
loop
exitwhen i > lv_numOfUnits
set lv_evalUnit = FirstOfGroup(lv_group)
call sAI_saveUnitToHash(lv_evalUnit)
call GroupRemoveUnit(lv_group, lv_evalUnit)
set i = i + 1
endloop
//========================================
// Player AI Inits
//========================================
//========================================
// PREFABS
//========================================
call s_runPrefabs()
//PLUG LEAKS
call DestroyGroup(lv_group)
set lv_group = null
set lv_numOfUnits = 0
set i = 0
set lv_evalUnit = null
endfunction
function fx_projectile_update takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location l = LoadLocationHandleBJ(0, StringHashBJ(tIS + "_impactLoc"), udg_tempHash)
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l1 = LoadLocationHandleBJ(0, StringHashBJ(tIS + "_loc"), udg_tempHash)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real z = GetUnitFlyHeight(u)
local real tX = s_tDR(tIS, "tX")
local real tY = s_tDR(tIS, "tY")
local real tZ = s_tDR(tIS, "tZ")
local real incX = 0
local real incY = 0
local real incZ = 0
local integer incs = 0
local real speedX = s_tDR(tIS, "speedX")
local real speedY = s_tDR(tIS, "speedY")
local real speedZ = s_tDR(tIS, "speedZ")
local real dX = 0
local real dY = 0
local real dZ = 0
//MAIN PART
set dX = tX - x
set dY = tY - y
set dZ = tZ - z
if (speedX != 0) then
set incX = dX / speedX
else
set incX = 0
endif
if (speedY != 0) then
set incY = dY / speedY
else
set incY = 0
endif
if (speedZ != 0) then
set incZ = dZ / speedZ
else
set incZ = 0
endif
if (z + incZ > 0) then
set speedZ = speedZ - 10
else
set speedZ = 0
endif
//set x = x + incX
//set y = y + incY
//set z = z + incZ
set x = x + speedX
set y = y + speedY
set z = z + speedZ
call s_tDR_s(speedZ, tIS, "speedZ")
call SetUnitX(u, x)
call SetUnitY(u, y)
call SetUnitFlyHeightBJ( u, z, ((z + incZ) * 8) ) // 8 frames ps
if (z <= 0) then
call DestroyTimer(t)
call KillUnit(u)
call RemoveLocation(l)
call RemoveLocation(l1)
else
call TimerStart(t, 0.125, false, function fx_projectile_update)
endif
//PLUG LEAKS
set l = null
set t = null
set l1 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set incX = 0
set incY = 0
set incZ = 0
set incs = 0
set speedX = 0
set speedY = 0
set speedZ = 0
set dX = 0
set dY = 0
set dZ = 0
endfunction
function s_rockProjectileSmall takes unit u, location l, location l2, real v, real vZ returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = ""
local location l1 = null
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real speedX = 0
local real speedY = 0
local real speedZ = 0
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local real angXY = AngleBetweenPoints(l, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(l, l2)
//MAIN PART
//projectile
call CreateNUnitsAtLoc( 1, 'n01G', GetOwningPlayer(udg_EarthKing), l, GetRandomDirectionDeg() )
call KillUnit(GetLastCreatedUnit())
call CreateNUnitsAtLoc( 1, 'n01G', GetOwningPlayer(udg_EarthKing), l, GetRandomDirectionDeg() )
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call SetUnitFlyHeight( GetLastCreatedUnit(), 50, 0)
call SetUnitTimeScalePercent( GetLastCreatedUnit(), GetRandomReal(50, 125 ))
call GroupAddUnit(udg_rocks, bj_lastCreatedUnit)
set speedX = GetRandomReal(-v,v)
set speedY = GetRandomReal(-v,v)
call s_tDL_s(l, tIS, "loc")
call s_tDL_s(l2, tIS, "impactLoc")
call s_tDR_s(speedX, tIS, "speedX")
call s_tDR_s(speedY, tIS, "speedY")
call s_tDR_s(vZ, tIS, "speedZ")
if (u != null) then
call s_tDI_s(GetConvertedPlayerId(GetOwningPlayer(u)), tIS, "owner")
else
call s_tDI_s(0, tIS, "owner")
endif
call TimerStart(t, 0.125, false, function fx_projectile_update)
//PLUG LEAKS
set l = null
set t = null
set l1 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set speedX = 0
set speedY = 0
set speedZ = 0
set dX = 0
set dY = 0
set dZ = 0
set angXY = 0
set angZ = 0
set distXY = 0
endfunction
function s_rockProjectileTarget takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l = s_tDL(tIS, "loc")
local location l2 = s_tDL(tIS, "targetLoc")
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real speedX = 0
local real speedY = 0
local real speedZ = 0
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local location uL = GetUnitLoc(u)
local real angXY = AngleBetweenPoints(uL, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(uL, l2)
local real speedXY = s_tDR(tIS, "speedXY")
local real centerDist = s_tDR(tIS, "centerDist")
local group g = null
local integer pID = s_uDI(u, "owner")
local unit eU = null
local real dmg = s_tDR(tIS, "damage")
local real radius = s_tDR(tIS, "radius")
local location nL = null
//MAIN PART
//set speedXY = 10 // test
//math
//set speedX = Cos(angXY) * speedXY * 0.125
//set speedY = Sin(angXY) * speedXY * 0.125
set nL = PolarProjectionBJ( uL,speedXY * 0.125, angXY)
set z = GetUnitFlyHeight(u)
set z = z + ((distXY - centerDist) / (speedXY * 0.125)) // In theory this creates a clean arc?
//call SetLocZ(nL, z)
//call SetUnitPositionLoc(u, nL)
//call SetUnitPosition(u, GetLocX(nL), GetLocY(nL), GetLocZ(nL))
call SetUnitPosition(u, GetLocationX(nL), GetLocationY(nL))
//set z = z + 5 // test
//call DisplayTextToForce(GetPlayersAll(), R2S(speedX))
//call DisplayTextToForce(GetPlayersAll(), R2S(speedY))
//call PingMinimapLocForForce( GetPlayersAll(), uL, 1 )
//call PingMinimapLocForForce( GetPlayersAll(), l2, 1 )
//projectile
//call SetUnitX(u, x + speedX)
//call SetUnitY(u, y + speedY)
call SetUnitFlyHeight(u, z, 0)
//For huge rocks, add that info.
if z <= 100 and (distXY - centerDist) < 0 then
set g = GetUnitsInRangeOfLocAll(radius, uL)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
if ((BlzIsUnitInvulnerable(eU) == false ) and ( GetConvertedPlayerId(GetOwningPlayer(eU)) != pID )) then // won't hurt caster
call UnitDamageTargetBJ( u, eU, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call KillUnit(u)
call DestroyTimer(t)
call DestroyGroup(g)
call sAI_deleteDataTree(tIS, udg_tempHash)
//call DisplayTextToForce(GetPlayersAll(), "rock boom")
else
call s_tDR_s(speedX, tIS, "speedX")
call s_tDR_s(speedY, tIS, "speedY")
call s_tDR_s(speedZ, tIS, "speedZ")
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s(distXY, tIS, "distXY")
call TimerStart(t, 0.125, false, function s_rockProjectileTarget)
//call DisplayTextToForce(GetPlayersAll(), "rock update")
endif
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set speedX = 0
set speedY = 0
set speedZ = 0
set dX = 0
set dY = 0
set dZ = 0
call RemoveLocation(uL)
set uL = null
set eU = null
set angXY = 0
set angZ = 0
set distXY = 0
set speedXY = 0
set centerDist = 0
call DestroyGroup(g)
set g = null
set pID = 0
set dmg = 0
set radius = 0
call RemoveLocation(nL)
set nL = null
endfunction
function s_linearRock_update takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local real rTime = s_tDR(tIS, "time")
local unit u = s_tDU(tIS, "unit")
local real dmg = s_tDR(tIS, "damage")
local unit tUnit = s_tDU(tIS, "targetUnit")
local real speed = s_tDR(tIS, "speed")
local real dist = 0
local real steps = s_tDI(tIS, "steps")
local location l = GetUnitLoc(u)
local location l2 = GetUnitLoc(tUnit)
local real inc = s_tDR(tIS, "inc")
local real a = AngleBetweenPoints(l, l2)
local location l3 = PolarProjectionBJ(l, inc, a)
//MAIN PART
set dist = DistanceBetweenPoints(l, l2)
call SetUnitPositionLoc(u, l3)
if dist < 100 then
call DestroyTimer(t)
call KillUnit(u)
call SetUnitLifeBJ( tUnit, ( GetUnitStateSwap(UNIT_STATE_LIFE, tUnit) - dmg ) )
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call TimerStart(t, udg_gameloop, false, function s_linearRock_update)
endif
//PLUG LEAKS
set t = null
set tIS = ""
set rTime = 0
set u = null
set dmg = 0
set tUnit = null
set speed = 0
set dist = 0
set steps = 0
set l = null
set l2 = null
set l3 = null
set a = 0
set inc = 0
endfunction
function s_linearRock takes location l, location l2, real dmg, real speed, unit tUnit returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = null
local real dist = DistanceBetweenPoints(l, l2)
local integer steps = 0
//MAIN PART
if speed > 0 then
set steps = R2I(dist / (speed * 0.125))
endif
//create rock
call CreateNUnitsAtLoc( 1, 'n01G', GetOwningPlayer(u), l, GetRandomDirectionDeg() )
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call SetUnitFlyHeight( GetLastCreatedUnit(), 100, 0)
call s_tDR_s(dmg, tIS, "damage")
call s_tDI_s(steps, tIS, "steps")
call s_tDU_s(tUnit, tIS, "targetUnit")
call TimerStart(t, 0.125, false, function s_linearRock_update)
//PLUG LEAKS
set t = null
set l = null
set l2 = null
set dmg = 0
set tUnit = null
set speed = 0
set dist = 0
set steps = 0
endfunction
function s_rockProjectileHuge takes unit u, location l, location l2, real speedXY returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = ""
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local real angXY = AngleBetweenPoints(l, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(l, l2)
//MAIN PART
//math
//projectile
call CreateNUnitsAtLoc( 1, 'n01G', GetOwningPlayer(u), l, GetRandomDirectionDeg() )
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call SetUnitFlyHeight( GetLastCreatedUnit(), z, 0)
//just scale huge and increase damage
call s_tDL_s(l, tIS, "loc")
call s_tDL_s(l2, tIS, "targetLoc")
call s_tDR_s(50, tIS, "damage")
call s_tDR_s(400, tIS, "radius")
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s((distXY / 2), tIS, "centerDist")
if (u != null) then
call s_tDI_s(GetConvertedPlayerId(GetOwningPlayer(u)), tIS, "owner")
else
call s_tDI_s(0, tIS, "owner")
endif
call TimerStart(t, 0.125, false, function s_rockProjectileTarget)
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set dX = 0
set dY = 0
set dZ = 0
set angXY = 0
set angZ = 0
set distXY = 0
endfunction
function fx_heightBlend_loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real time = s_tDR(tIS, "time")
local real inc = s_tDR(tIS, "inc")
local real height = s_tDR(tIS, "height")
local effect e = s_tDE(tIS, "effect")
//MAIN PART
if time > 0 then
set height = height + inc
call BlzSetSpecialEffectZ( e, height )
set time = time - udg_gameloop_fx
call s_tDR_s(time, tIS, "time")
call s_tDR_s(height, tIS, "height")
call TimerStart(t, udg_gameloop_fx, false, function fx_heightBlend_loop)
else
call DestroyTimer(t)
call DestroyEffect(e)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set time = 0
set height = 0
set e = null
endfunction
function fx_heightBlend takes effect e, real height, real time returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real inc = 0
local real h2 = BlzGetLocalSpecialEffectZ(e)
//MAIN PART
set inc = (height - h2) * (udg_gameloop_fx * time)
call s_tDE_s(e, tIS, "effect")
call s_tDR_s(h2, tIS, "height")
call s_tDR_s(time, tIS, "time")
call s_tDR_s(inc, tIS, "inc")
call TimerStart(t, 0, false, function fx_heightBlend_loop)
//PLUG LEAKS
set height = 0
set time = 0
set t = null
set tI = 0
set tIS = ""
set inc = 0
set h2 = 0
endfunction
function fx_warningIndicator takes string eS, location l, real time returns nothing
//MAIN PART
call AddSpecialEffectLoc(eS, l)
call s_destroyEffect_main(bj_lastCreatedEffect, time)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set eS = ""
set time = 0
endfunction
function s_abilFinished takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local string dLS = LoadStringBJ(0, StringHashBJ(tIS + "_abilityDLS"), udg_tempHash)
local hashtable ht = udg_UnitAI
//MAIN PART
call DestroyTimer(t)
call sAI_saveBooleanParameter(false, "abilityBeingCast", dLS, udg_UnitAI)
call sAI_deleteDataTree(tIS, udg_tempHash) // if this doesn't work properly it's going to leak to hell and create the minecraft underworld
//PLUG LEAKS
set t= null
set tIS = ""
set dLS = ""
set ht = null
endfunction
//===========================================================
function s_unitExpire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local hashtable ht = udg_UnitAI
local unit u = LoadUnitHandleBJ(0, StringHashBJ(tIS + "_unit"), udg_tempHash)
//MAIN PART
call DestroyTimer(t)
call KillUnit(u)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
set t= null
set tIS = ""
set ht = null
set u = null
endfunction
//===========================================================
function s_unit_timedExpire_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = LoadUnitHandleBJ(0, StringHashBJ(tIS + "_unit"), udg_tempHash)
//MAIN PART
call KillUnit(u)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
//params
set u = null
endfunction
function s_unit_timedExpire takes unit u, real time returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call sAI_saveUnitParameter(u, "unit", tIS, udg_tempHash)
call TimerStart(t, time, false, function s_unit_timedExpire_expires)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
//params
set u = null
set time = 0
endfunction
function fx_stopCamShake takes nothing returns nothing
//MAIN PART
call DestroyTimer(GetExpiredTimer())
call CameraClearNoiseForPlayer( Player(0) )
//PLUG LEAKS
endfunction
function c_pauseTimers takes boolean b returns nothing
local integer i = 1
local string s = "timer_indexCount"
local integer sI = StringHash(s)
local integer iC = LoadIntegerBJ(0, sI, udg_generalHash)
local timer t = null
local string iS = ""
//MAIN PART
loop
exitwhen i > iC
set iS = I2S(i)
set sI = StringHash("timer_" + iS)
set t = LoadTimerHandleBJ(0, sI, udg_generalHash)
call PauseTimerBJ(b, t)
set i = i + 1
endloop
//PLUG LEAKS
set b = false
set i = 0
set s = ""
set iC = 0
set t = null
set sI = 0
set iS = ""
endfunction
function c_add_timer takes timer t returns nothing
call sAI_addTimerParameter(t, "", "timer", udg_generalHash)
endfunction
function cinematic_checkSkip takes nothing returns nothing
call StartTimerBJ(udg_CinematicTransmissionTimer, false, GetLastTransmissionDurationBJ())
loop
exitwhen (TimerGetRemaining(udg_CinematicTransmissionTimer) <= 0 )
if (udg_QuitCinematic == true) then
return
endif
call TriggerSleepAction(0.125)
endloop
return
endfunction
function cinematic_checkWaitSkip takes real r returns nothing
call StartTimerBJ(udg_CinematicTransmissionTimer, false, r)
loop
exitwhen (TimerGetRemaining(udg_CinematicTransmissionTimer) <= 0 )
if (udg_QuitCinematic == true) then
return
endif
call TriggerSleepAction(0.125)
endloop
return
endfunction
function s_bM_contextObject takes nothing returns nothing
local real gH = 0 // ground height
local location l = null
//MAIN PART
// PLUG LEAKS
call RemoveLocation(l)
set l = null
set gH = 0
endfunction
// e.g. destroy rock and create new one to shoot back
// temporarily switch with enemy unit to absorb an attack
//teleport with enemy over water and drown them
//10% to kill, everything else damage
function s_firestorm_loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location l = s_tDL(tIS, "loc")
local group g = null
local real dist = s_tDR(tIS, "dist")
local real distEnd = 3000 //s_tDR(tIS, "distEnd")
local real ang = s_tDR(tIS, "angle")
local integer pI = GetConvertedPlayerId(GetOwningPlayer(udg_CineKael))
local unit eU = null
local real x = 0
local real y = 0
local location l2 = l
local unit u = s_tDU(tIS, "unit")
local real damage = s_uDR(u, "ability_firestorm_damage")
//MAIN PART
set x = GetLocationX(l)
set y = GetLocationY(l)
call s_effect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", Location(x,y), 6)
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 2, 1)
//call DisplayTextToForce(GetPlayersAll(), "dist: " + R2S(dist))
//call DisplayTextToForce(GetPlayersAll(), "distEnd: " + R2S(distEnd))
set g = GetUnitsInRangeOfLocAll(1000, l)
set eU = FirstOfGroup(g)
loop
exitwhen eU == null
if IsPlayerEnemy(GetOwningPlayer(eU), GetOwningPlayer(u)) and BlzIsUnitInvulnerable(eU) == false then
call KillUnit(eU)
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//call DisplayTextToForce(GetPlayersAll(), "derp")
call DestroyTimer(t)
call DestroyGroup(g)
call RemoveLocation(l)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set t = null
set tIS = ""
set dist = 0
set distEnd = 0
set ang = 0
set pI = 0
set eU = null
set x = 0
set y = 0
set u = null
endfunction
//=================================================
//=================================================
//=================================================
//=================================================
function s_firestorm takes unit u, location l, integer count, real ang, real angOffset returns nothing
local timer t = null
local string tIS = ""
local integer i = 1
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real dist = 200
local location l2 = null
local real time = 0.25
//MAIN PART
call s_effect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", Location(x,y), 6)
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 2, 1)
loop
exitwhen (i>count)
loop
exitwhen dist > 3000
set t = CreateTimer()
set tIS = I2S(GetHandleId(t))
call s_tDR_s(2000, tIS, "distEnd")
set l2 = PolarProjectionBJ(l, dist, ang)
set x = GetLocationX(l2)
set y = GetLocationY(l2)
call s_tDL_s(Location(x,y), tIS, "loc")
call s_tDR_s(ang, tIS, "angle")
call s_tDU_s(u, tIS, "unit")
call TimerStart(t, time, false, function s_firestorm_loop)
set time = time + 0.25
set dist = dist + 200
endloop
set time = 0.25
set ang = ang + angOffset
set dist = 200
set i = i + 1
endloop
//PLUG LEAKS
set u = null
call RemoveLocation(l)
set l = null
set count = 0
set ang = 0
set angOffset = 0
set t = null
set tIS = ""
set i = 0
set l2 = null
set time = 0
set dist = 0
endfunction
function dragons_timeSphereFX takes nothing returns nothing
local real z = 0
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = udg_BronzeDragon
local location uL = GetUnitLoc(u)
local boolean pL = sAI_playerCamInRange(uL, 3000)
//MAIN PART
set z = GetLocationZ(uL)
call AddSpecialEffectLocBJ( uL, "Abilities\\Spells\\Human\\AerialShackles\\AerialShacklesTarget.mdl" )
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 10, 2)
call sAI_saveEffectParameter(bj_lastCreatedEffect, "effect", tIS, udg_tempHash)
call TimerStart(t, 4, false, function s_destroyEffect)
if (pL == true) then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 2, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0 )
endif
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set z = 0
set t = null
set tIS = ""
set pL = false
endfunction
function dragons_timeSphere takes nothing returns nothing
local unit u = udg_BronzeDragon
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(2000, uL)
local location l = null
local unit eU = FirstOfGroup(g)
//MAIN PART
call dragons_timeSphereFX()
loop
exitwhen (eU == null)
//set l = s_uDL(eU, "abilityEffect_chronomagic_savedPosition") //we're not using this one yet
set l = PolarProjectionBJ(GetRectCenter(gg_rct_KaelTH), 1000, GetRandomDirectionDeg())
call SetUnitPositionLoc(eU, l)
set eU = FirstOfGroup(g)
call RemoveLocation(l)
endloop
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
call DestroyGroup(g)
set g = null
set l = null
set u = null
set eU = null
endfunction
function dragons_chronoSave takes nothing returns nothing
local group g = GetUnitsInRectAll(GetPlayableMapRect())
local unit u = udg_BronzeDragon
local string uIS = I2S(GetHandleId(u))
local unit eU = FirstOfGroup(g)
local string eUIS = ""
local location eUL = null
//MAIN PART
call sAI_deleteDataTree(uIS + "_effect_chronomagic", udg_UnitAI)
loop
exitwhen (eU == null)
set eUL = GetUnitLoc(eU)
set eUIS = I2S(GetHandleId(eU))
call s_uDL_s(eUL, uIS, "effect_chronomagic_" + eUIS + "_savedPosition")
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
call RemoveLocation(eUL)
endloop
//PLUG LEAKS
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set eU = null
set eUIS = ""
set eUL = null
endfunction
function bd_update takes nothing returns nothing
local real dist = 0
local location uL = GetUnitLoc(udg_BronzeDragon)
local location l = null
local rect r = GetPlayableMapRect()
local group g = null
local unit eU = null
local location eUL = null
local boolean b = false
local real a = 0
local location l2 = null
local integer i = 1
local integer iC = 10
//MAIN PART
loop
exitwhen i > iC or b == true
set l2 = GetRectCenter(gg_rct_KaelTH)
set udg_tempReal = GetRandomDirectionDeg()
set l = PolarProjectionBJ(uL, 2100, udg_tempReal)
set dist = DistanceBetweenPoints(l, l2)
call DestroyGroup(g)
set g = GetUnitsInRangeOfLocAll(2000, l)
set eU = FirstOfGroup(g)
loop
exitwhen eU == null or b == true
if eU == udg_Gustivus or eU == udg_GaleWinterFreeze or eU == udg_EarthKing or eU == udg_ChildOfAir or eU == udg_FireOgre or dist < 2000 then
else
set b = true
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
set i = i + 1
endloop
if b == true then
call GroupPointOrderLocBJ(udg_BronzeDragons, "move", l)
else
call GroupImmediateOrderBJ(udg_BronzeDragons, "stop")
endif
//PLUG LEAKS
set dist = 0
call RemoveLocation(uL)
set uL = null
call RemoveLocation(l)
set l = null
set r = null
call DestroyGroup(g)
set g = null
set eU = null
call RemoveLocation(eUL)
set eUL = null
set b = false
set a = 0
call RemoveLocation(l2)
set l2 = null
set i = 0
set iC = 0
endfunction
function dragons_detect takes nothing returns nothing
local unit u = udg_BronzeDragon
local string uIS = I2S(GetHandleId(u))
local string aIS = s_uDS(u, "ai")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(2000, uL)
local unit eU = FirstOfGroup(g)
local boolean found = false
//MAIN PART
loop
exitwhen eU == null or found == true
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(eU)) == true and TimerGetRemaining(udg_Timer_Dragons_Timesphere) <= 0 then
call s_uDS_s("timesphere", uIS, "ai")
call s_uDU_s(eU, uIS, "targetUnit")
call StartTimerBJ(udg_Timer_Dragons_Timesphere, false, 30)
set found = true
endif
call GroupRemoveUnit(g,eU)
set eU = FirstOfGroup(g)
endloop
//call DisplayTextToForce( GetPlayersAll(), "dragons detect" )
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set aIS = ""
set uIS = ""
call DestroyGroup(g)
set g = null
set eU = null
set found = false
endfunction
function s_cOA_tornadoTeleport_effect takes unit u, location l returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call SetUnitPositionLoc(u, l)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
set uIS = ""
endfunction
function s_cOA_tornado_check takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l = GetUnitLoc(u)
local group g = s_uDG(u, "group")
//
local group eG = CreateGroup()
local unit eU = null
local real cT = 0
local real time = s_tDR(tIS, "time")
local group tG = GetUnitsInRangeOfLocAll(300, l)
local string eUIS = ""
local location rC = GetRectCenter(gg_rct_KaelTH)
local location home = PolarProjectionBJ(rC, GetRandomReal(200, 1000), GetRandomDirectionDeg())
//MAIN PART
set time = time - 0.125
call s_tDR_s(time, tIS, "time")
call GroupAddGroup(eG, g)
set eU = FirstOfGroup(eG)
loop
exitwhen (eU == null)
set eUIS = I2S(GetHandleId(eU))
if IsUnitInGroup(eU, tG) == false then
call s_uDR_s(0, eUIS, "state_ability_cOATornado_time")
call GroupRemoveUnit(g, eU)
endif
set cT = s_uDR(eU, "state_ability_cOATornado_time")
if(cT >= 5.0) then
call s_cOA_tornadoTeleport_effect(eU, home)
call s_uDR_s(0, eUIS, "state_ability_cOATornado_time")
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call s_uDR_s(cT + 0.125, I2S(GetHandleId(eU)), "state_ability_cOATornado_time")
endif
set eU = FirstOfGroup(eG)
endloop
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
set t = null
set u = null
set uIS = ""
set tIS = ""
endfunction
function s_stormEffect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location l = s_tDL(tIS, "loc")
local real radius = s_tDR(tIS, "radius")
local group g = GetUnitsInRangeOfLocAll( radius, l)
local unit eU = null
local real time = s_tDR(tIS, "time")
local location uL = null
//MAIN PART
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
set eU = FirstOfGroup(g)
//call DisplayTextToForce( GetPlayersAll(), "zap" )
loop
exitwhen (eU == null)
set uL = GetUnitLoc(eU)
call s_stun(eU, time)
call SetUnitLifeBJ( eU, GetUnitStateSwap(UNIT_STATE_LIFE, eU) - 50 )
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
set t = null
set tIS = ""
set l = null
set radius = 0
set g = null
set eU = null
set time = 0
set uL = null
endfunction
function s_cOA_skystorm takes nothing returns nothing
local timer t = null
local integer tI = 0
local string tIS = ""
local unit u = udg_ChildOfAir
local string uIS = I2S(GetHandleId(u))
local location l = null
local group g = null
local real time = 2
local real r = 125
local real dmg = 125
//
local real delay = 2
local real time2 = 2
local real delay2 = 2
local integer iCount = s_uDI(u, "ability_skystorm_lightning_count")
local integer i = 1
local integer iC = 12
local timer t2 = CreateTimer()
local string tIS2 = I2S(GetHandleId(t2))
//MAIN PART
call s_ability_startCasting(u, "skystorm")
set l = GetRectCenter(gg_rct_CoA_x_Summon_AE_01)
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call RemoveLocation(l)
set l = GetRectCenter(gg_rct_CoA_x_Summon_AE_02)
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call RemoveLocation(l)
set l = GetRectCenter(gg_rct_CoA_x_Summon_AE_03)
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call RemoveLocation(l)
set l = GetRectCenter(gg_rct_CoA_x_Summon_AE_04)
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call RemoveLocation(l)
set l = GetRectCenter(gg_rct_CoA_x_Summon_AE_05)
call AddSpecialEffectLocBJ( l, "Doodads\\Cinematic\\Lightningbolt\\Lightningbolt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call RemoveLocation(l)
//"the spirits"
loop
exitwhen i > iC
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set l = GetRandomLocInRect(gg_rct_Region_074)
call s_tDL_s(l, tIS, "loc")
call s_tDR_s(r, tIS, "radius")
call s_tDR_s(dmg, tIS, "damage")
call s_tDR_s(2, tIS, "time")
call TimerStart(t, time2, false, function s_stormEffect)
//call DisplayTextToForce( GetPlayersAll(), "cast lightning" )
set time2 = time2 + 1
set i = i + 1
endloop
call s_tDU_s(u, tIS2, "unit")
call s_tDS_s("skystorm", tIS2, "abilityString")
call TimerStart(t2, time2, false, function s_ability_finishCasting_t)
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set t = null
set u = null
set uIS = ""
set tIS = ""
set time = 0
set r = 0
set dmg = 0
set iCount = 0
set delay = 0
set time2 = 0
set delay2 = 0
set iCount = 0
set i = 0
set iC = 0
set t2 = null
set tIS2 = ""
endfunction
function cOA_endlessWind takes nothing returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = udg_ChildOfAir
local string uIS = I2S(GetHandleId(u))
local group g = null
local location uL = GetUnitLoc(u)
local real ang = GetRandomDirectionDeg()
local location l = null
local integer i = 1
local location l2 = null
local integer num = 0
local timer t2 = CreateTimer()
local string tIS2 = I2S(GetHandleId(t2))
//MAIN PART
call s_ability_startCasting(u, "endlesswinds")
loop
exitwhen i > num
set udg_tempReal = GetRandomReal(250.00, 1400.00)
set udg_tempReal2 = GetRandomDirectionDeg()
set l = PolarProjectionBJ(GetRectCenter(gg_rct_CoA_Final_Form), udg_tempReal, udg_tempReal2)
call CreateNUnitsAtLoc( 1, 'n01D', GetOwningPlayer(u), l, bj_UNIT_FACING )
set uL = GetUnitLoc(bj_lastCreatedUnit)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call s_tDL_s(l2, tIS, "loc")
call s_tDR_s(15, tIS, "time")
set ang = ang + 180
call RemoveLocation(l)
set l = PolarProjectionBJ(uL, 1000, ang)
call IssuePointOrderLoc(bj_lastCreatedUnit, "move", l2)
call TimerStart(t, 0, false, function s_cOA_tornado_check)
call RemoveLocation(uL)
call RemoveLocation(l)
set i = i + 1
endloop
call s_tDU_s(u, tIS2, "unit")
call s_tDS_s("skystorm", tIS2, "abilityString")
call TimerStart(t2, 30, false, function s_ability_finishCasting_t)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
set t = null
set u = null
set uIS = ""
set tIS = ""
call RemoveLocation(l)
set l = null
call RemoveLocation(uL)
set uL = null
set ang = 0
set l2 = null
set num = 0
set t2 = null
set tIS2 = ""
endfunction
function cOA_detect takes nothing returns nothing
local unit u = udg_ChildOfAir
local string uIS = I2S(GetHandleId(u))
local string aIS = s_uDS(u, "ai")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(2000, uL)
local unit eU = FirstOfGroup(g)
local boolean found = false
//MAIN PART
if s_uDB(u, "ability_skystorm_currentlyExecuting") == false and s_uDB(u, "ability_endlesswinds_currentlyExecuting") == false and s_uDS(u, "ai") == "attacking" then
call PauseTimerBJ(true, udg_Timer_CoA_EndlessWinds_Cycle)
call PauseTimerBJ(false, udg_Timer_CoA_Skystorm_Cycle)
call StartTimerBJ(udg_Timer_CoA_Skystorm, false, 30)
call s_cOA_skystorm()
call s_uDB_s(true, uIS, "ability_skystorm_currentlyExecuting")
//call DisplayTextToForce( GetPlayersAll(), "start skystorm" )
endif
loop
exitwhen eU == null or found == true
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(eU)) == true then
call s_uDS_s("attacking", uIS, "ai")
call s_uDU_s(eU, uIS, "targetUnit")
set found = true
endif
call GroupRemoveUnit(g,eU)
set eU = FirstOfGroup(g)
endloop
//call DisplayTextToForce( GetPlayersAll(), "coa detect" )
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set aIS = ""
set uIS = ""
call DestroyGroup(g)
set g = null
set eU = null
set found = false
endfunction
function s_cOA_aiInit takes nothing returns nothing
local unit u = udg_ChildOfAir
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDI_s(3, uIS, "ability_skystorm_count")
call s_uDR_s(2, uIS, "ability_skystorm_period")
call s_uDI_s(9, uIS, "ability_skystorm_lightning_count")
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function s_blizzardStrike takes location l returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call fx_delayedEffect( "Abilities\\Spells\\Human\\Blizzard\\BlizzardTarget.mdl", l, 0, 6 )
//PLUG LEAKS
// destroy timer in expireEffect
set l = null
set t = null
set tIS = ""
endfunction
function s_freezeEffect takes location l, real time returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local group g = GetUnitsInRangeOfLocAll( 200, l)
local unit eU = null
local location uL = null
//MAIN PART
//call fx_delayedEffect( "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", l, 0, time)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
set uL = GetUnitLoc(eU)
call AddSpecialEffectLocBJ( uL, "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, time)
call s_stun(eU, time)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//PLUG LEAKS
call DestroyTimer(t)
set t = null
call DestroyGroup(g)
set g = null
set eU = null
set l = null
set tIS = ""
call RemoveLocation(uL)
set uL = null
set time = 0
endfunction
function s_Gale_freezeBlast_effect takes nothing returns nothing // creates Impale style lines of freezing novas
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l = s_tDL(tIS, "loc")
local real ang = s_tDR(tIS, "angle")
local real dist = s_tDR(tIS, "distance")
local real distEnd = s_tDR(tIS, "distanceMax")
local real period = s_tDR(tIS, "period")
local real radius = s_tDR(tIS, "radius")
local unit eU = null
local group g = GetUnitsInRangeOfLocAll(radius, l)
//MAIN PART
set l = PolarProjectionBJ(l, 175, ang)
set dist = dist + 175
call s_tDR_s(dist, tIS, "dist")
call s_tDL_s(l, tIS, "loc")
call s_freezeEffect(l, 10)
if (dist > distEnd) then
call DestroyTimer(t)
call RemoveLocation(l)
else
call TimerStart(t, period, false, function s_Gale_freezeBlast_effect)
endif
//call DisplayTextToForce(GetPlayersAll(), "freezeblast effect")
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set t = null
set u = null
set uIS = ""
set tIS = ""
set ang = 0
set dist = 0
set distEnd = 0
set period = 0
set radius = 0
set eU = null
call DestroyGroup(g)
set g = null
endfunction
function s_Gale_freezeBlast takes nothing returns nothing // creates Impale style lines of freezing novas
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_GaleWinterFreeze
local string uIS = I2S(GetHandleId(u))
local location l = GetUnitLoc(u)
local group g = null
local unit tUnit = s_uDU(u, "targetUnit")
local location l2 = GetUnitLoc(tUnit)
local real ang = AngleBetweenPoints(l, l2)
local real dist = 0
local real distEnd = 2000
local real period = 0.25
local real radius = 125
//MAIN PART
call s_tDR_s(ang, tIS, "angle")
call s_tDR_s(dist, tIS, "distance")
call s_tDR_s(distEnd, tIS, "distanceMax")
call s_tDR_s(period, tIS, "period")
call s_tDR_s(radius, tIS, "radius")
call s_tDL_s(l, tIS, "loc")
call TimerStart(t, 0, false, function s_Gale_freezeBlast_effect)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(ang - 33, tIS, "angle")
call s_tDR_s(dist, tIS, "distance")
call s_tDR_s(distEnd, tIS, "distanceMax")
call s_tDR_s(period, tIS, "period")
call s_tDR_s(radius, tIS, "radius")
call s_tDL_s(l, tIS, "loc")
call TimerStart(t, 0, false, function s_Gale_freezeBlast_effect)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(ang + 33, tIS, "angle")
call s_tDR_s(dist, tIS, "distance")
call s_tDR_s(distEnd, tIS, "distanceMax")
call s_tDR_s(period, tIS, "period")
call s_tDR_s(radius, tIS, "radius")
call s_tDL_s(l, tIS, "loc")
call TimerStart(t, 0, false, function s_Gale_freezeBlast_effect)
//PLUG LEAKS
call RemoveLocation(l2)
set l = null
call DestroyGroup(g)
set g = null
set t = null
set u = null
set uIS = ""
set tIS = ""
endfunction
function s_Gale_winterVengeance takes nothing returns nothing
local unit u = udg_GaleWinterFreeze
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local unit eU = null
local group g = GetUnitsInRectAll(GetPlayableMapRect())
local location l = null
//MAIN PART
set eU = FirstOfGroup(g)
loop
exitwhen eU == null
set l = GetUnitLoc(eU)
if s_uDS(eU, "gender") == "male" then
call s_freezeEffect(l, 15)
//call DisplayTextToForce( GetPlayersAll(), "froze unit" )
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
call RemoveLocation(l)
endloop
//call DisplayTextToForce( GetPlayersAll(), "WINTER HAS COME" )
//PLUG LEAKS
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set eU = null
set t = null
endfunction
function gale_detect takes nothing returns nothing
local unit u = udg_GaleWinterFreeze
local string uIS = I2S(GetHandleId(u))
local string aIS = s_uDS(u, "ai")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(1200, uL)
local unit eU = FirstOfGroup(g)
local boolean found = false
local boolean casting = s_uDB(u, "casting")
//MAIN PART
loop
exitwhen eU == null or found == true
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(eU)) == true and casting == false then
call StartTimerBJ(udg_Timer_Gale_FreezingBlast, true, 70)
call PauseTimerBJ( true, udg_Timer_Gale_WinterFreeze )
call s_uDB_s(true, uIS, "casting")
//call DisplayTextToForce(GetPlayersAll(), "freeze blast!")
call s_uDS_s("attacking", uIS, "ai")
call s_uDU_s(eU, uIS, "targetUnit")
call s_Gale_freezeBlast()
set found = true
endif
call GroupRemoveUnit(g,eU)
set eU = FirstOfGroup(g)
endloop
if found == false and casting == false then
if aIS != "winterfreeze" then
call StartTimerBJ(udg_Timer_Gale_WinterFreeze, true, 70)
call PauseTimerBJ( true, udg_Timer_Gale_FreezingBlast )
endif
call s_uDS_s("winterfreeze", uIS, "ai")
endif
//call DisplayTextToForce( GetPlayersAll(), "gale detect" )
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set aIS = ""
set uIS = ""
call DestroyGroup(g)
set g = null
set eU = null
set found = false
endfunction
function fireOgre_detect takes nothing returns nothing
local unit u = udg_FireOgre
local string uIS = I2S(GetHandleId(u))
local string aIS = s_uDS(u, "ai")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(2000, uL)
local unit eU = FirstOfGroup(g)
local boolean found = false
//MAIN PART
if s_uDB(u, "ability_rockThrow_casting") == false and s_uDS(u, "ai") != "attacking" then
call PauseTimerBJ(false, udg_Timer_FireOgre_RockThrow)
call EnableTrigger(gg_trg_Fire_Ogre_Chucks_Rocks)
endif
call s_uDS_s("", uIS, "ai")
loop
exitwhen eU == null or found == true
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(eU)) == true then
call s_uDS_s("attacking", uIS, "ai")
call s_uDU_s(eU, uIS, "targetUnit")
call PauseTimerBJ(true, udg_Timer_FireOgre_RockThrow)
set found = true
endif
call GroupRemoveUnit(g,eU)
set eU = FirstOfGroup(g)
endloop
call ConditionalTriggerExecute( gg_trg_FireOgre_Pick_Taunt )
//call DisplayTextToForce( GetPlayersAll(), "donkey detect" )
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set aIS = ""
set uIS = ""
call DestroyGroup(g)
set g = null
set eU = null
set found = false
endfunction
function fireOgre_rockThrow takes nothing returns nothing
local unit u = udg_FireOgre
local location tL = null
local real x = 0
local real y = 0
local real z = 0
// throws and learns from impact
endfunction
function fireOgre_monitorAttacks takes nothing returns nothing
local unit u = udg_FireOgre
local string uIS = I2S(GetHandleId(u))
local unit mU = s_uDU(u, "attackProjectile")
local location mUL = GetUnitLoc(mU)
local real x = GetLocationX(mUL)
local real y = GetLocationY(mUL)
local real z = GetUnitFlyHeight(mU)
local real targetX = GetLocationX(s_uDL(u, "attackProjectile_targetLoc"))
local real targetY = GetLocationY(s_uDL(u, "attackProjectile_targetLoc"))
local real targetZ = GetLocationZ(s_uDL(u, "attackProjectile_targetLoc"))
local real diffV = 0
local real dist = 0
local real bestDist = 0
local real bestX = s_uDR(u, "attackProjectile_bestX")
local real bestY = s_uDR(u, "attackProjectile_bestY")
local real bestZ = s_uDR(u, "attackProjectile_bestZ")
local real aimX = s_uDR(u, "attackProjectile_aimX")
local real aimY = s_uDR(u, "attackProjectile_aimY")
local real aimZ = s_uDR(u, "attackProjectile_aimZ")
local real bestAimX = s_uDR(u, "attackProjectile_bestAimX")
local real bestAimY = s_uDR(u, "attackProjectile_bestAimY")
local real bestAimZ = s_uDR(u, "attackProjectile_bestAimZ")
//MAIN PART
set diffV = RAbsBJ(targetX - x)
if diffV < bestX then
set bestX = diffV
call s_uDR_s(bestX, uIS, "attackProjectile_bestX")
call s_uDR_s(aimX, uIS, "attackProjectile_bestAimX")
endif
set diffV = RAbsBJ(targetY - y)
if diffV < bestY then
set bestY = diffV
call s_uDR_s(bestY, uIS, "attackProjectile_bestY")
call s_uDR_s(aimY, uIS, "attackProjectile_bestAimY")
endif
set diffV = RAbsBJ(targetZ - z)
if diffV < bestZ then
set bestZ = diffV
call s_uDR_s(bestZ, uIS, "attackProjectile_bestZ")
call s_uDR_s(aimZ, uIS, "attackProjectile_bestAimZ")
endif
//PLUG LEAKS
set u = null
set uIS = ""
set mU = null
call RemoveLocation(mUL)
set mUL = null
set x = 0
set y = 0
set z = 0
set targetX = 0
set targetY = 0
set targetZ = 0
set diffV = 0
set dist = 0
set bestDist = 0
set bestX = 0
set bestY = 0
set bestZ = 0
set aimX = 0
set aimY = 0
set aimZ = 0
set bestAimX = 0
set bestAimY = 0
set bestAimZ = 0
endfunction
function s_eK_updateArcPath takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l = s_tDL(tIS, "centerPoint")
local location uL = GetUnitLoc(u)
local real a = AngleBetweenPoints(l, uL)
local real dist = DistanceBetweenPoints(l, uL)
local real arcDone = s_tDR(tIS, "arcDone")
local real arcTarget = s_tDR(tIS, "arcTarget")
//MAIN PART
set a = a + 5
set arcDone = arcDone + 5
call s_tDR_s(arcDone, tIS, "arcDone")
set l = PolarProjectionBJ(l, dist, a)
call IssuePointOrderLocBJ(u, "move", l)
if ((arcDone < arcTarget) and (IsUnitAliveBJ(u) == true)) then
call TimerStart(t, 0.125, false, function s_eK_updateArcPath)
elseif (IsUnitAliveBJ(u) == true) then
call RemoveLocation(l)
call DestroyTimer(t)
call s_uDB_s(false, uIS, "ability_wallRun_using")
endif
//PLUG LEAKS
set l = null
set t = null
set u = null
set uIS = ""
set tIS = ""
set a = 0
set dist = 0
endfunction
function s_eK_circleRun takes unit u, location l, real arc returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = I2S(GetHandleId(u))
// arc is total amount the unit runs around, uses this after hitting wall and shoots rocks at you
//MAIN PART
call s_sTimer(t, tIS)
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(arc, tIS, "arcTarget")
call s_uDB_s(false, uIS, "ability_wallRun_ready")
call s_uDB_s(true, uIS, "ability_wallRun_using")
//PLUG LEAKS
set l = null
set t = null
set u = null
set uIS = ""
set tIS = ""
endfunction
function s_eK_turnFinished takes nothing returns nothing
local timer t = GetExpiredTimer()
local string uIS = I2S(GetHandleId(udg_EarthKing))
//MAIN PART
call s_uDB_s(false, uIS, "turning")
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set uIS = ""
endfunction
function s_eK_turnToward takes location l, real r returns nothing // remember to destroy loc in capture function
local string uIS = I2S(GetHandleId(udg_EarthKing))
//MAIN PART
call SetUnitFacingToFaceLocTimed( udg_EarthKing, l, r )
call s_uDB_s(true, uIS, "turning")
call TimerStart(CreateTimer(), r, false, function s_eK_turnFinished)
//PLUG LEAKS
set uIS = ""
set l = null
set r = 0
endfunction
function s_eK_finishCharge takes nothing returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = I2S(GetHandleId(udg_EarthKing))
//MAIN PART
call s_uDB_s(false, uIS, "ability_charge_using")
//PLUG LEAKS
set t = null
set uIS = ""
set tIS = ""
endfunction
function s_eK_pickChargePath takes nothing returns nothing
local unit u = udg_EarthKing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = I2S(GetHandleId(u))
local real arc = GetRandomReal(0, 360)
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(arc, tIS, "arcTarget")
call s_uDB_s(true, uIS, "ability_charge_using")
//PLUG LEAKS
set t = null
set u = null
set uIS = ""
set tIS = ""
set arc = 0
endfunction
function s_eK_finishCharge takes nothing returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = I2S(GetHandleId(udg_EarthKing))
//MAIN PART
call s_uDB_s(false, uIS, "ability_charge_using")
//PLUG LEAKS
set t = null
set uIS = ""
set tIS = ""
endfunction
function s_eK_pickChargePath takes nothing returns nothing
local unit u = udg_EarthKing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = I2S(GetHandleId(u))
local real arc = GetRandomReal(0, 360)
//MAIN PART
call s_sTimer(t, tIS)
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(arc, tIS, "arcTarget")
call s_uDB_s(true, uIS, "ability_charge_using")
//PLUG LEAKS
set t = null
set u = null
set uIS = ""
set tIS = ""
set arc = 0
endfunction
function s_eK_aiInit takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
//exits
set udg_tempLoc = GetRectCenter(gg_rct_The_Blip)
call sAI_saveLocationParameter(udg_tempLoc, "exit1", "Units_" + uIS, udg_UnitAI)
set udg_tempLoc = GetRectCenter(gg_rct_EarthKing_x_Exit_02)
call sAI_saveLocationParameter(udg_tempLoc, "exit2", "Units_" + uIS, udg_UnitAI)
set udg_tempLoc = GetRectCenter(gg_rct_EarthKing_x_Exit_03)
call sAI_saveLocationParameter(udg_tempLoc, "exit3", "Units_" + uIS, udg_UnitAI)
//
call s_uDI_s(8, uIS, "rockCount")
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function s_eK_flingRocks takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location l = null
local location uL = GetUnitLoc(u)
local location l2 = null
local real oS = 0
local real oSR = 0
local integer rocks = s_uDI(u, "rockCount")
local integer i = 1
local real uF = GetUnitFacing(u)
//MAIN PART
set oS = uF
set oSR = -40
if s_uDI(u, "state_stun") <= 0 then
loop
exitwhen (i > 8)
set oS = oS + oSR
set l = PolarProjectionBJ(uL, 100, oS)
call s_rockProjectileSmall(u, l, l2, 30, GetRandomReal(0,50) )
if (i >= 4) then
set oSR = 40
set oS = uF
endif
set i = i + 1
endloop
endif
//PLUG LEAKS
set l = null
set l2 = null
set u = null
set uIS = ""
call RemoveLocation(uL)
set uL = null
set oS = 0
set oSR = 0
set rocks = 0
set i = 0
set uF = 0
endfunction
function s_eK_flingRocksSmall takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location l = null
local location uL = GetUnitLoc(u)
local location l2 = null
local real oS = 0
local real oSR = 0
local integer rocks = s_uDI(u, "rockCount")
local integer i = 1
local real uF = GetUnitFacing(u)
//MAIN PART
set oS = uF
set oSR = -40
if s_uDI(u, "state_stun") <= 0 then
loop
exitwhen (i > 8)
set oS = oS + oSR
set l = PolarProjectionBJ(uL, 100, oS)
call s_rockProjectileSmall(u, l, l2, 10, GetRandomReal(0,25) )
if (i >= 4) then
set oSR = 40
set oS = uF
endif
set i = i + 1
endloop
endif
//PLUG LEAKS
set l = null
set l2 = null
set u = null
set uIS = ""
call RemoveLocation(uL)
set uL = null
set oS = 0
set oSR = 0
set rocks = 0
set i = 0
set uF = 0
endfunction
function eK_scanTerrain takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local real uA = GetUnitFacing(u)
local location uL = GetUnitLoc(u)
local integer tI = s_uDI(u, "cliff_level")
local integer cTI = 0
local location nL = null
local integer nTI = 0
local boolean impacted = false
local string cOS = s_uDS(u, "current_order")
//
local location oL = s_uDL(u, "current_order_loc")
local real oLA = AngleBetweenPoints(uL, oL)
local integer sTI = s_uDI(u, "cliff_level_start")
//MAIN PART
set uA = AngleBetweenPoints(uL, oL)
set nL = PolarProjectionBJ(uL, 250, uA)
set cTI = GetTerrainCliffLevelBJ(uL)
set nTI = GetTerrainCliffLevelBJ(nL)
if tI == 0 then
set tI = cTI
endif
if nTI != sTI then
set impacted = true
endif
if s_uDS(u, "ai") != "retreat" and cOS == "move" and s_uDI(u, "state_stun") == 0 and impacted == true then
call s_stun(u, 15)
call s_eK_flingRocks()
call SetUnitVertexColorBJ( udg_EarthKing, 20, 100.00, 20.00, 0 )
endif
call s_uDI_s(cTI, uIS, "cliff_level")
//PLUG LEAKS
set u = null
set uIS = ""
set uA = 0
set uL = null
set tI = 0
set cTI = 0
set nL = null
set nTI = 0
set impacted = false
set cOS = ""
endfunction
function fx_eK_feetStampede_effect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local location uL = GetUnitLoc(udg_EarthKing)
local integer fI = LoadIntegerBJ(0, StringHashBJ(tIS + "_footIndex"), udg_tempHash) // get offset information from tIS and calculate it right now
local boolean lastFoot = LoadBooleanBJ(0, StringHashBJ(tIS + "_isLastFoot"), udg_tempHash)
local integer i = 1
local location l = null
local real uF = GetUnitFacing(udg_EarthKing)
//MAIN PART
if (fI == i) then
set l = PolarProjectionBJ(uL, 256, uF -60)
endif
set i = i + 1
if (fI == i) then
set l = PolarProjectionBJ(uL, 256, uF + 60)
endif
set i = i + 1
if (fI == i) then
set l = PolarProjectionBJ(uL, 256, uF -300)
endif
set i = i + 1
if (fI == i) then
set l = PolarProjectionBJ(uL, 256, uF + 300)
endif
set i = i + 1
call AddSpecialEffectLocBJ( l, "Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 5) // dunno if need or not
call sAI_deleteDataTree(tIS, udg_tempHash) // all use individual timers
//PLUG LEAKS
call DestroyTimer(t)
set t = null
call RemoveLocation(l)
call RemoveLocation(uL)
set l = null
set uL = null
set fI = 0
set lastFoot = false
set uF = 0
set i = 0
set tIS = ""
endfunction
function fx_eK_feetStampede takes nothing returns nothing
local unit u = udg_EarthKing
local location uL = GetUnitLoc(u)
local location f1 = null
local location f2 = null
local location f3 = null
local location f4 = null //these are actually offsets, not the final location
local timer t = GetExpiredTimer()
local string tIS = ""
local timer fXT = null
local string fXTIS = ""
local real delay = 0
local boolean stampeding = s_uDB(u, "stampeding")
//MAIN PART
call DestroyTimer(t)
if (stampeding == true) then
set t = CreateTimer()
set tIS = I2S(GetHandleId(t))
call s_sTimer(t, tIS)
call sAI_saveIntegerParameter(1, "footIndex", tIS, udg_tempHash)
call TimerStart(t, 0, false, function fx_eK_feetStampede_effect)
set t = CreateTimer()
set tIS = I2S(GetHandleId(t))
call s_sTimer(t, tIS)
call sAI_saveIntegerParameter(2, "footIndex", tIS, udg_tempHash)
call TimerStart(t, 0.25, false, function fx_eK_feetStampede_effect)
set t = CreateTimer()
set tIS = I2S(GetHandleId(t))
call s_sTimer(t, tIS)
call sAI_saveIntegerParameter(3, "footIndex", tIS, udg_tempHash)
call TimerStart(t, 0.5, false, function fx_eK_feetStampede_effect)
set t = CreateTimer()
set tIS = I2S(GetHandleId(t))
call s_sTimer(t, tIS)
call sAI_saveIntegerParameter(4, "footIndex", tIS, udg_tempHash)
call sAI_saveBooleanParameter(true, "isLastFoot", tIS, udg_tempHash)
call TimerStart(t, 0.75, false, function fx_eK_feetStampede_effect)
call TimerStart(CreateTimer(), 2, false, function fx_eK_feetStampede)
endif
//PLUG LEAKS
call RemoveLocation(f1)
call RemoveLocation(f2)
call RemoveLocation(f3)
call RemoveLocation(f4)
call RemoveLocation(uL)
set f1 = null
set f2 = null
set f3 = null
set f4 = null
set uL = null
set u = null
set t = null
set tIS = ""
set fXT = null
set fXTIS = ""
set delay = 0
set stampeding = false
endfunction
function fx_feetQuake takes unit u returns nothing
local location uL = GetUnitLoc(u)
//MAIN PART
//call s_effect( "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl", uL, 3 ) //for some reason s_effect is failing
//call s_destroyEffect_main(bj_lastCreatedEffect, 5)
call AddSpecialEffectLocBJ( uL, "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 5)
//PLUG LEAKS
set u = null
call RemoveLocation(uL)
set uL = null
endfunction
function s_eK_stampedeCrush takes nothing returns nothing
local unit u = udg_EarthKing
local location uL = GetUnitLoc(u)
local real uF = GetUnitFacing(u)
local location l = null
local rect r = null
local group g = null
local unit eU = null
local boolean stampeding = s_uDB(u, "stampeding")
//MAIN PART
set l = PolarProjectionBJ(uL, 250, uF)
set r = RectFromCenterSizeBJ(l, 200.00, 200.00)
set g = GetUnitsInRectAll(r)
call GroupRemoveUnit(g, u)
set eU = FirstOfGroup(g)
if s_uDS(u, "current_order") == "move" then
loop
exitwhen (eU == null)
call KillUnit(eU)
call GroupRemoveUnit(g,eU)
set eU = FirstOfGroup(g)
endloop
endif
//PLUG LEAKS
call DestroyGroup(g)
set g = null
call RemoveLocation(uL)
call RemoveLocation(l)
set uL = null
set l = null
call RemoveRect(r)
set r = null
set eU = null
set u = null
set uF = 0
set stampeding = false
endfunction
function eK_stampede takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location uL = GetUnitLoc(u)
local real rA = GetRandomDirectionDeg()
local location cL = GetRectCenter(gg_rct_EK_Battlezone)
local location l = PolarProjectionBJ(cL, 2000, rA)
//MAIN PART
call s_uDS_s("charging", uIS, "ai")
call IssuePointOrderLoc(udg_EarthKing, "move", l)
call s_uDS_s("move", uIS, "current_order")
call s_uDS_s("point", uIS, "current_order_type")
call RemoveLocation(s_uDL(u, "current_order_loc"))
call s_uDL_s(l, uIS, "current_order_loc")
call EnableTrigger(gg_trg_EarthKing_x_Rock_Fling)
call EnableTrigger(gg_trg_EarthKing_x_Crushing_Feet)
//call DisplayTextToForce( GetPlayersAll(), "stampede" )
//PLUG LEAKS
set u = null
set uIS = ""
call RemoveLocation(uL)
set uL = null
set rA = 0
set l = null
call RemoveLocation(cL)
set cL = null
endfunction
function eK_attack takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location cL = GetRectCenter(gg_rct_EK_Battlezone)
local location uL = GetUnitLoc(u)
local real rA = GetRandomDirectionDeg()
local location l = PolarProjectionBJ(uL, 2000, rA)
//MAIN PART
call s_uDS_s("attacking", uIS, "ai")
call IssuePointOrderLoc(udg_EarthKing, "attack", l)
call s_uDS_s("attack", uIS, "current_order")
call s_uDS_s("point", uIS, "current_order_type")
call RemoveLocation(s_uDL(u, "current_order_loc"))
call s_uDL_s(l, uIS, "current_order_loc")
//call DisplayTextToForce( GetPlayersAll(), "attack" )
//PLUG LEAKS
set u = null
set uIS = ""
call RemoveLocation(uL)
set uL = null
set rA = 0
set l = null
call RemoveLocation(cL)
set cL = null
endfunction
function eK_runsToBlip takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location l = s_uDL(u, "retreatDest")
//MAIN PART
call IssuePointOrderLoc(udg_EarthKing, "move", l)
call s_uDS_s("move", uIS, "current_order")
call s_uDS_s("point", uIS, "current_order_type")
call s_uDL_s(l, uIS, "current_order_loc")
// PLUG LEAKS
set u = null
set uIS = ""
set l = null
endfunction
function eK_pickRetreat takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local integer i = GetRandomInt(1, 3)
local location l = null
//MAIN PART
call RemoveLocation(s_uDL(u, "current_order_loc"))
call RemoveLocation(s_uDL(u, "retreatDest"))
if (i == 1) then
set l = GetRectCenter(gg_rct_The_Blip)
endif
if (i == 2) then
set l = GetRectCenter(gg_rct_EarthKing_x_Exit_02)
endif
if (i == 3) then
set l = GetRectCenter(gg_rct_EarthKing_x_Exit_03)
endif
call s_uDL_s(l, uIS, "retreatDest")
//PLUG LEAKS
set l = null
set i = 0
set u = null
set uIS = ""
endfunction
function eK_retreat takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDS_s("retreating", uIS, "ai")
call eK_pickRetreat()
call eK_runsToBlip()
//call DisplayTextToForce( GetPlayersAll(), "retreat" )
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function eK_blips takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location l = s_uDL(u, "retreatDest")
//MAIN PART
call ShowUnitHide( udg_EarthKing )
call SetUnitInvulnerable( udg_EarthKing, true )
call StartTimerBJ(udg_Timer_EK_Blipped, false, 10)
call IssueImmediateOrder(udg_EarthKing, "stop")
call s_uDS_s("stop", uIS, "current_order")
call s_uDS_s("none", uIS, "current_order_type")
//call DisplayTextToForce( GetPlayersAll(), "blip" )
// PLUG LEAKS
set u = null
set uIS = ""
set l = null
endfunction
function eK_return takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location l = GetRectCenter(gg_rct_EK_Idle)
//MAIN PART
call ShowUnitShow( udg_EarthKing )
call SetUnitInvulnerable( udg_EarthKing, false )
call s_uDS_s("returning", uIS, "ai")
call IssuePointOrderLoc(udg_EarthKing, "move", l)
call s_uDS_s("move", uIS, "current_order")
call s_uDS_s("point", uIS, "current_order_type")
call RemoveLocation(s_uDL(u, "current_order_loc"))
call s_uDL_s(l, uIS, "current_order_loc")
//call DisplayTextToForce( GetPlayersAll(), "return" )
//PLUG LEAKS
set u = null
set uIS = ""
set l = null
endfunction
function eK_reset takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call s_uDS_s("idle", uIS, "ai")
call IssueImmediateOrder(udg_EarthKing, "stop")
call s_uDS_s("stop", uIS, "current_order")
call s_uDS_s("none", uIS, "current_order_type")
//call DisplayTextToForce( GetPlayersAll(), "reset" )
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function eK_detect takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(2000, uL)
local unit eU = null
local string aiS = s_uDS(u, "ai")
local boolean found = false
//MAIN PART
set eU = FirstOfGroup(g)
loop
exitwhen eU == null or found == true
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(eU)) == true and (aiS == "idle" or aiS == "") then
call eK_stampede()
call StartTimerBJ( udg_Timer_EK_Stampede, false, 20 )
call StartTimerBJ( udg_Timer_EK_Stampeding, true, 5 )
set found = true
call s_uDU_s(eU, uIS, "target_unit")
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
if s_uDS(u, "ai") == "charging" and s_uDI(u, "state_stun") <= 0 then
call SetUnitVertexColorBJ( udg_EarthKing, 100.00, 0.00, 0.00, 0 )
elseif s_uDI(u, "state_stun") > 0 then
call SetUnitVertexColorBJ( udg_EarthKing, 0.00, 100.00, 0.00, 0 )
else
call SetUnitVertexColorBJ( udg_EarthKing, 100.00, 100.00, 100.00, 0 )
endif
//PLUG LEAKS
set u = null
set uIS = ""
call RemoveLocation(uL)
set uL = null
call DestroyGroup(g)
set g = null
set eU = null
set aiS = ""
set found = false
endfunction
function eK_changeOrder takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local string oS = s_uDS(u, "current_order")
local string oType = s_uDS(u, "current_order_type")
local location l = s_uDL(u, "current_order_loc")
local unit u2 = s_uDU(u, "current_order_unit")
//MAIN PART
//PLUG LEAKS
set u = null
set uIS = ""
set oS = ""
set oType = ""
set l = null
set u2 = null
endfunction
function eK_order takes nothing returns nothing
local unit u = udg_EarthKing
local string uIS = I2S(GetHandleId(u))
local string oS = s_uDS(u, "current_order")
local string oType = s_uDS(u, "current_order_type")
local location l = s_uDL(u, "current_order_loc")
local unit u2 = s_uDU(u, "current_order_unit")
//MAIN PART
if oType == "point" then
call IssuePointOrderLocBJ( u, oS, l )
elseif oType == "unit" then
call IssueTargetOrderBJ( u, oS, u2 )
else
call IssueImmediateOrderBJ( u, oS )
endif
//PLUG LEAKS
set u = null
set uIS = ""
set oS = ""
set oType = ""
set l = null
set u2 = null
endfunction
function hero_unpause takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
//MAIN PART
if udg_CinematicModeOn == false then
call PauseUnitBJ(false, u)
call DestroyTimer(t)
endif
//PLUG LEAKS
set t = null
set tIS = ""
set u = null
endfunction
function hero_pause takes unit u, real r returns nothing
local timer t = CreateTimer()
local string tIS = ""
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call TimerStart(t, r, false, function hero_unpause)
//PLUG LEAKS
set t = null
set tIS = ""
set u = null
set r = 0
endfunction
function hero_rockAttack takes unit u, integer num, rect rct returns nothing
local location l = null
local real rand = 0
local integer i = 1
local location uL = GetUnitLoc(u)
local location tL = GetUnitLoc(udg_EarthKing)
//
local real speed = 1000
local integer steps = 0
local real dist = 0
local timer t = null
local integer tI = 0
local string tIS = ""
local unit rock = null
//MAIN PART
loop
exitwhen i > num
set l = GetRandomLocInRect(rct)
set rand = GetRandomReal(0, 150)
call CreateNUnitsAtLoc( 1, 'n01G', Player(5), l, GetRandomDirectionDeg() )
call SetUnitFlyHeight(bj_lastCreatedUnit, rand, 1)
set rock = bj_lastCreatedUnit
set dist = DistanceBetweenPoints(uL, tL)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(50, tIS, "damage")
call s_tDU_s(rock, tIS, "unit")
call s_tDU_s(udg_EarthKing, tIS, "targetUnit")
call s_tDL_s(l, tIS, "loc")
call s_tDR_s(speed * udg_gameloop, tIS, "inc")
call s_tDR_s(speed, tIS, "speed")
call TimerStart(t, 1, false, function s_linearRock_update) //adding 1 second to account for the rock's lift period
set i = i + 1
endloop
//PLUG LEAKS
set l = null
set rand = 0
set i = 0
set uL = null
set tL = null
endfunction
function fx_chargeMissile2_scale takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local real time = s_tDR(tIS, "time")
local real scale = s_tDR(tIS, "scale")
local effect e = s_tDE(tIS, "effect")
//MAIN PART
call sAI_scaleEffectOverTime(e, scale, time)
call s_tDE_s(null, tIS, "effect")
call sAI_deleteDataTree(tIS, udg_tempHash) //so that the effect isn't destroyed because we're still using it
call DestroyTimer(t)
//PLUG LEAKS
set u = null
set uIS = ""
set t = null
set tIS = ""
set time = 0
set scale = 0
set e = null
endfunction
function fx_chargeMissile2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local real time = s_tDR(tIS, "time")
local real chargeTime = s_tDR(tIS, "charge_time")
local effect e = s_tDE(tIS, "effect")
local location uL = s_tDL(tIS, "loc")
local location tL = null
local real a = 0
local location l = null
local real scale = s_tDR(tIS, "scale")
local timer t2 = CreateTimer()
local real scaling = s_tDR(tIS, "scaling")
local real scale_start = s_tDR(tIS, "scale_start")
local real scale_end = s_tDR(tIS, "scale_end")
local boolean initPassed = s_tDB(tIS, "init_passed")
local real height = s_tDR(tIS, "height")
local real inc = s_tDR(tIS, "inc")
//MAIN PART
if uL == null then
set uL = GetUnitLoc(u)
endif
set tL = GetRectCenter(gg_rct_Dragonbreath)
set a = AngleBetweenPoints(uL, tL)
set l = PolarProjectionBJ(uL, 200, a)
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set scaling = 1
set scale = 1
endif
if scale_start == 0 then
set scale_start = 8
set scale_end = 0.1
call s_tDR_s(scale_start, tIS, "scale_start")
call s_tDR_s(scale_end, tIS, "scale_end")
endif
if chargeTime <= 0 then
set chargeTime = 6
call s_tDR_s(chargeTime, tIS, "charge_time")
endif
if initPassed == false and time <= 0 then
set time = chargeTime
call s_tDR_s(time, tIS, "time")
endif
if e == null then
call AddSpecialEffectLocBJ( l, "Abilities\\Weapons\\WitchDoctorMissile\\WitchDoctorMissile.mdl" )
set e = GetLastCreatedEffectBJ()
call s_tDE_s(e, tIS, "effect")
call BlzSetSpecialEffectZ( e, 300 + height )
call BlzSetSpecialEffectColor( e, 0, 255, 0 )
call BlzSetSpecialEffectScale( e, scale_start )
endif
if initPassed == false and inc == 0 then
set inc = ((scale_end - scale_start) / chargeTime)
call s_tDR_s(inc, tIS, "inc")
set scale = scale_start
call s_tDR_s(scale, tIS, "scale")
endif
if initPassed == false then
call s_tDB_s(true, tIS, "init_passed")
endif
//==================================================================================
set scaling = time / chargeTime
set time = time - (1 * scaling)
call s_tDR_s(time, tIS, "time")
if time < 0.0625 then
set time = 0
else
set scale = scale + (inc * scaling)
call s_tDR_s(scale, tIS, "scale")
//call DisplayTextToForce(GetPlayersAll(), "inc: " + R2S(inc))
//call DisplayTextToForce(GetPlayersAll(), "scale: " + R2S(scale))
call s_tDR_s(scaling, tIS, "scaling")
set tI = GetHandleId(t2)
set tIS = I2S(tI)
call s_tDR_s(scale * 0.1, tIS, "scale")
call s_tDR_s(0.5 * scaling, tIS, "time")
call s_tDE_s(e, tIS, "effect")
call TimerStart(t2, 0, false, function fx_chargeMissile2_scale)
set t2 = CreateTimer()
set tI = GetHandleId(t2)
set tIS = I2S(tI)
call s_tDR_s(scale, tIS, "scale")
call s_tDR_s(0.5 * scaling, tIS, "time")
call s_tDE_s(e, tIS, "effect")
call TimerStart(t2, 0.5 * scaling, false, function fx_chargeMissile2_scale)
endif
if time <= 0 then
call s_destroyEffect_main(e, 0)
call DestroyTimer(t)
call RemoveLocation(uL)
else
set time = 1 * scaling
if time < udg_gameloop_fx then
set time = udg_gameloop_fx
endif
call TimerStart(t, 1 * scaling, false, function fx_chargeMissile2)
endif
//PLUG LEAKS
set u = null
set uIS = ""
set t = null
set tIS = ""
set time = 0
set e = null
call RemoveLocation(tL)
call RemoveLocation(l)
set uL = null
set tL = null
set a = 0
set l = null
set scale = 0
set t2 = null
set scaling = 0
set scale_start = 0
set scale_end = 0
set initPassed = false
set height = 0
set inc = 0
endfunction
function s_g_fireElementals_expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = LoadUnitHandleBJ(0, StringHashBJ(tIS + "_unit"), udg_tempHash)
//MAIN PART
call UnitRemoveAbilityBJ( 'A02F', u )
call KillUnit(u)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
//params
set u = null
endfunction
function s_g_fireElementals takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = udg_Gustivus
local location uL = GetUnitLoc(u)
local real uF = GetUnitFacing(u)
local real ang = GetRandomReal(-60, 60)
local location l = PolarProjectionBJ(uL, 1500, uF + ang)
local location l1 = PolarProjectionBJ(uL, 450, uF)
//MAIN PART
call CreateNUnitsAtLoc( 1, 'h01P', GetOwningPlayer(udg_Gustivus), l1, GetRandomDirectionDeg() )
call IssuePointOrderLoc(GetLastCreatedUnit(), "move", l)
call UnitAddAbilityBJ( 'A02F', u )
call sAI_saveUnitParameter(GetLastCreatedUnit(), "unit", tIS, udg_tempHash)
call TimerStart(t, 10, false, function s_g_fireElementals_expire)
//PLUG LEAKS
call RemoveLocation(uL)
call RemoveLocation(l)
call RemoveLocation(l1)
set uL = null
set l = null
set l1 = null
set t = null
set tIS = ""
set uF = 0
set ang = 0
endfunction
function s_g_fireElementals_main takes location l returns nothing
local timer t = null
local real time = 0
local real delay = 0.5
local integer casts = 12
local integer i = 1
//MAIN PART
loop
exitwhen (i > casts)
set t = CreateTimer()
call TimerStart(t, time, false, function s_g_fireElementals)
set i = i + 1
endloop
//PLUG LEAKS
set t = null
set time = 0
set delay = 0
set casts = 0
set i = 0
//params
call RemoveLocation(l)
set l = null
endfunction
function s_g_sLavaSpawn_expires takes unit u returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call KillUnit(u)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
//params
set u = null
endfunction
function s_g_targetHero takes nothing returns nothing
local unit tU = GroupPickRandomUnit(udg_GFight_Heroes)
local string uIS = I2S(GetHandleId(udg_Gustivus))
//MAIN PART
call sAI_saveUnitParameter(tU, "targetHero", "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
set tU = null
set uIS = ""
endfunction
function s_g_alterAttackAngle_expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local integer count = LoadIntegerBJ(0, StringHashBJ(tIS + "_count"), udg_tempHash)
local real attackAngle = s_uDR(udg_Gustivus, "attackAngle")
local real inc = LoadRealBJ(0, StringHashBJ(tIS + "_inc"), udg_tempHash)
local string uIS = I2S(GetHandleId(udg_Gustivus))
//MAIN PART
set attackAngle = attackAngle + inc
call sAI_saveRealParameter(attackAngle, "attackAngle", "Units_" + uIS, udg_UnitAI)
if (count <= 0) then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
set count = count -1
call sAI_saveIntegerParameter(count, "count", tIS, udg_tempHash)
endif
//PLUG LEAKS
set t = null
set tIS = ""
set count = 0
set attackAngle = 0
set inc = 0
set uIS = ""
endfunction
function s_g_alterAttackAngle takes real ang, real time returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local integer count = 0
local real inc = 0
//MAIN PART
//call sAI_saveRealParameter(tU, "targetHero", "Units_" + uIS, udg_UnitAI)
if (time > 0) then
set inc = ang / time
set count = R2I(ang /inc) // a bit inexact doe
else
set inc = ang
set count = 1
endif
call sAI_saveIntegerParameter(count, "count", tIS, udg_tempHash)
call sAI_saveRealParameter(inc, "inc", tIS, udg_tempHash)
//PLUG LEAKS
set u = null
set uIS = ""
set t = null
set tIS = ""
set count = 0
set inc = 0
endfunction
function g_destroyFText takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call DestroyTextTagBJ( udg_G_FText )
endfunction
function g_finalWords takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call DestroyTextTagBJ( udg_G_FText )
call CreateTextTagUnitBJ( "|cffff00ffT|r|cffe603e6h|r|cffcd06cde|r|cffb409b4 |r|cff9b0d9be|r|cff831083n|r|cff691369d|r|cff501750.|r|cff381a38.|r|cff1e1d1e.|r", udg_Gustivus, 0.00, 10, 100, 100, 100, 0 )
set udg_G_FText = GetLastCreatedTextTag()
call TimerStart(CreateTimer(), 10, false, function g_destroyFText)
endfunction
function g_darktides takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call DestroyTextTagBJ( udg_G_FText )
call CreateTextTagUnitBJ( "|cffffffffT|r|cfffff3ffh|r|cffffe6ffe|r|cffffd9ff |r|cffffccfft|r|cffffc0ffi|r|cffffb3ffd|r|cffffa6ffe|r|cffff99ffs|r|cffff8dff |r|cffff80ffc|r|cffff73ffo|r|cffff66ffm|r|cffff5affe|r|cffff4dff |r|cffff40fft|r|cffff33ffo|r|cffff27ff |r|cffff1affm|r|cffff0dffe|r|cffff00ff!|r", udg_Gustivus, 0.00, 10, 100, 100, 100, 0 )
set udg_G_FText = GetLastCreatedTextTag()
call TimerStart(CreateTimer(), 10, false, function g_destroyFText)
endfunction
function s_lightningXYZ_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local lightning lE = LoadLightningHandleBJ(0, StringHashBJ(tIS + "_lightning"), udg_tempHash)
//MAIN PART
call DestroyLightningBJ( lE )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
set lE = null
endfunction
function s_lightningXYZ takes real x, real y, real z, real tX, real tY, real tZ, real time, real r, real g, real b returns nothing
local unit u = udg_Gustivus
local location uL = GetUnitLoc(u)
local location l = null
local real ang = GetUnitFacing(u)
local real dist = 600
local location dLoc = null
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local integer count = s_uDI(u, "lightning_remainingCount")
local real delay = 0.5
local integer rI = GetRandomInt(1,4)
//MAIN PART
set l = PolarProjectionBJ(uL, 300, ang)
if rI == 1 then
set bj_lastCreatedLightning = AddLightningEx("CHIM", true, x, y, z, tX, tY, tZ)
endif
if rI == 2 then
set bj_lastCreatedLightning = AddLightningEx("HWPB", true, x, y, z, tX, tY, tZ)
endif
if rI == 3 then
set bj_lastCreatedLightning = AddLightningEx("AFOD", true, x, y, z, tX, tY, tZ)
endif
if rI == 4 then
set bj_lastCreatedLightning = AddLightningEx("CLPB", true, x, y, z, tX, tY, tZ)
endif
call SetLightningColorBJ( bj_lastCreatedLightning, r, g, b, 0 )
call sAI_saveLightningParameter(bj_lastCreatedLightning, "lightning", tIS, udg_tempHash) // does the placeholding DLS string create memory leak? prob not
call TimerStart(t, time, false, function s_lightningXYZ_expires)
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
call RemoveLocation(l)
set l = null
set u = null
set ang = 0
set dist = 0
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set r = 0
set g = 0
set b = 0
set t = null
set tIS = ""
set count = 0
set delay = 0
set time = 0
set rI = 0
endfunction
function s_lightningXYZ_main takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local location uL = GetUnitLoc(u)
local real dist = 600
local real ang1 = GetUnitFacing(u)
local real ang2 = GetRandomReal(-60,60)
local real x = GetLocationX(uL)
local real y = GetLocationY(uL)
local real z = GetLocationZ(uL) + 200
local real tX = 0
local real tY = 0
local real tZ = 0
local real r = GetRandomReal(0, 255) // can change this to select stronger for reds greens etc
local real g = GetRandomReal(0, 255)
local real b = GetRandomReal(0, 255)
local integer count = s_uDI(u, "lightning_count")
local integer remainingCount = s_uDI(u, "lightning_remainingCount")
local real delay = 0.0625
local real time = 0.5
local timer t = null
//MAIN PART
if (remainingCount == 0) then
call sAI_saveIntegerParameter(count, "lightning_remainingCount", "Units_" + uIS, udg_UnitAI)
call sAI_saveBooleanParameter(false, "lightning_casting", "Units_" + uIS, udg_UnitAI)
else
call sAI_saveBooleanParameter(true, "lightning_casting", "Units_" + uIS, udg_UnitAI)
set t = CreateTimer()
//gets origin
call s_g_setLightningOffset()
//target
set udg_tempLoc = PolarProjectionBJ(uL, dist, (ang1 + ang2)) // have to make sure this gets cleaned in all uses
set tX = GetLocationX(udg_tempLoc)
set tY = GetLocationY(udg_tempLoc)
set tZ = GetLocationZ(udg_tempLoc) + GetRandomReal(0, 800)
//effect
call s_lightningXYZ(x,y,z, tX,tY,tZ, time, r,g,b)
//update
call sAI_saveIntegerParameter(remainingCount - 1, "lightning_remainingCount", "Units_" + uIS, udg_UnitAI)
//loop
call TimerStart(t, delay, false, function s_lightningXYZ_main)
endif
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
set uIS = ""
set dist = 0
set ang1 = 0
set ang2 = 0
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set r = 0
set g = 0
set b = 0
set t = null
set count = 0
set remainingCount = 0
set delay = 0
set time = 0
endfunction
function s_g_fireHeadFX_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local effect fx = s_uDE(u, "fx_fireheadFX")
//MAIN PART
call DestroyEffect(fx)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set fx = null
endfunction
function s_g_fireHeadFX takes real time returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer()
//MAIN PART
call AddSpecialEffectTargetUnitBJ( "head", u, "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl" )
call BlzSetSpecialEffectScale( GetLastCreatedEffectBJ(), 2.00 )
call sAI_saveEffectParameter(GetLastCreatedEffectBJ(), "fx_fireheadFX", "Units_" + uIS, udg_UnitAI)
call TimerStart(t, time, false, function s_g_fireHeadFX_expires)
//PLUG LEAKS
set t = null
set u = null
set uIS = ""
set time = 0
endfunction
function s_g_chargeMissileFX_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local effect fx = s_uDE(u, "fx_chargeMissileFX")
//MAIN PART
call DestroyEffect(fx)
call sAI_saveEffectParameter(null, "fx_chargeMissileFX", "Units_" + uIS, udg_UnitAI)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set u = null
set uIS = ""
set fx = null
endfunction
function s_g_chargeMissileFX takes real time returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call AddSpecialEffectLocBJ( udg_tempLoc, "Abilities\\Spells\\Human\\AerialShackles\\AerialShacklesTarget.mdl" )
call sAI_saveEffectParameter(GetLastCreatedEffectBJ(), "fx_chargeMissileFX", "Units_" + uIS, udg_UnitAI)
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 0.5, 0)
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 2, 2)
// can create a "vibrating" power up effect
call sAI_saveEffectParameter(bj_lastCreatedEffect, "effect", tIS, udg_tempHash)
call TimerStart(t, time, false, function s_g_chargeMissileFX_expires)
//PLUG LEAKS
set t = null
set u = null
set uIS = ""
set time = 0
endfunction
function fx_chargeMissile2_scale takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local real time = s_tDR(tIS, "time")
local real scale_start = s_tDR(tIS, "scale_start")
local real scale_end = s_tDR(tIS, "scale_end")
local effect e = s_tDE(tIS, "effect")
//MAIN PART
call sAI_scaleEffectOverTime(e, scale_start, scale_end, time)
call s_tDE_s(null, tIS, "effect")
call sAI_deleteDataTree(tIS, udg_tempHash) //so that the effect isn't destroyed because we're still using it
call DestroyTimer(t)
//PLUG LEAKS
set u = null
set uIS = ""
set t = null
set tIS = ""
set time = 0
set scale_start = 0
set scale_end = 0
set e = null
endfunction
function fx_chargeMissile2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local real time = s_tDR(tIS, "time")
local real chargeTime = s_tDR(tIS, "charge_time")
local effect e = s_tDE(tIS, "effect")
local location uL = s_tDL(tIS, "loc")
local location tL = null
local real a = 0
local location l = null
local real scale = s_tDR(tIS, "scale")
local timer t2 = CreateTimer()
local real scaling = s_tDR(tIS, "scaling")
local real scale_start = s_tDR(tIS, "scale_start")
local real scale_end = s_tDR(tIS, "scale_end")
local boolean initPassed = s_tDB(tIS, "init_passed")
local real height = s_tDR(tIS, "height")
local real inc = s_tDR(tIS, "inc")
local real dist = s_tDR(tIS, "dist")
local string eS = s_tDS(tIS, "effectType_string")
local real pulse_min = s_tDR(tIS, "pulse_min")
//MAIN PART
if uL == null then
set uL = GetUnitLoc(u)
call s_tDL_s(uL, tIS, "loc")
endif
set tL = GetRectCenter(gg_rct_Dragonbreath)
set a = AngleBetweenPoints(uL, tL)
set l = PolarProjectionBJ(uL, 200 + dist, a)
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set scaling = 1
set scale = 1
endif
if scale_start == 0 then
set scale_start = 8
set scale_end = 0.1
call s_tDR_s(scale_start, tIS, "scale_start")
call s_tDR_s(scale_end, tIS, "scale_end")
endif
if chargeTime <= 0 then
set chargeTime = 6
call s_tDR_s(chargeTime, tIS, "charge_time")
endif
if initPassed == false and time <= 0 then
set time = chargeTime
call s_tDR_s(time, tIS, "time")
endif
if e == null then
if eS == "" then
set eS = "Abilities\\Weapons\\WitchDoctorMissile\\WitchDoctorMissile.mdl"
endif
call AddSpecialEffectLocBJ( l, eS )
set e = GetLastCreatedEffectBJ()
call s_tDE_s(e, tIS, "effect")
call BlzSetSpecialEffectZ( e, 300 + height )
call BlzSetSpecialEffectColor( e, 0, 255, 0 )
call BlzSetSpecialEffectScale( e, scale_start )
endif
if initPassed == false and inc == 0 then
set inc = ((scale_end - scale_start) / chargeTime)
call s_tDR_s(inc, tIS, "inc")
set scale = scale_start
call s_tDR_s(scale, tIS, "scale")
endif
if initPassed == false then
call s_tDB_s(true, tIS, "init_passed")
endif
//==================================================================================
set scaling = time / chargeTime
set time = time - (1 * scaling)
call s_tDR_s(time, tIS, "time")
if time < 0.0625 or scaling < 0.0625 then
set time = 0
else
if pulse_min == 0 then
set pulse_min = 0.0125
endif
set scale = scale + (inc * scaling)
call s_tDR_s(scale, tIS, "scale")
//call DisplayTextToForce(GetPlayersAll(), "inc: " + R2S(inc))
//call DisplayTextToForce(GetPlayersAll(), "scale: " + R2S(scale))
call s_tDR_s(scaling, tIS, "scaling")
set tI = GetHandleId(t2)
set tIS = I2S(tI)
call s_tDR_s(scale - (inc * scaling), tIS, "scale_start")
call s_tDR_s(scale * pulse_min, tIS, "scale_end")
call s_tDR_s(0.5 * scaling, tIS, "time")
call s_tDE_s(e, tIS, "effect")
call TimerStart(t2, 0, false, function fx_chargeMissile2_scale)
set t2 = CreateTimer()
set tI = GetHandleId(t2)
set tIS = I2S(tI)
call s_tDR_s(scale * pulse_min, tIS, "scale_start")
call s_tDR_s(scale, tIS, "scale_end")
call s_tDR_s(0.5 * scaling, tIS, "time")
call s_tDE_s(e, tIS, "effect")
call TimerStart(t2, 0.5 * scaling, false, function fx_chargeMissile2_scale)
endif
if time <= 0 or (scale < scale_start or scale > scale_end) then
call s_destroyEffect_main(e, 0)
call DestroyTimer(t)
call RemoveLocation(uL)
else
set time = 1 * scaling
if time < udg_gameloop_fx then
set time = udg_gameloop_fx
endif
call TimerStart(t, 1 * scaling, false, function fx_chargeMissile2)
endif
//PLUG LEAKS
set u = null
set uIS = ""
set t = null
set tIS = ""
set time = 0
set e = null
call RemoveLocation(tL)
call RemoveLocation(l)
set uL = null
set tL = null
set a = 0
set l = null
set scale = 0
set t2 = null
set scaling = 0
set scale_start = 0
set scale_end = 0
set initPassed = false
set height = 0
set inc = 0
set dist = 0
set eS = ""
set pulse_min = 0
endfunction
function s_g_lightningHeadFX takes real time returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer()
local real randOffset = GetRandomReal(0, 60)
//MAIN PART
call sAI_saveIntegerParameter(12, "lightning_remainingCount", "Units_" + uIS, udg_UnitAI)
call sAI_saveBooleanParameter(false, "lightning_casting", "Units_" + uIS, udg_UnitAI)
call s_lightningXYZ_main()
//PLUG LEAKS
set t = null
set u = null
set uIS = ""
set time = 0
set randOffset = 0
endfunction
function g_roar takes nothing returns nothing
local unit u = udg_Gustivus
local location uL = GetUnitLoc(u)
local player p = Player(0)
//MAIN PART
call AddSpecialEffectLocBJ( uL, "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl" ) //"Abilities\\Spells\\NightElf\\BattleRoar\\RoarCasterTarget.mdl"
call s_destroyEffect_main(GetLastCreatedEffectBJ(), 4 )
call CameraSetEQNoiseForPlayer( p, 1.00 )
call TimerStart(CreateTimer(), 3, false, function fx_stopCamShake)
//PLUG LEAKS
set u = null
call RemoveLocation(uL)
set uL = null
set p = null
endfunction
function s_g_timeSphereFX takes nothing returns nothing
local real z = 0
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 6.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 100.00, 0 )
call s_g_setLightningOffset()
set z = GetLocationZ(udg_tempLoc)
call AddSpecialEffectLocBJ( udg_tempLoc, "Abilities\\Spells\\Human\\AerialShackles\\AerialShacklesTarget.mdl" )
call sAI_scaleEffectOverTime(bj_lastCreatedEffect, 1, 45, 3)
call sAI_saveEffectParameter(bj_lastCreatedEffect, "effect", tIS, udg_tempHash)
call TimerStart(t, 3, false, function s_destroyEffect)
//PLUG LEAKS
set z = 0
set t = null
set tIS = ""
endfunction
function g_sTentacle takes nothing returns nothing
local unit u = udg_Gustivus
local location l = s_uDL(u, "ability_sTentacle_loc")
local unit eU = s_uDU(u, "targetHero") // from activating the fight
local location uL1 = GetUnitLoc(eU)
local real ang = GetRandomDirectionDeg()
local real ang1 = s_uDR(u, "ability_sTentacle__ang")
local real dist = GetRandomReal(200, 800)
local string uIS = I2S(GetHandleId(u))
local timer t = CreateTimer() //unique id for cast ability
local string tIS = I2S(GetHandleId(t))
local integer casts = s_uDI(u, "ability_sTentacle_numCasts")
local location l2 = null
//MAIN PART
call sAI_saveBooleanParameter(true, "abilityBeingCast", "Units_" + uIS + "_ability_sTentacle", udg_UnitAI)
//save casts
call sAI_saveIntegerParameter(casts, "remainingCasts", tIS, udg_tempHash)
set l2 = GetUnitLoc(eU)
set l = PolarProjectionBJ(l2, dist, ang)
call CreateNUnitsAtLoc( 1, 'n01O', GetOwningPlayer(udg_Gustivus), l, GetRandomDirectionDeg() ) // SpideryTentacle
call sAI_saveIntegerParameter(s_uDI(u, "remainingCasts") - 1, "remainingCasts", tIS, udg_tempHash)
call DisplayTextToForce(GetPlayersAll(), "spawn tentacles")
// PLUG LEAKS
call RemoveLocation(uL1)
set u = null
set uL1 = null
call RemoveLocation(l)
set l = null
call RemoveLocation(l2)
set l2 = null
set dist = 0
set ang = 0
set ang1 = 0
set uIS = ""
set t = null
set tIS = ""
set casts = 0
endfunction
function g_sTentacle_main takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local integer i = 1
local integer i2 = 6
//MAIN PART
loop
exitwhen i > i2
call g_sTentacle()
set i = i + 1
endloop
//PLUG LEAKS
set u = null
set uIS = ""
set i = 0
set i2 = 0
endfunction
function s_g_darkness_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real time = s_tDR(tIS, "time")
//MAIN PART
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, time, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100, 100, 100, 10.00 )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function g_darkness_fadeout takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real time = s_tDR(tIS, "fadeout_time")
//MAIN PART
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, time, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100, 100, 100, 10.00 )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function g_darkness takes real time, real delay returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
//MAIN PART
//call AddSpecialEffectTargetUnitBJ( "origin", udg_Gustivus, "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl" )
//call s_destroyEffect_main(bj_lastCreatedEffect, 4)
call s_tDR_s(time * 0.4, tIS, "fadeout_time")
call TimerStart(t, delay, false, function g_darkness_fadeout)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(time * 0.4, tIS, "time")
call TimerStart(t, delay + (time * 0.6), false, function s_g_darkness_expires)
call TimerStart(CreateTimer(), 0, false, function g_darktides)
//PLUG LEAKS
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function s_g_light_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real time = s_tDR(tIS, "time")
//MAIN PART
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, time, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0.00 )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function g_light_fadeout takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real time = s_tDR(tIS, "fadeout_time")
//MAIN PART
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, time, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0.00 )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function g_light takes real time, real delay returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
//MAIN PART
call s_tDR_s(time * 0.4, tIS, "fadeout_time")
call TimerStart(t, delay, false, function g_light_fadeout)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(time * 0.4, tIS, "time")
call TimerStart(t, delay + (time * 0.6), false, function s_g_light_expires)
//PLUG LEAKS
set time = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function g_firebreath_check takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(125, uL)
local unit eU = null
local player p = GetOwningPlayer(u)
local player tP = null
local integer pI = GetConvertedPlayerId(p)
local integer tPI = 0
local location tUL = null
//MAIN PART
if IsUnitAliveBJ(u) == true then
set eU = FirstOfGroup(g)
loop
exitwhen eU == null or IsUnitAliveBJ(u) == false
set tP = GetOwningPlayer(eU)
if IsPlayerEnemy(p, tP) == true and (BlzIsUnitInvulnerable(eU) == false ) then
call UnitDamageTargetBJ( u, eU, 40, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
set tUL = GetUnitLoc(eU)
call AddSpecialEffectLocBJ( tUL, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call RemoveLocation(tUL)
call s_stun(eU, 3)
call KillUnit(u)
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call TimerStart(t, 0.125, false, function g_firebreath_check)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set t = null
set tIS = ""
set u = null
set p = null
set tP = null
set pI = 0
set tPI = 0
set tUL = null
endfunction
function s_g_fireBreath_expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
//MAIN PART
call KillUnit(u)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
set u = null
endfunction
//===============================================================================
//===============================================================================
function g_firebreath_missile takes nothing returns nothing
local unit u = udg_Gustivus
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local location l = s_tDL(tIS, "loc")
local real ang = s_tDR(tIS, "angle")
local real rA = GetRandomDirectionDeg()
//MAIN PART
call CreateNUnitsAtLoc( 1, 'h01P', GetOwningPlayer(udg_Gustivus), l, ang )
set l = PolarProjectionBJ(l, 1500, ang)
call IssuePointOrderLoc(GetLastCreatedUnit(), "move", l)
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call TimerStart(t, 5, false, function s_g_fireBreath_expire)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call TimerStart(t, 0, false, function g_firebreath_check)
//call DisplayTextToForce(GetPlayersAll(), "cast fb missile")
// PLUG LEAKS
set u = null
set t = null
set tI = 0
set tIS = ""
set l = null
set ang = 0
set rA = 0
endfunction
function s_g_fireBreath takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_Gustivus
local location uL = GetUnitLoc(u)
local real uF = GetUnitFacing(u)
local real ang = s_tDR(tIS, "angle")
local location l = PolarProjectionBJ(uL, 1500, ang)
local location l1 = PolarProjectionBJ(uL, 450, uF)
local real time = 0
local integer balls = s_uDI(u, "ability_firebreath_cast_missiles")
local real period = s_uDR(u, "ability_firebreath_cast_period")
local integer i = 1
//MAIN PART
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
//============================
call RemoveLocation(uL)
//call DisplayTextToForce(GetPlayersAll(), "balls " + I2S(balls))
call SetUnitAnimation( udg_Gustivus, "spell" )
call QueueUnitAnimationBJ( udg_Gustivus, "stand" )
loop
exitwhen i > balls
set uL = GetUnitLoc(u)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(ang, tIS, "angle")
call s_tDL_s(uL, tIS, "loc")
call TimerStart(t, time, false, function g_firebreath_missile)
set time = time + period
set i = i + 1
//call DisplayTextToForce(GetPlayersAll(), I2S(i))
endloop
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l1)
set uL = null
set l = null
set l1 = null
set t = null
set tI = 0
set tIS = ""
set uF = 0
set ang = 0
set time = 0
set balls = 0
set period = 0
set i = 0
endfunction
//===============================================================================
//===============================================================================
function sfx_fireball takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call PlaySoundOnUnitBJ( gg_snd_i_fireball1, 100, udg_Gustivus )
endfunction
//===============================================================================
//===============================================================================
function g_fireBreath_main takes nothing returns nothing
local unit u = udg_Gustivus
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local timer t = GetExpiredTimer()
local real time = 0
local real delay = s_uDR(u, "ability_firebreath_cast_delay")
local integer casts = s_uDI(u, "ability_firebreath_cast_count")
local integer i = 1
local location l = null
local unit tU = s_uDU(u, "targetHero")
local integer rCasts = s_uDI(u, "ability_firebreath_cast_count_remaining")
local location uL = GetUnitLoc(u)
local location tUL = GetUnitLoc(tU)
local location l2 = GetRectCenter(gg_rct_Dragonbreath)
local integer tI = 0
local string tIS = ""
local real rA = GetRandomReal(-45, 45)
local real a = AngleBetweenPoints(uL, l2)
local real castTime = 6
//MAIN PART
call DestroyTimer(t)
//because this function will loop itself, just plugging leaks
if rCasts > 0 then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(a + rA, tIS, "angle")
call TimerStart(t, castTime, false, function s_g_fireBreath)
endif
if rCasts > 0 then
set t = CreateTimer()
call s_uDI_s(rCasts - 1, uIS + "_ability_firebreath_cast_count", "remaining")
call TimerStart(CreateTimer(), castTime - 1, false, function sfx_fireball)
call TimerStart(t, delay, false, function g_fireBreath_main)
//ANIMATION
call PlaySoundBJ( gg_snd_mixkit_storm_coming_whoosh_2408 )
call g_roar()
call s_g_lightningHeadFX(5)
call fx_chargeMissile2()
call DisplayTextToForce(GetPlayersAll(), "fire breath")
else
call s_uDI_s(casts, uIS + "_ability_firebreath_cast_count", "remaining")
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set time = 0
set delay = 0
set casts = 0
set i = 0
call RemoveLocation(l)
set l = null
set tU = null
set rCasts = 0
set uL = null
set tUL = null
call RemoveLocation(l2)
set l2 = null
set tI = 0
set tIS = ""
set rA = 0
set a = 0
set castTime = 0
endfunction
function s_laserProjectileTarget takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local string uIS = I2S(GetHandleId(u))
local location l = s_tDL(tIS, "loc")
local location l2 = s_tDL(tIS, "targetLoc")
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real speedX = 0
local real speedY = 0
local real speedZ = 0
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local location uL = GetUnitLoc(u)
local real angXY = AngleBetweenPoints(uL, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(uL, l2)
local real speedXY = s_tDR(tIS, "speedXY")
local real centerDist = s_tDR(tIS, "centerDist")
local group g = null
local integer pID = s_uDI(u, "owner")
local unit eU = null
local real dmg = s_tDR(tIS, "damage")
local real radius = s_tDR(tIS, "radius")
local location nL = null
//MAIN PART
//math
set nL = PolarProjectionBJ( uL,speedXY * udg_gameloop_fx, angXY)
set z = GetUnitFlyHeight(u)
set z = z + ((distXY - centerDist) / (speedXY * udg_gameloop_fx)) // In theory this creates a clean arc?
call SetUnitPosition(u, GetLocationX(nL), GetLocationY(nL))
//projectile
call SetUnitFlyHeight(u, z, 0)
if z <= 100 and (distXY - centerDist) < 0 then
set g = GetUnitsInRangeOfLocAll(radius, uL)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
if ((BlzIsUnitInvulnerable(eU) == false ) and ( GetConvertedPlayerId(GetOwningPlayer(eU)) != pID )) then // won't hurt caster
call UnitDamageTargetBJ( u, eU, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call KillUnit(u)
call DestroyTimer(t)
call DestroyGroup(g)
call sAI_deleteDataTree(tIS, udg_tempHash)
//call DisplayTextToForce(GetPlayersAll(), "rock boom")
else
call s_tDR_s(speedX, tIS, "speedX")
call s_tDR_s(speedY, tIS, "speedY")
call s_tDR_s(speedZ, tIS, "speedZ")
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s(distXY, tIS, "distXY")
call TimerStart(t, udg_gameloop_fx, false, function s_laserProjectileTarget)
//call DisplayTextToForce(GetPlayersAll(), "laser update")
endif
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set speedX = 0
set speedY = 0
set speedZ = 0
set dX = 0
set dY = 0
set dZ = 0
call RemoveLocation(uL)
set uL = null
set eU = null
set angXY = 0
set angZ = 0
set distXY = 0
set speedXY = 0
set centerDist = 0
call DestroyGroup(g)
set g = null
set pID = 0
set dmg = 0
set radius = 0
call RemoveLocation(nL)
set nL = null
endfunction
function s_laserProjectile takes unit u, location l, location l2, real speedXY returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
local string uIS = ""
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local real angXY = AngleBetweenPoints(l, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(l, l2)
//MAIN PART
//math
//projectile
call CreateNUnitsAtLoc( 1, 'h025', GetOwningPlayer(u), l, GetRandomDirectionDeg() )
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call SetUnitFlyHeight( GetLastCreatedUnit(), z, 0)
call s_tDL_s(l, tIS, "loc")
call s_tDL_s(l2, tIS, "targetLoc")
call s_tDR_s(400, tIS, "damage")
call s_tDR_s(200, tIS, "radius")
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s((distXY / 2), tIS, "centerDist")
call TimerStart(t, udg_gameloop_fx, false, function s_laserProjectileTarget)
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set dX = 0
set dY = 0
set dZ = 0
set angXY = 0
set angZ = 0
set distXY = 0
endfunction
function g_laserToss takes nothing returns nothing
local unit u = udg_Gustivus
local location l = GetUnitLoc(udg_Gustivus)
local location l2 = null
local location l3 = GetRectCenter(gg_rct_Dragonbreath)
local location l4 = null
// //============================================================
//MAIN PART
set udg_tempReal = AngleBetweenPoints(l, l3)
set l4 = PolarProjectionBJ(l, 100, udg_tempReal)
// //============================================================
// //============================================================
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 12
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_tempReal = GetRandomReal(0, 750.00)
set udg_tempReal2 = GetRandomDirectionDeg()
set l2 = PolarProjectionBJ(l3, udg_tempReal, udg_tempReal2)
set udg_tempReal = GetRandomReal(200.00, 600.00)
call s_laserProjectile(u, l4, l2, udg_tempReal)
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
//PLUG LEAKS
call RemoveLocation(l3)
set l = null
set l2 = null
set l3 = null
set l4 = null
endfunction
function g_earthquake takes nothing returns nothing
local unit u = udg_Gustivus
local unit tU = s_uDU(u, "targetHero")
local location tUL = GetUnitLoc(tU)
//MAIN PART
call IssuePointOrderLocBJ( u, "earthquake", tUL )
call DisplayTextToForce(GetPlayersAll(), "earthquake")
//PLUG LEAKS
call RemoveLocation(tUL)
set tUL = null
set u = null
set tU = null
endfunction
function g_epiclaser_check takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local location uL = GetUnitLoc(u)
local group g = GetUnitsInRangeOfLocAll(250, uL)
local unit eU = null
local player p = GetOwningPlayer(u)
local player tP = null
local integer pI = GetConvertedPlayerId(p)
local integer tPI = 0
local location tUL = null
//MAIN PART
if IsUnitAliveBJ(u) == true then
set eU = FirstOfGroup(g)
loop
exitwhen eU == null or IsUnitAliveBJ(u) == false
set tP = GetOwningPlayer(eU)
if IsPlayerEnemy(p, tP) == true and (BlzIsUnitInvulnerable(eU) == false ) then
call UnitDamageTargetBJ( u, eU, 40, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
set tUL = GetUnitLoc(eU)
call AddSpecialEffectLocBJ( tUL, "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" ) //"Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl"
call s_destroyEffect_main(bj_lastCreatedEffect, 8)
call RemoveLocation(tUL)
call s_stun(eU, 3)
//call KillUnit(u)
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call TimerStart(t, 0.125, false, function g_epiclaser_check)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set t = null
set tIS = ""
set u = null
set p = null
set tP = null
set pI = 0
set tPI = 0
set tUL = null
endfunction
function g_epiclaser_expire takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
//MAIN PART
call KillUnit(u)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
set u = null
endfunction
//===============================================================================
//===============================================================================
function g_epiclaser_missile takes nothing returns nothing
local unit u = udg_Gustivus
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local location l = s_tDL(tIS, "loc")
local real ang = s_tDR(tIS, "angle")
local real rA = GetRandomDirectionDeg()
local real uF = GetUnitFacing(u)
local location uL = GetUnitLoc(u)
local location l2 = PolarProjectionBJ(uL, 300, ang)
local integer uTI = s_tDI(tIS, "unitTypeId") //h025
//MAIN PART
if uTI == 0 then
set uTI = 'h028'
endif
call CreateNUnitsAtLoc( 1, uTI, GetOwningPlayer(udg_Gustivus), l2, ang )
set l = PolarProjectionBJ(l, 1500, ang)
call IssuePointOrderLoc(GetLastCreatedUnit(), "move", l)
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call TimerStart(t, 5, false, function g_epiclaser_expire)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call TimerStart(t, 0, false, function g_epiclaser_check)
//call DisplayTextToForce(GetPlayersAll(), "cast fb missile")
// PLUG LEAKS
set u = null
set t = null
set tI = 0
set tIS = ""
set l = null
set ang = 0
set rA = 0
set uF = 0
call RemoveLocation(uL)
set uL = null
call RemoveLocation(l2)
set l2 = null
set uTI = 0
endfunction
function g_epiclaser_attack takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_Gustivus
local location uL = GetUnitLoc(u)
local real uF = GetUnitFacing(u)
local real ang = s_tDR(tIS, "angle")
local location l = PolarProjectionBJ(uL, 1500, ang)
local location l1 = PolarProjectionBJ(uL, 450, uF)
local real time = 0
local integer balls = s_uDI(u, "ability_epiclaser_cast_missiles")
local real period = s_uDR(u, "ability_epiclaser_cast_period")
local integer i = 1
//MAIN PART
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
//============================
call RemoveLocation(uL)
//call DisplayTextToForce(GetPlayersAll(), "balls " + I2S(balls))
loop
exitwhen i > balls
set uL = GetUnitLoc(u)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(ang, tIS, "angle")
call s_tDL_s(uL, tIS, "loc")
call TimerStart(t, time, false, function g_epiclaser_missile)
set time = time + period
set i = i + 1
//call DisplayTextToForce(GetPlayersAll(), I2S(i))
endloop
call SetUnitAnimation( udg_Gustivus, "spell" )
call QueueUnitAnimationBJ( udg_Gustivus, "stand" )
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l1)
set uL = null
set l = null
set l1 = null
set t = null
set tI = 0
set tIS = ""
set uF = 0
set ang = 0
set time = 0
set balls = 0
set period = 0
set i = 0
endfunction
//===============================================================================
//===============================================================================
function g_epiclaser takes nothing returns nothing
local unit u = udg_Gustivus
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local timer t = GetExpiredTimer()
local real time = 0
local real delay = s_uDR(u, "ability_epiclaser_cast_delay")
local integer casts = s_uDI(u, "ability_epiclaser_cast_count")
local integer i = 1
local location l = null
local unit tU = s_uDU(u, "targetHero")
local integer rCasts = s_uDI(u, "ability_epiclaser_cast_count_remaining")
local location uL = GetUnitLoc(u)
local location tUL = GetUnitLoc(tU)
local location l2 = GetRectCenter(gg_rct_Dragonbreath)
local integer tI = 0
local string tIS = ""
local real rA = 0
local real a = AngleBetweenPoints(uL, l2)
local real castTime = 4
local timer t2 = null
//MAIN PART
call DestroyTimer(t)
//because this function will loop itself, just plugging leaks
if rCasts > 0 then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(a, tIS, "angle")
call TimerStart(t, castTime, false, function g_epiclaser_attack)
endif
if rCasts > 0 then
set t = CreateTimer()
call s_uDI_s(rCasts - 1, uIS + "ability_epiclaser_cast_count", "remaining")
call TimerStart(t, delay, false, function g_epiclaser)
else
call s_uDI_s(casts, uIS + "ability_epiclaser_cast_count", "remaining")
endif
//ANIMATION
call g_darkness(4, 0)
call s_g_lightningHeadFX(5)
set t2 = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDR_s(12, tIS, "scale_start")
call s_tDR_s(0.1, tIS, "scale_end")
call TimerStart(t2, 0, false, function fx_chargeMissile2)
//call DisplayTextToForce(GetPlayersAll(), "epic laser")
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set time = 0
set delay = 0
set casts = 0
set i = 0
call RemoveLocation(l)
set l = null
set tU = null
set rCasts = 0
set uL = null
set tUL = null
call RemoveLocation(l2)
set l2 = null
set tI = 0
set tIS = ""
set rA = 0
set a = 0
set castTime = 0
set t2 = null
endfunction
function s_projectileMissile takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit") // gets the original caster
local integer uI = 0
local string uIS = ""
local location l = s_tDL(tIS, "loc")
local location l2 = s_tDL(tIS, "targetLoc")
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real speedX = 0
local real speedY = 0
local real speedZ = 0
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local location uL = GetUnitLoc(u)
local real angXY = AngleBetweenPoints(uL, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(uL, l2)
local real speedXY = s_tDR(tIS, "speedXY")
local real centerDist = s_tDR(tIS, "centerDist")
local group g = null
local integer pID = s_uDI(u, "owner")
local unit eU = null
local real dmg = s_tDR(tIS, "damage")
local real radius = s_tDR(tIS, "radius")
local location nL = null
local integer missileT = s_tDI(tIS, "unitTypeId")
//MAIN PART
//math
if missileT == 0 then
set missileT = 'h025'
endif
call CreateNUnitsAtLoc( 1, missileT, GetOwningPlayer(u), l, GetRandomDirectionDeg() )
call s_tDU_s(GetLastCreatedUnit(), tIS, "unit")
call SetUnitFlyHeight( GetLastCreatedUnit(), z, 0)
set u = GetLastCreatedUnit()
set uI = GetHandleId(u)
set uIS = I2S(uI)
set uL = GetUnitLoc(u)
set angXY = AngleBetweenPoints(l, l2)
set distXY = DistanceBetweenPoints(l, l2)
set nL = PolarProjectionBJ( l,speedXY * udg_gameloop_fx, angXY)
set z = GetUnitFlyHeight(u)
set z = z + ((distXY - centerDist) / (speedXY * udg_gameloop_fx)) // In theory this creates a clean arc?
call SetUnitPosition(u, GetLocationX(nL), GetLocationY(nL))
//projectile
call SetUnitFlyHeight(u, z, 0)
if z <= 100 and (distXY - centerDist) < 0 then
set g = GetUnitsInRangeOfLocAll(radius, uL)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
if ((BlzIsUnitInvulnerable(eU) == false ) and ( GetConvertedPlayerId(GetOwningPlayer(eU)) != pID )) then // won't hurt caster
call UnitDamageTargetBJ( u, eU, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call KillUnit(u)
call DestroyTimer(t)
call DestroyGroup(g)
call sAI_deleteDataTree(tIS, udg_tempHash)
//call DisplayTextToForce(GetPlayersAll(), "rock boom")
else
call s_tDR_s(speedX, tIS, "speedX")
call s_tDR_s(speedY, tIS, "speedY")
call s_tDR_s(speedZ, tIS, "speedZ")
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s(distXY, tIS, "distXY")
call TimerStart(t, udg_gameloop_fx, false, function s_laserProjectileTarget)
//call DisplayTextToForce(GetPlayersAll(), "laser update")
endif
if s_tDB(tIS, "theEnd") == true then
call KillUnit(udg_Kael)
call KillUnit(udg_Saira)
endif
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uI = 0
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set speedX = 0
set speedY = 0
set speedZ = 0
set dX = 0
set dY = 0
set dZ = 0
call RemoveLocation(uL)
set uL = null
set eU = null
set angXY = 0
set angZ = 0
set distXY = 0
set speedXY = 0
set centerDist = 0
call DestroyGroup(g)
set g = null
set pID = 0
set dmg = 0
set radius = 0
call RemoveLocation(nL)
set nL = null
set missileT = 0
endfunction
function s_projectile takes timer t returns nothing
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local location l = s_tDL(tIS, "loc")
local location l2 = s_tDL(tIS, "targetLoc")
local real speedXY = s_tDR(tIS, "speedXY")
local real delay = s_tDR(tIS, "delay")
//
local string uIS = ""
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local real z = GetLocationZ(l)
local real tX = GetLocationX(l2)
local real tY = GetLocationY(l2)
local real tZ = GetLocationZ(l2)
local real dX = tX - x
local real dY = tY - y
local real dZ = tZ - z
local real angXY = AngleBetweenPoints(l, l2)
local real angZ = 0
local real distXY = DistanceBetweenPoints(l, l2)
local integer uTI = s_tDI(tIS, "unitTypeId")
//MAIN PART
//math
//projectile
call s_tDL_s(l, tIS, "loc")
call s_tDL_s(l2, tIS, "targetLoc")
if s_tDR(tIS, "damage") == 0 then
call s_tDR_s(400, tIS, "damage")
endif
if s_tDR(tIS, "radius") == 0 then
call s_tDR_s(200, tIS, "radius")
endif
call s_tDR_s(speedXY, tIS, "speedXY")
call s_tDR_s((distXY / 2), tIS, "centerDist")
if uTI == 0 then
call s_tDI_s('h025', tIS, "unitTypeId")
endif
call TimerStart(t, delay, false, function s_projectileMissile)
//PLUG LEAKS
set l = null
set t = null
set l2 = null
set u = null
set uIS = ""
set tIS = ""
set x = 0
set y = 0
set z = 0
set tX = 0
set tY = 0
set tZ = 0
set dX = 0
set dY = 0
set dZ = 0
set angXY = 0
set angZ = 0
set distXY = 0
set uTI = 0
endfunction
function g_spiritbomb takes nothing returns nothing
local unit u = udg_Gustivus
local location l = GetUnitLoc(udg_Gustivus)
local location l2 = null
local location l3 = GetRectCenter(gg_rct_Dragonbreath)
local location l4 = null
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real chargeTime = 60
local real delay = 0
//MAIN PART
//CHARGE EFFECT
call s_tDR_s(0.1, tIS, "scale_start")
call s_tDR_s(6, tIS, "scale_end")
call s_tDR_s(chargeTime, tIS, "charge_time")
call s_tDR_s(-150, tIS, "dist")
call s_tDR_s(200, tIS, "height")
//call s_tDS_s("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", tIS, "effectType_string")
call s_tDR_s(1, tIS, "pulse_min")
call s_tDU_s(u, tIS, "unit")
call s_tDL_s(l, tIS, "loc")
call TimerStart(t, delay, false, function fx_chargeMissile2)
// //============================================================
// //============================================================
set udg_tempReal = AngleBetweenPoints(l, l3)
set l4 = PolarProjectionBJ(l, 100, udg_tempReal)
// //============================================================
// //============================================================
//SHOOT GIANT SPIRIT BOMB
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set udg_tempReal = 150
call s_tDU_s(u, tIS, "unit")
call s_tDL_s(l4, tIS, "loc")
call s_tDL_s(l3, tIS, "targetLoc")
call s_tDR_s(udg_tempReal, tIS, "speedXY")
call s_tDR_s(chargeTime - 1, tIS, "delay")
call s_tDR_s(8, tIS, "scale")
call s_tDI_s('h026', tIS, "unitTypeId")
call s_tDR_s(2000, tIS, "radius")
call s_tDR_s(5000, tIS, "damage")
call s_tDB_s(true, tIS, "theEnd")
call s_projectile(t)
//FINAL WORDS
call TimerStart(CreateTimer(), chargeTime - 1, false, function g_finalWords)
//FINAL LIGHT
call g_light(5, chargeTime + 10)
//PLUG LEAKS
set u = null
set t = null
set tI = 0
set tIS = ""
set l = null
set l2 = null
set l3 = null
set l4 = null
set chargeTime = 0
set delay = 0
endfunction
function sAI_GustivusAI_main takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
//local integer numAbils = s_uDI(u, "ability_metaList_numList") + s_uDI(u, "ability_numList") // update names, also maybe move meta data to Child param
local integer numAbils = 4
local integer i = GetRandomInt(1, numAbils)
local integer i2 = 1
local location l = GetRectCenter(gg_rct_Gustivus_Start)
local boolean casting = false
local real lifeP = GetUnitLifePercent(u)
//MAIN PART
//============================================
//testing
//============================================
//set i = 5
//============================================
call SetUnitPosition(u, GetLocationX(l), GetLocationY(l))
call SetUnitFacingToFaceLocTimed( udg_Gustivus, GetRectCenter(gg_rct_Dragonbreath), 1.00 )
if lifeP < 45 then
call s_uDI_s(6, uIS, "ability_firebreath_cast_count")
call s_uDI_s(9, uIS, "ability_laserball_cast_count")
elseif lifeP < 66 then
call s_uDI_s(4, uIS, "ability_firebreath_cast_count")
call s_uDI_s(6, uIS, "ability_laserball_cast_count")
elseif lifeP < 85 then
call s_uDI_s(2, uIS, "ability_firebreath_cast_count")
endif
if lifeP < 25 then
set i = 5
endif
if s_uDB(u, "currentlyCasting") == false then
if i == i2 then
call g_sTentacle_main()
call s_uDS_s("Spawn Spider Tentacles", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_SpawnTentacles, false, 30)
endif
set i2 = i2 + 1
if i == i2 then
call g_fireBreath_main()
call s_uDS_s("firebreath", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_Firebreath, false, 30)
endif
set i2 = i2 + 1
if i == i2 then
call g_epiclaser()
call s_uDS_s("epiclaser", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_EpicLaser, false, 20)
endif
set i2 = i2 + 1
if i == i2 then
call g_laserToss()
call s_uDS_s("laserballs", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_Laserballs, false, 20)
endif
set i2 = i2 + 1
if i == i2 then
call g_spiritbomb()
call s_uDS_s("spiritbomb", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_Spiritbomb, false, 70)
endif
set i2 = i2 + 1
if i == i2 then
call g_earthquake()
call s_uDS_s("earthquake", uIS, "casting")
call s_uDB_s(true, uIS, "currentlyCasting")
call StartTimerBJ(udg_Timer_Gustivus_Earthquake, false, 30)
endif
set i2 = i2 + 1
endif
//call DisplayTextToForce(GetPlayersAll(), "gustivus ai loop")
//PLUG LEAKS
set u = null
set uIS = ""
set numAbils = 0
set i = 0
call RemoveLocation(l)
set l = null
set casting = false
set lifeP = 0
endfunction
function sAI_GustivusAI_init takes nothing returns nothing
local unit u = udg_Gustivus
local string uIS = I2S(GetHandleId(u))
local location l = GetRectCenter(gg_rct_Dragonbreath)
local integer hI = GetTerrainCliffLevelBJ(l)
//MAIN PART
//ABILITIES
call s_uDS_s("", uIS, "ability") //start root preliminaries (or create function)
call s_uDR_s(300, uIS + "_ability_firestorm", "damage") // for next update
//SUMMON TENTACLES
call s_uDS_s("", uIS + "_ability", "spawn_tentacles")
call s_uDS_s("", uIS + "_ability_spawn_tentacles", "cast")
call s_uDR_s(1, uIS + "_ability_spawn_tentacles", "delay")
call s_uDR_s(0.125, uIS + "_ability_spawn_tentacles", "period")
//=============================
call s_uDI_s(6, uIS + "_ability_spawn_tentacles_cast", "count")
call s_uDI_s(6, uIS + "_ability_spawn_tentacles_cast_count", "remaining")
//=============================
call sAI_saveStringParameter("", "lightning", "Units_" + uIS, udg_UnitAI)
call s_uDI_s(6, uIS, "ability_lightning_cast_count")
//FIREBREATH
call s_uDS_s("", uIS + "_ability", "firebreath")
call s_uDS_s("", uIS + "_ability_firebreath", "cast")
//preliminaries done
call s_uDR_s(0.25, uIS + "_ability_firebreath_cast", "period")
call s_uDR_s(5, uIS + "_ability_firebreath_cast", "delay")
call s_uDI_s(12, uIS + "_ability_firebreath_cast", "missiles")
call s_uDI_s(1, uIS + "_ability_firebreath_cast", "count") // start as test
call s_uDI_s(1, uIS + "_ability_firebreath_cast_count", "remaining")
//EPICLASER
call s_uDS_s("", uIS + "_ability", "epiclaser")
call s_uDS_s("", uIS + "_ability_epiclaser", "cast")
//preliminaries done
call s_uDR_s(0.0625, uIS + "_ability_epiclaser_cast", "period")
call s_uDR_s(10, uIS + "_ability_epiclaser_cast", "delay")
call s_uDI_s(36, uIS + "_ability_epiclaser_cast", "missiles")
call s_uDI_s(1, uIS + "_ability_epiclaser_cast", "count")
call s_uDI_s(1, uIS + "_ability_epiclaser_cast_count", "remaining")
//LASER BALLS
call s_uDS_s("", uIS + "_ability", "laserballs")
call s_uDS_s("", uIS + "_ability_laserballs", "cast")
//preliminaries done
call s_uDR_s(0.5, uIS + "_ability_laserballs_cast", "period")
call s_uDR_s(10, uIS + "_ability_laserballs_cast", "delay")
call s_uDI_s(4, uIS + "_ability_laserballs_cast", "missiles")
call s_uDI_s(2, uIS + "_ability_laserballs_cast", "count")
call s_uDI_s(1, uIS + "_ability_laserballs_cast_count", "remaining")
//SPIRIT BOMB
call s_uDS_s("", uIS + "_ability", "spiritbomb")
call s_uDS_s("", uIS + "_ability_spiritbomb", "cast")
//preliminaries done
call s_uDR_s(0.5, uIS + "_ability_spiritbomb_cast", "period")
call s_uDR_s(10, uIS + "_ability_spiritbomb_cast", "delay")
call s_uDI_s(4, uIS + "_ability_spiritbomb_cast", "missiles")
call s_uDI_s(2, uIS + "_ability_spiritbomb_cast", "count")
call s_uDI_s(1, uIS + "_ability_spiritbomb_cast_count", "remaining")
//EARTHQUAKE
//shakes screen, random boulder tosses from earthquake zones
// or summons or meteors
call s_uDS_s("", uIS + "_ability", "earthquake")
call s_uDS_s("", uIS + "_ability_earthquake", "cast")
//preliminaries done
//call s_uDR_s(0.5, uIS + "_ability_earthquake_cast", "period")
//call s_uDR_s(3, uIS + "_ability_earthquake_cast", "delay")
//=================================================================
//=================================================================
//=================================================================
call IssueImmediateOrderBJ(u, "holdposition")
call EnableTrigger(gg_trg_Gustivus_AI_Loop)
//PLUG LEAKS
set u = null
set uIS = ""
endfunction
function s_projectileAbility takes string s returns nothing
//PLUG LEAKS
set s = ""
endfunction
function s_SpiderQueenCheckDest takes nothing returns nothing
local unit u = udg_SpiderQueen
local location uL = GetUnitLoc(u)
local real dist = DistanceBetweenPoints(udg_SpiderQueen_Dest, uL)
//MAIN PART
if ((dist <= 2.0) or (TimerGetRemaining(udg_SpiderQueen_Impatience) == 0)) then
call RemoveLocation(udg_SpiderQueen_Dest)
set udg_SpiderQueen_Dest = null
else
call IssuePointOrderLoc(udg_SpiderQueen, "move", udg_SpiderQueen_Dest)
endif
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set dist = 0
set u = null
endfunction
function s_sQ_rockFallEffect takes nothing returns nothing
local timer t = GetExpiredTimer()
local string s = I2S(GetHandleId(t)) + "_unit"
local unit u = LoadUnitHandleBJ(0, StringHashBJ(s), udg_tempHash)
local location uL = GetUnitLoc(u)
//MAIN PART
call CameraClearNoiseForPlayer( Player(0) )
call KillUnit(u)
//call DisplayTextToForce( GetPlayersAll(), "boop" )
call PlaySoundAtPointBJ( gg_snd_ThunderBoltMissileDeath, 100, uL, 0 )
call FlushChildHashtableBJ( StringHashBJ(s), udg_tempHash )
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
call DestroyTimer(t)
set s = ""
set t = null
set u = null
endfunction
function s_sQ_rockFall takes nothing returns nothing
local location l = null
local integer i = 1
local integer iC = udg_SpiderQueen_Rocks
local real speed = 200
local real height = 0
local real time = 0
local unit u = null
local timer t = null
local location uL = GetUnitLoc(udg_SpiderQueen)
//mew
local location l1 = GetRectCenter(gg_rct_sQ_move_to)
local location l2 = GetCameraTargetPositionLoc()
local real r = DistanceBetweenPoints(l1, l2)
//MAIN PART
if (r < 1500.00 ) then
call CameraSetEQNoiseForPlayer( Player(0), 2.00 )
endif
call PlaySoundAtPointBJ( gg_snd_ThunderClapCaster, 100, uL, 0 )
loop
exitwhen (i > iC)
set l = GetRandomLocInRect(gg_rct_rocks)
call CreateNUnitsAtLoc( 1, 'n01G', GetOwningPlayer(udg_SpiderQueen), l, GetRandomDirectionDeg() )
set u = GetLastCreatedUnit()
set height = BlzGetLocalUnitZ(u)
call SetUnitFlyHeightBJ( u, -50, speed )
if (speed != 0) then
set t = CreateTimer()
call sAI_saveUnitParameter(u, "unit", I2S(GetHandleId(t)), udg_tempHash)
set time = height / speed
set time = 2
call TimerStart(t, time, false, function s_sQ_rockFallEffect)
endif
call RemoveLocation(l)
set i = i + 1
endloop
call StartTimerBJ(udg_SpiderQueen_RockTimer, false, 20)
// PLUG LEAKS
call RemoveLocation(l)
set l = null
call RemoveLocation(uL)
set uL = null
call RemoveLocation(l1)
set l1 = null
call RemoveLocation(l2)
set l2 = null
set i = 0
set iC = 0
set r = 0
set speed = 0
set height = 0
set time = 0
set u = null
endfunction
function s_sQ_spawnSpiders takes nothing returns nothing
endfunction
function s_sQ_throwHammer takes nothing returns nothing
if (UnitHasItemOfTypeBJ(udg_SpiderQueen, 'I00P') == false) then // replace with throwable hammer
// "i'll get my hammer!"
else
endif
endfunction
function s_sQ_move takes nothing returns nothing
call IssuePointOrderLoc(udg_SpiderQueen, "move", udg_SpiderQueen_Dest)
endfunction
function s_sQ_move takes nothing returns nothing
call IssuePointOrderLoc(udg_SpiderQueen, "move", udg_SpiderQueen_Dest)
endfunction
function s_sQ_move takes nothing returns nothing
call IssuePointOrderLoc(udg_SpiderQueen, "move", udg_SpiderQueen_Dest)
endfunction
function s_sQ_return takes nothing returns nothing
local location l = null
local unit u = udg_SpiderQueen
//MAIN PART
if ( RectContainsUnit(gg_rct_spiderqueenreturn, udg_SpiderQueen) == true ) then
call SetUnitFacingToFaceLocTimed( udg_SpiderQueen, GetRectCenter(gg_rct_spiderqueenface), 0 )
else
call IssuePointOrderLocBJ( udg_SpiderQueen, "move", GetRectCenter(gg_rct_spiderqueenreturn) )
endif
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
endfunction
function s_sQ_emerge takes nothing returns nothing
local location l = null
local integer i = GetRandomInt(1,4)
local integer i2 = 1
local unit u = udg_SpiderQueen
//MAIN PART
if (i == i2) then
set l = GetRectCenter(gg_rct_sQ1)
endif
set i2 = i2 + 1
if (i == i2) then
set l = GetRectCenter(gg_rct_sQ2)
endif
set i2 = i2 + 1
if (i == i2) then
set l = GetRectCenter(gg_rct_sQ3)
endif
set i2 = i2 + 1
if (i == i2) then
set l = GetRectCenter(gg_rct_sQ4)
endif
set i2 = i2 + 1
call SetUnitPositionLoc( u, l )
call ShowUnitShow( u )
call SetUnitInvulnerable( udg_SpiderQueen, false )
call PauseUnitBJ( false, udg_SpiderQueen )
set udg_SpiderQueen_Hidden = false
//set udg_SpiderQueen_Spell = udg_str_move
call RemoveLocation(udg_SpiderQueen_Dest)
set udg_SpiderQueen_Dest = GetRandomLocInRect(gg_rct_sQ_move_to)
call s_sQ_return()
//PLUG LEAKS
set u = null
call RemoveLocation(l)
set l = null
set i = 0
set i2 = 0
endfunction
function s_sQ_hideEffect takes nothing returns nothing
local unit u = udg_SpiderQueen
//MAIN PART
call ShowUnitHide( u )
call SetUnitFlyHeightBJ( u, 0, 9000 )
call DestroyEffectBJ( udg_SpiderQueen_LaunchFX )
//PLUG LEAKS
call DestroyTimer(GetExpiredTimer())
set u = null
endfunction
function s_sQ_hide takes nothing returns nothing // launches directly up
local unit u = udg_SpiderQueen
local location uL = GetUnitLoc(u)
//MAIN PART
call AddSpecialEffectLocBJ( uL, "Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl" )
set udg_SpiderQueen_LaunchFX = GetLastCreatedEffectBJ()
call SetUnitFlyHeightBJ( u, 600, 600 )
call PlaySoundAtPointBJ( gg_snd_ThunderBoltMissileDeath, 100, uL, 0 )
call SetUnitInvulnerable( udg_SpiderQueen, true )
call PauseUnitBJ( true, udg_SpiderQueen )
set udg_SpiderQueen_Hidden = true
call EnableTrigger( gg_trg_SQ_Emerge_Timer )
call StartTimerBJ(udg_SpiderQueen_EmergeTimer, false, 10)
call TimerStart(CreateTimer(), 1, false, function s_sQ_hideEffect)
//PLUG LEAKS
call RemoveLocation(uL)
set uL = null
set u = null
endfunction
function s_isUnitEnemy takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_SpiderQueen)) == true )
endfunction
function s_spiderQueenUseSpell takes nothing returns nothing
local integer i = GetRandomInt(1,2)
local string s = udg_SpiderQueen_Spell
local group g = GetUnitsInRectMatching(gg_rct_Optic_Queen_Battlezone, Condition(function s_isUnitEnemy))
local unit u = GroupPickRandomUnit(g)
local location uL = GetUnitLoc(u)
//MAIN PART
if (s == udg_str_spawnSpiders) then
call s_sQ_spawnSpiders()
endif
if ((s == udg_str_rockFall)) then
call s_sQ_rockFall()
endif
if (s == udg_str_ensnare) then
call IssueTargetOrderBJ( udg_SpiderQueen, "ensnare", u )
endif
if (s == udg_str_retreat) then
if ((udg_SpiderQueen_Hidden == false) and (TimerGetRemaining(udg_SpiderQueen_EmergeTimer) <= 0) and (TimerGetRemaining(udg_SpiderQueen_RockTimer) <= 0)) then
call s_sQ_hide()
endif
endif
if (s == udg_str_attack) then
call IssueTargetOrderBJ( udg_SpiderQueen, "attack", u )
endif
if (s == udg_str_laser) then
call IssueTargetOrderBJ( udg_SpiderQueen, "shadowstrike", u )
endif
if (s == udg_str_throwHammer) then
call IssueTargetOrderBJ( udg_SpiderQueen, "thunderbolt", u )
endif
if (s == udg_str_move) then
call s_sQ_move()
endif
//PLUG LEAKS
call DestroyGroup(g)
set g = null
call RemoveLocation(uL)
set uL = null
set u = null
set s = ""
set i = 0
endfunction
function s_spiderQueenSelectSpell takes nothing returns nothing
local integer i = GetRandomInt(1,6)
local integer i2 = 1
//MAIN PART
//MAIN
if (udg_SpiderQueen_Spell == udg_str_retreat) then
//=============================
else
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_spawnSpiders
endif
set i2 = i2 + 1
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_ensnare
endif
set i2 = i2 + 1
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_retreat
endif
set i2 = i2 + 1
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_throwHammer
endif
set i2 = i2 + 1
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_laser
endif
set i2 = i2 + 1
if (i == i2) then
set udg_SpiderQueen_Spell = udg_str_attack
endif
set i2 = i2 + 1
endif
//CATCHES
if (udg_SpiderQueen_Hidden == true) and (TimerGetRemaining(udg_SpiderQueen_EmergeTimer) > 0 ) then
set udg_SpiderQueen_Spell = udg_str_rockFall
elseif (udg_SpiderQueen_Hidden == true) and (TimerGetRemaining(udg_SpiderQueen_EmergeTimer) <= 0 ) then
set udg_SpiderQueen_Spell = udg_str_retreat
endif
if ((udg_SpiderQueen_Hidden == false) and (udg_SpiderQueen_Enemies == false)) then
set udg_SpiderQueen_Spell = ""
call s_sQ_return()
endif
//PLUG LEAKS
set i = 0
set i2 = 0
endfunction
function s_spiderQueenAI takes nothing returns nothing
local unit u = udg_SpiderQueen
//MAIN PART
call s_spiderQueenSelectSpell()
call s_spiderQueenUseSpell()
//PLUG LEAKS
set u = null
endfunction
function s_rP_findIdleReplacement takes unit u, string dLS returns nothing
local string uIS = I2S(GetHandleId(u))
local location l = null
local group g = null
//
local unit eU = null
local string uTS = s_uDS(u, dLS + "_uTS") // to avoid confusion with index names, although the root dir will be uTS, it just saves it within index too
local integer pID = GetConvertedPlayerId(GetOwningPlayer(u))
local boolean rPFound = false
local group rPG = null
local group availableGroup = LoadGroupHandleBJ(0, StringHashBJ("Player_" + I2S(pID) + "_army_idle"), udg_PlayerAI[pID])
local integer availableUnits = LoadIntegerBJ(0, StringHashBJ("Player_" + I2S(pID) + "_army_idle_" + uTS + "_indexCount"), udg_PlayerAI[pID])
local group targetGroup = null // where the requested unit is going, the AI records the guard position as where the player orders it, "command level" orders
//MAIN PART
if (availableUnits > 0) then
set eU = FirstOfGroup(availableGroup)
loop
exitwhen (eU == null)
if (UnitId2StringBJ(GetUnitTypeId(eU)) == uTS) then
call s_rP_assignReplaceUnit(u, eU)
endif
set eU = FirstOfGroup(availableGroup)
endloop
else
endif
//PLUG LEAKS
call RemoveLocation(l)
set l = null
call DestroyGroup(g)
set g = null
set u = null
set uIS = ""
set uTS = ""
endfunction
function rP_recallGuard takes unit rP, unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer rPI = GetHandleId(rP)
local string rPIS = I2S(rPI)
local string oS = s_uDS(u, "issued_order")
local location l = s_uDL(u, "issued_order_loc")
local unit tU = s_uDU(u, "issued_order_unit")
local real dist = 0
local location l1 = GetUnitLoc(rP)
local location l2 = GetUnitLoc(u)
local real gDist = 1500
local location gL = s_uDL(rP, "rebuild_" + uIS + "_loc")
local boolean isHarvester = s_uDB(u, "harvester")
//MAIN PART
set dist = DistanceBetweenPoints(l1, l)
if gL != null and dist > gDist and isHarvester == false then
call IssuePointOrderLocBJ(u, "move", gL)
endif
//PLUG LEAKS
set uI = 0
set uIS = ""
set rPI = 0
set rPIS = ""
set oS = ""
set l = null
set tU = null
set dist = 0
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
set gDist = 0
set gL = null
set isHarvester = false
endfunction
function rP_setUnitOrder takes unit rP, integer i returns nothing
local integer rPI = GetHandleId(rP)
local string rPIS = I2S(rPI)
local real dist = 0
local location l1 = GetUnitLoc(rP)
local string iS = I2S(i)
local location gL = s_uDL(rP, "rebuild_" + iS + "_loc")
local unit u = s_uDU(rP, "rebuild_" + iS)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local location l2 = GetUnitLoc(u)
local location l = s_uDL(u, "issued_order_loc")
local player p = GetOwningPlayer(u)
local integer pI = GetConvertedPlayerId(p)
local boolean selected = IsUnitSelected(u, p) == true
local boolean byPlayer = s_uDB(u, "issued_order_byPlayer")
local string oS = s_uDS(u, "issued_order")
local unit tU = s_uDU(u, "harvest_target_unit")
local destructable tD = s_uDDE(u, "harvest_target_destructible")
local string hType = s_uDS(u, "harvest_target_type")
local boolean iH = s_uDB(u, "harvester")
//MAIN PART
if l != null then
set dist = DistanceBetweenPoints(l1, l)
if (gL == null or byPlayer == true) and dist <= 1500 then
set gL = l
call s_uDL_s(l, rPIS, "rebuild_" + iS + "_loc")
endif
endif
set dist = DistanceBetweenPoints(l1, l2)
if gL == null and dist <= 1500 then
set gL = l
call s_uDL_s(l2, rPIS, "rebuild_" + iS + "_loc")
else
call RemoveLocation(l2)
endif
if selected == false then
if iH == true and oS == "stop" then
if hType == "unit" then
call IssueTargetOrderBJ(u, "harvest", tU)
elseif hType == "destructible" then
call IssueTargetOrderBJ(u, "harvest", tD)
endif
endif
if iH == false and byPlayer == false and oS != "resumeharvesting" then
call IssuePointOrderLocBJ(u, "attack", gL)
endif
endif
//PLUG LEAKS
call RemoveLocation(l1)
set rPI = 0
set rPIS = ""
set dist = 0
set l1 = null
set l2 = null
set iS = ""
set gL = null
set u = null
set uI = 0
set uIS = ""
set p = null
set pI = 0
set selected = false
set oS = ""
set tU = null
set tD = null
set hType = ""
set iH = false
endfunction
function s_reportPost_addUnit takes unit rP, unit u returns nothing
local string rPIS = I2S(GetHandleId(rP))
local string uTS = UnitId2StringBJ(GetUnitTypeId(u))
local string uIS = I2S(GetHandleId(u))
local location l = GetUnitLoc(u)
local string iS = ""
local integer sI = 0
//MAIN PART
call s_uDB_s(true, uIS, "isInReportPostGroup")
call s_uDU_s(rP, uIS, "reportPost")
// save index, because uIS' would be replaced anyway
call sAI_addUnitParameter(u, "rebuild", "Units_" + rPIS, udg_UnitAI)
set udg_tempString = udg_lastPLS
call sAI_saveStringParameter(uTS, "unitType", udg_tempString, udg_UnitAI)
set sI = StringHash(udg_tempString + "_name")
set iS = LoadStringBJ(0, sI, udg_UnitAI)
set sI = S2I(iS)
call rP_setUnitOrder(rP, sI)
// or current order target loc if move etc
//call DisplayTextToForce( GetPlayersAll(), "adding to group of " + rPIS + "_rebuild_group" )
//PLUG LEAKS
set rP = null
set u = null
set rPIS = ""
set l = null
set uTS = ""
set uIS = ""
set iS = ""
set sI = 0
endfunction
function s_reportPost_addUnitGroup takes unit rP, group uG returns nothing
local string rPIS = I2S(GetHandleId(rP))
local group g = s_uDG(rP, "rebuild_group")
//
local group tG = CreateGroup()
local unit eU = null
//MAIN PART
if (g == null) then
set g = CreateGroup()
call s_uDG_s(g, rPIS, "rebuild_group")
endif
call GroupAddGroup(tG, uG)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
call s_reportPost_addUnit(rP, eU)
call GroupRemoveUnit(tG, eU)
set eU = FirstOfGroup(tG)
endloop
//PLUG LEAKS
call DestroyGroup(tG)
set tG = null
set rP = null
set uG = null
set rPIS = ""
set g = null
endfunction
function s_reportPost_addUnit takes unit rP, unit u returns nothing
local string rPIS = I2S(GetHandleId(rP))
local group g = s_uDG(rP, "rebuild_group")
local string uTS = UnitId2StringBJ(GetUnitTypeId(u))
local string uIS = I2S(GetHandleId(u))
//
local location l = GetUnitLoc(u)
//MAIN PART
if (g == null) then
set g = CreateGroup()
call s_uDG_s(g, rPIS, "rebuild_group")
endif
call GroupAddUnit(g, u)
call s_uDB_s(true, uIS, "isInReportPostGroup")
call s_uDU_s(rP, uIS, "reportPost")
call sAI_addUnitParameter(u, "reportPost_unit", rPIS, udg_UnitAI)
set udg_tempString = udg_lastPLS
call s_uDI_s(LoadIntegerBJ(0, StringHash("Units_" + rPIS + "_reportPost_unit_indexCount"), udg_UnitAI), uIS, "reportPostIndex")
call sAI_saveStringParameter(uTS, "unitType", udg_tempString, udg_UnitAI)
call sAI_saveLocationParameter(l, "guardPost", udg_tempString, udg_UnitAI) // or current order target loc if move etc
call DisplayTextToForce( GetPlayersAll(), "adding to group of " + rPIS + "_rebuild_group" )
//PLUG LEAKS
set rP = null
set u = null
set rPIS = ""
set g = null
set uTS = ""
set uIS = ""
endfunction
function s_reportPost_clearGroup takes unit rP returns nothing
local string rPIS = I2S(GetHandleId(rP))
local group g = s_uDG(rP, "rebuild_group")
local unit eU = FirstOfGroup(g)
local string eUIS = ""
//
local string iS = ""
local string lIS = ""
//MAIN PART
//call DisplayTextToForce( GetPlayersAll(), "clearing group of " + rPIS + "_rebuild_group" )
if g != null then
//call DisplayTextToForce( GetPlayersAll(), "group exists" )
else
//call DisplayTextToForce( GetPlayersAll(), "group doesn't exist" )
endif
loop
exitwhen eU == null
set eUIS = I2S(GetHandleId(eU))
call s_uDB_s(false, eUIS, "isInReportPostGroup")
call s_uDU_s(null, eUIS, "reportPost")
call UnitRemoveBuffBJ( 'Bspl', eU )
call s_uDI_s(0, eUIS, "reportPostIndex")
//call DisplayTextToForce( GetPlayersAll(), "cleared unit" )
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call sAI_deleteDataTree("Units_" + rPIS + "_reportPost_unit", udg_UnitAI) //Clearing all units, not rearranging for dead one which just gets replaced, not cleared yet
call GroupClear( g )
//PLUG LEAKS
set rP = null
set rPIS = ""
set g = null
set eU = null
set eUIS = ""
endfunction
function s_playerCanBuild takes integer pI, string tUTS returns boolean
local string pIS = I2S(pI)
local integer count = 0
//MAIN PART
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_indexCount") // check this
set count = LoadIntegerBJ( 0, udg_tempInt, udg_PlayerAI[pI])
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_metaList_indexCount")
set count = count + udg_tempInt
if count != 0 then
set udg_tempBoolean = true
//call DisplayTextToForce( GetPlayersAll(), "player can build " + tUTS )
else
set udg_tempBoolean = false
//call DisplayTextToForce( GetPlayersAll(), "player can NOT build " + tUTS )
endif
//PLUG LEAKS
set pI = 0
set pIS = ""
set tUTS = ""
set count = 0
//RETURNS
return udg_tempBoolean
endfunction
function s_trainingCount takes unit u, string tUTS returns integer
//MAIN PART
set udg_tempInt = s_uDI(u, "training_" + tUTS + "_count")
//PLUG LEAKS
set u = null
set tUTS = ""
//RETURNS
return udg_tempInt
endfunction
function s_unitTrained takes nothing returns nothing
local unit trainer = GetTriggerUnit()
local unit trained = GetTrainedUnit()
local integer pI = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string tRIS = I2S(GetHandleId(trainer))
local string tRIS2 = I2S(GetHandleId(trained))
local string tUTS = UnitId2StringBJ(GetUnitTypeId(trainer))
local string uTS = UnitId2StringBJ(GetUnitTypeId(trained))
local integer i = s_uDI(trainer, "training_" + uTS + "_count")
local integer sI = 0
local group g = null
//MAIN PART
call s_uDI_s(i - 1, tRIS, "training_" + uTS + "_count")
if s_uDI( trainer, "wants_" + uTS + "_count") > 0 then
call s_uDI_s(i - 1, tRIS, "wants_" + uTS + "_count")
endif
if s_uDB(trainer, "autosupply") == true then
call s_uDB_s(true, tRIS2, "autosupplyUnit")
endif
if s_uDG(trainer, "trainedUnits") == null then
call s_uDG_s(CreateGroup(), tRIS, "trainedUnits")
endif
call GroupAddUnit(s_uDG(trainer, "trainedUnits"), trained)
//==========================================
// Add to Player.
set sI = StringHash("Terms_" + uTS + "_group")
set g = LoadGroupHandleBJ(0, sI, udg_PlayerAI[pI])
if g == null then
set g = CreateGroup()
call sAI_saveStringParameter("", uTS, "Terms", udg_PlayerAI[pI])
endif
call GroupAddUnit(g, trained)
call sAI_saveGroupParameter(g, "group", "Terms_" + uTS, udg_PlayerAI[pI])
//=========================================
call sAI_saveBooleanParameter(true, tUTS, "Terms_" + uTS + "_built_by", udg_PlayerAI[pI])
call sAI_saveBooleanParameter(true, uTS, "Terms_" + tUTS + "_builds", udg_PlayerAI[pI])
//call DisplayTextToForce(GetPlayersAll(), "unitTrained: " + "Terms_" + uTS + "_built_by_" + tUTS)
//call sAI_addStringParameter(tUTS, "built_by", "Terms_" + uTS, udg_PlayerAI[pI])
//call sAI_addStringParameter(uTS, "builds", "Terms_" + tUTS, udg_PlayerAI[pI])
//PLUG LEAKS
set trainer = null
set trained = null
set pI = 0
set tRIS = ""
set tRIS2 = ""
set uTS = ""
set tUTS = ""
set i = 0
set sI = 0
set g = null
endfunction
function s_unitQueued takes nothing returns nothing
local unit trainer = GetTriggerUnit()
local integer pI = GetConvertedPlayerId(GetOwningPlayer(trainer))
local string tRIS = I2S(GetHandleId(trainer))
local integer tUTI = GetUnitTypeId(trainer)
local integer uTI = GetTrainedUnitType()
local string tUTS = UnitId2StringBJ(tUTI)
local string uTS = UnitId2StringBJ(uTI)
local integer i = s_uDI(trainer, "training_" + uTS + "_count")
local group g = null
//MAIN PART
call s_uDI_s(i + 1, tRIS, "training_" + uTS + "_count")
//==========================================
// Add to Player.
set i = StringHash("Terms_" + tUTS + "_group")
set g = LoadGroupHandleBJ(0, i, udg_PlayerAI[pI])
if g == null then
set g = CreateGroup()
call sAI_saveStringParameter("", tUTS, "Terms", udg_PlayerAI[pI])
endif
call GroupAddUnit(g, trainer)
//
call sAI_saveGroupParameter(g, "group", "Terms_" + tUTS, udg_PlayerAI[pI])
//==========================================
call sAI_saveBooleanParameter(true, tUTS, "Terms_" + uTS + "_built_by", udg_PlayerAI[pI])
call sAI_saveBooleanParameter(true, uTS, "Terms_" + tUTS + "_builds", udg_PlayerAI[pI])
//call DisplayTextToForce(GetPlayersAll(), "unitQueued: " + "Terms_" + uTS + "_built_by_" + tUTS)
//PLUG LEAKS
set trainer = null
set pI = 0
set tRIS = ""
set tUTI = 0
set uTI = 0
set tUTS = ""
set uTS = ""
set i = 0
set g = null
endfunction
function s_unitCancelled takes nothing returns nothing
local unit trainer = GetTriggerUnit()
local unit trained = GetTrainedUnit()
local string tRIS = I2S(GetHandleId(trainer))
local string tRIS2 = I2S(GetHandleId(trainer))
local string uTS = UnitId2StringBJ(GetUnitTypeId(trained))
local integer i = s_uDI(trainer, "training_" + uTS + "_count")
//MAIN PART
call s_uDI_s(i - 1, tRIS, "training_" + uTS + "_count")
//PLUG LEAKS
set trainer = null
set trained = null
set tRIS = ""
set tRIS2 = ""
set uTS = ""
set i = 0
endfunction
function s_unitCanBuild takes unit u, string uTS returns boolean
local integer pI = GetConvertedPlayerId(GetOwningPlayer(u))
local string pIS = I2S(pI)
local integer count = 0
local integer tUTI = GetUnitTypeId(u)
local string tUTS = UnitId2StringBJ(tUTI)
//MAIN PART
set udg_tempInt = StringHash("Terms_" + uTS + "_built_by_" + tUTS)
if LoadBooleanBJ(0, udg_tempInt, udg_PlayerAI[pI]) ==true then
set udg_tempBoolean = true
//call DisplayTextToForce(GetPlayersAll(), "unitcanbuild: " + "Terms_" + uTS + "_built_by_" + tUTS)
else
set udg_tempBoolean = false
//call DisplayTextToForce(GetPlayersAll(), "unitcanbuild: (NOT): " + "Terms_" + uTS + "_built_by_" + tUTS)
endif
//PLUG LEAKS
set u = null
set uTS = ""
set pI = 0
set pIS = ""
set count = 0
set tUTI = 0
set tUTS = ""
// RETURNS
return udg_tempBoolean
endfunction
function s_unitIssuedOrder takes nothing returns nothing
local unit u = GetOrderedUnit()
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local player p = GetOwningPlayer(u)
local integer pI = GetConvertedPlayerId(p)
local string pIS = I2S(pI)
local integer count = 0
local integer tUTI = GetUnitTypeId(u)
local string tUTS = UnitId2StringBJ(tUTI)
local location l = GetOrderPointLoc()
local unit tU = GetOrderTargetUnit()
local integer ord = GetIssuedOrderIdBJ()
local string ordS = OrderId2StringBJ(ord)
local destructable d = GetOrderTargetDestructable()
local boolean selected = IsUnitSelected(u, p) == true
//MAIN PART
if ordS == "harvest" then
call s_uDB_s(true, uIS, "harvester")
call s_uDB_s(true, uIS, "harvest_target_unit")
if d != null then
call s_uDS_s("destructible", uIS, "harvest_target_type")
call s_uDDE_s(d, uIS, "harvest_target_destructible")
endif
if tU != null then
call s_uDS_s("unit", uIS, "harvest_target_type")
call s_uDU_s(tU, uIS, "harvest_target_unit")
endif
elseif ordS != "resumeharvesting" then
//call DisplayTextToForce(GetPlayersAll(), ordS)
call s_uDB_s(false, uIS, "harvester")
call s_uDB_s(false, uIS, "harvest_target_unit")
call s_uDS_s("", uIS, "harvest_target_type")
call s_uDDE_s(null, uIS, "harvest_target_destructible")
call s_uDU_s(null, uIS, "harvest_target_unit")
endif
//=========================================
//It will constantly update harvest target as needed.
//If this bugs, can save other information.
//=========================================
call s_uDU_s(null, uIS, "issued_order_unit")
call s_uDDE_s(null, uIS, "issued_order_destructible")
call RemoveLocation(s_uDL(u, "issued_order_loc"))
if tU != null then
call s_uDS_s("unit", uIS, "issued_order_type")
call s_uDU_s(tU, uIS, "issued_order_unit")
elseif l != null then
call s_uDS_s("loc", uIS, "issued_order_type")
call s_uDL_s(l, uIS, "issued_order_loc")
elseif d != null then
call s_uDS_s("destructible", uIS, "issued_order_type")
call s_uDDE_s(d, uIS, "issued_order_destructible")
else
call s_uDS_s("immediate", uIS, "issued_order_type")
call s_uDL_s(GetUnitLoc(u), uIS, "issued_order_loc")
endif
if ordS != "returnresources" then
call s_uDS_s(ordS, uIS, "issued_order")
endif
if selected == true then
call s_uDB_s(true, uIS, "issued_order_byPlayer")
else
call s_uDB_s(false, uIS, "issued_order_byPlayer")
endif
//I don't think this will work for queued orders, though.
//PLUG LEAKS
set u = null
set pI = 0
set pIS = ""
set count = 0
set tUTI = 0
set tUTS = ""
set l = null
set tU = null
set ord = 0
set ordS = ""
set d = null
set p = null
set selected = false
// RETURNS
endfunction
function rP_cancelRequest takes unit rP, string uTS, integer i returns nothing
local integer rPI = GetHandleId(rP)
local string rPIS = I2S(rPI)
local unit trainer = s_uDU(rP, "trainer")
local integer tPI = GetHandleId(trainer)
local string tPIS = I2S(tPI)
//MAIN PART
if s_uDI(rP, "wants_" + uTS + "_count") > 0 then
call s_uDI_i(i * -1, rP, "count", "wants_" + uTS)
call s_uDI_i(i * -1, rP, "count", "requested_" + uTS) //if requests are less than wants, it adds more requests, this can happen if the trainer is killed
endif
if s_uDI(rP, "wants_" + uTS + "_count") > 0 then
call s_uDI_i(i * -1, trainer, "count", "wants_" + uTS)
//if using a cancel i'd need to test it to get specific resut
endif
//i believe it also, or instead needs to update "training", rather than "wants" on the trainer
//PLUG LEAKS
set rP = null
set uTS = ""
set rPI = 0
set rPIS = ""
set i = 0
set trainer = null
set tPI = 0
set tPIS = ""
endfunction
function s_qMem takes unit u, string s returns nothing
endfunction
function rP_detachGuard takes unit rP, unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer rPI = GetHandleId(rP)
local string rPIS = I2S(rPI)
local string oS = s_uDS(u, "issued_order")
local location l = s_uDL(u, "issued_order_loc")
local unit tU = s_uDU(u, "issued_order_unit")
local real dist = 0
local location l1 = GetUnitLoc(rP)
local location l2 = GetUnitLoc(u)
local real gDist = 1500
local location gL = s_uDL(rP, "rebuild_" + uIS + "_loc")
//
local boolean alive = IsUnitAliveBJ(u)
local integer uTI = GetUnitTypeId(u)
local string uTS = UnitId2String(uTI)
//MAIN PART
call s_uDB_s(false, uIS, "autosupplyUnit")
if s_uDI(rP, "wants_" + uTS + "_count") > 0 and alive == false then
call rP_cancelRequest(rP, uTS, 1)
endif
call sAI_deleteDataTree("Units_" + rPIS + "_rebuild_" + uIS, udg_UnitAI)
//PLUG LEAKS
set uI = 0
set uIS = ""
set rPI = 0
set rPIS = ""
set oS = ""
set l = null
set tU = null
set dist = 0
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
set gDist = 0
set gL = null
endfunction
function uA_governGuards takes nothing returns nothing
local unit u = udg_uAI_Unit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local real dist = 0
local unit eU = null
local location l1 = GetUnitLoc(u)
local location l2 = null
local real gDist = 1500
local location gL = s_uDL(u, "rebuild_" + uIS + "_loc")
local boolean alive = IsUnitAliveBJ(u)
local integer uTI = GetUnitTypeId(u)
local string uTS = UnitId2String(uTI)
local integer i = 1
local integer iC = 0
local string iS = ""
local string s = ""
local boolean iH = false
//MAIN PART
set iC = s_uDI(u, "rebuild_indexCount")
//call DisplayTextToForce(GetPlayersAll(), "govern")
loop
exitwhen i > iC
set iS = I2S(i)
set eU = s_uDU(u, "rebuild_" + iS)
set alive = IsUnitAliveBJ(eU)
//call DisplayTextToForce(GetPlayersAll(), "govern 1")
if eU != null and alive == true then
set l2 = GetUnitLoc(eU)
set dist = DistanceBetweenPoints(l1, l2)
//call DisplayTextToForce(GetPlayersAll(), "govern: eu == something")
call rP_setUnitOrder(u, i)
//call DisplayTextToForce(GetPlayersAll(), "set guard loc")
endif
set i = i + 1
endloop
// PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set dist = 0
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
set gDist = 0
set gL = null
set alive = false
set uTI = 0
set uTS = ""
set eU = null
set i = 0
set iC = 0
set iS = ""
set s = ""
set iH = false
endfunction
function s_cancel takes unit u returns nothing
// MAIN PART
call IssueImmediateOrderById( u, 851976 )
//PLUG LEAKS
set u = null
endfunction
function s_testTrain takes unit u, string uTS returns boolean
local integer count = s_trainingCount(u, uTS)
//MAIN PART
call IssueImmediateOrderBJ(u, uTS)
if s_unitCanBuild(u, uTS) == true then
call s_cancel(u)
//call DisplayTextToForce(GetPlayersAll(), "found new trainer")
set udg_tempBoolean = true
else
//call DisplayTextToForce(GetPlayersAll(), "you FAILED")
set udg_tempBoolean = false
endif
//PLUG LEAKS
set u = null
set uTS = ""
set count = 0
//RETURNS
return udg_tempBoolean
endfunction
function s_createRequestData takes unit u, unit trainer, string uTS, integer i returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer tRI = GetHandleId(trainer)
local string tRIS = I2S(tRI)
local integer count = 0
local string s = ""
//MAIN PART
call s_uDS_s("", uIS, "requested")
call s_uDS_s("", uIS + "_requested", uTS)
call s_uDS_s("", uIS + "_requested_" + uTS, "trainer")
set s = uIS + "_requested_" + uTS
set s = s + "_trainer"
call s_uDS_s("", s, tRIS)
set count = s_uDI(u, "requested_" + uTS + "_count")
call s_uDI_s(count + i, uIS + "_requested_" + uTS, "count")
set count = s_uDI(u, "requested_" + uTS + "_trainer_" + tRIS + "_count")
set s = "_requested_" + uTS
set s = s + "_trainer_" + tRIS
call s_uDI_s(count + i, uIS + s, "count")
// remember: requested vs wants
//=======================================
if s_uDG(trainer, "supplied_group") == null then
call s_uDG_s(CreateGroup(), tRIS, "supplied_group")
endif
call GroupAddUnit(s_uDG(trainer, "supplied_group"), u)
call s_uDS_s("", tRIS, "requests")
call s_uDS_s("", tRIS + "_requests", uIS)
call s_uDS_s("", tRIS + "_requests_" + uIS, uTS)
set count = s_uDI(u, "requests_" + uIS + "_" + uTS + "_count")
call s_uDI_s(count + i, "requests_" + uIS + "_" + uTS, "count")
//=============================================
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set trainer = null
set uTS = ""
set count = 0
set i = 0
endfunction
function s_cancelRQ takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit supplied = null
local integer sRI = 0
local string sRIS = ""
local integer count = 0
local integer num = 0
local group g = s_uDG(u, "supplied_group")
local unit eU = FirstOfGroup(g)
local integer sI = 0
local string iS = ""
local string s = ""
local string uTS = ""
local integer i = 1
local integer iC = 0
//MAIN PART
set supplied = FirstOfGroup(g)
loop
exitwhen supplied == null
set sRI = GetHandleId(supplied)
set sRIS = I2S(sRI)
set s = "requests_" + sRIS
set s = s + "_" + uTS + "_count"
set num = s_uDI(u, s )
set s = "Units_" + uIS + "_requests_"
set s = s + sRIS + "_metaList_indexCount"
set sI = StringHash(s)
set iC = LoadIntegerBJ(0, sI, udg_UnitAI)
loop
exitwhen i > iC
set iS = I2S(i)
set s = uIS + "_requests_" + sRIS + "_metaList_" + iS
set sI = StringHash(s)
set uTS = LoadStringBJ(0, sI, udg_UnitAI)
//TRAINER UPDATES AMOUNT REQUESTED TOTAL, AND REQUESTED FROM SUPPLIED
set s = "requests_" + uTS + "_count"
set count = s_uDI(u, s)
call s_uDI_s(count - num, uIS + "_requests_" + uTS, "count")
set s = "requests_" + sRIS + "_" + uTS
set s = s + "_count"
set count = s_uDI(u, s)
call s_uDI_s(count - num, uIS, s)
//SUPPLIED UPDATES AMOUNT REQUEST TOTAL, AND AMOUNT REQUESTED FROM TRAINER
set s = "requested_" + uTS
set s = s + "_" + uIS + "_count"
set count = s_uDI(supplied, s)
call s_uDI_s(count - num, sRIS, s)
set s = "requested_" + uTS
set s = s + "_count"
set count = s_uDI(supplied, s)
call s_uDI_s(count - num, sRIS, s)
set i = i + 1
endloop
call GroupRemoveUnit(g, supplied)
set supplied = FirstOfGroup(g)
set i = 1
endloop
//PLUG LEAKS
call DestroyGroup(g)
set num = 0
set g = null
set eU = null
set u = null
set uI = 0
set uIS = ""
set supplied = null
set sRI = 0
set sRIS = ""
set uTS = ""
set count = 0
set i = 0
set iC = 0
set sI = 0
set iS = ""
set s = ""
endfunction
function s_addWant takes unit u, string s, integer i returns nothing
local string uIS = I2S(GetHandleId(u))
//MAIN PART
call sAI_saveBooleanParameter(true, s, "Units_" + uIS + "_wants", udg_UnitAI)
call s_uDI_i(i, u, "count", "wants_" + s)
//PLUG LEAKS
set u = null
set uIS = ""
set s = ""
set i = 0
endfunction
function rP_addRequest takes unit u, string tUTS returns nothing
local string uIS = I2S(GetHandleId(u))
local integer num = s_uDI(u, "training_" + tUTS + "_count")
local integer num2 = num
local integer pI = GetConvertedPlayerId(GetOwningPlayer(u))
local integer wantNum = s_uDI(u, "wants_" + tUTS + "_count")
local boolean pCanBuild = s_playerCanBuild(pI, tUTS)
local group g = CreateGroup()
local unit eU = FirstOfGroup(g)
local integer ePI = 0
local boolean processFinished = false
local integer i = 1
local integer iC = 0
local boolean iMode = true
local string uTS = ""
local real dist = 0
local unit bestUnit = null
local integer mIC = 0
local group g2 = CreateGroup()
local string s = ""
local integer sI = 0
local string iS = ""
local boolean b = false
//MAIN PART
set udg_tempReal = 0
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_indexCount")
set iC = LoadIntegerBJ(0, udg_tempInt, udg_PlayerAI[pI])
loop
exitwhen processFinished == true
if iMode == true then
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_" + I2S(i))
set uTS = LoadStringBJ(0, udg_tempInt, udg_PlayerAI[pI])
else
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_metaList_" + I2S(i)) //Gives name, other gives number like it should.
set uTS = LoadStringBJ(0, udg_tempInt, udg_PlayerAI[pI])
endif
set udg_tempInt = StringHash("Terms_" + uTS + "_group") // simple as
call GroupAddGroup(LoadGroupHandleBJ(0, udg_tempInt, udg_PlayerAI[pI]), g) //Remember this adds group (param1) TO group
//call DisplayTextToForce(GetPlayersAll(), "supplier name " + uTS + ": searched")
if LoadGroupHandleBJ(0, udg_tempInt, udg_PlayerAI[pI]) != null then
//call DisplayTextToForce(GetPlayersAll(), uTS + ": group exists")
//call DisplayTextToForce(GetPlayersAll(), "group contains: " + UnitId2String(GetUnitTypeId(FirstOfGroup(g))))
endif
//========
set i = i + 1
//========
if iMode == true and i > iC then
set iMode = false
set i = 1
set udg_tempInt = StringHash("Terms_" + tUTS + "_built_by_metaList_indexCount")
set iC = LoadIntegerBJ(0, udg_tempInt, udg_PlayerAI[pI])
elseif iMode == false and i > iC then
set processFinished = true
endif
endloop
set processFinished = false
set i = 1
//================
call GroupAddGroup(g, g2)
set eU = FirstOfGroup(g2)
set udg_tempLoc = GetUnitLoc(u)
set dist = 0
set udg_tempReal = 0
//call DisplayTextToForce(GetPlayersAll(), "group 2 contains: " + UnitId2String(GetUnitTypeId(FirstOfGroup(g2))))
loop
exitwhen eU == null or processFinished == true
//just pick every unit, try to train
set udg_tempLoc2 = GetUnitLoc(eU)
set udg_tempReal = DistanceBetweenPoints(udg_tempLoc , udg_tempLoc2)
if (udg_tempReal < dist or dist == 0) and GetConvertedPlayerId(GetOwningPlayer(eU)) == pI and s_uDB(eU, "autosupply") == true then
//call DisplayTextToForce(GetPlayersAll(), "potential supplier found")
set dist = udg_tempReal
set bestUnit = eU
endif
call RemoveLocation(udg_tempLoc2)
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
call DestroyGroup(g2)
set g2 = CreateGroup()
//CREATE REQUEST
// account for unknown trainers (can it train and cancel to learn quick?)
if bestUnit == null then
//call DisplayTextToForce( GetPlayersAll(), "no information found" )
//call DisplayTextToForce( GetPlayersAll(), "find trainer" )
set dist = 0
set udg_tempReal = 0
call GroupAddGroup(GetUnitsInRectAll(GetEntireMapRect()), g2 )
set eU = FirstOfGroup(g2)
loop
exitwhen eU == null
set udg_tempLoc2 = GetUnitLoc(eU)
set udg_tempReal = DistanceBetweenPoints(udg_tempLoc , udg_tempLoc2)
set udg_tempBoolean = s_testTrain(eU, tUTS)
if (udg_tempReal < dist or dist == 0) and GetConvertedPlayerId(GetOwningPlayer(eU)) == pI and s_uDB(eU, "autosupply") == true and udg_tempBoolean == true then
set dist = udg_tempReal
set bestUnit = eU //find these while we're here
endif
call GroupRemoveUnit(g2, eU)
set eU = FirstOfGroup(g2)
endloop
endif
//maybe just adds to training data on RP
if bestUnit != null then
call IssueImmediateOrderBJ(bestUnit, tUTS)
//call DisplayTextToForce( GetPlayersAll(), "builder found" )
set s = "Units_" + uIS + "_isTrainer"
set sI = StringHash(s)
set b = LoadBooleanBJ(0, sI, udg_UnitAI)
if b == false then
call pF_trainer(bestUnit)
endif
call s_createRequestData(u, bestUnit, tUTS, 1)
call s_addWant(bestUnit, tUTS, 1)
//call s_addWant(u, tUTS, 1) //shewwd work
else
//call DisplayTextToForce( GetPlayersAll(), "no builder found" )
endif
//PLUG LEAKS
set u = null
set tUTS = ""
call DestroyGroup(g)
set g = null
set pCanBuild = false
set eU = null
set ePI = 0
set processFinished = false
set i = 0
set iC = 0
set iMode = true
set uTS = ""
set dist = 0
set bestUnit = null
set mIC = 0
call DestroyGroup(g2)
set g2 = null
set s = ""
set sI = 0
set iS = ""
set b = false
//RETURNS
endfunction
function rP_removeRequest takes unit u, string tUTS returns nothing
local string uIS = I2S(GetHandleId(u))
local integer num = s_uDI(u, "training_" + tUTS + "_count")
local integer num2 = num
local integer pI = GetConvertedPlayerId(GetOwningPlayer(u))
local integer wantNum = s_uDI(u, "wants_" + tUTS + "_count")
local boolean pCanBuild = s_playerCanBuild(pI, tUTS)
local group g = CreateGroup()
local unit eU = FirstOfGroup(g)
local integer ePI = 0
local boolean processFinished = false
local integer i = 1
local integer iC = 0
local boolean iMode = true
local string uTS = ""
local real dist = 0
local unit bestUnit = null
local integer mIC = 0
local group g2 = CreateGroup()
local string s = ""
local integer sI = 0
local string iS = ""
local boolean b = false
local string name = ""
local boolean found = false
//MAIN PART
set s = "Units_" + uIS + "_requested_"
set s = s + uTS + "_trainer_indexCount"
set sI = StringHash(s)
set iC = LoadIntegerBJ(0, sI, udg_UnitAI)
loop
exitwhen i > iC or found == true
set iS = I2S(i)
set s = "Units_" + uIS + "_requested_"
set s = s + uTS + "_trainer_metaList_" + iS
set sI = StringHash(s)
set name = LoadStringBJ(0, sI, udg_UnitAI)
set s = "Units_" + name + "_unit"
set sI = StringHash(s)
set bestUnit = LoadUnitHandleBJ(0, sI, udg_UnitAI) //make sure this is saved
//=======================
call s_createRequestData(u, bestUnit, tUTS, -1)
call s_addWant(bestUnit, tUTS, -1)
call s_addWant(u, tUTS, -1)
endloop
//PLUG LEAKS
set u = null
set tUTS = ""
call DestroyGroup(g)
set g = null
set pCanBuild = false
set eU = null
set ePI = 0
set processFinished = false
set i = 0
set iC = 0
set iMode = true
set uTS = ""
set dist = 0
set bestUnit = null
set mIC = 0
call DestroyGroup(g2)
set g2 = null
set s = ""
set sI = 0
set iS = ""
set b = false
set name = ""
set found = false
//RETURNS
endfunction
function rP_unitDies takes nothing returns nothing
local unit u = GetDyingUnit()
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit rP = s_uDU(u, "reportPost")
local integer uTI = GetUnitTypeId(u)
local string uTS = UnitId2String(uTI)
//MAIN PART
if s_uDB(u, "isInReportPostGroup") == true then
set udg_tempString = UnitId2String(GetUnitTypeId(u))
call s_addWant(rP, uTS, 1)
call rP_addRequest(rP, udg_tempString)
//call DisplayTextToForce( GetPlayersAll(), "added request for" + udg_tempString )
endif
if (IsUnitType(u, UNIT_TYPE_HERO) == false) then
//call sAI_baseRemoveUnit(p,b,u)
//i think technically delete data tree should cover this, if i add effect in there, which should be a good test
call s_cancelRQ(u)
call sAI_deleteDataTree(("Units_" + uIS), udg_UnitAI)
endif
call DestroyEffect(LoadEffectHandleBJ(0, StringHashBJ("Units_" + uIS + "_saved_specialEffect"), udg_UnitAI))
//PLUG LEAKS
set u = null
set rP = null
set uI = 0
set uIS = ""
endfunction
function uA_resupplyUnit takes nothing returns nothing
local unit u = udg_uAI_Unit
local string uIS = udg_uAI_uIS
local string pIS = I2S(GetConvertedPlayerId(GetOwningPlayer(u)))
local string baseIDS = I2S(s_uDI(u, "baseID"))
local group g = null
local group sortGroup = null
local unit eU = null
local integer i = 1
local integer iC = s_uDI(u, "rebuild_indexCount")
local boolean found = false
local unit trainer = null
local string tRIS = ""
local string uTS = ""
local string rStr = ""
local string iS = ""
local integer eUI = 0
local string eUTS = ""
local string s = ""
local boolean b = false
local location l = null
local unit rU = null
local string eUIS = ""
//MAIN PART
//call DisplayTextToForce(GetPlayersAll(), "gather")
loop
exitwhen i > iC
set iS = I2S(i)
set s = "rebuild_" + iS
set rU = s_uDU(u, s)
set s = "rebuild_" + iS + "_unitType" //just loops group and checks for dead (wants are created in death trigger)
set uTS = s_uDS(u, s) // remember to save unitType
set g = GetUnitsInRectAll(GetEntireMapRect())
set eU = FirstOfGroup(g)
if IsUnitAliveBJ(rU) == true then
set found = true
endif
//call DisplayTextToForce(GetPlayersAll(), "gather 1")
loop
exitwhen eU == null or found == true
//call DisplayTextToForce(GetPlayersAll(), "gather 2")
set eUI = GetUnitTypeId(eU)
set eUTS = UnitId2String(eUI)
set eUI = GetHandleId(eU)
set eUIS = I2S(eUI)
set b = s_uDB(eU, "autosupplyUnit") and s_uDU(eU, "reportPost") == null
if uTS == eUTS and b == true then
set l = s_uDL(u, "rebuild_" + iS + "_loc")
call s_uDU_s(eU, uIS, "rebuild_" + iS)
call s_uDU_s(u, eUIS, "reportPost")
call s_uDB_s(true, eUIS, "isInReportPostGroup")
if s_uDI(u, "wants_" + uTS + "_count") > 0 then
call s_uDI_i(-1, u, "count", "wants_" + uTS) //check which of these needs it (i think i save to unit types not indexes)
endif
call IssuePointOrderLocBJ(eU, "attack", l)
//call DisplayTextToForce(GetPlayersAll(), "unit moving to resupply")
set found = true
//=========
endif
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
set b = false
endloop
set found = false
call DestroyGroup(g)
set i = i + 1
endloop
//call DisplayTextToForce(GetPlayersAll(), "resupply order issued")
// PLUG LEAKS
set u = null
set uIS = ""
set pIS = ""
set baseIDS = ""
set sortGroup = null
call DestroyGroup(g)
set g = null
set eU = null
set i = 0
set iC = 0
set found = false
set trainer = null
set tRIS = ""
set uTS = ""
set rStr = ""
set iS = ""
set eUI = 0
set eUTS = ""
set s = ""
set b = false
set rU = null
set eUIS = ""
endfunction
function uA_performRequests takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
local integer i = 1
local integer iC = 0
local boolean iMode = true
local integer count = 0
local string s = ""
//MAIN PART
set iC = s_uDI(u, "wants_metaList_indexCount")
loop
exitwhen i > iC
set s = I2S(i)
set s = s_uDS(u, "wants_metaList_" + s)
set count = s_uDI(u, "training_" + s + "_count")
if count < s_uDI(u, "wants_" + s + "_count") then
call IssueImmediateOrderBJ(u, s)
endif
set i = i + 1
endloop
//PLUG LEAKS
set u = null
set uIS = ""
set i = 0
set iC = 0
set iMode = false
set count = 0
set s = ""
endfunction
function rP_checkForAddedUnits takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = s_tDU(tIS, "unit")
local location l = s_tDL(tIS, "loc")
local string uIS = I2S(GetHandleId(u))
local real time = s_tDR(tIS, "time") - 1
//=====================================================
local group cG = GetUnitsInRangeOfLocAll(1200, l)
local unit eU = FirstOfGroup(cG)
local string eUIS = ""
//MAIN PART
loop
exitwhen eU == null
set eUIS = I2S(GetHandleId(eU))
if (GetOwningPlayer(u) == GetOwningPlayer(eU)) and (IsUnitType(eU, UNIT_TYPE_STRUCTURE) == false) and (UnitHasBuffBJ(eU, 'Bspl') == true) and (s_uDB(eU, "isInReportPostGroup") != true) then
//call DisplayTextToForce( GetPlayersAll(), "added unit to report post! voila!" )
call s_reportPost_addUnit(u, eU)
endif
call GroupRemoveUnit(cG, eU)
set eU = FirstOfGroup(cG)
endloop
if time <= 0 then
call DestroyTimer(t)
else
call s_tDR_s(time, tIS, "time")
call TimerStart(t, 1, false, function rP_checkForAddedUnits)
endif
//PLUG LEAKS
set u = null
set uIS = ""
set tIS = ""
call RemoveLocation(l)
set l = null
set t = null
set time = 0
call DestroyGroup(cG)
set cG = null
set eU = null
set eUIS = ""
endfunction
function fireOgre_rockThrow takes nothing returns nothing
local unit u = udg_FireOgre
local location tL = null
local real x = 0
local real y = 0
local real z = 0
// throws and learns from impact
endfunction
function fireOgre_monitorAttacks takes nothing returns nothing
local unit u = udg_FireOgre
local string uIS = I2S(GetHandleId(u))
local unit mU = s_uDU(u, "attackProjectile")
local location mUL = GetUnitLoc(mU)
local real x = GetLocationX(mUL)
local real y = GetLocationY(mUL)
local real z = GetUnitFlyHeight(mU)
local real targetX = GetLocationX(s_uDL(u, "attackProjectile_targetLoc"))
local real targetY = GetLocationY(s_uDL(u, "attackProjectile_targetLoc"))
local real targetZ = GetLocationZ(s_uDL(u, "attackProjectile_targetLoc"))
local real diffV = 0
local real dist = 0
local real bestDist = 0
local real bestX = s_uDR(u, "attackProjectile_bestX")
local real bestY = s_uDR(u, "attackProjectile_bestY")
local real bestZ = s_uDR(u, "attackProjectile_bestZ")
local real aimX = s_uDR(u, "attackProjectile_aimX")
local real aimY = s_uDR(u, "attackProjectile_aimY")
local real aimZ = s_uDR(u, "attackProjectile_aimZ")
local real bestAimX = s_uDR(u, "attackProjectile_bestAimX")
local real bestAimY = s_uDR(u, "attackProjectile_bestAimY")
local real bestAimZ = s_uDR(u, "attackProjectile_bestAimZ")
//MAIN PART
set diffV = RAbsBJ(targetX - x)
if diffV < bestX then
set bestX = diffV
call s_uDR_s(bestX, uIS, "attackProjectile_bestX")
call s_uDR_s(aimX, uIS, "attackProjectile_bestAimX")
endif
set diffV = RAbsBJ(targetY - y)
if diffV < bestY then
set bestY = diffV
call s_uDR_s(bestY, uIS, "attackProjectile_bestY")
call s_uDR_s(aimY, uIS, "attackProjectile_bestAimY")
endif
set diffV = RAbsBJ(targetZ - z)
if diffV < bestZ then
set bestZ = diffV
call s_uDR_s(bestZ, uIS, "attackProjectile_bestZ")
call s_uDR_s(aimZ, uIS, "attackProjectile_bestAimZ")
endif
//PLUG LEAKS
set u = null
set uIS = ""
set mU = null
call RemoveLocation(mUL)
set mUL = null
set x = 0
set y = 0
set z = 0
set targetX = 0
set targetY = 0
set targetZ = 0
set diffV = 0
set dist = 0
set bestDist = 0
set bestX = 0
set bestY = 0
set bestZ = 0
set aimX = 0
set aimY = 0
set aimZ = 0
set bestAimX = 0
set bestAimY = 0
set bestAimZ = 0
endfunction
function e_earthWard takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
local group g = s_uDG(u, "ability_earthward_group")
local unit eU = FirstOfGroup(g)
local unit sU = udg_tempUnit
local location l = GetUnitLoc(u)
local location l2 = GetUnitLoc(sU)
//
local location eL = null
//MAIN PART
set udg_tempReal = AngleBetweenPoints(l, l2)
loop
exitwhen eU == null
call KillUnit(eU)
call GroupRemoveUnit(g, eU)
set eL = GetUnitLoc(eU)
call AddSpecialEffectLocBJ( eL, "Objects\\Spawnmodels\\Human\\FragmentationShards\\FragBoomSpawn.mdl" )
call RemoveLocation(eL)
call RemoveUnit(eU)
set eU = FirstOfGroup(g)
endloop
call DestroyGroup(g)
set g = CreateGroup()
call s_uDG_s(g, uIS, "ability_earthward_group")
call GroupAddUnit(g, sU)
set eL = GetUnitLoc(sU)
call AddSpecialEffectLocBJ( eL, "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 10)
call RemoveLocation(eL)
call CreateNUnitsAtLoc( 1, 'h024', GetOwningPlayer(u), PolarProjectionBJ(GetUnitLoc(GetSummonedUnit()), 256.00, ( udg_tempReal + 90.00 )), GetRandomDirectionDeg() )
call GroupAddUnit(g, bj_lastCreatedUnit)
set eL = GetUnitLoc(bj_lastCreatedUnit)
call AddSpecialEffectLocBJ( eL, "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 10)
call RemoveLocation(eL)
call CreateNUnitsAtLoc( 1, 'h024', GetOwningPlayer(u), PolarProjectionBJ(GetUnitLoc(GetSummonedUnit()), 256.00, ( udg_tempReal - 90.00 )), GetRandomDirectionDeg() )
call GroupAddUnit(g, bj_lastCreatedUnit)
set eL = GetUnitLoc(bj_lastCreatedUnit)
call AddSpecialEffectLocBJ( eL, "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 10)
call RemoveLocation(eL)
//PLUG LEAKS
set u = null
set uIS = ""
set eU = null
set g = null
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
set sU = null
endfunction
function e_death takes unit u returns nothing
local string uIS = I2S(GetHandleId(u))
local group g = s_uDG(u, "ability_earthward_group")
local unit eU = FirstOfGroup(g)
//MAIN PART
loop
exitwhen eU == null
call KillUnit(eU)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
call DestroyGroup(g)
call sAI_deleteDataTree(uIS, udg_UnitAI)
//PLUG LEAKS
set u = null
set uIS = ""
set eU = null
call DestroyGroup(g)
set g = null
endfunction
//group handles may be a convenient ai "empty"
function l_groupUpdate takes integer gI returns nothing
local string pathS = ""
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string gIS = I2S(gI)
local group g = s_uDG(u, "army_" + gIS + "_group")
local integer i = 1
local integer iC = 0
local integer pIC = 0
local group sortGroup = CreateGroup()
local unit eU = null
local real dist = 0
local integer cI = 0
local location eUL = null
local location tP = null
local string iS = ""
local integer eUI = 0
local string eUIS = ""
local boolean go = false
local integer count = s_uDI(u, "army_" + gIS + "_count") //how many reached target zone
local integer gSize = CountUnitsInGroup(g)
local integer tI = R2I(gSize * 0.8)
local timer wT = s_uDT(u, "army_" + gIS + "_timer")
//local string test = ""
//MAIN PART
//everything is actually saved to lilith's uIS
set pathS = "army_" + gIS + "_loc"
set pIC = s_uDI(u, pathS + "_indexCount")
call GroupAddGroup(g, sortGroup)
set eU = FirstOfGroup(sortGroup)
//call DisplayTextToForce(GetPlayersAll(), "pIC: " + I2S(pIC))
//call DisplayTextToForce(GetPlayersAll(), "gSize: " + I2S(gSize))
set count = 0
set cI = s_uDI(u, pathS + "_currentIndex")
loop
exitwhen eU == null
set eUL = GetUnitLoc(eU)
set eUI = GetHandleId(eU)
set eUIS = I2S(eUI)
set iS = I2S(cI)
set tP = s_uDL(u, pathS + "_" + iS)
set dist = DistanceBetweenPoints(eUL, tP)
//call DisplayTextToForce(GetPlayersAll(), "str loc cI 2: " + pathS + "_currentIndex")
//call DisplayTextToForce(GetPlayersAll(), "cI: " + I2S(cI))
//call DisplayTextToForce(GetPlayersAll(), "eu dist: " + R2S(dist))
//set test = s_uDS(u, pathS + "_test")
//call DisplayTextToForce(GetPlayersAll(), "test: " + test)
call IssuePointOrderLoc(eU, "attack", tP)
if dist < 1100 then
set count = count + 1
elseif TimerGetRemaining(wT) == 0 and wT != null then
call KillUnit(u)
endif
// if the right num enter area it starts timing, if other units don't make it in time they die and group moves on
set i = 1
call GroupRemoveUnit(sortGroup, eU)
set eU = FirstOfGroup(sortGroup)
endloop
call s_uDI_s(count, uIS + "_army_" + gIS, "count")
if count >= tI and wT == null then
call StartTimerBJ(CreateTimer(), false, 15)
call s_uDT_s(bj_lastStartedTimer, uIS + "_army_" + gIS, "timer")
endif
if count >= gSize or (TimerGetRemaining(wT) == 0 and wT != null) then
call s_uDI_s(cI + 1, uIS + "_" + pathS, "currentIndex")
call DestroyTimer(wT)
endif
//PLUG LEAKS
set pathS = ""
set u = null
set uI = 0
set uIS = ""
set gIS = ""
set g = null
set i = 0
set iC = 0
set pIC = 0
set sortGroup = null
set eU = null
set dist = 0
set cI = 0
set eUL = null
set tP = null
set iS = ""
set eUI = 0
set eUIS = ""
set go = false
set count = 0
set gSize = 0
set tI = 0
set wT = null
endfunction
function l_moveArmies takes nothing returns nothing
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local group g = null
local integer i = 1
local integer iC = 0
local string iS = ""
//MAIN PART
set iC = s_uDI(u, "army_indexCount")
loop
exitwhen i > iC
call l_groupUpdate(i)
set i = i + 1
endloop
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set g = null
set i = 0
set iC = 0
set iS = ""
endfunction
function l_addPath takes group g returns nothing
local location l = null
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string str = ""
//MAIN PART
//preamble
call sAI_addStringParameter("", "army", "Units_" + uIS, udg_UnitAI)
set str = udg_lastPLS
call sAI_saveGroupParameter(g, "group", str, udg_UnitAI)
//=======================
set l = GetRectCenter(gg_rct_LilithArmy01)
call sAI_addLocationParameter(l, "loc", str, udg_UnitAI)
set l = GetRectCenter(gg_rct_LilithArmy02)
call sAI_addLocationParameter(l, "loc", str, udg_UnitAI)
set l = GetRectCenter(gg_rct_LilithArmy03)
call sAI_addLocationParameter(l, "loc", str, udg_UnitAI)
set l = GetRectCenter(gg_rct_LilithArmy04)
call sAI_addLocationParameter(l, "loc", str, udg_UnitAI)
set l = GetRectCenter(gg_rct_LilithArmy05)
call sAI_addLocationParameter(l, "loc", str, udg_UnitAI)
call sAI_saveIntegerParameter(1, "currentIndex", str + "_loc", udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "str loc cI: " + udg_lastPLS)
call s_uDI_s(0, str, "count")
call sAI_saveIntegerParameter(0, "count", str, udg_UnitAI)
// call s_uDS_s("poop", str + "_loc", "test")
//PLUG LEAKS
set g = null
set l = null
set u = null
set uI = 0
set uIS = ""
set str = ""
endfunction
function l_aiLoop takes nothing returns nothing
call l_moveArmies()
endfunction
function l_initAI takes nothing returns nothing
endfunction
function minion_guardUnit takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string oDLS = s_tDS(tIS, "orderDLS")
local unit targetUnit = null
local real a = 0
local real d = 0
local location l = null
//MAIN PART
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set u = udg_uAI_Unit
set uI = GetHandleId(u)
set uIS = I2S(uI)
set oDLS = udg_uAI_oDLS
endif
//===============================
//SET VARIABLES
//===============================
set targetUnit = LoadUnitHandleBJ(0, StringHash(oDLS + "_attach_host"), udg_UnitAI)
set a = LoadRealBJ(0, StringHash(oDLS + "_attach_angle"), udg_UnitAI)
set d = LoadRealBJ(0, StringHash(oDLS + "_attach_dist"), udg_UnitAI)
set l = GetUnitLoc(targetUnit)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set oDLS = ""
set targetUnit = null
set a = 0
set d = 0
set l = null
endfunction
function pf_guardUnit takes unit u, unit host, real dist, real angle returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set host = null
set dist = 0
set angle = 0
endfunction
function s_timedTextTag takes unit u, string s, real duration returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call s_tDTT_s(tT. tIS, "texttag")
call TimerStart(t, duration, false, function s_expireTextTag)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function s_expireTextTag takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local texttag tT = s_tDTT(tIS, "texttag")
//MAIN PART
call DestroyTextTagBJ( tT )
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set tT = null
endfunction
function s_timedTextTag takes unit u, string s, real duration returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call CreateTextTagUnitBJ( s, u, 100, 10, 100, 100, 100, 0 )
call s_tDTT_s(GetLastCreatedTextTag(), tIS, "texttag")
call TimerStart(t, duration, false, function s_expireTextTag)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function uo_mineRockAndStone takes nothing returns nothing
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit tU = null //find something to mine, that isn't being mined
local group g = null
local unit eU = null
local location l = null
local integer uTI = 0
local location uL = GetUnitLoc(u)
local boolean findRock = false
local real rA = GetRandomDirectionDeg()
//MAIN PART
set g = GetUnitsInRangeOfLocAll(512, uL)
set eU = FirstOfGroup(g)
if eU == null then
set findRock = true
endif
loop
exitwhen eU == null
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
if findRock == true then
set l = PolarProjectionBJ(uL, 100, rA)
call IssuePointOrderLocBJ(u, "attack", l)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set tU = null
set g = null
set eU = null
set l = null
set uTI = 0
call RemoveLocation(uL)
set uL = null
set findRock = false
set rA = 0
endfunction
function uo_mineRockAndStone takes nothing returns nothing
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit tU = null //find something to mine, that isn't being mined
local group g = null
local unit eU = null
local location l = null
local integer uTI = 0
local location uL = GetUnitLoc(u)
local boolean findRock = false
local real rA = GetRandomDirectionDeg()
//MAIN PART
set g = GetUnitsInRangeOfLocAll(512, uL)
set eU = FirstOfGroup(g)
if eU == null then
set findRock = true
endif
loop
exitwhen eU == null
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
if findRock == true then
set l = PolarProjectionBJ(uL, 100, rA)
call IssuePointOrderLocBJ(u, "attack", l)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set tU = null
set g = null
set eU = null
set l = null
set uTI = 0
call RemoveLocation(uL)
set uL = null
set findRock = false
set rA = 0
endfunction
function uO_rockAndStoneTalk takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
//
local string str = ""
local integer i = 1
local integer iC = 0
local string iS = ""
//MAIN PART
set iC = LoadIntegerBJ(0, StringHash("Units_" + uIS + "_conversation_indexCount"), udg_UnitAI)
set i = GetRandomInt(1, iC)
set iS = I2S(i)
set str = LoadStringBJ(0, StringHash("Units_" + uIS + "_conversation_" + iS), udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set abStr = ""
endfunction
function pf_cd_dwarfRockAndStone takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string str = ""
local string str2 = "conversation"
local string str3 = "Units_" + uIS
//MAIN PART
call sAI_addStringParameter("Rock and stone!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("We're rich!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("I love mining!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Ew what's that?!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("I just stepped in something!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Yuck, is that your face?!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Don't step on that!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Ye fellas know any gud tunes?", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Me boots have so many holes they're wearing my feet!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("(sings)", str2, str3, udg_UnitAI)
call sAI_addStringParameter("I cud use a pint!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("How many beers do you need to get sober?", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Did something move?", str2, str3, udg_UnitAI)
call sAI_addStringParameter("What was that?", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Damn deep Dwarves, I bet they're watching.", str2, str3, udg_UnitAI)
call sAI_addStringParameter("I forged your mother, rock!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Is that an itch? Let me scratch it!", str2, str3, udg_UnitAI)
call sAI_addStringParameter("(farts)", str2, str3, udg_UnitAI)
call sAI_addStringParameter("(farts loudly)", str2, str3, udg_UnitAI)
call sAI_addStringParameter("(squeaks a fart)", str2, str3, udg_UnitAI)
call sAI_addStringParameter("Who remembered to bring a mule?", str2, str3, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set str = ""
set str2 = ""
set str3 = ""
endfunction
function pf_rSDwarf takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local location l = null
local string s = ""
local trigger t = null
local boolean terminated = false
//MAIN PART
//MINE ROCK AND STONE
call s_addOrder(u, "Mine Rock and Stone", t, l, terminated)
//CONVERSATION
call s_addOrder(u, "Talk", t, l, terminated) // basically they just walk back toward each other
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function uo_useAb takes nothing returns nothing
local unit u = udg_uAI_Unit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = LoadUnitHandleBJ(0, StringHash(abStr + "_targetUnit"), udg_UnitAI)
local boolean cliffLocked = LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = LoadIntegerBJ(0, StringHash(abStr + "_targetCliffLevel"), udg_UnitAI)
local integer cI = 0
local boolean found = false
//MAIN PART
loop
exitwhen i > 8 or found == true
set a = 45 * r
set l2 = PolarProjectionBJ(l, dist, a)
set cI = GetTerrainCliffLevelBJ(l2)
if tCI == cI then
set found = true
endif
set i = i + 1
endloop
if found == true then
call IssuePointOrderLocBJ(tU, "move", l2)
endif
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function uo_45Move takes nothing returns nothing
local unit u = udg_uAI_Unit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_uAI_oDLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = 400
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = u
local boolean cliffLocked = true //LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = GetTerrainCliffLevelBJ(l)
local integer cI = 0
local boolean found = false
//MAIN PART
loop
exitwhen i > 8 or found == true
set a = 45 + (90 * r)
set l2 = PolarProjectionBJ(l, dist, a)
set cI = GetTerrainCliffLevelBJ(l2)
if tCI == cI then
set found = true
endif
set i = i + 1
endloop
if found == true then
call IssuePointOrderLocBJ(tU, "move", l2)
endif
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function init_fxStrings takes nothing returns nothing
set udg_fxs_dispel = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl"
endfunction
function ab_line takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local integer num = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
local real aOf = 0
local integer uT = LoadIntegerBJ(0, StringHash(abStr + "_unitType"), udg_UnitAI) // make arcane arrow (and use yaw etc)
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI) // Set this in the host trigger
local integer i = 1
local real time = LoadRealBJ(0, StringHash(abStr + "_time"), udg_UnitAI)
local real period = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
//MAIN PART
call DestroyTimer(t)
loop
exitwhen i > num
call DisplayTextToForce(GetPlayersAll(), "a: " + R2S(a))
set l2 = PolarProjectionBJ(l, dist, a)
call CreateNUnitsAtLoc(1, uT, p, l2, 0)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call s_tDU_s(u, tIS, "host")
call s_tDS_s(abStr, tIS, "abilityDLS")
call s_tDR_s(a, tIS, "angle") // in theory can also use "rotation" for interesting bullet bends (like Vampire Survivors bird)
call TimerStart(t, time, false, function ab_lineP)
set i = i + 1
set time = time + period
endloop
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set num = 0
set aOf = 0
set uT = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set time = 0
set period = 0
endfunction
function ab_target takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local string abStr = s_tDS(tIS, "abilityDLS") //udg_AB_DLS
local unit host = LoadUnitHandleBJ(0, StringHash(abStr + "_host"), udg_UnitAI)
local unit u = LoadUnitHandleBJ(0, StringHash(abStr + "_unit"), udg_UnitAI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local location l = LoadLocationHandleBJ(0, StringHash(abStr + "_loc"), udg_UnitAI)
local integer uTI = LoadIntegerBJ(0, StringHash(abStr + "_unitType"), udg_UnitAI)
//MAIN PART
if u == null then
call CreateNUnitsAtLoc( 1, uTI, Player(0), l, bj_UNIT_FACING )
set u = bj_lastCreatedUnit
call sAI_saveUnitParameter(u, "unit", abStr, udg_UnitAI)
endif
call SetUnitPositionLoc(u, l)
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set l = null
set uTI = 0
endfunction
function ab_lineP takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = s_tDU(tIS, "host")
local string abStr = s_tDS(tIS, "abilityDLS")
local integer sI = StringHash(abStr)
local real speed = LoadRealBJ(0, StringHash(abStr + "_speed"), udg_UnitAI)
local real tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
local location l1 = GetUnitLoc(host)
local location l2 = GetUnitLoc(u)
local location l3 = null
local real angle = s_tDR(tIS, "angle")
local real dist = 0 //LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI) // get dist from origin (if there's a max
local real maxDist = LoadRealBJ(0, StringHash(abStr + "_dist_max"), udg_UnitAI)
local boolean uAlive = IsUnitAliveBJ(u)
//MAIN PART
set dist = DistanceBetweenPoints(l1, l2)
if dist >= maxDist then
call KillUnit(u)
endif
set dist = speed * tPeriod
set l3 = PolarProjectionBJ(l2, dist, angle)
call SetUnitPositionLoc(u, l3)
//call DisplayTextToForce(GetPlayersAll(), "pew")
if uAlive == true then
call TimerStart(t, tPeriod, false, function ab_lineP)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
call RemoveLocation(l1)
call RemoveLocation(l2)
call RemoveLocation(l3)
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set speed = 0
set tPeriod = 0
set l1 = null
set l2 = null
set l3 = null
set angle = 0
set dist = 0
set maxDist = 0
set uAlive = false
endfunction
function ab_line takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local integer num = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
local real aOf = 0
local integer uT = LoadIntegerBJ(0, StringHash(abStr + "_unitType"), udg_UnitAI) // make arcane arrow (and use yaw etc)
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI) // Set this in the host trigger
local integer i = 1
local real time = LoadRealBJ(0, StringHash(abStr + "_time"), udg_UnitAI)
local real period = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
//MAIN PART
call DestroyTimer(t)
loop
exitwhen i > num
call DisplayTextToForce(GetPlayersAll(), "a: " + R2S(a))
set l2 = PolarProjectionBJ(l, dist, a)
call CreateNUnitsAtLoc(1, uT, p, l2, 0)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call s_tDU_s(u, tIS, "host")
call s_tDS_s(abStr, tIS, "abilityDLS")
call s_tDR_s(a, tIS, "angle") // in theory can also use "rotation" for interesting bullet bends (like Vampire Survivors bird)
call TimerStart(t, time, false, function ab_lineP)
set i = i + 1
set time = time + period
endloop
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set num = 0
set aOf = 0
set uT = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set time = 0
set period = 0
endfunction
function ab_3DLineP takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = s_tDU(tIS, "host")
local string abStr = s_tDS(tIS, "abilityDLS")
local integer sI = StringHash(abStr)
local real speed = LoadRealBJ(0, StringHash(abStr + "_speed"), udg_UnitAI)
local real tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
local location l1 = GetUnitLoc(host)//LoadLocationHandleBJ(0, StringHash(abStr + "_location_start"), udg_UnitAI) //GetUnitLoc(host)
local location l2 = GetUnitLoc(u)
local location l3 = null
local real angle = s_tDR(tIS, "angle")
local real dist = 0 //LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI) // get dist from origin (if there's a max
local real maxDist = LoadRealBJ(0, StringHash(abStr + "_dist_max"), udg_UnitAI)
local boolean uAlive = IsUnitAliveBJ(u)
local real pitch = s_tDR(tIS, "pitch")//LoadRealBJ(0, StringHash(abStr + "_pitch"), udg_UnitAI)
local real zD = 0
local boolean loopContinued = s_tDB(tIS, "loopContinued")
local real pZ = BlzGetLocalUnitZ(u) //need ground z
local real uF = 0
local real hFH = 0
local real sM = LoadRealBJ(0, StringHash(abStr + "_scale_mod"), udg_UnitAI)
local real r = s_tDR(tIS, "scale")
local real tElapsed = s_tDR(tIS, "time_elapsed")
//MAIN PART
if r == 0 then
set r = 1.5
endif
set tElapsed = tElapsed + tPeriod
call s_tDR_s(tElapsed, tIS, "time_elapsed")
if loopContinued == false then
set uF = GetUnitFacing(host)
set hFH = GetUnitFlyHeight(host)
set l2 = PolarProjectionBJ(l1, 150, uF)
call SetUnitFlyHeight(u, hFH, 0)
set angle = uF + LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI) + 180
set pitch = LoadRealBJ(0, StringHash(abStr + "_pitch"), udg_UnitAI)
call s_tDR_s(angle, tIS, "angle")
call s_tDR_s(pitch, tIS, "pitch")
endif
set dist = Cos((pitch))
if dist == 0 then
set dist = 0
else
set dist = RAbsBJ(DistanceBetweenPoints(l1, l2) / dist) //l1 should probably be a set "start location" not host which could move
endif
//call DisplayTextToForce(GetPlayersAll(), "dist: " + R2S(dist))
if dist >= maxDist then //this didn't seem to return correct value???? oh waiiiit, cos dist from unit center duh probly?
//call KillUnit(u)
endif
set zD = (Sin((pitch)) * speed) * tPeriod
set dist = ((Cos((pitch)) * speed) * tPeriod)
call DisplayTextToForce(GetPlayersAll(), "zD: " + R2S(zD))
//call DisplayTextToForce(GetPlayersAll(), "tPeriod: " + R2S(tPeriod))
call DisplayTextToForce(GetPlayersAll(), "dist: " + R2S(dist))
set l3 = PolarProjectionBJ(l2, dist, angle)
call SetUnitPositionLoc(u, l3)
set zD = ((zD + GetUnitFlyHeight(u)) - BlzGetLocalUnitZ(u)) + pZ
if zD < 0 then
set zD = 0
endif
call SetUnitFlyHeight(u, zD, 0)
set r = r + (sM * tPeriod)
call SetUnitScale( u, r,r,r)
call s_tDR_s(r, tIS, "scale")
if uAlive == true and tElapsed < 2 then //and zD > 0
call s_tDB_s(true, tIS, "loopContinued")
call TimerStart(t, tPeriod, false, function ab_3DLineP)
else
call KillUnit(u)
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
call RemoveLocation(l2)
call RemoveLocation(l3)
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set speed = 0
set tPeriod = 0
set l1 = null
set l2 = null
set l3 = null
set angle = 0
set dist = 0
set maxDist = 0
set uAlive = false
set pitch = 0
set zD = 0
set loopContinued = false
set pZ = 0
set uF = 0
set sM = 0
set r = 0
set tElapsed = 0
endfunction
function ab_3DLine takes nothing returns nothing
local timer t = null
local integer tI = 0
local string tIS = ""
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local integer num = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
local real aOf = 0
local integer uT = LoadIntegerBJ(0, StringHash(abStr + "_unitType"), udg_UnitAI)
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI)
local integer i = 1
local real time = 0 //LoadRealBJ(0, StringHash(abStr + "_time"), udg_UnitAI)
local real period = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
local real pitch = LoadRealBJ(0, StringHash(abStr + "_pitch"), udg_UnitAI)
//MAIN PART
loop
exitwhen i > num
//call DisplayTextToForce(GetPlayersAll(), "a: " + R2S(a))
set l2 = PolarProjectionBJ(l, dist, a)
call CreateNUnitsAtLoc(1, uT, p, l2, 0)
call SetUnitInvulnerable( bj_lastCreatedUnit, true )
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call s_tDU_s(u, tIS, "host")
call s_tDS_s(abStr, tIS, "abilityDLS")
call s_tDR_s(dist, tIS, "startDist")
call s_tDR_s(a, tIS, "startAngle")
call TimerStart(t, time, false, function ab_3DLineP)
set i = i + 1
set time = time + period
endloop
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set num = 0
set aOf = 0
set uT = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set time = 0
set period = 0
set pitch = 0
endfunction
function ab_increaseDist takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local string abStr = s_tDS(tIS, "abilityDLS") //gets from the ability being used so all methods will modify the spell properly in a connected way
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = null
local integer sI = 0
local real speed = 0
local real tPeriod = 0
local real dist = 0
local real maxDist = 0
local boolean uAlive = false
local real distMod = 0
//MAIN PART
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set abStr = udg_AB_DLS
set u = udg_ABUnit
call s_tDS_s(abStr, tIS, "abilityDLS")
call s_tDU_s(u, tIS, "unit")
call s_tDU_s(u, tIS, "host")
endif
//======================================
//UPDATE VARS
//======================================
set uI = GetHandleId(u)
set uIS = I2S(uI)
set host = s_tDU(tIS, "host")
set sI = StringHash(abStr)
set speed = LoadRealBJ(0, StringHash(abStr + "_speed"), udg_UnitAI)
set tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
set dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
set maxDist = LoadRealBJ(0, StringHash(abStr + "_dist_max"), udg_UnitAI)
set uAlive = IsUnitAliveBJ(u)
set distMod = LoadRealBJ(0, StringHash(abStr + "_dist_mod"), udg_UnitAI)
//Is this faster or slower than if I called a seperate function?
//=========================================================
set dist = dist + distMod
call sAI_saveRealParameter(dist, "dist", abStr, udg_UnitAI)
if uAlive == true and dist < maxDist then
call TimerStart(t, tPeriod, false, function ab_increaseDist)
else
call DestroyTimer(t)
endif
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set speed = 0
set tPeriod = 0
set dist = 0
set maxDist = 0
set distMod = 0
set uAlive = false
endfunction
function ab_increasePitchYaw takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local string abStr = ""
local unit host = null
local unit u = null
local integer uI = 0
local string uIS = ""
local integer sI = 0
local real speed = 0
local real tPeriod = 0
local real dist = 0
local real maxDist = 0
local boolean uAlive = false
local real yawMod = 0
local real pitchMod = 0
local real time = 0
local timer t2 = null
local real angle = 0
local real pitch = 0
local integer iC = 0
local integer cI = 0
local string iS = ""
//MAIN PART
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
set abStr = udg_AB_DLS
call s_tDS_s(abStr, tIS, "abilityDLS")
endif
set abStr = s_tDS(tIS, "abilityDLS")
set host = LoadUnitHandleBJ(0, StringHash(abStr + "_host"), udg_UnitAI)
set u = LoadUnitHandleBJ(0, StringHash(abStr + "_unit"), udg_UnitAI)
set uI = GetHandleId(u)
set uIS = I2S(uI)
set sI = StringHash(abStr)
set speed = LoadRealBJ(0, StringHash(abStr + "_speed"), udg_UnitAI)
set tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
set dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
set maxDist = LoadRealBJ(0, StringHash(abStr + "_dist_max"), udg_UnitAI)
set time = LoadRealBJ(0, StringHash(abStr + "_time"), udg_UnitAI)
set t2 = LoadTimerHandleBJ(0, StringHash(abStr + "_timer"), udg_UnitAI)
set angle = LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI)
set pitch = LoadRealBJ(0, StringHash(abStr + "_pitch"), udg_UnitAI)
set iC = LoadIntegerBJ(0, StringHash(abStr + "_yaw_mod_indexCount"), udg_UnitAI)
set cI = LoadIntegerBJ(0, StringHash(abStr + "_yaw_mod_currentIndex"), udg_UnitAI)
set iS = I2S(cI)
if t2 == null then
set t2 = CreateTimer()
call sAI_saveTimerParameter(t2, "timer", abStr, udg_UnitAI)
endif
if TimerGetRemaining(t2) <= 0 then
call StartTimerBJ(t2, false, time)
set cI = cI + 1
if cI > iC then
//set cI = 1
set cI = GetRandomInt(1,iC) //actually just randomise it suh
endif
call sAI_saveIntegerParameter(cI, "currentIndex", abStr + "_yaw_mod", udg_UnitAI)
call sAI_saveIntegerParameter(cI, "currentIndex", abStr + "_pitch_mod", udg_UnitAI)
endif
set iS = I2S(cI)
set yawMod = LoadRealBJ(0, StringHash(abStr + "_yaw_mod_" + iS), udg_UnitAI)
set pitchMod = LoadRealBJ(0, StringHash(abStr + "_pitch_mod_" + iS), udg_UnitAI) * tPeriod
set angle = angle + yawMod
set pitch = pitch + pitchMod
if angle > 360 then
//set angle = angle - 360
elseif angle < 360 then
//set angle = angle + 360
endif
if pitch > 360 then
//set pitch = pitch - 360
elseif pitch < -360 then
//set pitch = pitch + 360
endif
call sAI_saveRealParameter(angle, "angle", abStr, udg_UnitAI)
call sAI_saveRealParameter(pitch, "pitch", abStr, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "iC: " + I2S(iC))
//call DisplayTextToForce(GetPlayersAll(), "cI: " + I2S(cI))
//call DisplayTextToForce(GetPlayersAll(), "angle: " + R2S(angle))
//call DisplayTextToForce(GetPlayersAll(), "yaw mod: " + R2S(yawMod))
//call DisplayTextToForce(GetPlayersAll(), "yaw: " + R2S(angle))
//call DisplayTextToForce(GetPlayersAll(), "pitch: " + R2S(pitch))
//call DisplayTextToForce(GetPlayersAll(), "time: " + R2S(TimerGetRemaining(t2)))
call TimerStart(t, tPeriod, false, function ab_increasePitchYaw)
//call DestroyTimer(t)
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set speed = 0
set tPeriod = 0
set dist = 0
set maxDist = 0
set uAlive = false
set yawMod = 0
set pitchMod = 0
set time = 0
set t2 = null
set angle = 0
set pitch = 0
set iC = 0
set cI = 0
set iS = ""
endfunction
function ab_3DRotUnit takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = s_tDU(tIS, "host")
local string abStr = s_tDS(tIS, "abilityDLS")
local integer sI = StringHash(abStr)
local real rotV = LoadRealBJ(0, StringHash(abStr + "_rotation_speed"), udg_UnitAI)
local real tPeriod = LoadRealBJ(0, StringHash(abStr + "_rotation_period"), udg_UnitAI)
local location l1 = GetUnitLoc(host)
local location l2 = GetUnitLoc(u)
local location l3 = null
local real rot = s_tDR(tIS, "rot")
local real rotPitch = s_tDR(tIS, "rotPitch") //change all these to abstr so can be used collectively?
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local boolean uAlive = IsUnitAliveBJ(u)
local real zD = 0
//MAIN PART
set rot = rot + rotV
if rot > 360 then
set rot = rot - 360
endif
call s_tDR_s(rot, tIS, "rot")
call s_tDR_s(rotPitch, tIS, "rotPitch")
set l3 = PolarProjectionBJ(l1, dist, rot)
call SetUnitPositionLoc(u, l3)
set zD = GetUnitFlyHeight(u) + (Tan(rotPitch) * dist) // might need to adjust for terrain differences
call SetUnitFlyHeight(u, zD, 0)
//call DisplayTextToForce(GetPlayersAll(), "update loc")
//call DisplayTextToForce(GetPlayersAll(), "rot " + R2S(rot))
//call DisplayTextToForce(GetPlayersAll(), "rotV " + R2S(rotV))
//call DisplayTextToForce(GetPlayersAll(), "tPeriod " + R2S(tPeriod))
if uAlive == true then
else
//call DestroyTimer(t)
endif
call TimerStart(t, tPeriod, false, function ab_3DRotUnit)
//call DisplayTextToForce(GetPlayersAll(), "loop rot")
//PLUG LEAKS
call RemoveLocation(l1)
call RemoveLocation(l2)
call RemoveLocation(l3)
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set rotV = 0
set tPeriod = 0
set l1 = null
set l2 = null
set l3 = null
set rot = 0
set rotPitch = 0
set dist = 0
set uAlive = false
set zD = 0
endfunction
function ab_waveHeight takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = s_tDU(tIS, "host")
local string abStr = s_tDS(tIS, "abilityDLS") //gets from the ability being used so all methods will modify the spell properly in a connected way
local integer sI = StringHash(abStr)
local real speed = LoadRealBJ(0, StringHash(abStr + "_speed"), udg_UnitAI)
local real tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local real maxDist = LoadRealBJ(0, StringHash(abStr + "_dist_max"), udg_UnitAI)
local boolean uAlive = IsUnitAliveBJ(u)
local real distMod = LoadRealBJ(0, StringHash(abStr + "_dist_mod"), udg_UnitAI)
//MAIN PART
set dist = dist + distMod
call sAI_saveRealParameter(dist, "dist", abStr, udg_UnitAI)
if uAlive == true and dist < maxDist then
call TimerStart(t, tPeriod, false, function ab_increaseDist)
else
call DestroyTimer(t)
endif
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set speed = 0
set tPeriod = 0
set dist = 0
set maxDist = 0
set distMod = 0
set uAlive = false
endfunction
function ab_45Move takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = LoadUnitHandleBJ(0, StringHash(abStr + "_targetUnit"), udg_UnitAI)
local boolean cliffLocked = LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = LoadIntegerBJ(0, StringHash(abStr + "_targetCliffLevel"), udg_UnitAI)
local integer cI = 0
local boolean found = false
//MAIN PART
loop
exitwhen i > 8 or found == true
set a = 45 * r
set l2 = PolarProjectionBJ(l, dist, a)
set cI = GetTerrainCliffLevelBJ(l2)
if tCI == cI then
set found = true
endif
set i = i + 1
endloop
if found == true then
call IssuePointOrderLocBJ(tU, "move", l2)
endif
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function ab_scan takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = LoadUnitHandleBJ(0, StringHash(abStr + "_targetUnit"), udg_UnitAI)
local boolean cliffLocked = LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = LoadIntegerBJ(0, StringHash(abStr + "_targetCliffLevel"), udg_UnitAI)
local integer cI = 0
local boolean found = false
//MAIN PART
call s_effect(udg_fxs_dispel, l, 10)
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function ab_absorb takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = LoadUnitHandleBJ(0, StringHash(abStr + "_targetUnit"), udg_UnitAI)
local boolean cliffLocked = LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = LoadIntegerBJ(0, StringHash(abStr + "_targetCliffLevel"), udg_UnitAI)
local integer cI = 0
local boolean found = false
//MAIN PART
//use leech lightning, and float created tome book effects towards host
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function ab_absorb takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local real aOf = 0
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0 // Set this in the host trigger
local integer i = 1
local unit tU = LoadUnitHandleBJ(0, StringHash(abStr + "_targetUnit"), udg_UnitAI)
local boolean cliffLocked = LoadBooleanBJ(0, StringHash(abStr + "_cliffLocked"), udg_UnitAI)
local real r = I2R(GetRandomInt(1, 8))
local integer tCI = LoadIntegerBJ(0, StringHash(abStr + "_targetCliffLevel"), udg_UnitAI)
local integer cI = 0
local boolean found = false
//MAIN PART
//use leech lightning, and float created tome book effects towards host
//PLUG LEAKS
call RemoveLocation(l)
call RemoveLocation(l2)
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set aOf = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
set tU = null
set cliffLocked = false
set r = 0
set tCI = 0
set cI = 0
set found = false
endfunction
function ab_rotUnit takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit host = s_tDU(tIS, "host")
local string abStr = s_tDS(tIS, "abilityDLS")
local integer sI = StringHash(abStr)
local real rotV = LoadRealBJ(0, StringHash(abStr + "_rotation_speed"), udg_UnitAI)
local real tPeriod = LoadRealBJ(0, StringHash(abStr + "_rotation_period"), udg_UnitAI)
local location l1 = GetUnitLoc(host)
local location l2 = GetUnitLoc(u)
local location l3 = null
local real rot = s_tDR(tIS, "rot")
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI) //this should be modified by increase dist
local boolean uAlive = IsUnitAliveBJ(u)
//MAIN PART
if tPeriod == 0 then
set tPeriod = LoadRealBJ(0, StringHash(abStr + "_period"), udg_UnitAI)
endif
if tPeriod == 0 then
set tPeriod = 0.125
endif
set rot = rot + rotV
if rot > 360 then
set rot = rot - 360
endif
call s_tDR_s(rot, tIS, "rot")
set l3 = PolarProjectionBJ(l1, dist, rot)
call SetUnitPositionLoc(u, l3)
//call DisplayTextToForce(GetPlayersAll(), "update loc")
//call DisplayTextToForce(GetPlayersAll(), "rot " + R2S(rot))
//call DisplayTextToForce(GetPlayersAll(), "rotV " + R2S(rotV))
//call DisplayTextToForce(GetPlayersAll(), "tPeriod " + R2S(tPeriod))
if uAlive == true then
else
//call DestroyTimer(t)
endif
call TimerStart(t, tPeriod, false, function ab_rotUnit)
//call DisplayTextToForce(GetPlayersAll(), "loop rot")
//PLUG LEAKS
call RemoveLocation(l1)
call RemoveLocation(l2)
call RemoveLocation(l3)
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set host = null
set abStr = ""
set sI = 0
set rotV = 0
set tPeriod = 0
set l1 = null
set l2 = null
set l3 = null
set rot = 0
set dist = 0
set uAlive = false
endfunction
function ab_rotDef takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local integer num = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
local real aOf = 0
local integer uT = LoadIntegerBJ(0, StringHash(abStr + "_unitType"), udg_UnitAI)
local location l = GetUnitLoc(u)
local location l2 = null
local real dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
local player p = GetOwningPlayer(u)
local real a = 0
local integer i = 1
local real height = LoadRealBJ(0, StringHash(abStr + "_height"), udg_UnitAI)
//MAIN PART
call DestroyTimer(t)
if num > 0 then
set aOf = 360 / I2R(num)
endif
//call DisplayTextToForce(GetPlayersAll(), "aOf: " + R2S(aOf))
loop
exitwhen i > num
//call DisplayTextToForce(GetPlayersAll(), "a: " + R2S(a))
set l2 = PolarProjectionBJ(l, dist, a)
call CreateNUnitsAtLoc(1, uT, p, l2, 0)
call SetUnitFlyHeight(bj_lastCreatedUnit, height, 0)
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
call s_tDU_s(bj_lastCreatedUnit, tIS, "unit")
call s_tDU_s(u, tIS, "host")
call s_tDS_s(abStr, tIS, "abilityDLS")
call s_tDR_s(a, tIS, "rot")
call TimerStart(t, 0, false, function ab_rotUnit)
set a = a + aOf
set i = i + 1
endloop
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set num = 0
set aOf = 0
set uT = 0
set l = null
set dist = 0
set p = null
set a = 0
set i = 0
endfunction
function ABUnit_soul takes string aBS returns nothing
call sAI_saveIntegerParameter('h02B', "unitType", aBS, udg_UnitAI)
set aBS = ""
endfunction
function ABUnit_tome takes string aBS returns nothing
call sAI_saveIntegerParameter('h02A', "unitType", aBS, udg_UnitAI)
set aBS = ""
endfunction
function ABUnit_lantern takes string aBS returns nothing
call sAI_saveIntegerParameter('h02D', "unitType", aBS, udg_UnitAI)
set aBS = ""
endfunction
function ABUnit_shard takes string aBS returns nothing
call sAI_saveIntegerParameter('h02C', "unitType", aBS, udg_UnitAI)
set aBS = ""
endfunction
function ab_gardenExpires takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local string abStr = s_tDS(tIS, "abilityDLS")
local boolean abActive = LoadBooleanBJ(0, StringHash(abStr + "_active"), udg_UnitAI)
local real time = 0
local group g = LoadGroupHandleBJ(0, StringHash(abStr + "_ghosts_group"), udg_UnitAI)
local unit eU = FirstOfGroup(g)
//MAIN PART
loop
exitwhen eU == null
call KillUnit(eU)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup
endloop
call DestroyGroup(g)
//
call sAI_saveBooleanParameter(false, "active", abStr, udg_UnitAI)
//revert terrain here
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function ab_gardenLight takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local string abStr = s_tDS(tIS, "abilityDLS")
local boolean abActive = LoadBooleanBJ(0, StringHash(abStr + "_active"), udg_UnitAI)
local real period = s_tDR(tIS, "period")
local location l = s_tDL(tIS, "loc")
//MAIN PART
if period == 0 then
set period = 1
endif
set l = PolarProjectionBJ(l, GetRandomReal(0, 300), GetRandomDirectionDeg())
call AddSpecialEffectLocBJ( l, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 10)
if abActive == true then
call TimerStart(t, period, false, function ab_gardenLight)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set abStr = ""
set abActive = false
set period = 0
set l = null
endfunction
function ab_gardenGhost takes location l returns nothing
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = udg_AB_DLS
local group g = LoadGroupHandleBJ(0, StringHash(abStr + "_ghosts_group"), udg_UnitAI)
//MAIN PART
if g == null then
set g = CreateGroup()
call sAI_saveGroupParameter(g, "ghosts_group", abStr, udg_UnitAI)
endif
call CreateNUnitsAtLoc( 1, 'Ekgg', Player(0), l, bj_UNIT_FACING )
call GroupAddUnit(g, bj_lastCreatedUnit)
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set g = null
endfunction
function ab_createTerrainPatch takes string dls, location l, integer tTI returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local string abStr = udg_AB_DLS
local integer pTTI = 0
local boolean alreadyTerrained = false
local real x = 0
local real y = 0
local string xS = ""
local string yS = ""
local integer count = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
//local location l = LoadLocationHandleBJ(0, StringHash(abStr + "_location")
//local integer tTI = LoadIntegerBJ(0, StringHash(abStr + "_terrainType")
//MAIN PART
//check if terrain already terrained
set pTTI = GetTerrainTypeBJ(l)
call SetTerrainTypeBJ( l, tTI, -1, 1, 0 )
set x = GetLocationX(l)
set y = GetLocationY(l)
set xS = R2S(x)
set yS = R2S(y)
//creategarden
if LoadIntegerBJ(0, StringHash(dls + "_terrain_" + xS + yS),udg_UnitAI) != 0 then
set alreadyTerrained = true
endif
call sAI_saveIntegerParameter(tTI, "terrain_" + xS + yS, dls, udg_tempHash)
call sAI_saveLocationParameter(l, "loc", dls + "_terrain_" + xS + yS, udg_tempHash)
if alreadyTerrained == false then
call sAI_saveIntegerParameter(pTTI, "terrain_" + xS + yS + "_original", dls, udg_tempHash)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set l = null
set tTI = 0
endfunction
function ab_garden takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit") //this is an effect, it'll execute and kill projectile etc
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local string abStr = udg_AB_DLS
local integer count = LoadIntegerBJ(0, StringHash(abStr + "_count"), udg_UnitAI)
local integer i = 1
local location l = LoadLocationHandleBJ(0, StringHash(abStr + "_location"), udg_UnitAI)
local string dls = ""
local real dist = 0
local real distMax = 0 //we use this to determine how far the projectile is actually going
//this may be an artifact power, in which case the data is automatically generated, but if lilith, then that gives info
local rect r = RectFromCenterSizeBJ(l, 400.00, 400.00)
//MAIN PART
//needs to account for overwriting as well
call DestroyTimer(t)
call sAI_addStringParameter("", "garden", "terrain", udg_tempHash)
set dls = udg_lastPLS
loop
exitwhen i > count
call ab_createTerrainPatch(dls, l, 'Bgrs')
set i = i + 1
endloop
call AddSpecialEffectLocBJ( l, "Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl" )
call s_destroyEffect_main(bj_lastCreatedEffect, 15)
//
call AddWeatherEffectSaveLast( r, 'RAhr' )
call sAI_addWeatherParameter(GetLastCreatedWeatherEffect(), "weather", dls, udg_UnitAI)
call AddWeatherEffectSaveLast( r, 'LRaa' )
call sAI_addWeatherParameter(GetLastCreatedWeatherEffect(), "weather", dls, udg_UnitAI)
call AddWeatherEffectSaveLast( r, 'FDgh' )
call sAI_addWeatherParameter(GetLastCreatedWeatherEffect(), "weather", dls, udg_UnitAI)
//
//maybe use forcefield special fx and dancing wisps and stuff
//also tranquility
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function ab_check takes string dls returns nothing
local unit u = LoadUnitHandleBJ(0, StringHash(dls + "_unit"), udg_UnitAI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = dls
local integer i = 1
local integer iC = 0
local trigger tR = null
local string iS = ""
//MAIN PART
//loop through ability effects etc
set iC = LoadIntegerBJ(0, StringHash(dls + "_effect_trigger_indexCount"), udg_UnitAI)
loop
exitwhen i > iC
set iS = I2S(i)
set tR = LoadTriggerHandleBJ(0, StringHash( dls + "_effect_trigger_" + iS), udg_UnitAI) //triggers added and defined by the creation system, it'll be like create thing, create motion, etc, create whatever init effects
call TriggerExecute(tR)
set i = i + 1
endloop
// these
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set abStr = ""
set i = 0
set iC = 0
set tR = null
set iS = ""
endfunction
function ab_effectLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string dls = s_tDS(tIS, "abilityDLS")
local real tPeriod = s_tDR(tIS, "period")
local boolean isAlive = IsUnitAliveBJ(u)
//MAIN PART
if isAlive == false then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call ab_check(dls)
call TimerStart(t, tPeriod, false, function ab_effectLoop)
endif
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
set tPeriod = 0
set isAlive = false
set dls = ""
endfunction
function ab_use takes string dls returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = dls
local integer i = 1
local integer iC = 0
local trigger tR = null
local string iS = ""
//MAIN PART
//loop through ability effects etc
set iC = LoadIntegerBJ(0, StringHash(dls + "_method_trigger_indexCount"), udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "ab use activated")
//call DisplayTextToForce(GetPlayersAll(), "ab iC " + I2S(iC))
//call DisplayTextToForce(GetPlayersAll(), "dls " + dls)
loop
exitwhen i > iC
set iS = I2S(i)
set tR = LoadTriggerHandleBJ(0, StringHash( dls + "_method_trigger_" + iS), udg_UnitAI) //triggers added and defined by the creation system, it'll be like create thing, create motion, etc, create whatever init effects
call TriggerExecute(tR)
//call DisplayTextToForce(GetPlayersAll(), "method trigger activated")
set i = i + 1
endloop
//call TimerStart(t, 0, false, function ab_effectLoop)
// the triggers executed here would be the "methods" which is the overall spell type, as well as any instants
// the spells are generated as projectiles, which then check and trigger their contained effects
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set u = null
set uI = 0
set uIS = ""
endfunction
function ab_addAbil takes unit u, string name, trigger method, integer artifact returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string dls = ""
//MAIN PART
call sAI_addStringParameter(name, "ability", "Units_" + uIS, udg_UnitAI)
set dls = udg_lastPLS
set udg_AB_lastCreatedAB = udg_lastPLS
//call DisplayTextToForce(GetPlayersAll(), "pls " + udg_lastPLS)
call sAI_saveIntegerParameter(artifact, "unitType", dls, udg_UnitAI)
call sAI_saveIntegerParameter(12, "count", dls, udg_UnitAI)
call sAI_saveRealParameter(100, "dist", dls, udg_UnitAI)
call sAI_saveRealParameter(5, "rotation_speed", dls, udg_UnitAI)
call sAI_saveRealParameter(udg_gameloop, "rotation_period", dls, udg_UnitAI)
call sAI_saveLocationParameter(GetUnitLoc(u), "host_loc", dls, udg_UnitAI)
call sAI_addTriggerParameter(method, "method_trigger", dls, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "pls2: " + udg_lastPLS)
//call DisplayTextToForce(GetPlayersAll(), "pls2 iC: " + I2S(LoadIntegerBJ(0, StringHash(dls + "_method_trigger_indexCount"), udg_UnitAI)))
// and then add effects, which would be triggers
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set name = ""
set method = null
set artifact = 0
endfunction
function ab_addAbilEmpty takes unit u, string name returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string dls = ""
//MAIN PART
call sAI_addStringParameter(name, "ability", "Units_" + uIS, udg_UnitAI)
set dls = udg_lastPLS
set udg_AB_lastCreatedAB = udg_lastPLS
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set name = ""
set dls = ""
endfunction
function ab_addEffect takes string dls, trigger e returns nothing
//MAIN PART
call sAI_addTriggerParameter(e, "effect_trigger", dls, udg_UnitAI)
//PLUG LEAKS
set dls = ""
set e = null
endfunction
function ab_createFromSelected takes string name returns nothing
local trigger method = udg_MethodSelected
local integer artifact = udg_ArtifactSelected
local trigger e = null
local integer i = 0
local integer iC = 2
local string dls = ""
//MAIN PART
call ab_addAbil(udg_ABUnit, name, method, artifact)
set dls = udg_AB_lastCreatedAB
loop
exitwhen i > iC
set e = udg_EffectSelected[i]
call ab_addEffect(dls, e)
set i = i + 1
endloop
//PLUG LEAKS
set name = ""
set dls = ""
set method = null
set artifact = 0
set e = null
set i = 0
set iC = 0
endfunction
function find_uABDLS_byName takes unit u, string str returns string
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string rStr = ""
local integer sI = 0
local integer i = 1
local integer iC = 0
local string iS = ""
local string str2 = ""
//MAIN PART
set sI = StringHash( "Units_" + uIS + "_mem_" + str) //checks fast memory for a link
set rStr = LoadStringBJ(0, sI, udg_UnitAI)
if rStr == "" then
set sI = StringHash( "Units_" + uIS + "_ability_metaList_" + str) //checks directly for meta name
set rStr = LoadStringBJ(0, sI, udg_UnitAI)
endif
//==========================================
//Check Index if Meta Not Matched
//==========================================
if rStr == "" then //for this we're just checking if the dls exists, not the name because we're checking it as a path
set sI = StringHash("Units_" + uIS + "_ability_indexCount")
set iC = LoadIntegerBJ(0, sI, udg_UnitAI)
//ordinary index
loop
exitwhen i > iC or rStr == str
set iS = I2S(i)
set str2 = "Units_" + uIS + "_ability_" + iS
set sI = StringHash(str2) //checks name value directly at path
set rStr = LoadStringBJ(0, sI, udg_UnitAI)
if rStr != str then
set sI = StringHash(str2 + "_name") //checks for separate name entry if not found
set rStr = LoadStringBJ(0, sI, udg_UnitAI)
if rStr == str then
set rStr = str2
else
set rStr = ""
endif
else
set rStr = str2
endif
set i = i + 1
endloop
endif
//Check Meta in further detail.
set i = 1
if rStr == "" then // again, just a path check first
set sI = StringHash("Units_" + uIS + "_ability_metaList_indexCount")
set iC = LoadIntegerBJ(0, sI, udg_UnitAI)
loop
exitwhen i > iC or rStr != ""
set iS = I2S(i)
set str2 = "Units_" + uIS + "_ability_metaList_" + iS
set sI = StringHash(str2)
set rStr = LoadStringBJ(0, sI, udg_UnitAI) // the meta index returns the name which is the data location
set sI = StringHash("Units_" + uIS + "_ability_" + rStr + "_name") //checks that metas don't also have a separate name entry that matches
set rStr = LoadStringBJ(0, sI, udg_UnitAI)
if rStr == str then
set rStr = str2
else
set rStr = ""
endif
set i = i + 1
endloop
endif
if rStr != "" then
call sAI_saveStringParameter(rStr, str, "Units_" + uIS + "_mem", udg_UnitAI)
endif
set udg_tempString = rStr
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set rStr = ""
set sI = 0
set i = 1
set iC = 0
set iS = ""
set str2 = ""
//RETURN
return udg_tempString
endfunction
native BlzSetMousePos takes integer x, integer y returns nothing
native BlzGetLocalClientWidth takes nothing returns integer
native BlzGetLocalClientHeight takes nothing returns integer
function s_mouseMove takes nothing returns nothing
local location l1 = udg_MouseLastPos
local location l2 = udg_MousePos
local real x = 0
local real y = 0
local real z = 0
//MAIN PART
set x = GetLocationX(udg_MousePos) - GetLocationX(udg_MouseLastPos)
set y = GetLocationY(udg_MousePos) - GetLocationY(udg_MouseLastPos)
call DisplayTextToForce(GetPlayersAll(), "mouseRelativeX: " + R2S(x))
call DisplayTextToForce(GetPlayersAll(), "mouseRelativeY: " + R2S(y))
//PLUG LEAKS
set l1 = udg_MouseLastPos
set l2 = udg_MousePos
set x = 0
set y = 0
set z = 0
endfunction
function af_refreshMenu_artifact takes nothing returns nothing
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Artifact: " + udg_AF_artifactText)
set udg_ArcaneForge_B_Artifact = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Method: " + udg_AF_methodText )
set udg_ArcaneForge_B_Method = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Effect 1: " + udg_AF_effectText[0])
set udg_ArcaneForge_B_Effect[0] = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Effect 2: " + udg_AF_effectText[1])
set udg_ArcaneForge_B_Effect[1] = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Effect 3: " + udg_AF_effectText[2])
set udg_ArcaneForge_B_Effect[2] = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Accept" )
set udg_ArcaneForge_B_Accept = GetLastCreatedButtonBJ()
call DialogAddButtonBJ( udg_ArcaneForgeMenu_Artifact, "Back" )
set udg_ArcaneForge_B_A2Main = GetLastCreatedButtonBJ()
endfunction
function afb_nextMethod takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string mDLS = "Units_" + uIS + "_AF_effect"
local integer cI = s_uDI(u, "AF_method_currentIndex")
local integer iC = s_uDI(u, "AF_method_indexCount")
local string iS = ""
local string str = ""
//MAIN PART
set cI = cI + 1
if cI > iC then
set cI = 1
endif
call s_uDI_s(cI, uIS, "AF_method_currentIndex")
set iS = I2S(cI)
set str = s_uDS(u, "AF_method_" + iS + "_name")
set udg_AF_methodText = str
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set mDLS = ""
set cI = 0
set iC = 0
set iS = ""
set str = ""
endfunction
function afb_nextArtifact takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string mDLS = "Units_" + uIS + "_AF_effect"
local integer cI = s_uDI(u, "AF_artifact_currentIndex")
local integer iC = s_uDI(u, "AF_artifact_indexCount")
local string iS = ""
local string str = ""
//MAIN PART
set cI = cI + 1
if cI > iC then
set cI = 1
endif
call s_uDI_s(cI, uIS, "AF_artifact_currentIndex")
set iS = I2S(cI)
set str = s_uDS(u, "AF_artifact_" + iS + "_name")
set udg_AF_artifactText = str
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set mDLS = ""
set cI = 0
set iC = 0
set iS = ""
set str = ""
endfunction
function afb_nextEffect1 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer cI = s_uDI(u, "AF_effect_1_currentIndex")
local integer iC = s_uDI(u, "AF_effect_indexCount")
local string iS = ""
local string str = ""
//MAIN PART
set cI = cI + 1
if cI > iC then
set cI = 1
endif
call s_uDI_s(cI, uIS, "AF_effect_1_currentIndex")
set iS = I2S(cI)
set str = s_uDS(u, "AF_effect_" + iS + "_name")
//set str = s_uDS(u, "AF_effect_1_name")
set udg_EffectSelected[0] = s_uDTR(u, "AF_effect_" + iS)
set udg_AF_effectText[0] = str
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set cI = 0
set iC = 0
set iS = ""
set str = ""
endfunction
function afb_nextEffect2 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string mDLS = "Units_" + uIS + "_AF_effect"
local integer cI = s_uDI(u, "AF_effect_2_currentIndex")
local integer iC = s_uDI(u, "AF_effect_indexCount")
local string iS = ""
local string str = ""
//MAIN PART
set cI = cI + 1
if cI > iC then
set cI = 1
endif
call s_uDI_s(cI, uIS, "AF_effect_2_currentIndex")
set iS = I2S(cI)
set str = s_uDS(u, "AF_effect_" + iS + "_name")
set udg_EffectSelected[1] = s_uDTR(u, "AF_effect" + iS)
set udg_AF_effectText[1] = str
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set mDLS = ""
set cI = 0
set iC = 0
set iS = ""
set str = ""
endfunction
function afb_nextEffect3 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string mDLS = "Units_" + uIS + "_AF_effect"
local integer cI = s_uDI(u, "AF_effect_3_currentIndex")
local integer iC = s_uDI(u, "AF_effect_indexCount")
local string iS = ""
local string str = ""
//MAIN PART
set cI = cI + 1
if cI > iC then
set cI = 1
endif
call s_uDI_s(cI, uIS, "AF_effect_3_currentIndex")
set iS = I2S(cI)
set str = s_uDS(u, "AF_effect_" + iS + "_name")
set udg_EffectSelected[2] = s_uDTR(u, "AF_effect" + iS)
set udg_AF_effectText[2] = str
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set mDLS = ""
set cI = 0
set iC = 0
set iS = ""
set str = ""
endfunction
function ab_addResource takes unit u, string name, integer amount returns nothing
endfunction
function af_createArtifact takes unit u, string name, integer aI returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call sAI_addIntegerParameter(aI, "AF_artifact", "Units_" + uIS, udg_UnitAI)
call sAI_saveStringParameter(name, "name", udg_lastPLS, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set name = ""
set aI = 0
endfunction
function af_createMethod takes unit u, string name, trigger tR returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call sAI_addTriggerParameter(tR, "AF_method", "Units_" + uIS, udg_UnitAI)
call sAI_saveStringParameter(name, "name", udg_lastPLS, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set name = ""
set tR = null
endfunction
function af_createEffect takes unit u, string name, trigger tR returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call sAI_addTriggerParameter(tR, "AF_effect", "Units_" + uIS, udg_UnitAI)
call sAI_saveStringParameter(name, "name", udg_lastPLS, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set name = ""
set tR = null
endfunction
function ab_createMethod takes string dls, string name, trigger tR returns nothing
//MAIN PART
call sAI_addTriggerParameter(tR, "method_trigger", dls, udg_UnitAI)
call sAI_saveStringParameter(name, "name", udg_lastPLS, udg_UnitAI)
//PLUG LEAKS
set dls = ""
set name = ""
set tR = null
endfunction
function ab_createEffect takes string dls, string name, trigger tR returns nothing
//MAIN PART
call sAI_addTriggerParameter(tR, "effect_trigger", dls, udg_UnitAI)
call sAI_saveStringParameter(name, "name", udg_lastPLS, udg_UnitAI)
//PLUG LEAKS
set dls = ""
set name = ""
set tR = null
endfunction
function ab_arcanebolt takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//
local string str = s_tDS(tIS, "dls")
local location uL = GetUnitLoc(u)
local location startLocation = s_uDL(u, str + "_location_target")
local location targetLocation = s_uDL(u, str + "_location_target")
local location mP = udg_MousePos
local real ang = 0
//MAIN PART
if str == "" then
set str = udg_AB_DLS
endif
if targetLocation == null then
set targetLocation = mP
endif
set ang = AngleBetweenPoints(uL, targetLocation)
set startLocation = PolarProjectionBJ(uL, 50, ang)
call s_uDL_s(startLocation, uIS, str + "_location_start")
call s_uDL_s(startLocation, uIS, str + "_location_end")
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function pf_arcanearrow takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
set udg_ABUnit = u
call ab_addAbilEmpty(u, "Arcane Arrow")
set udg_AB_DLS = udg_AB_lastCreatedAB
//requires ab_str?
//METHOD
call ab_createMethod(udg_AB_DLS, "Spear", gg_trg_AB_x_Targeting_x_Line)
//EFFECT
call ab_createEffect(udg_AB_DLS, "Arcane Damage", gg_trg_AB_Effect_x_Damage)
call sAI_saveIntegerParameter(1, "count", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(25, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(900, "dist_max", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveLocationParameter(GetUnitLoc(u), "location_start", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(udg_gameloop_fx, "period", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter('h02E', "unitType", udg_AB_lastCreatedAB, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_garden takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
set udg_ABUnit = u
call ab_addAbilEmpty(u, "Garden")
set udg_AB_DLS = udg_AB_lastCreatedAB
//METHOD
call ab_createMethod(udg_AB_DLS, "Arrow", gg_trg_AB_x_Targeting_x_Target)
call sAI_saveIntegerParameter(1, "count", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(75, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(1000, "dist_max", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(4, "ghosts_count", udg_AB_lastCreatedAB, udg_UnitAI)
//EFFECT
call ab_createEffect(udg_AB_DLS, "Garden", gg_trg_AB_Effect_x_Garden)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_method_rotSelf takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createMethod(u, "Defense Circle", gg_trg_AB_x_Targeting_x_RotSelf)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_method_line takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createMethod(u, "Spear", gg_trg_AB_x_Targeting_x_RotSelf)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_method_target takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createMethod(u, "Arrow", gg_trg_AB_x_Targeting_x_RotSelf)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_method_targetAOE takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createMethod(u, "Erupt", gg_trg_AB_x_Targeting_x_RotSelf)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_effect_lightning takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createEffect(u, "Lightning Charge", null)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_effect_knockback takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createEffect(u, "Batter", gg_trg_AB_Effect_x_Knockback)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_effect_damage takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createEffect(u, "Physical Strike", gg_trg_AB_Effect_x_Damage)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_effect_holyLight takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createEffect(u, "Holy Light", gg_trg_AB_Effect_x_Holy_Light)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_effect_summonWolves takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createEffect(u, "Summon Spirit Keeper", null)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_ab_shards takes nothing returns nothing
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
set udg_MethodSelected = gg_trg_AB_x_Targeting_x_RotSelf
set udg_ArtifactSelected = 'h02C'
set udg_EffectSelected[0] = gg_trg_AB_Effect_x_Holy_Light
call ab_createFromSelected("defense_shards")
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_ab_shards2 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
set udg_MethodSelected = gg_trg_AB_x_Targeting_x_RotSelf
set udg_ArtifactSelected = 'h02D'
call ab_createFromSelected("defense_shards")
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_ab_dragonbreathUltimate takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call ab_addAbilEmpty(u, "firebreath ultimate")
call ab_createMethod(udg_AB_lastCreatedAB, "Shoot Flame", gg_trg_AB_x_Targeting_x_3D_Line)
call ab_createMethod(udg_AB_lastCreatedAB, "Omni Flame", gg_trg_AB_x_Targeting_x_Increase_PitchYaw)
//actually what i need is not rotate and increase distance, it's literally to circle yaw and pitch of new projectile direction
//
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(180, "count", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(75, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(400, "dist_max", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveLocationParameter(GetUnitLoc(u), "location_start", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(udg_gameloop_fx, "period", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(-60, "pitch", udg_AB_lastCreatedAB, udg_UnitAI)
//
call sAI_addRealParameter(16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(1, "yaw_mod_currentIndex", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(1, "pitch_mod_currentIndex", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(2, "time", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(0, "scale_mod", udg_AB_lastCreatedAB, udg_UnitAI)
//
call sAI_saveIntegerParameter('h02E', "unitType", udg_AB_lastCreatedAB, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "ym iC: " + I2S(LoadIntegerBJ(0, StringHash(udg_AB_lastCreatedAB + "_yaw_mod_indexCount"), udg_UnitAI)))
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_ab_ringOfFire takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call ab_addAbilEmpty(u, "Fire Erupt")
//===================================
// METHODS
//===================================
//call ab_createMethod(udg_AB_lastCreatedAB, "Update Start Location", gg_trg_AB_x_TransferData_UnitLocation)
//maybe could add method as well that transfers data like host loc at "run time"
call ab_createMethod(udg_AB_lastCreatedAB, "Ring of Fire", gg_trg_AB_x_Targeting_x_RotSelf)
call ab_createMethod(udg_AB_lastCreatedAB, "Expand", gg_trg_AB_x_Targeting_x_Increase_Dist)
//actually what i need is not rotate and increase distance, it's literally to circle yaw and pitch of new projectile direction
//
//===================================
// EFFECTS
//===================================
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(12, "count", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(0, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(50, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(400, "dist_max", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(10, "dist_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveUnitParameter(u, "host", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveLocationParameter(GetUnitLoc(u), "location_start", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(udg_gameloop_fx, "period", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(2, "rotation_speed", udg_AB_lastCreatedAB, udg_UnitAI)
//
//call sAI_addRealParameter(16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveIntegerParameter(1, "yaw_mod_currentIndex", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(2, "time", udg_AB_lastCreatedAB, udg_UnitAI)
//
call sAI_saveIntegerParameter('h02E', "unitType", udg_AB_lastCreatedAB, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_ab_dragonbreathUltimate takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call ab_addAbilEmpty(u, "firebreath ultimate")
call ab_createMethod(udg_AB_lastCreatedAB, "Shoot Flame", gg_trg_AB_x_Targeting_x_3D_Line)
call ab_createMethod(udg_AB_lastCreatedAB, "Omni Flame", gg_trg_AB_x_Targeting_x_Increase_PitchYaw)
//actually what i need is not rotate and increase distance, it's literally to circle yaw and pitch of new projectile direction
//
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(180, "count", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(75, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(400, "dist_max", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveLocationParameter(GetUnitLoc(u), "location_start", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(udg_gameloop_fx, "period", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(-60, "pitch", udg_AB_lastCreatedAB, udg_UnitAI)
//
call sAI_addRealParameter(16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(1, "yaw_mod_currentIndex", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(1, "pitch_mod_currentIndex", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-16, "yaw_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_addRealParameter(-4, "pitch_mod", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(2, "time", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(0, "scale_mod", udg_AB_lastCreatedAB, udg_UnitAI)
//
//easy, just use the right timing and angles, and we'll cut it like a ribbon, angled fireball slashes (like suped up sword slashes but fire)
call sAI_saveIntegerParameter('h02E', "unitType", udg_AB_lastCreatedAB, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "ym iC: " + I2S(LoadIntegerBJ(0, StringHash(udg_AB_lastCreatedAB + "_yaw_mod_indexCount"), udg_UnitAI)))
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_artifact_shards takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createArtifact(u, "Chaos Shards", 'h02C')
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_artifact_tome takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createArtifact(u, "Tome", 'h02A')
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_artifact_soul takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createArtifact(u, "Captured Soul", 'h02B')
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_artifact_lantern takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call af_createArtifact(u, "Magical Lantern", 'h02D')
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_uo_move45 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local location l = GetUnitLoc(u) //GetRectCenter(gg_rct_HOM)
//MAIN PART
call ab_addAbilEmpty(u, "Move 45")
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveUnitParameter(udg_DarkRangerLilith, "enemy", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(GetTerrainCliffLevelBJ(l), "cliffLevel", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(GetTerrainCliffLevelBJ(l), "targetCliffLevel", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveUnitParameter(udg_ABUnit, "targetUnit", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(75, "height", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
//call sAI_saveRealParameter(200, "speed", udg_AB_lastCreatedAB, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
call RemoveLocation(l)
set l = null
endfunction
function pf_uo_msFace90 takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local location l = GetUnitLoc(u) //GetRectCenter(gg_rct_HOM)
//MAIN PART
call ab_addAbilEmpty(u, "face 90")
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveUnitParameter(udg_DarkRangerLilith, "enemy", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveIntegerParameter(GetTerrainCliffLevelBJ(l), "cliffLevel", udg_AB_lastCreatedAB, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_uo_msMoveToward takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call ab_addAbilEmpty(u, "move")
call sAI_saveUnitParameter(udg_ABUnit, "host", udg_AB_lastCreatedAB, udg_UnitAI)
call sAI_saveRealParameter(125, "dist", udg_AB_lastCreatedAB, udg_UnitAI)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function pf_magicStatue takes unit u returns nothing
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call pf_uo_msMoveToward(u)
call pf_uo_msFace90(u)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function initAFPrefabs takes nothing returns nothing
call pf_method_rotSelf(udg_DarkRangerLilith)
call pf_method_line(udg_DarkRangerLilith)
call pf_effect_damage(udg_DarkRangerLilith)
call pf_effect_holyLight(udg_DarkRangerLilith)
call pf_effect_summonWolves(udg_DarkRangerLilith)
call pf_artifact_shards(udg_DarkRangerLilith)
call pf_artifact_tome(udg_DarkRangerLilith)
call pf_artifact_soul(udg_DarkRangerLilith)
call pf_garden(udg_DarkRangerLilith)
call pf_arcanearrow(udg_DarkRangerLilith)
//
call pf_method_rotSelf(udg_Herodin)
call pf_method_line(udg_Herodin)
call pf_artifact_shards(udg_Herodin)
call pf_artifact_tome(udg_Herodin)
call pf_artifact_soul(udg_Herodin)
call pf_artifact_lantern(udg_Herodin)
endfunction
function addPrefabs takes unit u returns nothing
call pf_method_rotSelf(u)
call pf_method_line(u)
call pf_artifact_shards(u)
call pf_artifact_tome(u)
call pf_artifact_soul(u)
call pf_artifact_lantern(u)
endfunction
function snakePart_follow takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit fU = s_tDU(tIS, "follow_unit")
// update to be a unit in the chain of units
local location uL = GetUnitLoc(u)
local location fUL = GetUnitLoc(fU)
local real ang = 0
local real dist = 100
local real fUF = GetUnitFacing(fU)
local boolean isAlive = IsUnitAliveBJ(u)
local real period = s_tDR(tIS, "period")
local location l = null
local real nF = GetUnitFacing(fU)
local real dist2 = 0
local real dist3 = 0
local real currentX = GetLocationX(uL)
local real currentY = GetLocationY(uL)
local real currentZ = BlzGetLocalUnitZ(u) + GetUnitFlyHeight(u)
local location newL = null
local real targetX = s_tDR(tIS, "target_X")
local real targetY = s_tDR(tIS, "target_Y")
local real targetZ = s_tDR(tIS, "target_Z")
//local unit host = s_tDU(tIS, "host")
local real distTargetSoft = RAbsBJ((targetX + targetY + targetZ) - (currentX + currentY + currentZ))
local real speed = s_tDR(tIS, "speed") * period
local real mod = 1
//
local effect e = s_tDE(tIS, "fx")
local real uF = GetUnitFacing(u)
local real pYaw = s_tDR(tIS, "fx_previousYaw")
local real fUZ = BlzGetLocalUnitZ(fU) + GetUnitFlyHeight(fU)
local real pitch = 0
local integer lC = s_tDI(tIS, "loopsRemaining")
//MAIN PART
set ang = nF + 180
set l = Location(targetX, targetY)
set dist2 = DistanceBetweenPoints(uL, l)
set dist3 = DistanceBetweenPoints(uL, fUL)
set nF = AngleBetweenPoints(uL, l)
if (dist3 > dist) or (RAbsBJ(fUZ - currentZ) > dist) or (RAbsBJ(targetZ - currentZ) > dist) then
if targetX >= currentX then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetX - currentX) > 0 then
if speed <= RAbsBJ(targetX - currentX) then
call SetUnitX(u, currentX + (speed * mod))
else
call SetUnitX(u, targetX)
endif
endif
if targetY >= currentY then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetY - currentY) > 0 then
if speed <= RAbsBJ(targetY - currentY) then
call SetUnitY(u, currentY + (speed * mod))
else
call SetUnitY(u, targetY)
endif
endif
if targetZ >= currentZ then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetZ - currentZ) > 0 then
if speed <= RAbsBJ(targetZ - currentZ) then
set currentZ = (currentZ + (speed * mod))
else
set currentZ = targetZ
endif
endif
call SetUnitFlyHeight(u, currentZ - BlzGetLocalUnitZ(u), 0)
//Set Facing
//call SetUnitFacing(u, nF)
endif
//call DisplayTextToForce(GetPlayersAll(), "currentZ: " + R2S(currentZ))
//call DisplayTextToForce(GetPlayersAll(), "targetZ: " + R2S(targetZ))
set distTargetSoft = RAbsBJ((targetX + targetY + targetZ) - (currentX + currentY + currentZ))
if distTargetSoft <= 0 then
set targetX = GetLocationX(fUL)
set targetY = GetLocationY(fUL)
set targetZ = BlzGetLocalUnitZ(fU) + GetUnitFlyHeight(fU)
call s_tDR_s(targetX, tIS, "target_X")
call s_tDR_s(targetY, tIS, "target_Y")
call s_tDR_s(targetZ, tIS, "target_Z")
call s_tDI_s(1, tIS, "loopsRemaining")
set lC = 1
endif
//fx
call BlzSetSpecialEffectX( e, currentX)
call BlzSetSpecialEffectY( e, currentY )
call BlzSetSpecialEffectZ( e, BlzGetLocalUnitZ(u) + GetUnitFlyHeight(u))
if lC >= 0 then
call RemoveLocation(uL)
set uL = Location(currentX, currentY)
call RemoveLocation(l)
set l = Location(targetX, targetY)
set nF = Deg2Rad(AngleBetweenPoints(uL, l))
set dist2 = DistanceBetweenPoints(uL, l)
if dist2 >= 0 then
call BlzSetSpecialEffectYaw( e, nF )
//set pitch = Deg2Rad(Atan2BJ(dist2, (targetZ - currentZ))) // y, x ??? for some reason???
set pitch = Deg2Rad(Atan2BJ((targetZ - currentZ), dist2) * - 1)
call BlzSetSpecialEffectPitch( e, pitch )
call s_tDI_s(0, tIS, "loopsRemaining")
endif
endif
if isAlive == true then
call TimerStart(t, period, false, function snakePart_follow)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
call RemoveLocation(uL)
call RemoveLocation(fUL)
call RemoveLocation(l)
call RemoveLocation(newL)
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set uL = null
set fUL = null
set ang = 0
set dist = 0
set fUF = 0
set isAlive = false
set period = 0
set l = null
set nF = 0
set dist2 = 0
set dist3 = 0
set currentX = 0
set currentY = 0
set currentZ = 0
set newL = null
set targetX = 0
set targetY = 0
set targetZ = 0
//set host = null
set distTargetSoft = 0
set speed = 0
set mod = 1
endfunction
function fx_snake_newPart takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer r = GetRandomInt(0, 255)
local integer g = GetRandomInt(0, 255)
local integer b = GetRandomInt(0, 255)
local real uF = GetUnitFacing(u)
local boolean isAlive = IsUnitAliveBJ(u)
local boolean fxActive = true
local real period = s_tDR(tIS, "period")
local location uL = GetUnitLoc(u)
local integer cPick = GetRandomInt(1,3)
local real dist = s_tDR(tIS, "dist")
local integer num = s_tDI(tIS, "count")
local location l = PolarProjectionBJ(uL, dist, uF + 180)
local timer t2 = CreateTimer()
local integer tI2 = GetHandleId(t2)
local string tIS2 = I2S(tI2)
local unit u2 = udg_lastSPart
local location uL2 = GetUnitLoc(udg_lastSPart)
local real z2 = 0
//MAIN PART
set num = num - 1
call s_tDI_s(num, tIS, "count")
//create unit here
call CreateNUnitsAtLoc( 1, 'nshf', Player(0), l, uF )
call SetUnitPathing( bj_lastCreatedUnit, false )
call SetUnitInvulnerable( bj_lastCreatedUnit, true )
//call ShowUnitHide( bj_lastCreatedUnit )
//call SetUnitVertexColorBJ( bj_lastCreatedUnit, 100, 100, 100, 100.00 )
call s_tDU_s(bj_lastCreatedUnit, tIS2, "unit")
call s_tDU_s(udg_lastSPart, tIS2, "follow_unit")
set udg_lastSPart = bj_lastCreatedUnit
call SetUnitFlyHeight( bj_lastCreatedUnit, 0.00, 0 )
call s_tDR_s(GetLocationX(uL2), tIS2, "target_X")
call s_tDR_s(GetLocationY(uL2), tIS2, "target_Y")
call s_tDR_s(BlzGetLocalUnitZ(u2) + GetUnitFlyHeight(u2), tIS2, "target_Z")
call s_tDR_s(300, tIS2, "speed")
call s_tDR_s(udg_gameloop_fx, tIS2, "period")
//create the overlapping effects here
call RemoveLocation(uL)
set uL = GetUnitLoc(bj_lastCreatedUnit)
call AddSpecialEffectLocBJ( uL, "Units\\Undead\\ScarabLvl3\\ScarabLvl3.mdl" )
call BlzSetSpecialEffectScale( bj_lastCreatedEffect, 2 )
call s_tDE_s(bj_lastCreatedEffect, tIS2, "fx")
call TimerStart(t2, 0, false, function snakePart_follow)
if num == 0 then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call TimerStart(t, period, false, function fx_snake_newPart)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set r = 0
set g = 0
set b = 0
set uF = 0
set isAlive = false
set fxActive = false
call RemoveLocation(uL)
set uL = null
set dist = 0
set num = 0
call RemoveLocation(l)
set l = null
set t2 = null
set tI2 = 0
set tIS2 = ""
call RemoveLocation(uL2)
set u2 = null
set uL2 = null
set z2 = 0
endfunction
function fx_snake_newPart_start takes unit u, integer num returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(0.25, tIS, "period")
call s_tDR_s(100, tIS, "dist")
call s_tDI_s(num, tIS, "count")
call TimerStart(t, 0, false, function fx_snake_newPart)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set num = 0
endfunction
function snake_headfx takes nothing returns nothing
local timer t = GetExpiredTimer()
local location l = GetUnitLoc(udg_snakehead)
local real currentX = GetLocationX(l)
local real currentY = GetLocationY(l)
local real currentZ = BlzGetLocalUnitZ(udg_snakehead) + GetUnitFlyHeight(udg_snakehead)
local unit u = udg_snakehead
local real targetX = s_uDR(u, "fly_targetX")
local real targetY = s_uDR(u, "fly_targetY")
local real targetZ = BlzGetLocalUnitZ(udg_snakehead) + s_uDR(u, "fly_targetZ")
local real speed = GetUnitMoveSpeed(u) * udg_gameloop_fx
local real mod = 1
local effect e = udg_snakeheadfx
local real uF = GetUnitFacing(u)
local real dist = 0
//MAIN PART
//=========================================================
if targetX >= currentX then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetX - currentX) > 0 then
if speed <= RAbsBJ(targetX - currentX) then
//call SetUnitX(u, currentX + (speed * mod))
else
//call SetUnitX(u, targetX)
endif
endif
if targetY >= currentY then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetY - currentY) > 0 then
if speed <= RAbsBJ(targetY - currentY) then
//call SetUnitY(u, currentY + (speed * mod))
else
//call SetUnitY(u, targetY)
endif
endif
if targetZ >= currentZ then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetZ - currentZ) > 0 then
if speed <= RAbsBJ(targetZ - currentZ) then
set currentZ = currentZ + (speed * mod)
else
set currentZ = targetZ
endif
endif
call SetUnitFlyHeight(u, currentZ - BlzGetLocalUnitZ(udg_snakehead), 0)
call BlzSetSpecialEffectX( udg_snakeheadfx, currentX)
call BlzSetSpecialEffectY( udg_snakeheadfx, currentY )
call BlzSetSpecialEffectZ( udg_snakeheadfx, currentZ )
call BlzSetSpecialEffectYaw( udg_snakeheadfx, Deg2Rad(uF))
//set dist = DistanceBetweenPoints(u, tL)
//set pitch = Deg2Rad(Atan2BJ((targetZ - currentZ), dist) * - 1)
//call BlzSetSpecialEffectPitch( udg_snakeheadfx, pitch )
//=========================================================
//call DisplayTextToForce(GetPlayersAll(), "currentZ: " + R2S(currentZ))
if t == null then
set t = CreateTimer()
endif
call TimerStart(t, udg_gameloop_fx, false,function snake_headfx)
//PLUG LEAKS
set t = null
call RemoveLocation(l)
set l = null
set currentX = 0
set currentY = 0
set currentZ = 0
set u = null
set targetX = 0
set targetY = 0
set targetZ = 0
set speed = 0
set mod = 0
set e = null
set uF = 0
set dist = 0
endfunction
function snake_init takes nothing returns nothing
local unit u = udg_snakehead
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local location uL = GetUnitLoc(u)
//MAIN PART
call s_uDR_s(GetLocationX(uL), uIS, "fly_targetX")
call s_uDR_s(GetLocationY(uL), uIS, "fly_targetY")
call s_uDR_s(BlzGetLocalUnitZ(u) + GetUnitFlyHeight(u), uIS, "fly_targetZ")
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
endfunction
function snake_headfx takes nothing returns nothing
local timer t = GetExpiredTimer()
local location l = GetUnitLoc(udg_snakehead)
local real currentX = GetLocationX(l)
local real currentY = GetLocationY(l)
local real currentZ = BlzGetLocalUnitZ(udg_snakehead) + GetUnitFlyHeight(udg_snakehead)
local unit u = udg_snakehead
local real targetX = s_uDR(u, "fly_targetX")
local real targetY = s_uDR(u, "fly_targetY")
local real targetZ = s_uDR(u, "fly_targetZ")
local real speed = GetUnitMoveSpeed(u)
local real mod = 1
local effect e = udg_snakehead_fx
//MAIN PART
call BlzSetSpecialEffectX( udg_snakeheadfx, currentX)
call BlzSetSpecialEffectY( udg_snakeheadfx, currentY )
call BlzSetSpecialEffectZ( udg_snakeheadfx, currentZ )
//=========================================================
if targetX >= currentX then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetX - currentX) > 0 then
if speed <= RAbsBJ(targetX - currentX) then
call BlzSetSpecialEffectX( e, currentX + (speed * mod))
else
call BlzSetSpecialEffectX( e, targetX)
endif
endif
if targetY >= currentY then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetY - currentY) > 0 then
if speed <= RAbsBJ(targetY - currentY) then
call BlzSetSpecialEffectY( e, currentY + (speed * mod))
else
call BlzSetSpecialEffectY( e, targetY)
endif
endif
if targetZ >= currentZ then
set mod = 1
else
set mod = -1
endif
if RAbsBJ(targetZ - currentZ) > 0 then
if speed <= RAbsBJ(targetZ - currentZ) then
call BlzSetSpecialEffectZ( e, currentZ + (speed * mod))
else
call BlzSetSpecialEffectZ( e, targetZ)
endif
endif
//=========================================================
//call DisplayTextToForce(GetPlayersAll(), "currentZ: " + R2S(currentZ))
if t == null then
set t = CreateTimer()
endif
call TimerStart(t, udg_gameloop_fx, false,function snake_headfx)
//PLUG LEAKS
set t = null
call RemoveLocation(l)
set l = null
set currentX = 0
set currentY = 0
set currentZ = 0
endfunction
function lilith_bounce takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer r = GetRandomInt(0, 255)
local integer g = GetRandomInt(0, 255)
local integer b = GetRandomInt(0, 255)
local real uF = GetUnitFacing(u)
local boolean isAlive = IsUnitAliveBJ(u)
local boolean fxActive = true
local real period = s_tDR(tIS, "period")
local location uL = GetUnitLoc(u)
local integer cPick = GetRandomInt(1,3)
//MAIN PART
if cPick == 1 then
set r = 255
set g = 0
set b = 0
elseif cPick == 2 then
set r = 0
set g = 255
set b = 0
elseif cPick == 3 then
set r = 0
set g = 0
set b = 255
endif
call AddSpecialEffectLocBJ( uL, "Units\\Creeps\\BansheeRanger\\BansheeRanger.mdl" )
call BlzSetSpecialEffectAlpha( GetLastCreatedEffectBJ(), 75 )
call BlzSetSpecialEffectColor( GetLastCreatedEffectBJ(), r, g, b )
call BlzSetSpecialEffectYaw( GetLastCreatedEffectBJ(), uF )
call BlzSetSpecialEffectColorByPlayer( GetLastCreatedEffectBJ(), Player(PLAYER_NEUTRAL_PASSIVE) )
call s_destroyEffect_main(bj_lastCreatedEffect, 3)
if isAlive == false then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call TimerStart(t, period, false, function fx_l_afterImage)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set r = 0
set g = 0
set b = 0
set uF = 0
set isAlive = false
set fxActive = false
call RemoveLocation(uL)
set uL = null
endfunction
function lilith_bounce_start takes nothing returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(0.25, tIS, "period")
call TimerStart(t, 0, false, function fx_l_afterImage)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function fx_l_afterImage takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer r = GetRandomInt(0, 255)
local integer g = GetRandomInt(0, 255)
local integer b = GetRandomInt(0, 255)
local real uF = GetUnitFacing(u)
local boolean isAlive = IsUnitAliveBJ(u)
local boolean fxActive = true
local real period = s_tDR(tIS, "period")
local location uL = GetUnitLoc(u)
local integer cPick = GetRandomInt(1,3)
//MAIN PART
if cPick == 1 then
set r = 255
set g = 0
set b = 0
elseif cPick == 2 then
set r = 0
set g = 255
set b = 0
elseif cPick == 3 then
set r = 0
set g = 0
set b = 255
endif
call AddSpecialEffectLocBJ( uL, "Units\\Creeps\\BansheeRanger\\BansheeRanger.mdl" )
call BlzSetSpecialEffectAlpha( GetLastCreatedEffectBJ(), 75 )
call BlzSetSpecialEffectColor( GetLastCreatedEffectBJ(), r, g, b )
call BlzSetSpecialEffectYaw( GetLastCreatedEffectBJ(), uF )
call BlzSetSpecialEffectColorByPlayer( GetLastCreatedEffectBJ(), Player(PLAYER_NEUTRAL_PASSIVE) )
call s_destroyEffect_main(bj_lastCreatedEffect, 3)
if isAlive == false then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call TimerStart(t, period, false, function fx_l_afterImage)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set r = 0
set g = 0
set b = 0
set uF = 0
set isAlive = false
set fxActive = false
call RemoveLocation(uL)
set uL = null
endfunction
function fx_l_afterImageStart takes unit u returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(0.25, tIS, "period")
call TimerStart(t, 0, false, function fx_l_afterImage)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function fx_l_afterImage takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local integer r = GetRandomInt(0, 255)
local integer g = GetRandomInt(0, 255)
local integer b = GetRandomInt(0, 255)
local real uF = GetUnitFacing(u)
local boolean isAlive = IsUnitAliveBJ(u)
local boolean fxActive = true
local real period = s_tDR(tIS, "period")
local location uL = GetUnitLoc(u)
local integer cPick = GetRandomInt(1,3)
//MAIN PART
if cPick == 1 then
set r = 255
set g = 0
set b = 0
elseif cPick == 2 then
set r = 0
set g = 255
set b = 0
elseif cPick == 3 then
set r = 0
set g = 0
set b = 255
endif
call AddSpecialEffectLocBJ( uL, "Units\\Creeps\\BansheeRanger\\BansheeRanger.mdl" )
call BlzSetSpecialEffectAlpha( GetLastCreatedEffectBJ(), 75 )
call BlzSetSpecialEffectColor( GetLastCreatedEffectBJ(), r, g, b )
call BlzSetSpecialEffectYaw( GetLastCreatedEffectBJ(), uF )
call BlzSetSpecialEffectColorByPlayer( GetLastCreatedEffectBJ(), Player(PLAYER_NEUTRAL_PASSIVE) )
call s_destroyEffect_main(bj_lastCreatedEffect, 3)
if isAlive == false then
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
else
call TimerStart(t, period, false, function fx_l_afterImage)
endif
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set r = 0
set g = 0
set b = 0
set uF = 0
set isAlive = false
set fxActive = false
call RemoveLocation(uL)
set uL = null
endfunction
function fx_l_afterImageStart takes unit u returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
call s_tDU_s(u, tIS, "unit")
call s_tDR_s(0.125, tIS, "period")
call TimerStart(t, 0, false, function fx_l_afterImage)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function objectCollision takes string oIDS returns string
local integer chunkI = 0 //we may introduce scale sizes, so we can use bounding sizes to make it more efficient too
local integer cubeX = R2I(x * 0.01)
local integer cubeY = R2I(y * 0.01)
local integer cubeZ = R2I(z * 0.01) //i think this should simplify to a useful block
local string oIDS = ""
local string str = ""
local integer sI = 0
local real hitboxSize = 0 //use this to get scale system
local integer scaleIC = LoadIntegerBJ(0, StringHash("scaleSize_indexCount"), udg_generalHash)
local integer scale = 1
local integer i = 1
local boolean found = false
local string iS = ""
local string sS = ""
//
local boolean projectile = false
//use abilities for attack, eat sheep etc
// can add abilities to "events" as well, so triggers will trigger upon "collision _event" attached to unit etc (they get run in place)
//MAIN PART
loop
exitwhen i > scaleIC or found == true
set iS = I2S(i)
set scale = S2I(LoadStringBJ(0, StringHash("hitbox_scaleSize_metaList" + iS), udg_generalHash)) //this returns name which happens to be scaleSize
set cubeX = cubeX / scale
set cubeY = cubeY / scale
set cubeZ = cubeZ / scale //this needs to be tested but i think its the right idea
set str = I2S(cubeX)
set str = str + "," + I2S(cubeY)
set str = str + "," + I2S(cubeZ)
set sS = I2S(scale)
set sI = StringHash("scale_" + sS + "_hitbox_" + str)
set udg_tempString = LoadStringBJ(0, sI, udg_UnitAI)
if LoadBooleanBJ(0, StringHash(udg_tempString), udg_UnitAI) == true then
set found = true
else
set udg_tempString = ""
endif
set i = i + 1
endloop
//PLUG LEAKS
set x = 0
set y = 0
set z = 0
set chunkI = 0
set cubeX = 0
set cubeY = 0
set cubeZ = 0
set oIDS = ""
set str = ""
set sI = 0
set hitboxSize = 0
set scaleIC = 0
set scale = 0
set i = 0
set found = true
//RETURNS
return udg_tempString
endfunction
function s_resortRefList takes string dls, integer index, hashtable ht returns nothing
local string iS = I2S(index)
local integer iC = LoadIntegerBJ(0, StringHash(dls + "_indexCount"), ht)
local string str = LoadStringBJ(0, StringHash(dls + "_" + iS), ht)
//MAIN PART
set iS = I2S(iC)
set str = LoadStringBJ(0, StringHash(dls + "_" + iS), ht)
call sAI_deleteDataTree(dls + "_" + iS, ht)
set iS = I2S(index)
call sAI_saveStringParameter(str, iS, dls, ht) //this should move the last place entry and replace this one that was deleted
//UPDATE OBJECT REF TRACKING
call sAI_saveStringParameter("objectRef_" + iS, "objectRef", str, udg_UnitAI) //str should be the object ids
call sAI_saveIntegerParameter(index, "objectRef", str, udg_UnitAI)
//i think should work?
// UPDATE THE INDEXCOUNT
set iC = iC - 1
call sAI_saveIntegerParameter(iC, "indexCount", dls, udg_UnitAI)
//PLUG LEAKS
set dls = ""
set index = 0
set ht = null
set iS = ""
set iC = 0
set str = ""
endfunction
function s_destroyObject takes string dls returns nothing
local string refDLS = LoadStringBJ(0, StringHashBJ(dls + "_objectRef"), udg_UnitAI)
local integer refI = LoadIntegerBJ(0, StringHashBJ(dls + "_objectRef_index"), udg_UnitAI)
//MAIN PART
call DestroyEffect(LoadEffectHandleBJ(0, StringHash(dls + "_model_main"), udg_UnitAI))
call sAI_deleteDataTree(dls, udg_UnitAI)
//call s_resortRefList(refDLS, refI, udg_UnitAI)
//PLUG LEAKS
set refDLS = ""
set refI = 0
endfunction
function idf_eatSheep takes nothing returns nothing
local string dls = LoadStringBJ(0, StringHash(udg_DragonIDS + "_detected_enemy"), udg_UnitAI)
local string name = LoadStringBJ(0, StringHash(dls), udg_UnitAI)
//MAIN PART
if dls != "" and dls != udg_testdls and name == "Flying Sheep" then
set udg_numSheep_Eaten = udg_numSheep_Eaten + 1
set udg_numSheep = udg_numSheep - 1
set udg_testdls = dls
call s_destroyObject(dls)
//call DisplayTextToForce(GetPlayersAll(), "Sheep Collected!")
//call DisplayTextToForce(GetPlayersAll(), "sheep dls: " + dls)
endif
call sAI_saveStringParameter("", "detected_enemy", udg_DragonIDS, udg_UnitAI)
//PLUG LEAKS
set dls = ""
set name = ""
endfunction
function s_playerDetectObjectFirst takes real range returns nothing
local integer i = 1
local integer iC = LoadIntegerBJ(0, StringHash("objectRef_indexCount"), udg_UnitAI)
local string iS = I2S(i)
local real pX = 0
local real pY = 0
local real pZ = 0
local real x = 0
local real y = 0
local real z = 0
local string dls = ""
local boolean found = false
//MAIN PART
set pX = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_x"), udg_UnitAI)
set pY = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_y"), udg_UnitAI)
set pZ = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_z"), udg_UnitAI)
loop
exitwhen i > iC or found == true
set iS = I2S(i)
set dls = LoadStringBJ(0, StringHash("objectRef_" + iS), udg_UnitAI)
set dls = "object_" + dls
//call DisplayTextToForce(GetPlayersAll(), "dls2: " + dls)
//call DisplayTextToForce(GetPlayersAll(), "dls2D: " + udg_DragonIDS)
set x = LoadRealBJ(0, StringHash(dls + "_position_x"), udg_UnitAI)
set y = LoadRealBJ(0, StringHash(dls + "_position_y"), udg_UnitAI)
set z = LoadRealBJ(0, StringHash(dls + "_position_z"), udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "iC: " + I2S(iC))
//call DisplayTextToForce(GetPlayersAll(), "i: " + I2S(i))
if ((RAbsBJ(x - pX) < range) and (RAbsBJ(y - pY) < range) and (RAbsBJ(z - pZ) < range)) and dls != udg_DragonIDS then
set found = true
//call DisplayTextToForce(GetPlayersAll(), "Pxyz: " + R2S(pX) + R2S(pY) + R2S(pZ) )
//call DisplayTextToForce(GetPlayersAll(), "xyz: " + R2S(x) + R2S(y) + R2S(z) )
else
set dls = ""
endif
set i = i + 1
endloop
call sAI_saveStringParameter(dls, "detected_enemy", udg_DragonIDS, udg_UnitAI) // a soft collision
//PLUG LEAKS
set range = 0
set i = 1
set iC = LoadIntegerBJ(0, StringHash("objectRef_indexCount"), udg_UnitAI)
set iS = I2S(i)
set pX = 0
set pY = 0
set pZ = 0
set x = 0
set y = 0
set z = 0
set dls = ""
set found = false
//RETURNS
endfunction
function s_updateObject takes string dls returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local effect model_main = LoadEffectHandleBJ(0, StringHash(dls + "_model_main"), udg_UnitAI)
local real x = LoadRealBJ(0, StringHash(dls + "_position_x"), udg_UnitAI)
local real y = LoadRealBJ(0, StringHash(dls + "_position_y"), udg_UnitAI)
local real z = LoadRealBJ(0, StringHash(dls + "_position_z"), udg_UnitAI)
local real yaw = LoadRealBJ(0, StringHash(dls + "_orientation_yaw"), udg_UnitAI)
local real pitch = LoadRealBJ(0, StringHash(dls + "_orientation_pitch"), udg_UnitAI)
local real pX = 0
local real pY = 0
local real pZ = 0
local real dist = 0
local real distMax = 0
local effect e = model_main
local real mX = LoadRealBJ(0,StringHash(dls + "_movement_x"), udg_UnitAI)
local real mY = LoadRealBJ(0,StringHash(dls + "_movement_y"), udg_UnitAI)
local real mZ = LoadRealBJ(0,StringHash(dls + "_movement_z"), udg_UnitAI)
local real nX = 0
local real nY = 0
local real nZ = 0
local boolean move = LoadBooleanBJ(0,StringHash(dls + "_move"), udg_UnitAI)
//MAIN PART
set nX = x + mX
set nY = y + mY
set nZ = z + mZ
//RENDER OBJECT
call BlzSetSpecialEffectYaw( model_main, Deg2Rad(yaw) )
call BlzSetSpecialEffectPitch( model_main, Deg2Rad(pitch) )
call sAI_saveRealParameter(nX, "position_x", dls, udg_UnitAI)
call sAI_saveRealParameter(nY, "position_y", dls, udg_UnitAI)
call sAI_saveRealParameter(nZ, "position_z", dls, udg_UnitAI)
// to render anything on map, you subtract player's "position" in the infinite space
set pX = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_x"), udg_UnitAI)
set pY = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_y"), udg_UnitAI)
set pZ = LoadRealBJ(0,StringHash(udg_DragonIDS + "_position_z"), udg_UnitAI)
if RAbsBJ(nX - pX) < 2500 and RAbsBJ(nY - pY) < 2500 and RAbsBJ(nZ - pZ) < 2500 then
//call BlzSetSpecialEffectAlpha( GetLastCreatedEffectBJ(), 255 )
else
//call BlzSetSpecialEffectAlpha( GetLastCreatedEffectBJ(), 0 )
endif
call BlzSetSpecialEffectX( e, nX - pX)
call BlzSetSpecialEffectY( e, nY - pY)
call BlzSetSpecialEffectZ( e, nZ - pZ)
//call BlzSetSpecialEffectHeight( e, nZ - pZ )
if dls == udg_DragonIDS then
//call BlzSetSpecialEffectHeight( e, 0 )
//call DisplayTextToForce(GetPlayersAll(), "dragon updated")
//call DisplayTextToForce(GetPlayersAll(), "dragon yaw: " + R2S(yaw))
//call DisplayTextToForce(GetPlayersAll(), "posX: " + R2S(pX))
//call DisplayTextToForce(GetPlayersAll(), "posY: " + R2S(pY))
//call DisplayTextToForce(GetPlayersAll(), "posZ: " + R2S(pZ - pZ))
else
//call DisplayTextToForce(GetPlayersAll(), "posX: " + R2S(nX - pX))
//call DisplayTextToForce(GetPlayersAll(), "posY: " + R2S(nY - pY))
//call DisplayTextToForce(GetPlayersAll(), "other dls: " + dls)
//call DisplayTextToForce(GetPlayersAll(), "other posZ: " + R2S(nZ - pZ))
endif
//PLUG LEAKS
set model_main = null
set t = null
set tI = 0
set tIS = ""
set x = 0
set y = 0
set z = 0
set yaw = 0
set pitch = 0
set pX = 0
set pY = 0
set pZ = 0
set dist = 0
set distMax = 0
set e = null
endfunction
function s_updateAllObjects takes nothing returns nothing
local string dls = ""
local integer i = 1
local integer iC = LoadIntegerBJ(0, StringHash("objectRef_indexCount"), udg_UnitAI)
local string iS = ""
local integer sI = 0
//MAIN PART
//call DisplayTextToForce(GetPlayersAll(), "objectRef iC: " + I2S(iC))
loop
exitwhen i > iC
set iS = I2S(i)
set sI = StringHash("objectRef_" + iS)
set dls = LoadStringBJ(0, sI, udg_UnitAI)
set dls = "object_" + dls
//call DisplayTextToForce(GetPlayersAll(), "dls: " + dls)
call s_updateObject(dls)
set i = i + 1
endloop
//PLUG LEAKS
set dls = ""
set i = 0
set iC = 0
set iS = ""
endfunction
function idf_addAimVector takes string object_dls, real yaw, real pitch returns nothing
local real cYaw = LoadRealBJ(0, StringHash(object_dls + "_orientation_yaw"), udg_UnitAI)
local real cPitch = LoadRealBJ(0, StringHash(object_dls + "_orientation_pitch"), udg_UnitAI)
//MAIN PART
set cYaw = cYaw + yaw
set cPitch = cPitch + pitch
if cYaw > 360 then
set cYaw = cYaw - 360
endif
if cPitch > 360 then
set cPitch = cPitch - 360
endif
call sAI_saveRealParameter(cYaw, "orientation_yaw", object_dls, udg_UnitAI)
call sAI_saveRealParameter(cPitch, "orientation_pitch", object_dls, udg_UnitAI)
//call DisplayTextToForce(GetPlayersAll(), "yaw: " + R2S(cYaw))
//PLUG LEAKS
set object_dls = ""
set yaw = 0
set pitch = 0
set cYaw = 0
set cPitch = 0
endfunction
function idf_changeMoveVector takes string object_dls, real yaw, real pitch returns nothing
local real x = LoadRealBJ(0, StringHash(object_dls + "_position_x"), udg_UnitAI)
local real y = LoadRealBJ(0, StringHash(object_dls + "_position_y"), udg_UnitAI)
local real z = LoadRealBJ(0, StringHash(object_dls + "_position_z"), udg_UnitAI)
local location l = Location(x,y)
local location l2 = null
local real dist = 0
local boolean move = LoadBooleanBJ(0,StringHash(object_dls + "_move"), udg_UnitAI)
local real speed = 300 * udg_gameloop_fx
//MAIN PART
set pitch = pitch * -1
set yaw = yaw
set z = (Sin(Deg2Rad(pitch)) * speed)
set dist = RAbsBJ(Cos(Deg2Rad(pitch)) * speed)
set x = (Cos(Deg2Rad(yaw)) * dist)
set y = (Sin(Deg2Rad(yaw)) * dist)
if move == true then
call sAI_saveRealParameter(x, "movement_x", object_dls, udg_UnitAI)
call sAI_saveRealParameter(y, "movement_y", object_dls, udg_UnitAI)
call sAI_saveRealParameter(z, "movement_z", object_dls, udg_UnitAI)
else
call sAI_saveRealParameter(0, "movement_x", object_dls, udg_UnitAI)
call sAI_saveRealParameter(0, "movement_y", object_dls, udg_UnitAI)
call sAI_saveRealParameter(0, "movement_z", object_dls, udg_UnitAI)
endif
//call DisplayTextToForce(GetPlayersAll(), "yaw: " + R2S(yaw))
//call DisplayTextToForce(GetPlayersAll(), "pitch: " + R2S(pitch))
//call DisplayTextToForce(GetPlayersAll(), "x: " + R2S(x))
//call DisplayTextToForce(GetPlayersAll(), "y: " + R2S(y))
//call DisplayTextToForce(GetPlayersAll(), "z: " + R2S(z))
//PLUG LEAKS
set object_dls = ""
set yaw = 0
set pitch = 0
set x = 0
set y = 0
set z = 0
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
set dist = 0
endfunction
function updateHitbox takes string oIDS, real pX, real pY, real pZ, real x, real y, real z returns nothing
local integer chunkI = 0 //we may introduce scale sizes, so we can use bounding sizes to make it more efficient too
local integer cubeX = 0
local integer cubeY = 0
local integer cubeZ = 0 //i think this should simplify to a useful block
local string str = ""
local integer sI = 0
local integer hitboxSize = LoadIntegerBJ(0, StringHash(oIDS + "_hitbox_scale"), udg_UnitAI)
local string sS = I2S(hitboxSize)
//MAIN PART
set cubeX = R2I(pX * 0.01)
set cubeY = R2I(pY * 0.01)
set cubeZ = R2I(pZ * 0.01)
set str = I2S(cubeX)
set str = str + "," + I2S(cubeY)
set str = str + "," + I2S(cubeZ)
call sAI_saveStringParameter("", str, "scale_" + sS + "_hitbox", udg_UnitAI)
set cubeX = R2I(x * 0.01)
set cubeY = R2I(y * 0.01)
set cubeZ = R2I(z * 0.01)
set str = I2S(cubeX)
set str = str + "," + I2S(cubeY)
set str = str + "," + I2S(cubeZ)
call sAI_saveStringParameter(oIDS, str, "scale_" + sS + "_hitbox", udg_UnitAI)
//PLUG LEAKS
set x = 0
set y = 0
set z = 0
set pX = 0
set pY = 0
set pZ = 0
set chunkI = 0
set cubeX = 0
set cubeY = 0
set cubeZ = 0
set oIDS = ""
set str = ""
set sI = 0
set hitboxSize = 0
set sS = ""
//RETURNS
endfunction
function hitboxReturn takes real x, real y, real z returns string
local integer chunkI = 0 //we may introduce scale sizes, so we can use bounding sizes to make it more efficient too
local integer cubeX = R2I(x * 0.01)
local integer cubeY = R2I(y * 0.01)
local integer cubeZ = R2I(z * 0.01) //i think this should simplify to a useful block
local string oIDS = ""
local string str = ""
local integer sI = 0
local real hitboxSize = 0 //use this to get scale system
local integer scaleIC = LoadIntegerBJ(0, StringHash("scaleSize_indexCount"), udg_generalHash)
local integer scale = 1
local integer i = 1
local boolean found = false
local string iS = ""
local string sS = ""
//MAIN PART
loop
exitwhen i > scaleIC or found == true
set iS = I2S(i)
set scale = S2I(LoadStringBJ(0, StringHash("hitbox_scaleSize_metaList" + iS), udg_generalHash)) //this returns name which happens to be scaleSize
set cubeX = cubeX / scale
set cubeY = cubeY / scale
set cubeZ = cubeZ / scale //this needs to be tested but i think its the right idea
set str = I2S(cubeX)
set str = str + "," + I2S(cubeY)
set str = str + "," + I2S(cubeZ)
set sS = I2S(scale)
set sI = StringHash("scale_" + sS + "_hitbox_" + str)
set udg_tempString = LoadStringBJ(0, sI, udg_UnitAI)
if LoadBooleanBJ(0, StringHash(udg_tempString), udg_UnitAI) == true then
set found = true
else
set udg_tempString = ""
endif
set i = i + 1
endloop
//PLUG LEAKS
set x = 0
set y = 0
set z = 0
set chunkI = 0
set cubeX = 0
set cubeY = 0
set cubeZ = 0
set oIDS = ""
set str = ""
set sI = 0
set hitboxSize = 0
set scaleIC = 0
set scale = 0
set i = 0
set found = true
//RETURNS
return udg_tempString
endfunction
function hitbox_addScale takes integer scale returns nothing
local string iS = I2S(scale)
local integer sI = StringHash("hitbox_scaleSize_" + iS)
//MAIN PART
call sAI_saveBooleanParameter(true, iS, "hitbox_scaleSize", udg_generalHash)
//PLUG LEAKS
set scale = 0
set iS = ""
set sI = 0
endfunction
function playerControl takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local real modSpeed = udg_gameloop_fx
local real speed = 100
local string dls = udg_DragonIDS
//TRANFORM MOVEMENT
local real moveX = 0
local real moveY = 0
local real moveZ = 0
local real yaw = LoadRealBJ(0, StringHash(dls + "_orientation_yaw"), udg_UnitAI)
local real pitch = LoadRealBJ(0, StringHash(dls + "_orientation_pitch"), udg_UnitAI)
//MAIN PART
if modSpeed == 0 then
set modSpeed = 0.125
endif
set speed = speed * modSpeed
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
endif
if udg_HoldingDown == true then
call idf_addAimVector(dls, 0, speed * -1) // pitch
endif
if udg_HoldingUp == true then
call idf_addAimVector(dls, 0, speed)
endif
if udg_HoldingLeft == true then
call idf_addAimVector(dls, speed, 0) //yaw
endif
if udg_HoldingRight == true then
call idf_addAimVector(dls, speed * -1, 0)
endif
call idf_changeMoveVector(dls, yaw, pitch)
if udg_Move == true then
call sAI_saveBooleanParameter(true, "move", dls, udg_UnitAI)
else
call sAI_saveBooleanParameter(false, "move", dls, udg_UnitAI)
endif
call TimerStart(t, modSpeed, false, function playerControl)
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set modSpeed = 0
set speed = 0
set dls = ""
set moveX = 0
set moveY = 0
set moveZ = 0
set yaw = 0
set pitch = 0
endfunction
function pf_monsterTypes_init takes nothing returns nothing
//MAIN PART
set udg_skeletonW = 'uske'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_skeletonA = 'uskm'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_giantSkeleton = 'nskg'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_battlegolem = 'narg'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_mudgolem = 'ngrk'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_cryptfiend = 'ucry'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_spider1 = 'nscb'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_spider2 = 'nspr'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_felhound1 = 'npfl'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_demon1 = 'nfgu'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_iceTroll = 'nitr'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_iceTrollP = 'nitp'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_hydra = 'nhyp'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_portal = 'hprt'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
set udg_portal = 'n023'
set udg_monsterTypeCount = udg_monsterTypeCount + 1
//PLUG LEAKS
endfunction
function hom_createPortal takes location l returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = null
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
//MAIN PART
//call pf_magicStatue(bj_lastCreatedUnit)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
endfunction
function hom_createMonster takes location l returns nothing
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local group g = CreateGroup()
local integer iC = udg_monsterTypeCount
local integer i = GetRandomInt(1, iC)
local integer i2 = 1
local integer uTI = 0
local integer count = 0
//MAIN PART
set count = 1
if i == i2 then
set uTI = udg_skeletonW
set count = 4
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_skeletonA
set count = 4
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_giantSkeleton
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_battlegolem
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_mudgolem
set count = 2
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_cryptfiend
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_spider1
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_spider2
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_felhound1
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_demon1
set count = 2
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_iceTroll
set count = 2
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_iceTrollP
endif
set i2 = i2 + 1
if i == i2 then
set uTI = udg_hydra
set count = GetRandomInt(0, 1)
endif
set i2 = i2 + 1
call CreateNUnitsAtLoc( count, uTI, Player(3), l, 0)
//PLUG LEAKS
call DestroyGroup(g)
set u = null
set uI = 0
set uIS = ""
set g = null
set i = 0
set i2 = 0
call RemoveLocation(l)
set l = null
set uTI = 0
set count = 0
endfunction
function hom_generateMonsters takes nothing returns nothing
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local group g = CreateGroup()
local integer i = 1
//
local location l = null
local unit eU = null
//MAIN PART
call GroupAddGroup(udg_Portals, g)
set eU = FirstOfGroup(g)
loop
exitwhen eU == null
set l = GetUnitLoc(eU)
call hom_createMonster(l)
//
call RemoveLocation(l)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//PLUG LEAKS
call DestroyGroup(g)
set u = null
set uI = 0
set uIS = ""
set g = null
set i = 0
set l = null //will be removed in other function
set eU = null
endfunction
function hom_generatePortals takes nothing returns nothing
local unit u = udg_DarkRangerLilith
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local group g = CreateGroup()
local integer i = 1
local location l = null
local unit eU = null
//MAIN PART
call GroupAddGroup(udg_MagicStatues, g)
set eU = FirstOfGroup(g)
loop
exitwhen eU == null
set l = GetUnitLoc(eU)
call hom_createPortal(l)
call RemoveLocation(l)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//PLUG LEAKS
call DestroyGroup(g)
set u = null
set uI = 0
set uIS = ""
set g = null
set i = 0
set l = null
set eU = null
set l = null
set eU = null
endfunction
function zT_changeSpeeds takes nothing returns nothing
local group g = CreateGroup()
local real dist = 0
local unit eU = null
local location l = GetUnitLoc(udg_CineKael)
local location uL = null
local real kaelDist = DistanceBetweenPoints(l, udg_zT_endLoc)
//MAIN PART
call GroupAddGroup(udg_zT_unitGroup, g)
set eU = FirstOfGroup(g)
loop
exitwhen (eU == null)
set uL = GetUnitLoc(eU)
set dist = DistanceBetweenPoints(uL, udg_zT_endLoc)
if (eU == udg_EarthKing) then
if (dist < kaelDist + 800) then
call SetUnitMoveSpeed( eU, udg_zT_speed * 0.7 )
elseif (dist > kaelDist + 1200) then
call SetUnitMoveSpeed( eU, udg_zT_speed * 2 )
else
call SetUnitMoveSpeed( eU, udg_zT_speed)
endif
elseif (eU != udg_CineKael) then
if (dist > kaelDist + 800) then
call SetUnitMoveSpeed( eU, udg_zT_speed * 2 )
else
call SetUnitMoveSpeed( eU, udg_zT_speed)
endif
endif
call RemoveLocation(uL)
call GroupRemoveUnit(g, eU)
set eU = FirstOfGroup(g)
endloop
//PLUG LEAKS
call DestroyGroup(g)
set g = null
set uL = null
call RemoveLocation(l)
set l = null
set eU = null
set dist = 0
endfunction
function camShake_expires takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local integer pI = s_tDI(tIS, "playerId")
//MAIN PART
call CameraClearNoiseForPlayer( Player(pI) )
call sAI_deleteDataTree(tIS, udg_tempHash)
//PLUG LEAKS
call DestroyTimer(t)
set t = null
set tIS = ""
set pI = 0
endfunction
function camShake takes player p , real mag, real duration returns nothing
local timer t = CreateTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
//MAIN PART
call CameraSetEQNoiseForPlayer( p, mag )
call s_tDI_s(GetConvertedPlayerId(p), tIS, "playerId")
call TimerStart(t, duration, false, function camShake_expires)
//PLUG LEAKS
set p = null
set mag = 0
set duration = 0
set t = null
set tI = 0
set tIS = ""
endfunction
function c_introRocks takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local real duration = s_tDR(tIS, "duration")
local real time = 3.25
//MAIN PART
if (udg_zT_on == true) then
call s_eK_flingRocks()
call TimerStart (t, time, false, function c_introRocks)
else
call DestroyTimer(t)
call sAI_deleteDataTree(tIS, udg_tempHash)
endif
//PLUG LEAKS
set t = null
set tIS = ""
set duration = 0
set time = 0
endfunction
function c_introStampede takes integer pI, real mag, real duration returns nothing
local timer t = CreateTimer()
local string tIS = I2S(GetHandleId(t))
//MAIN PART
call s_tDI_s(pI, tIS, "playerId")
call s_tDR_s(duration, tIS, "duration")
call s_tDR_s(mag, tIS, "magnitude")
call TimerStart (CreateTimer(), 2.5, false, function c_introRocks)
//PLUG LEAKS
set t = null
set tIS = ""
set mag = 0
set duration = 0
endfunction
function updatePlayerCamera takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local string dls = udg_DragonIDS
local real x = LoadRealBJ(0, StringHash(dls + "_position_x"), udg_UnitAI)
local real y = LoadRealBJ(0, StringHash(dls + "_position_y"), udg_UnitAI)
local real z = LoadRealBJ(0, StringHash(dls + "_position_z"), udg_UnitAI)
local real yaw = LoadRealBJ(0, StringHash(dls + "_orientation_yaw"), udg_UnitAI)
local real pitch = LoadRealBJ(0, StringHash(dls + "_orientation_pitch"), udg_UnitAI)
//MAIN PART
//call CameraSetupApplyForPlayer( true, gg_cam_Dragon_Cam, Player(0), 0 )
call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_FARZ, 15000.00, 0 )
call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ROTATION, yaw, 0 )
call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ANGLE_OF_ATTACK, (pitch * -1) + 0 , 0 )
call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ZOFFSET, 50, 0 )
call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_TARGET_DISTANCE, 150.00, 0 )
set udg_tempLoc = Location(0,0)
call PanCameraToTimedLocForPlayer( Player(0), udg_tempLoc, 0 )
call RemoveLocation(udg_tempLoc)
//call TimerStart(t, udg_gameloop_fx * 0.5, false, function updatePlayerCamera)
//PLUG LEAKS
set t = null
set tI = 0
set tIS = ""
set dls = ""
set x = 0
set y = 0
set z = 0
set yaw = 0
set pitch = 0
endfunction
function zT_cycle takes nothing returns nothing
local timer t = GetExpiredTimer()
local string tIS = I2S(GetHandleId(t))
local unit u = null
local string uIS = I2S(GetHandleId(u))
local location l = GetCameraTargetPositionLoc()
local group g = CreateGroup()
local group g2 = null
local location uL = GetUnitLoc(udg_DarkRangerLilith)
local location l1 = udg_zT_startLoc
local location l2 = udg_zT_endLoc
local location nL = null
local real ang = 0
local real offset = 0
local real x = 0
local real y = 0
local timer t2 = CreateTimer()
local timer t3 = CreateTimer()
local real distCheck = 3500
local real distMove = 2500
local boolean moveReversed = false
local real distFromEnd = 0
local real distFromStart = 0
local boolean move = false
//
//MAIN PART
//====================================================
set udg_zT_dist = distMove
set udg_zT_startLoc = udg_zT_wallStart[0]
set udg_zT_endLoc = udg_zT_wallEnd[0]
set distFromEnd = DistanceBetweenPoints(udg_zT_endLoc, uL)
set distFromStart = DistanceBetweenPoints(udg_zT_startLoc, uL)
if distFromStart > distCheck then
set udg_zTDistCovered[0] = udg_zTDistCovered[0] - distMove
set udg_zTDistCovered[1] = udg_zTDistCovered[1] - distMove
if udg_zTDistMin[0] < 0 then
set udg_zTDistMin[0] = 0
endif
if udg_zTDistMin[1] < 0 then
set udg_zTDistMin[1] = 0
endif
set udg_zTDistToStart = udg_zTDistToStart - distMove
set move = true
set l1 = udg_zT_startLoc
set l2 = udg_zT_endLoc
set udg_zT_ang = 315
elseif distFromEnd > distCheck then
set udg_zTDistCovered[0] = udg_zTDistCovered[0] + distMove
set udg_zTDistCovered[1] = udg_zTDistCovered[1] + distMove
if udg_zTDistCovered[0] > distCheck then
set udg_zTDistCovered[0] = distCheck
endif
if udg_zTDistCovered[1] > distCheck then
set udg_zTDistCovered[1] = distCheck
endif
set udg_zTDistToStart = udg_zTDistToStart + distMove
set move = true
set moveReversed = true
set l2 = udg_zT_startLoc
set l1 = udg_zT_endLoc
set udg_zT_ang = 135
endif
//=============================
//===========================================================================
//
//===========================================================================
//call GroupAddUnit(g, udg_Dragon)
//call GroupAddGroup(udg_zT_unitGroup, g)
//set u = FirstOfGroup(g)
if udg_zT_on == true then
set udg_zT_dist = distMove
//move gardens
//===========================================================================
//QUEUE TRIGGERS HERE
//===========================================================================
//call s_updateAllObjects()
call QueuedTriggerAddBJ( gg_trg_Update_All_Objects, false)
call QueuedTriggerAddBJ( gg_trg_Update_Camera, false)
call QueuedTriggerAddBJ( gg_trg_Player_Detection, false)
call QueuedTriggerAddBJ( gg_trg_Eat_Sheep, false)
//===========================================================================
//
//===========================================================================
endif
if (udg_zT_on == false) then
//call DisplayTextToForce(GetPlayersAll(), "loop ended")
//call DestroyTimer(t)
else
endif
call TimerStart(t, udg_gameloop_fx, false, function zT_cycle) // player will be able to set fps, 60 fps is quite nice
//call DisplayTextToForce(GetPlayersAll(), "loop")
//PLUG LEAKS
call RemoveLocation(l)
set l = null
set l1 = null
set l2 = null
set nL = null
set uL = null
call DestroyGroup(g)
set g = null
set g2 = null
set t = null
set u = null
set uIS = ""
set tIS = ""
set ang = 0
set offset = 0
set x = 0
set y = 0
set t2 = null
set t3 = null
set distMove = 0
set distCheck = 0
set moveReversed = false
set distFromEnd = 0
set distFromStart = 0
set uL = null
set move = false
endfunction
function zT_init takes nothing returns nothing
//MAIN PART
set udg_zT_wallStart[0] = null //GetRectCenter(gg_rct_Endless_Hall_01x02a)
set udg_zT_wallEnd[0] = null //GetRectCenter(gg_rct_Endless_Hall_01x02b)
set udg_zT_wallStart[1] = null //GetRectCenter(gg_rct_Endless_Hall_01x01a)
set udg_zT_wallEnd[1] = null //GetRectCenter(gg_rct_Endless_Hall_01x01b)
set udg_zTMaxDist = 0 //DistanceBetweenPoints(udg_zT_wallStart[0], udg_zT_wallEnd[0])
set udg_zTDistCovered[0] = 0 //DistanceBetweenPoints(udg_zT_wallStart[0], udg_zT_wallEnd[0])
set udg_zTDistCovered[1] = 0 //DistanceBetweenPoints(udg_zT_wallStart[1], udg_zT_wallEnd[1])
//call TriggerExecute(gg_trg_zT_Cam_Track_Dragon)
set udg_zT_on = true
call TimerStart(CreateTimer(), 0, false, function zT_cycle)
//call TimerStart(CreateTimer(), udg_gameloop_fx * 0.5, false, function updatePlayerCamera)
//PLUG LEAKS
endfunction
function s_createObjectClass takes string name returns nothing
local string idS = ""
//
local string eS = LoadStringBJ(0, StringHash(type_dls + "_modelString_main")
local effect e = null
local location l = Location(x, y)
//MAIN PART
call sAI_addStringParameter(name, "object", "", udg_UnitAI)
set idS = udg_lastPLS
call AddSpecialEffectLocBJ( l, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call sAI_saveEffectParameter(e, "model_main", idS, udg_UnitAI)
call sAI_saveRealParameter(x, "pos_x", idS, udg_UnitAI)
call sAI_saveRealParameter(y, "pos_y", idS, udg_UnitAI)
call sAI_saveRealParameter(z, "pos_z", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "orientation_yaw", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "orientation_pitch", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "move_x", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "move_y", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "move_z", idS, udg_UnitAI)
// then copy the rest from precreation parent data
//PLUG LEAKS
set type_dls = ""
set name = ""
set x = 0
set y = 0
set z = 0
set idS = ""
endfunction
function pf_oc_bdragonwhelp takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Dragon Whelp", "bdragonwhelp", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("units\\creeps\\BronzeDragonWelp\\BronzeDragonWelp.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function pf_oc_bdragon takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Bronze Dragon", "bDragon", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("units\\creeps\\BronzeDragon\\BronzeDragon.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function pf_oc_bdrake takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Drake", "bronzedrake1", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("Units\\Creeps\\BronzeDrake\\BronzeDrake.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function pf_oc_bdragonroost takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Bronze Dragon Roosting", "bronzedragonroosting1", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("buildings\\other\\DragonRoost\\DragonRoost.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function pf_oc_rockpillar1 takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Rock Pillar", "rockpillar", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("Doodads\\Barrens\\Rocks\\RockPillar\\RockPillar1.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function pf_oc_flyingsheep takes nothing returns nothing
local string str = ""
//MAIN PART
call sAI_addStringParameter("Flying Sheep", "flyingsheep", "object_class", udg_generalHash)
set str = udg_lastPLS
call sAI_saveStringParameter("units\\critters\\FlyingSheep\\FlyingSheep.mdl", "modelString_main", str, udg_generalHash)
//PLUG LEAKS
set str = ""
endfunction
function s_initObjectClasses takes nothing returns nothing
call pf_oc_bdragonwhelp()
call pf_oc_bdragon()
call pf_oc_bdrake()
call pf_oc_bdragonroost()
call pf_oc_rockpillar1()
call pf_oc_flyingsheep()
endfunction
function idf_createObject takes string type_dls, string name, real x, real y, real z returns nothing
local string idS = ""
local string eS = LoadStringBJ(0, StringHash(type_dls + "_modelString_main"), udg_generalHash)
local effect e = null
local location l = Location(x, y)
local string iS = ""
local integer refI = 0
//MAIN PART
set udg_objectI = udg_objectI + 1
set iS = I2S(udg_objectI)
call sAI_addStringParameter(iS, "", "objectRef", udg_UnitAI) //ref to handle data (a list that can be sorted easily)
set refI = LoadIntegerBJ(0, StringHash("objectRef_indexCount"), udg_UnitAI)
call sAI_saveStringParameter(name, iS, "object", udg_UnitAI) //actual data
set idS = udg_lastPLS
set udg_lastCreatedObjectIDS = udg_lastPLS
//============================================
//ADD TRACKBACK
call sAI_saveStringParameter("objectRef_" + iS, "objectRef", idS, udg_UnitAI)
call sAI_saveIntegerParameter(refI, "objectRef", idS, udg_UnitAI)
//============================================
call AddSpecialEffectLocBJ( l, eS )
//call DisplayTextToForce(GetPlayersAll(), "ids: " + idS)
set e = bj_lastCreatedEffect
call BlzSetSpecialEffectHeight( e, z )
//call BlzSetSpecialEffectZ( e, z)
call sAI_saveEffectParameter(e, "model_main", idS, udg_UnitAI)
call sAI_saveIntegerParameter(1, "hitbox_scale", idS, udg_UnitAI)
call hitbox_addScale(1)
call sAI_saveRealParameter(x, "position_x", idS, udg_UnitAI)
call sAI_saveRealParameter(y, "position_y", idS, udg_UnitAI)
call sAI_saveRealParameter(z, "position_z", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "orientation_yaw", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "orientation_pitch", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "movement_x", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "movement_y", idS, udg_UnitAI)
call sAI_saveRealParameter(0, "movement_z", idS, udg_UnitAI)
// then copy the rest from precreation parent data
//PLUG LEAKS
set type_dls = ""
set name = ""
set x = 0
set y = 0
set z = 0
set idS = ""
set eS = ""
set e = null
call RemoveLocation(l)
set l = null
set iS = ""
set refI = 0
endfunction
//does an attach method on inventory units, no rotation
//mules follow, vaults float attached
function ab_inventoryAttach takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tI = GetHandleId(t)
local string tIS = I2S(tI)
local unit u = s_tDU(tIS, "unit")
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local string abStr = s_tDS(tIS, "abilityDLS") //this ability is preset to the attachments, not host
local unit host = LoadUnitHandleBJ(0, StringHash(abStr + "_host"), udg_UnitAI)
local real a = s_tDR(tIS, "angle")
local real dist = s_tDR(tIS, "dist")
local location l = null
//MAIN PART
if t == null then
set t = CreateTimer()
set tI = GetHandleId(t)
set tIS = I2S(tI)
endif
if abStr == "" then
set abStr = s_tDS(tIS, "abilityDLS")
endif
if u == null then
set u = udg_ABUnit
set uI = GetHandleId(u)
set uIS = I2S(uI)
call s_tDU_s(u, tIS, "unit")
endif
set host = LoadUnitHandleBJ(0, StringHash(abStr + "_host"), udg_UnitAI)
set a = LoadRealBJ(0, StringHash(abStr + "_angle"), udg_UnitAI)
set dist = LoadRealBJ(0, StringHash(abStr + "_dist"), udg_UnitAI)
set host = LoadUnitHandleBJ(0, StringHash(abStr + "_host"), udg_UnitAI)
call TimerStart(t, udg_gameloop_fx, false, function ab_inventoryAttach)
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set t = null
set tI = 0
set tIS = ""
set abStr = ""
set host = null
set a = 0
set dist = 0
call RemoveLocation(l)
set l = null
endfunction
function ab_inventoryMove takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit iU = null
local item iI = null
local integer uTI = 0
local integer iTI = 0
local integer i = 1
local integer iC = 0
local string iS = ""
local location l = null
local integer iUI = 0
local string iUIS = ""
local location l2 = null
local location l3 = null
local real a = 0
//MAIN PART
set iC = s_uDI(u, "inventory_unit_indexCount")
set l = GetUnitLoc(u)
loop
exitwhen i > iC
set iS = I2S(i)
set iU = s_uDU(u, "inventory_unit_" + iS)
set l2 = GetUnitLoc(iU)
set a = AngleBetweenPoints(l, l2)
set l3 = PolarProjectionBJ(l, 75, a)
call IssuePointOrderLocBJ(iU, "move", l)
set iUI = GetHandleId(iU)
set iUIS = I2S(iUI)
call s_uDB_s(true, iUIS, "ability_inventory_active")
set i = i + 1
endloop
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set iU = null
set iI = null
set uTI = 0
set iTI = 0
set i = 1
set iC = 0
set iS = ""
call RemoveLocation(l)
set l = null
call RemoveLocation(l2)
set l2 = null
call RemoveLocation(l3)
set l3 = null
set a = 0
set iUI = 0
set iUIS = ""
endfunction
function ab_summonInventory takes nothing returns nothing
local unit u = udg_ABUnit
local integer uI = GetHandleId(u)
local string uIS = I2S(uI)
local unit iU = null
local item iI = null
local integer uTI = 0
local integer iTI = 0
local integer i = 1
local integer iC = 0
local string iS = ""
local location l = null
local integer iUI = 0
local string iUIS = ""
//MAIN PART
set iC = s_uDI(u, "inventory_unit_indexCount")
set l = GetUnitLoc(u)
loop
exitwhen i > iC
set iS = I2S(i)
set iU = s_uDU(u, "inventory_unit_" + iS)
call ShowUnitShow(iU)
call SetUnitPositionLoc(iU, l)
set iUI = GetHandleId(iU)
set iUIS = I2S(iUI)
call s_uDB_s(true, iUIS, "ability_inventory_active")
set i = i + 1
endloop
//PLUG LEAKS
set u = null
set uI = 0
set uIS = ""
set iU = null
set iI = null
set uTI = 0
set iTI = 0
set i = 1
set iC = 0
set iS = ""
call RemoveLocation(l)
set l = null
set iUI = 0
set iUIS = ""
endfunction
function returnRenderPosition takes string objectDLS returns nothing
local real x = 0
local real y = 0
local real z = 0
//MAIN PART
//PLUG LEAKS
set x = 0
set y = 0
set z = 0
endfunction