Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
//Thanks to anitarf and Vexorian @ wc3c.net for this library, it makes things easier.
library IsTerrainWalkable initializer Init
globals
// this value is how far from a point the item may end up for the point to be considered pathable
private constant real MAX_RANGE=10.
// the following two variables are set to the position of the item after each pathing check
// that way, if a point isn't pathable, these will be the coordinates of the nearest point that is
public real X=0.
public real Y=0.
private rect r
private item check
private item array hidden
private integer hiddenMax = 0
endglobals
private function Init takes nothing returns nothing
set check=CreateItem('ciri',0,0)
call SetItemVisible(check,false)
set r=Rect(0.0,0.0,128.0,128.0)
endfunction
private function HideBothersomeItem takes nothing returns nothing
if IsItemVisible(GetEnumItem()) then
set hidden[hiddenMax]=GetEnumItem()
call SetItemVisible(hidden[hiddenMax],false)
set hiddenMax=hiddenMax+1
endif
endfunction
function IsTerrainWalkable takes real x, real y returns boolean
// first, hide any items in the area so they don't get in the way of our item
call MoveRectTo(r,x,y)
call EnumItemsInRect(r,null,function HideBothersomeItem)
// try to move the check item and get it's coordinates
call SetItemPosition(check,x,y)//this unhides the item...
set X=GetItemX(check)
set Y=GetItemY(check)
call SetItemVisible(check,false)//...so we must hide it again
// before returning, unhide any items that got hidden at the start
loop
exitwhen hiddenMax<=0
set hiddenMax=hiddenMax-1
call SetItemVisible(hidden[hiddenMax],true)
set hidden[hiddenMax]=null
endloop
// return pathability status
return (x-X)*(x-X)+(y-Y)*(y-Y)<MAX_RANGE*MAX_RANGE
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library angleBetweenXY
function angleBetweenXY takes real xa, real ya, real xb, real yb returns real
return bj_RADTODEG*Atan2(yb-ya,xb-xa)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library remainingPlayers
globals
private integer counter=0
private group tempGroup=CreateGroup()
endglobals
private function f takes nothing returns boolean
if GetUnitTypeId(GetFilterUnit())=='h000' and GetWidgetLife(GetFilterUnit())>=1 then
set counter=counter+1
endif
return false
endfunction
function remainingPlayers takes nothing returns integer
set counter=0
call GroupEnumUnitsInRect(tempGroup,bj_mapInitialPlayableArea,Filter(function f))
return counter
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer timeElapsedT10=0
endglobals
scope timer initializer i
private function a takes nothing returns nothing
set timeElapsedT10=timeElapsedT10+1
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterTimerEvent(t,.1,true)
call TriggerAddAction(t,function a)
endfunction
endscope
//TESH.scrollpos=66
//TESH.alwaysfold=0
scope kb
private struct kData
unit u
real direction
integer power
integer gravPull
boolean friction
boolean killsTouchees
endstruct
globals
private timer time=CreateTimer()
private kData array kDB
private integer dbIndex=-1
private group GROUP=CreateGroup()
private unit tempBomb
private real tempGravPull
private player tempOwner
endglobals
private function f takes nothing returns boolean
if GetUnitTypeId(GetFilterUnit())=='h000' then
call SetUnitExploded(GetFilterUnit(),true)
call KillUnit(GetFilterUnit())
endif
return false
endfunction
private function f2 takes nothing returns boolean
local real angleTowards=angleBetweenXY(GetUnitX(GetFilterUnit()),GetUnitY(GetFilterUnit()),GetUnitX(tempBomb),GetUnitY(tempBomb))
local real distance=SquareRoot(((GetUnitX(GetFilterUnit())-GetUnitX(tempBomb))*(GetUnitX(GetFilterUnit())-GetUnitX(tempBomb)))+((GetUnitY(GetFilterUnit())-GetUnitY(tempBomb))*(GetUnitY(GetFilterUnit())-GetUnitY(tempBomb))))
if GetOwningPlayer(GetFilterUnit())!=tempOwner then
call SetUnitX(GetFilterUnit(),GetUnitX(GetFilterUnit())+(tempGravPull-distance)/20*Cos(angleTowards*bj_DEGTORAD))
call SetUnitY(GetFilterUnit(),GetUnitY(GetFilterUnit())+(tempGravPull-distance)/20*Sin(angleTowards*bj_DEGTORAD))
endif
return false
endfunction
private function p takes nothing returns nothing
local integer index=0
local kData tempDat
local real x
local real y
loop
exitwhen index>dbIndex
set tempDat=kDB[index]
set x=GetUnitX(tempDat.u)+tempDat.power*Cos(tempDat.direction*bj_DEGTORAD)
set y=GetUnitY(tempDat.u)+tempDat.power*Sin(tempDat.direction*bj_DEGTORAD)
if IsTerrainWalkable(x,y) then
call SetUnitX(tempDat.u,x)
call SetUnitY(tempDat.u,y)
else
set tempDat.direction=0-tempDat.direction
set x=GetUnitX(tempDat.u)+tempDat.power*Cos(tempDat.direction*bj_DEGTORAD)
set y=GetUnitY(tempDat.u)+tempDat.power*Sin(tempDat.direction*bj_DEGTORAD)
if IsTerrainWalkable(x,y) then
call SetUnitX(tempDat.u,x)
call SetUnitY(tempDat.u,y)
else
set tempDat.direction=tempDat.direction-180
endif
if tempDat.friction then
set tempDat.power=tempDat.power*3/4
endif
endif
if tempDat.killsTouchees then
call GroupEnumUnitsInRange(GROUP,GetUnitX(tempDat.u),GetUnitY(tempDat.u),70,Filter(function f))
endif
if tempDat.friction then
set tempDat.power=tempDat.power-1
endif
if GetUnitState(tempDat.u,UNIT_STATE_LIFE)<1 then
set tempDat.power=tempDat.power-1
endif
if tempDat.gravPull>0 then
set tempBomb=tempDat.u
set tempGravPull=tempDat.gravPull
set tempOwner=GetOwningPlayer(tempDat.u)
call GroupEnumUnitsInRange(GROUP,GetUnitX(tempDat.u),GetUnitY(tempDat.u),tempDat.gravPull,Filter(function f2))
endif
if tempDat.power<0 then
call tempDat.destroy()
set kDB[index]=kDB[dbIndex]
set dbIndex=dbIndex-1
if dbIndex==-1 then
call PauseTimer(time)
endif
endif
set index=index+1
endloop
endfunction
function knockb takes unit u, real direction, integer power, boolean friction, boolean killsTouchees, integer gravPull returns nothing
local kData tempDat=kData.create()
set tempDat.u=u
set tempDat.direction=direction
set tempDat.power=power
set tempDat.friction=friction
set tempDat.killsTouchees=killsTouchees
set tempDat.gravPull=gravPull
set dbIndex=dbIndex+1
set kDB[dbIndex]=tempDat
if dbIndex==0 then
call TimerStart(time,.03,true,function p)
endif
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
unit flamingGruntShooter
endglobals
scope init initializer i
private function i takes nothing returns nothing
local integer index=0
local trigger t=CreateTrigger()
call FogEnable(false)
call FogMaskEnable(false)
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|cff990000"+GetPlayerName(Player(0))+"|r can press escape at any time to launch flaming grunts!")
loop
exitwhen index>11
if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
call CreateUnit(Player(index),'h000',0,0,270)
endif
call SetPlayerAlliance(Player(index),Player(0),ALLIANCE_PASSIVE,true)
call SetPlayerAlliance(Player(0),Player(index),ALLIANCE_PASSIVE,true)
set index=index+1
endloop
set flamingGruntShooter=CreateUnit(Player(index),'h001',-765,-725,270)
call CreateUnit(Player(15),'h004',GetRandomReal(-640,640),GetRandomReal(-640,640),270)
call CreateUnit(Player(15),'h004',GetRandomReal(-640,640),GetRandomReal(-640,640),270)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope esc initializer i
private function a takes nothing returns nothing
call IssuePointOrder(flamingGruntShooter,"breathoffire",GetRandomReal(-640,-320),GetRandomReal(-640,-320))
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t,function a)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope flamingGruntCreate initializer i
private function c takes nothing returns boolean
local real facing
local unit u
if GetSpellAbilityId()=='A001' then
set facing=angleBetweenXY(GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit()),GetLocationX(GetSpellTargetLoc()),GetLocationY(GetSpellTargetLoc()))
set u=CreateUnit(Player(13),'h002',-640,-640,facing)
call PauseUnit(u,true)
call knockb(u,facing,GetRandomInt(5,12),false,true,0)
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope dies initializer i
globals
private group tempGroup=CreateGroup()
endglobals
private function rm takes nothing returns nothing
local integer index=0
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will restart momentarily.")
call TriggerSleepAction(5)
set timeElapsedT10=0
loop
exitwhen index>11
if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
call CreateUnit(Player(index),'h000',0,0,270)
endif
set index=index+1
endloop
call CreateUnit(Player(15),'h004',GetRandomReal(-640,640),GetRandomReal(-640,640),270)
call CreateUnit(Player(15),'h004',GetRandomReal(-640,640),GetRandomReal(-640,640),270)
endfunction
private function f takes nothing returns boolean
if GetUnitTypeId(GetFilterUnit())=='h002' or GetUnitTypeId(GetFilterUnit())=='h004' then
call KillUnit(GetFilterUnit())
endif
return false
endfunction
private function c takes nothing returns boolean
if GetUnitTypeId(GetDyingUnit())=='h000' then
call DisplayTextToPlayer(GetOwningPlayer(GetDyingUnit()),0,0,"You lasted |cff999999"+I2S(timeElapsedT10/10)+"|r seconds!")
if remainingPlayers()<1 then
call GroupEnumUnitsInRect(tempGroup,bj_mapInitialPlayableArea,Filter(function f))
call ExecuteFunc(SCOPE_PRIVATE+"rm")
endif
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
scope mb initializer i
globals
private multiboard mb
private timer time=CreateTimer()
private timer time2=CreateTimer()
endglobals
private function p takes nothing returns nothing
call MultiboardSetItemValue(MultiboardGetItem(mb,0,1),"|cffdddddd"+I2S(timeElapsedT10/10)+"|r") //Seconds
endfunction
private function p2 takes nothing returns nothing
local integer i=GetRandomInt(0,2)
if i==0 then
call MultiboardSetItemValue(MultiboardGetItem(mb,1,0),"|cff999900Map By:|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,1,1),"|cff555555Cokemonkey11|r")
elseif i==1 then
call MultiboardSetItemValue(MultiboardGetItem(mb,1,0),"|cff999900Visit:|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,1,1),"|cff555555clanlomm.co.cc|r")
elseif i==2 then
call MultiboardSetItemValue(MultiboardGetItem(mb,1,0),"|cff999900Visit:|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,1,1),"|cff555555hiveworkshop.com|r")
endif
endfunction
private function a takes nothing returns nothing
set mb=CreateMultiboard()
call MultiboardSetColumnCount(mb,2)
call MultiboardSetItemsStyle(mb,true,false)
call MultiboardSetItemsWidth(mb,.1)
call MultiboardSetRowCount(mb,2)
call MultiboardSetTitleText(mb,"|cff999999Very Scared Footmen|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,0,0),"|cffddddddRound Time:|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,0,1),"|cffdddddd0|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,1,0),"|cff999900Map By:|r")
call MultiboardSetItemValue(MultiboardGetItem(mb,1,1),"|cff555555Cokemonkey11|r")
call TimerStart(time,.5,true,function p)
call TimerStart(time2,10,true,function p2)
call MultiboardDisplay(mb,true)
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterTimerEvent(t,1,false)
call TriggerAddAction(t,function a)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope endGame initializer i
private function a takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|cff990000"+GetPlayerName(Player(0))+"|r has left! The game will end momentarily.")
call TriggerSleepAction(10)
call EndGame(false)
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_LEAVE)
call TriggerAddAction(t,function a)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope camZ initializer i
private function c takes nothing returns boolean
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE,2200,60)
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterTimerEvent(t,10,true)
call TriggerRegisterTimerEvent(t,1,false)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope push initializer i
private function c takes nothing returns boolean
if GetSpellAbilityId()=='A002' then
call knockb(GetSpellTargetUnit(),GetUnitFacing(GetSpellAbilityUnit()),35,true,false,0)
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope gravityBomb initializer i
private function c takes nothing returns boolean
local unit u
local unit target
local unit caster
if GetSpellAbilityId()=='A003' then
set u=CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'h003',GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit()),GetUnitFacing(GetSpellAbilityUnit()))
set target=GetSpellTargetUnit()
set caster=GetSpellAbilityUnit()
call SetUnitExploded(u,true)
call SetUnitMoveSpeed(u,1)
call UnitApplyTimedLife(u,'BHav',5)
call SetUnitPathing(u,false)
call knockb(u,GetUnitFacing(caster),7,false,false,200)
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
//Oh god, I'm using TSA AND locations. Hang myself.
scope teleportation initializer i
private function c takes nothing returns boolean
return GetSpellAbilityId()=='A005'
endfunction
private function a takes nothing returns nothing
local location omgImUsingLocations=GetSpellTargetLoc()
local real x=GetLocationX(omgImUsingLocations)+GetRandomReal(0,30)*Cos(GetRandomReal(0,360)*bj_DEGTORAD)
local real y=GetLocationY(omgImUsingLocations)+GetRandomReal(0,30)*Sin(GetRandomReal(0,360)*bj_DEGTORAD)
call TriggerSleepAction(5)
if GetWidgetLife(GetSpellAbilityUnit())>=1 and x<626 and x>-645 and y>-630 and y<650 then
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl",GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit())))
call SetUnitX(GetSpellAbilityUnit(),x)
call SetUnitY(GetSpellAbilityUnit(),y)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl",GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit())))
endif
call RemoveLocation(omgImUsingLocations)
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
call TriggerAddAction(t,function a)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope blink initializer i
private function c takes nothing returns boolean
local real x
local real y
if GetSpellAbilityId()=='A006' then
set x=GetUnitX(GetSpellAbilityUnit())+150*Cos(GetUnitFacing(GetSpellAbilityUnit())*bj_DEGTORAD)
set y=GetUnitY(GetSpellAbilityUnit())+150*Sin(GetUnitFacing(GetSpellAbilityUnit())*bj_DEGTORAD)
if x<626 and x>-645 and y>-630 and y<650 then
call SetUnitX(GetSpellAbilityUnit(),x)
call SetUnitY(GetSpellAbilityUnit(),y)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl",x,y))
endif
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope