//TESH.scrollpos=0
//TESH.alwaysfold=0
function fake takes nothing returns nothing
endfunction
Name | Type | is_array | initial_value |
Runners | group | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library DoorSystem initializer Init
// Door system by The_Witcher
//
// this system opens every instance of the registered doortypes when a units comes close
// if the unit moves away from the door it will close again
globals
//if this is true doors will only close on leave if there are no units in their range
public boolean CLOSE_ONLY_WHEN_EMPTY = true
// These are the standart animations for the doors in your map
private constant string STANDART_OPEN_ANIMATION = "Death Alternate"
private constant string STANDART_STAND_OPEN_ANIMATION = "Stand Alternate"
private constant string STANDART_CLOSE_ANIMATION = "Birth"
private constant string STANDART_STAND_CLOSE_ANIMATION = "stand"
endglobals
//Doors will only be triggered when the entering unit matches these conditions
private function DoorEventConditions takes nothing returns boolean
return not (IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) or GetUnitTypeId(GetFilterUnit()) == 0 )
endfunction
//-----------Don't modify anything below this line---------
globals
private integer array doors
private real array range
private integer total
private hashtable h
private boolexpr filt
private boolexpr enter
private integer i
private group g
private timer tim
endglobals
private function FilterFunc takes nothing returns boolean
return GetDestructableTypeId(GetFilterDestructable()) == doors[i] and LoadBoolean(h,GetHandleId(GetFilterDestructable()),1) != true and LoadBoolean(h,GetHandleId(GetFilterDestructable()),2) != true
endfunction
private function DoorActions takes nothing returns nothing
local destructable d = LoadDestructableHandle(h,GetHandleId(GetTriggeringTrigger()),0)
if GetTriggerEventId()==EVENT_GAME_ENTER_REGION and not LoadBoolean(h,GetHandleId(d),0) then
call KillDestructable(d)
call SaveBoolean(h,GetHandleId(d),0,true)
call SetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),4))
call QueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),5))
elseif GetTriggerEventId()==EVENT_GAME_LEAVE_REGION and LoadBoolean(h,GetHandleId(d),0) then
if not CLOSE_ONLY_WHEN_EMPTY then
call DestructableRestoreLife(d,GetDestructableMaxLife(d),true)
call SaveBoolean(h,GetHandleId(d),0,false)
call SetDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),6))
call QueueDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),7))
else
call GroupClear(g)
call GroupEnumUnitsInRect(g, LoadRectHandle(h,GetHandleId(d),3), enter)
if FirstOfGroup(g) == null then
call DestructableRestoreLife(d,GetDestructableMaxLife(d),true)
call SaveBoolean(h,GetHandleId(d),0,false)
call SetDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),6))
call QueueDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),7))
endif
endif
endif
set d = null
endfunction
private function RegisterEvents takes nothing returns nothing
local destructable d = GetEnumDestructable()
local trigger t = CreateTrigger()
local region g = CreateRegion()
local real x = GetDestructableX(d)
local real y = GetDestructableY(d)
local rect r = Rect(x-range[i], y-range[i], x+range[i], y+range[i])
call RegionAddRect(g,r)
call SaveBoolean(h,GetHandleId(d),0,false)
call SaveDestructableHandle(h,GetHandleId(t),0,d)
call SaveRectHandle(h,GetHandleId(d),3,r)
call SaveBoolean(h,GetHandleId(d),1,true)
call SaveStr(h,GetDestructableTypeId(d),4,STANDART_OPEN_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),5,STANDART_STAND_OPEN_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),6,STANDART_CLOSE_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),7,STANDART_STAND_CLOSE_ANIMATION)
call TriggerRegisterEnterRegion(t,g,enter)
call TriggerRegisterLeaveRegion(t,g,enter)
call TriggerAddAction(t,function DoorActions)
set t = null
set d = null
set r = null
set g = null
endfunction
private function RescanAll takes nothing returns nothing
set i = 0
loop
exitwhen i >= total
call EnumDestructablesInRect(bj_mapInitialPlayableArea, filt, function RegisterEvents)
set i = i + 1
endloop
endfunction
function OpenDoor takes destructable d, boolean flag returns nothing
call SaveBoolean(h,GetHandleId(h),0,flag)
endfunction
function ExcludeDoor takes destructable d, boolean flag returns nothing
call SaveBoolean(h,GetHandleId(h),2,flag)
endfunction
function ChangeDoorTypeAnimations takes integer id, string openAnimation, string standOpenAnimation, string closeAnimation, string standCloseAnimation returns nothing
call SaveStr(h,id,4,openAnimation)
call SaveStr(h,id,5,standOpenAnimation)
call SaveStr(h,id,6,closeAnimation)
call SaveStr(h,id,7,standCloseAnimation)
endfunction
function AddDoorType takes integer id, real enterRange returns nothing
set doors[total] = id
set range[total] = enterRange
call SaveStr(h,id,4,STANDART_OPEN_ANIMATION)
call SaveStr(h,id,5,STANDART_STAND_OPEN_ANIMATION)
call SaveStr(h,id,6,STANDART_CLOSE_ANIMATION)
call SaveStr(h,id,7,STANDART_STAND_CLOSE_ANIMATION)
set total = total + 1
call RescanAll()
endfunction
private function Init takes nothing returns nothing
set h = InitHashtable()
set total = 0
set filt = Condition(function FilterFunc)
set enter = Condition(function DoorEventConditions)
set g = CreateGroup()
set tim = CreateTimer()
endfunction
private function CatchNewDoors takes integer objectid, real x, real y, real face, real scale, integer variation returns nothing
call TimerStart(tim,0.01,false,function RescanAll)
endfunction
private function CatchNewDoors2 takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns nothing
call TimerStart(tim,0.01,false,function RescanAll)
endfunction
hook CreateDestructable CatchNewDoors
hook CreateDestructableZ CatchNewDoors2
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function callback2 takes nothing returns nothing
call SetUnitPosition( GetEnumUnit(), GetRandomReal(GetRectMinX(gg_rct_Gebiet_000), GetRectMaxX(gg_rct_Gebiet_000)), GetRandomReal(GetRectMinY(gg_rct_Gebiet_000), GetRectMaxY(gg_rct_Gebiet_000)))
endfunction
function callback takes nothing returns nothing
local location loc = Location(GetRandomReal(GetRectMinX(gg_rct_Gebiet_000), GetRectMaxX(gg_rct_Gebiet_000)), GetRandomReal(GetRectMinY(gg_rct_Gebiet_000), GetRectMaxY(gg_rct_Gebiet_000)))
call IssuePointOrderLoc( GetEnumUnit(), "move", loc)
call RemoveLocation(loc)
set loc = null
endfunction
function TimerFunc takes nothing returns nothing
call ForGroup( udg_Runners, function callback )
endfunction
function Trig_Test_Map_Actions takes nothing returns nothing
// Visibility
call FogEnable( false )
call FogMaskEnable( false )
// Running Villagers
call GroupEnumUnitsInRect(udg_Runners,gg_rct_Gebiet_001,null)
call ForGroup( udg_Runners, function callback2 )
call SetPlayerAllianceStateBJ( Player(0), Player(8), bj_ALLIANCE_ALLIED )
call SetPlayerAllianceStateBJ( Player(8), Player(0), bj_ALLIANCE_ALLIED )
call TimerFunc()
call TimerStart(CreateTimer(),10.,true, function TimerFunc)
//Texts
call DisplayTimedTextToPlayer(Player(0),0,0,9999999,"|cff08BD52D|r|cff08B44Eo|r|cff08AB4Ao|r|cff08A246r|r |cff08903Ea|r|cff08873An|r|cff087E36d|r |cff086C2EM|r|cff08632Ao|r|cff085A26d|r|cff085122i|r|cff08481Ef|r|cff083F1Ay|r |cff082D12C|r|cff08240Ea|r|cff081B0Am|r|cff000A10e|r|cff000F18r|r|cff001420a|r |cff001E30I|r|cff002338n|r|cff002840g|r|cff002D48a|r|cff003250m|r|cff003758e|r |cff004168S|r|cff004670y|r|cff004B78s|r|cff005080t|r|cff005588e|r|cff005A90m|r")
call DisplayTimedTextToPlayer(Player(0),0,0,9999999,"|cff08BD52b|r|cff07A648y|r |cff057834T|r|cff04612Ah|r|cff034A20e|r|cff023316_|r|cff011C0CW|r|cff021C2Ai|r|cff032A3Ft|r|cff043854c|r|cff054669h|r|cff06547Ee|r|cff076293r|r")
call DisplayTimedTextToPlayer(Player(0),0,0,9999999," ")
call DisplayTimedTextToPlayer(Player(0),0,0,9999999,"|cff08BD52W|r|cff08B44Ea|r|cff08AB4Al|r|cff08A246k|r |cff08903Ec|r|cff08873Al|r|cff087E36o|r|cff087532s|r|cff086C2Ee|r |cff085A26t|r|cff085122o|r |cff083F1Aa|r |cff082D12d|r|cff08240Eo|r|cff081B0Ao|r|cff081206r|r |cff000F15a|r|cff00141Cn|r|cff001923d|r |cff002331i|r|cff002838t|r |cff003246w|r|cff00374Di|r|cff003C54l|r|cff00415Bl|r |cff004B69o|r|cff005070p|r|cff005577e|r|cff005A7En|r|cff005F85!|r")
call DisplayTimedTextToPlayer(Player(0),0,0,9999999," ")
call DisplayTimedTextToPlayer(Player(0),0,0,9999999,"|cff08BD52U|r|cff08B54Fs|r|cff08AD4Ce|r |cff089D46t|r|cff089543h|r|cff088D40e|r |cff087D3Aa|r|cff087537r|r|cff086D34r|r|cff086531o|r|cff085D2Ew|r |cff084D28k|r|cff084525e|r|cff083D22y|r|cff08351Fs|r |cff082519t|r|cff081D16o|r |cff080D10m|r|cff00080Ca|r|cff000C12n|r|cff001018i|r|cff00141Ep|r|cff001824u|r|cff001C2Al|r|cff002030a|r|cff002436t|r|cff00283Ce|r |cff003048t|r|cff00344Eh|r|cff003854e|r |cff004060c|r|cff004466a|r|cff00486Cm|r|cff004C72e|r|cff005078r|r|cff00547Ea|r|cff005884!|r")
//************************************************************
// Camera System activate
set ModifyCamIngame_active[0] = true
// Door system setup
call AddDoorType( 'ATg2', 300)
call AddDoorType( 'B000', 150)
call ChangeDoorTypeAnimations( 'ATg2',"Death Alternate", "Death Alternate", "Stand","Stand")
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Init, 0., false)
call TriggerAddAction( gg_trg_Init, function Trig_Test_Map_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library KeyboardSystem initializer Init
// Keyboard System by The_Witcher
// This System helps you to get rid of all the triggers
// you would need for creating an effective arrow key
// system.
// This system has aditionally the power to add a key twice press event to a trigger
// you just need to adjust this little variable:
globals
// this is the time the player has to "double press" a key
// if a key is pressed twice in this time the registered triggers are executed
private constant real DELAY = 0.2
endglobals
// Use this function to see which keys are hold down:
//
// IsKeyDown( key, pl) returns boolean
// string player
//
// key can be KEY_LEFT, KEY_RIGHT, KEY_UP or KEY_DOWN
// pl is the player who is checked
// if the function returns true the key is hold down by player pl
//
// And this 2 functions to register a double press event to a trigger
//
// TriggerRegisterKeyDoublePressEvent(t, key)
//
// TriggerRegisterPlayerKeyDoublePressEvent(t, key, pl)
//
// TriggerRegisterKeyDoubleInterruptEvent(t, key)
//
// TriggerRegisterPlayerKeyDoubleInterruptEvent(t, key, pl)
//
// t is the trigger you want to register that event to
// key is the pressed key (again can be KEY_LEFT, KEY_RIGHT, KEY_UP or KEY_DOWN)
// pl is in the second function the player who has to press
// the keys to fire the trigger
// the first function fires the trigger regardless of which player pressed the key
//
//
//--------------Don't edit anything below---------------------------
globals
private timer array time[13]
private trigger array TRIGGERS
private trigger array TRIGGERS2
private integer total = 0
private integer total2 = 0
private integer array PLAYER
private integer array PLAYER2
private string array KEY
private string array KEY2
constant string KEY_LEFT = "left"
constant string KEY_RIGHT = "right"
constant string KEY_UP = "up"
constant string KEY_DOWN = "down"
private hashtable h = InitHashtable()
endglobals
function IsKeyDown takes string key, player pl returns boolean
return LoadBoolean(h,GetPlayerId(pl),StringHash(key))
endfunction
function TriggerRegisterKeyDoublePressEvent takes trigger t, string key returns nothing
set TRIGGERS[total] = t
set KEY[total] = key
set PLAYER[total] = 100
set total = total + 1
endfunction
function TriggerRegisterPlayerKeyDoublePressEvent takes trigger t, string key, player pl returns nothing
set TRIGGERS[total] = t
set KEY[total] = key
set PLAYER[total] = GetPlayerId(pl)
set total = total + 1
endfunction
function TriggerRegisterKeyDoubleInterruptEvent takes trigger t, string key returns nothing
set TRIGGERS2[total2] = t
set KEY2[total2] = key
set PLAYER2[total2] = 100
set total2 = total2 + 1
endfunction
function TriggerRegisterPlayerKeyDoubleInterruptEvent takes trigger t, string key, player pl returns nothing
set TRIGGERS2[total2] = t
set KEY2[total2] = key
set PLAYER2[total2] = GetPlayerId(pl)
set total2 = total2 + 1
endfunction
//! textmacro TriggerActions takes NAME, VarTrue, VarFalse
private function $NAME$press takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local integer x = 0
call SaveBoolean(h,i,StringHash("$VarTrue$"),true)
call SaveBoolean(h,i,StringHash("$VarFalse$"),false)
if LoadStr(h,i,StringHash("LastKey")) != "$VarTrue$" then
call TimerStart(time[i],0,false,null)
endif
if TimerGetRemaining(time[i]) > 0 and LoadStr(h,i,StringHash("LastKey")) == "$VarTrue$" then
call SaveInteger(h,i,StringHash("Debug"),0)
call SaveBoolean(h,i,StringHash("$VarTrue$Double"),true)
loop
exitwhen x >= total
if TriggerEvaluate(TRIGGERS[x]) and KEY[x] == "$VarTrue$" and (PLAYER[x] == 100 or PLAYER[x] == i) then
call TriggerExecute(TRIGGERS[x])
endif
set x = x + 1
endloop
endif
if LoadInteger(h,i,StringHash("Debug")) == 1 then
call TimerStart(time[i],DELAY,false,null)
else
call SaveInteger(h,i,StringHash("Debug"),1)
endif
call SaveStr(h,i,StringHash("LastKey"),"$VarTrue$")
endfunction
private function $NAME$release takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local integer x = 0
call SaveBoolean(h,i,StringHash("$VarTrue$"),false)
if LoadBoolean(h,i,StringHash("$VarTrue$Double")) then
call SaveBoolean(h,i,StringHash("$VarTrue$Double"),false)
loop
exitwhen x >= total2
if TriggerEvaluate(TRIGGERS2[x]) and KEY2[x] == "$VarTrue$" and (PLAYER2[x] == 100 or PLAYER2[x] == i) then
call TriggerExecute(TRIGGERS2[x])
endif
set x = x + 1
endloop
endif
endfunction
//! endtextmacro
//! runtextmacro TriggerActions("LEFT","left","right")
//! runtextmacro TriggerActions("RIGHT","right","left")
//! runtextmacro TriggerActions("UP","up","down")
//! runtextmacro TriggerActions("DOWN","down","up")
//! textmacro Initiate takes NAME
set i = 0
set t = CreateTrigger()
set tt = CreateTrigger()
call TriggerAddAction(t,function $NAME$press)
call TriggerAddAction(tt,function $NAME$release)
loop
exitwhen i > 12
call TriggerRegisterPlayerEvent(t,Player(i),EVENT_PLAYER_ARROW_$NAME$_DOWN)
call TriggerRegisterPlayerEvent(tt,Player(i),EVENT_PLAYER_ARROW_$NAME$_UP)
set i = i + 1
endloop
//! endtextmacro
private function Init takes nothing returns nothing
local trigger t
local trigger tt
local integer i
//! runtextmacro Initiate("LEFT")
//! runtextmacro Initiate("RIGHT")
//! runtextmacro Initiate("UP")
//! runtextmacro Initiate("DOWN")
set i = 0
loop
exitwhen i > 12
set time[i] = CreateTimer()
set i = i + 1
endloop
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library ModifyCamIngame initializer Init requires KeyboardSystem
// Modify Camera Ingame System
// by The_Witcher
//
// to activate this system for a specific player
//
// set ModifyCamIngame_active[ << id of player >> ] = true
//
// pretty easy huh? ;)
globals
// the timer interval, increase if laggy
private constant real INTERVAL = 0.01
//The camera field you manipualte with the left and right arrow key
private constant camerafield LEFT_RIGHT_MANIPULATE = CAMERA_FIELD_ROTATION
//The value the field gets changed each interval (right is + value, left is - value)
private constant real LEFT_RIGHT_STEP = 1
//The initial value of the field for left and right
private constant real LEFT_RIGHT_START = bj_CAMERA_DEFAULT_ROTATION
//The max value of the field for left and right (Set min and max to the same value to disable min and max)
private constant real LEFT_RIGHT_MAX = 0
//The min value of the field for left and right (Set min and max to the same value to disable min and max)
private constant real LEFT_RIGHT_MIN = 0
//The camera field you manipualte with the up and down arrow key
private constant camerafield UP_DOWN_MANIPULATE = CAMERA_FIELD_ANGLE_OF_ATTACK
//The value the field gets changed each interval (up is + value, down is - value)
private constant real UP_DOWN_STEP = -1
//The initial value of the field for up and down
private constant real UP_DOWN_START = bj_CAMERA_DEFAULT_AOA
//The max value of the field for up and down (Set min and max to the same value to disable min and max)
private constant real UP_DOWN_MAX = 340
//The min value of the field for up and down (Set min and max to the same value to disable min and max)
private constant real UP_DOWN_MIN = 270
endglobals
// DON'T MODIFY ANYTHING BELOW THIS LINE
globals
public boolean array active[12]
private real array lr[12]
private real array ud[12]
endglobals
private function process takes nothing returns nothing
local integer i = 0
local real x
local real y
loop
exitwhen i > bj_MAX_PLAYERS
if active[i] and (IsKeyDown(KEY_LEFT,Player(i)) or IsKeyDown(KEY_RIGHT,Player(i)) or IsKeyDown(KEY_UP,Player(i)) or IsKeyDown(KEY_DOWN,Player(i))) then
if GetLocalPlayer() == Player(i) then
set x = GetCameraTargetPositionX()
set y = GetCameraTargetPositionY()
endif
if IsKeyDown(KEY_LEFT,Player(i)) then
set lr[i] = lr[i] - LEFT_RIGHT_STEP
endif
if IsKeyDown(KEY_RIGHT,Player(i)) then
set lr[i] = lr[i] + LEFT_RIGHT_STEP
endif
if IsKeyDown(KEY_UP,Player(i)) then
set ud[i] = ud[i] + UP_DOWN_STEP
endif
if IsKeyDown(KEY_DOWN,Player(i)) then
set ud[i] = ud[i] - UP_DOWN_STEP
endif
if LEFT_RIGHT_MAX != LEFT_RIGHT_MIN then
set lr[i] = RMinBJ(LEFT_RIGHT_MAX, lr[i])
set lr[i] = RMaxBJ(LEFT_RIGHT_MIN, lr[i])
endif
if UP_DOWN_MAX != UP_DOWN_MIN then
set ud[i] = RMinBJ(UP_DOWN_MAX, ud[i])
set ud[i] = RMaxBJ(UP_DOWN_MIN, ud[i])
endif
if GetLocalPlayer() == Player(i) then
call SetCameraPosition(x,y)
call SetCameraField(LEFT_RIGHT_MANIPULATE,lr[i],0)
call SetCameraField(UP_DOWN_MANIPULATE,ud[i],0)
endif
endif
set i = i + 1
endloop
endfunction
private function Init takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 12 //= bj_MAX_PLAYERS
set ud[i] = UP_DOWN_START
set lr[i] = LEFT_RIGHT_START
set i = i + 1
endloop
call TimerStart(CreateTimer(), INTERVAL, true, function process)
endfunction
endlibrary