Name | Type | is_array | initial_value |
AI_Integer | integer | No | |
AI_Position | location | Yes | |
AncientEnemy_QCcount | integer | No | |
AncientEnemy_QRQ | questitem | Yes | |
AQ_Blocker | destructable | Yes | |
AQ_BossfightTimer | timer | No | |
AQ_BossfightWindow | timerdialog | No | |
AQ_SleepInteger | integer | No | |
AQ_Tsunami_AoE | real | No | |
AQ_Tsunami_Caster | unit | No | |
AQ_Tsunami_Dmg | real | No | |
AQ_Tsunami_Dummy | unit | No | |
AQ_Tsunami_Point | location | No | |
AQ_Tsunami_Timer | timer | No | |
AQ_Tsunami_Window | timerdialog | No | |
AQ_WaterMark_AoE | real | No | |
AQ_WaterMark_Caster | unit | No | |
AQ_WaterMark_Damage | real | No | |
AQ_WaterMark_Effect | effect | Yes | |
AQ_WaterMark_Target | unit | No | |
AQ_WaterMark_Timer | timer | No | |
AQ_WaterMark_Window | timerdialog | No | |
Arena_ArenaPartner | unitcode | No | |
Arena_Damagers | unitcode | Yes | |
Arena_Healers | unitcode | Yes | |
Arena_Lives | integer | Yes | |
Arena_OponentRoller | integer | Yes | |
Arena_OponentUnit | unitcode | Yes | |
Arena_RerollInt | integer | No | |
ArenaLivesReal1 | real | No | |
ArenaLivesReal2 | real | No | |
BarHash | hashtable | No | |
BarOffset | real | No | |
BeginCastTime | real | Yes | |
BeHiddenCount | integer | Yes | |
BeHiddenInteger | integer | Yes | |
BeHiddenReal | real | No | |
Bounty_1 | real | No | |
Bounty_2 | integer | No | |
Caster | unit | No | |
CastingBar | texttag | Yes | |
CastingBarSize | real | No | |
CastingGroup | group | No | |
CB_angle | real | No | |
CB_attacked_loc | location | No | |
CB_attacker | unit | No | |
CB_attacking_loc | location | No | |
CB_BOOOM | boolean | No | |
CB_chance_to_knockback | integer | Yes | |
CB_defender | unit | No | |
CB_distance | real | No | |
CB_distance_setup | real | Yes | |
CB_group | group | No | |
CB_hash | hashtable | No | |
CB_temploc | location | No | |
CB_time | real | No | |
CenterPoint | location | No | |
Combat_Event | real | No | |
Combat_Found | boolean | No | |
Combat_Group | group | No | |
Combat_Index1 | integervar | No | |
Combat_Index2 | integer | No | |
Combat_Index3 | integervar | No | |
Combat_Time | real | Yes | |
Combat_Unit | unit | Yes | |
CombatState_Unit | unit | No | |
DamageBlockingAbility | abilcode | No | |
DamageEvent | real | No | |
DamageEventAmount | real | No | |
DamageEventExplodesUnit | boolean | No | |
DamageEventOverride | boolean | No | |
DamageEventPrevAmt | real | No | |
DamageEventSource | unit | No | |
DamageEventsWasted | integer | No | |
DamageEventTarget | unit | No | |
DamageEventTrigger | trigger | No | |
DamageEventType | integer | No | |
DamageModifierEvent | real | No | |
DamageTypeDOT | integer | No | |
DamageTypeRanged | integer | No | |
DamageTypeSpell | integer | No | |
DmgEvLife | real | No | |
DmgEvN | integer | No | |
DmgEvStack | unit | Yes | |
DmgEvTimer | timer | No | |
DmgTypPrev | integer | No | |
EB_Angle | real | Yes | |
EB_Caster | unit | Yes | |
EB_CasterLoc | location | Yes | |
EB_Damage | real | Yes | |
EB_Distance | real | Yes | |
EB_Effect | unit | Yes | |
EB_EffectGroup | group | No | |
EB_EffectLoc | location | Yes | |
EB_EffectMove | location | Yes | |
EB_Speed | real | Yes | |
EB_Target | unit | Yes | |
EB_TargetLoc | location | Yes | |
EndCastTime | real | Yes | |
EnergyBolt_Attribute | integer | Yes | |
EvadeDelay | real | No | |
EvadeDist | real | No | |
EvadeGroup | group | No | |
F_Integers | integer | Yes | |
F_ReachedFading | real | Yes | |
F_RFS_Caster | unit | Yes | |
F_RFS_MaxDamage | real | Yes | |
F_SetFadeValue | boolean | Yes | |
F_Time | real | Yes | |
F_Unit | unit | Yes | |
Feb_Caster | unit | No | |
Feb_Damage | real | No | |
FeB_Target | unit | No | |
FeralSpiritExpiration | real | No | |
FishingLevel | integer | No | |
FSeal_Caster | unit | Yes | |
FSeal_CurrentRange | real | Yes | |
FSeal_DMG | real | Yes | |
FSeal_FireGroupDummy | group | Yes | |
FSeal_FirstEnd | boolean | Yes | |
FSeal_Index | integer | Yes | |
FSeal_LoopIsOn | boolean | Yes | |
FSeal_TempPoint | location | Yes | |
FSeal_Wait | real | Yes | |
GiantCrabEffect | effect | No | |
HandOfNature_Attribute | integer | Yes | |
Hashtable | hashtable | No | |
Hero | unit | No | |
Hero_BloodeffectInteger | integer | No | |
Hero_Revive_Timer | timer | No | |
Hero_Revive_unit | unit | No | |
Hero_Revive_Window | timerdialog | No | |
Hero_Tsunami_AoE | real | No | |
Hero_Tsunami_Attribute | integer | Yes | |
Hero_Tsunami_Caster | unit | No | |
Hero_Tsunami_Dmg | real | No | |
Hero_Tsunami_Dummy | unit | No | |
Hero_Tsunami_Point | location | No | |
Hero_Tsunami_Timer | timer | No | |
Hero_Tsunami_Window | timerdialog | No | |
Hero_WaterMark_Effect | effect | Yes | |
HolHin_Mana | real | No | |
HolHin_Spell_Random | integer | No | |
HolHin_Totem | unit | No | |
HolHinGrowth_Heal | real | No | |
HW_EffectGroup | group | No | |
IntoCaveTimer | timer | Yes | |
IntoCaveWindow | timerdialog | Yes | |
InvestigateCount | integer | No | |
IsleText | texttag | No | |
IsUnitBeingKnockedBack | boolean | Yes | |
JD_Angle | real | Yes | |
JD_BouncesCur | integer | Yes | |
JD_BouncesMax | integer | Yes | |
JD_DamageBig | real | Yes | |
JD_DamageSmall | real | Yes | |
JD_Distances | real | Yes | |
JD_Group | group | No | |
JD_HighSettings | real | Yes | |
JD_IntegerAVar | integervar | No | |
JD_Integers | integer | Yes | |
JD_JumpHigh | real | Yes | |
JD_Owner | unit | Yes | |
JD_ReachedDistance | real | Yes | |
JD_RealTimer | real | Yes | |
JD_SmallFalse_BigTrue | boolean | Yes | |
JD_SmallPoint | location | No | |
JD_SpeedUnits | real | Yes | |
JD_TempGroup | group | No | |
JD_TempPoint | location | Yes | |
JD_TreesDestroy | boolean | Yes | |
JD_Unit | unit | Yes | |
JDA_Caster | unit | No | |
JDA_DestroyTrees_Dash | boolean | No | |
JDA_JumpHigh_Distance | real | No | |
JDA_SmallFalse_BigTrue | boolean | No | |
JDA_Speed | real | No | |
JDA_TargetPoint | location | No | |
JDA_Unit | unit | No | |
key | integer | No | |
LadySeraspia | unit | No | |
Leapers | group | No | |
Lizard_Thunder_Dmg | real | No | |
LoadingBarText | string | No | |
MakruraBleed_Buff | buffcode | No | |
MakruraEffects | effect | No | |
MakruraTotem_Heal | real | No | |
MakruraTotem_Unit | unit | No | |
Max_Item | integer | Yes | |
Max_Item_Integer | integer | No | |
Max_Item_Max | integer | No | |
MQ_Effect | effect | Yes | |
MQ_Quest | quest | Yes | |
NF_Angle | real | No | |
NF_AngleSpeed | real | No | |
NF_Caster | unit | No | |
NF_CasterLoc | location | No | |
NF_CircleBaseRadius | real | No | |
NF_CircleCenter | location | Yes | |
NF_CircleCount | integer | No | |
NF_CircleGrowth | real | No | |
NF_CircleRadius | real | Yes | |
NF_Damage | real | No | |
NF_DamageRadius | real | No | |
NF_DamageReal | real | No | |
NF_Effect | unit | Yes | |
NF_EffectAngle | real | Yes | |
NF_EffectCount | integer | Yes | |
NF_EffectCreationRate | real | No | |
NF_EffectCreationRateReal | real | No | |
NF_EffectCreatLoc | location | No | |
NF_EffectGroup | group | No | |
NF_EffectMove | location | Yes | |
NF_EffectNumber | integer | No | |
NF_EffectNumberReal | integer | No | |
NF_RealCount | integer | No | |
NumberofTicks | integer | No | |
OnDelay | real | Yes | |
OnEvade | boolean | Yes | false |
OQ_Effect | effect | Yes | |
OQ_Quest | quest | Yes | |
p | location | No | |
Pas_Reg_Timer | timer | No | |
PasReg_Heal | real | No | |
PlayerColors | string | Yes | |
Points | location | Yes | |
Queen_heal | real | Yes | |
Queen_Integer | integer | Yes | |
Queen_Queen | unit | No | |
Queen_Spawn | unitcode | Yes | |
Queen_Zillian | unit | No | |
Question_String | string | Yes | |
R_group | group | No | |
R_hash | hashtable | No | |
R_heal | real | No | |
R_ticks | integer | No | |
R_time_count | real | No | |
RC_Angle | real | No | |
RC_Caster | unit | No | |
RC_CasterLoc | location | No | |
RC_Damage | real | No | |
RC_EffectCreationLoc | location | No | |
RC_EffectDistance | real | No | |
RC_EffectGroup | group | No | |
RC_EffectLoc | location | No | |
RC_EffectMove | location | No | |
RC_EffectRockCreationRate | real | No | |
RC_EffectRockCreationRateReal | real | No | |
RC_On | boolean | No | |
RC_RadiusMax | real | No | |
RC_RadiusMin | real | No | |
RC_RockArea | real | No | |
RC_Speed | real | No | |
RC_Time | real | No | |
Real | real | Yes | |
Res_Creep_Point | location | Yes | |
Res_Respawn_Time | real | No | |
Res_Temp_Integer | integer | No | |
RespawnTime | real | No | |
RF_AoE | real | No | |
RF_DamagePoint | location | No | |
RF_DamageTrees | boolean | No | |
RF_FallingTime | real | No | |
RF_MaxDamagePerRock | real | No | |
RF_MinDamagePerRock | real | No | |
RF_RockfallSequenceTimer | real | No | |
RF_RocksPerLevel | integer | No | |
RF_SineReals | real | Yes | |
RF_UnitGroup | group | No | |
RFA_Angle | real | Yes | |
RFA_Caster | unit | Yes | |
RFA_Distances | real | Yes | |
RFA_Group | group | No | |
RFA_HighSettings | real | Yes | |
RFA_Integers | integer | Yes | |
RFA_JumpHigh | real | Yes | |
RFA_MaxDmg | real | Yes | |
RFA_ReachedDistance | real | Yes | |
RFA_RealTimer | real | Yes | |
RFA_SpeedUnits | real | Yes | |
RFA_TempPoint | location | Yes | |
RFA_Unit | unit | Yes | |
RFAA_JumpHigh_Distance | real | No | |
RFAA_Speed | real | No | |
RFAA_TargetPoint | location | No | |
RFAA_Unit | unit | No | |
RFS_Caster | unit | Yes | |
RFS_Conjuring | boolean | Yes | |
RFS_ConjurPoint | location | No | |
RFS_DummyIntegers | integer | Yes | |
RFS_MaxDamage | real | Yes | |
RFS_NumberConjured | integer | Yes | |
RFS_NumberOfRocks | integer | Yes | |
RFS_Reals | real | Yes | |
RFS_TempPoint | location | Yes | |
RFS_Timer | real | Yes | |
RFSine_Caster | unit | Yes | |
RFSine_Integers | integer | Yes | |
RFSine_MaxDamage | real | Yes | |
RFSine_Unit | unit | Yes | |
RM_Count | real | No | |
RM_Count2 | integer | No | |
Salmon_Loot | itemcode | Yes | |
Salmon_Roller | integer | No | |
Sandfury_Reputation | integer | No | |
SB_Angle | real | Yes | |
SB_AOE | real | Yes | |
SB_Caster | unit | No | |
SB_Casters | unit | Yes | |
SB_ConvertedDamage | real | Yes | |
SB_CountIntegers | integer | Yes | |
SB_Damage | real | No | |
SB_DestroyTrees | boolean | No | |
SB_Distances | real | Yes | |
SB_DmgAOE | real | No | |
SB_Group | group | No | |
SB_HighSettings | real | Yes | |
SB_Integers | integer | Yes | |
SB_JumpHigh | real | Yes | |
SB_Points | location | Yes | |
SB_ReachedDistance | real | Yes | |
SB_Reals | real | No | |
SB_RealTimer | real | Yes | |
SB_SpeedIncreasement | real | No | |
SB_SpeedUnits | real | Yes | |
SB_TempPoint | location | Yes | |
SB_TotalUnitGroup | group | No | |
SB_TreesDestroy | boolean | Yes | |
SB_Unit | unit | Yes | |
SBA_Integers | integer | No | |
SBA_JumpHigh_Distance | real | No | |
SBA_Speed | real | No | |
SBA_TargetPoint | location | No | |
SBA_Unit | unit | No | |
SF_BouncesNumber | integer | No | |
SF_DamageBigMissiles | real | No | |
SF_DamageSmallMissiles | real | No | |
SF_DestroyTrees | boolean | No | |
SF_NumberOfSmallMissiles | integer | No | |
SF_RangeBetweenBounces | real | No | |
SF_RangeOfSmallMissiles | real | No | |
SF_TempPoint | location | Yes | |
SpiritWolf_Attribute | integer | No | |
T1_Droplist | itemcode | Yes | |
T2_Droplist | itemcode | Yes | |
T3_Droplist | itemcode | Yes | |
T4_Droplist | itemcode | Yes | |
Talk_String_NoQuest | string | Yes | |
Temp | integer | No | |
Temp_Real | real | No | |
TempAbil | abilcode | No | |
TempBoolean | boolean | No | |
TempInteger | integervar | No | |
TempInteger2 | integer | No | |
TempPoint | location | No | |
TempReal | real | No | |
TempString | string | No | |
TempUnit | unit | No | |
TempX | real | No | |
TempY | real | No | |
TidalSplashDmg | real | No | |
time | real | Yes | |
Trollskin_Attribute | integer | No | |
TrollWrathDmg | real | No | |
Turtlehunters_Reputation | integer | No | |
TurtleMana_Mana | real | No | |
TurtleStomp_Dmg | real | No | |
u | unit | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UMovNext | integer | Yes | |
UMovPrev | integer | Yes | |
UnitDamageRegistered | boolean | Yes | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes | |
UnitMoving | boolean | Yes | |
UnitMovingEvent | real | No | |
UnitMovingX | real | Yes | |
UnitMovingY | real | Yes | |
Warrior_Bleed_Caster | unit | Yes | |
Warrior_Bleed_Damage | real | Yes | |
Warrior_Bleed_DamageReal | real | Yes | |
Warrior_Bleed_EffectGroup | group | No | |
Warrior_Bleed_EffectTime | real | Yes | |
Warrior_Bleed_EffectTimeReal | real | Yes | |
Warrior_Bleed_Target | unit | Yes | |
Warrior_Bleed_Time | real | Yes | |
Warscream_Reputation | integer | No | |
WaterSplash_DMG | real | No | |
WindStrike_Attribute | integer | Yes | |
x | real | Yes | |
y | real | Yes |
//TESH.scrollpos=198
//TESH.alwaysfold=0
library AdvancedCameraSystem initializer Init
// Advanced Camera System by The_Witcher
//
// This is a very advanced advanced camera system which adjusts the camera
// distance to the target so the camera isn't looking through houses/trees/...
// and the cameras angle of attack so the view isn't blocked because of hills...
//
// useful for RPGs and that stuff
//
// To bind the camera to a unit for a player use
// SetCameraUnit( unit, player )
//
// if you want to have your normal camera again use
// ReleaseCameraUnit( player )
//
// in case you want to know which unit is bound to the camera for player xy use
// GetCameraUnit( player )
//
// to change the AngleOfAttack of a player ingame use
// SetCamDefaultAngleOfAttack( Player, NewValue )
//
// to change the maximal camera target distance of a player ingame use
// SetCamMaxDistance( Player, NewValue )
//
// to change the maximal distance behind the target, the z-offset is checked (for z-angle), of a player ingame use
// SetCamMaxZCheckDistance( Player, NewValue )
//
// SETUP PART
globals
// The max. distance the camera can have to the target
private real DEFAULT_MAX_DISTANCE = 1650
// The max. distance the zOffset behind the unit is checked (for zAngle)
private real DEFAULT_MAX_Z_CHECK_DISTANCE = 550
// the camera angle of attack correction after the zAngle calculation
private real DEFAULT_ANGLE_OF_ATTACK = -25
// the timer interval (0.01 is best but can lagg in huge maps with many of these short intervals)
private constant real INTERVAL = 0.04
// the time the camera will need to adjust
private constant real DELAY = 0.9
// the standart z of the camera
private constant real NORMAL_HEIGHT = 150
// the accuracy increases if the value gets smaller
private constant real ACCURACY = 100
// the secondary accruracy when the camera reaches a barricade (just leave at this amount)
private constant real EXTREME_ACCURACY = 10
endglobals
// SETUP END
// don't modify the code below!
globals
private item ite
private real array Aoa[15]
private real array Dist[15]
private real array CheckDist[15]
private unit array CamUnit[15]
private timer tim = CreateTimer()
private location loc = Location(0,0)
private integer active = 0
private hashtable h = InitHashtable()
endglobals
private function IsCoordPathable takes real x, real y returns boolean
call SetItemVisible(ite,true)
call SetItemPosition(ite,x,y)
set x = GetItemX( ite) - x
set y = GetItemY( ite) - y
call SetItemVisible(ite,false)
if x < 1 and x > -1 and y < 1 and y > -1 then
return true
endif
return false
endfunction
private function HideAllItems takes nothing returns nothing
if IsItemVisible(GetEnumItem()) then
call SaveInteger(h,GetHandleId(GetEnumItem()),0,1)
endif
call SetItemVisible(GetEnumItem(),false)
endfunction
private function ShowAllItems takes nothing returns nothing
if LoadInteger(h,GetHandleId(GetEnumItem()),0) == 1 then
call SetItemVisible(GetEnumItem(),true)
call FlushChildHashtable(h,GetHandleId(GetEnumItem()))
endif
endfunction
private function Actions takes nothing returns nothing
local real x
local real y
local real angle
local real rz
local real z
local integer i = 0
local integer Check
local real CheckDistance
local real DistanceDone
local rect rec
loop
exitwhen i >= bj_MAX_PLAYERS
if CamUnit[i] != null then
set DistanceDone = 0
set rz = 0
set x = GetUnitX(CamUnit[i])
set y = GetUnitY(CamUnit[i])
set Check = 1
set angle = (GetUnitFacing(CamUnit[i]) - 180)*bj_DEGTORAD
set CheckDistance = ACCURACY
set z = DEFAULT_ANGLE_OF_ATTACK
if not IsUnitType(CamUnit[i], UNIT_TYPE_FLYING) then
loop
set x = x + CheckDistance * Cos(angle)
set y = y + CheckDistance * Sin(angle)
set DistanceDone = DistanceDone + CheckDistance
call MoveLocation(loc,x,y)
set z = GetLocationZ(loc)
if RAbsBJ(z) > RAbsBJ(rz) and DistanceDone <= CheckDist[i] then
set rz = z
endif
if not IsCoordPathable(x,y)then
set rec = Rect(x-ACCURACY,y-ACCURACY,x+ACCURACY,y+ACCURACY)
call EnumItemsInRect(rec,null, function HideAllItems)
if not IsCoordPathable(x,y)then
set Check = 0
endif
call RemoveRect(rec)
endif
if Check == 0 and CheckDistance == ACCURACY then
set DistanceDone = DistanceDone - CheckDistance
set x = x - CheckDistance * Cos(angle)
set y = y - CheckDistance * Sin(angle)
set Check = 1
set CheckDistance = EXTREME_ACCURACY
endif
exitwhen (Check == 0 and CheckDistance == EXTREME_ACCURACY) or DistanceDone > Dist[i]
endloop
else
set DistanceDone = Dist[i]
endif
call MoveLocation(loc,GetUnitX(CamUnit[i]),GetUnitY(CamUnit[i]))
set x = GetLocationZ(loc)
set z = Atan2(x-rz,200) * bj_RADTODEG + Aoa[i]
if IsUnitType(CamUnit[i], UNIT_TYPE_FLYING) then
set z = Aoa[i]
endif
if GetLocalPlayer() == Player(i) then
call CameraSetSmoothingFactor(1)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, DistanceDone, DELAY)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, z, DELAY)
call SetCameraField(CAMERA_FIELD_ZOFFSET,GetCameraField(CAMERA_FIELD_ZOFFSET)+x+GetUnitFlyHeight(CamUnit[i])+NORMAL_HEIGHT-GetCameraTargetPositionZ(),DELAY)
call SetCameraField(CAMERA_FIELD_ROTATION, angle*bj_RADTODEG+180, DELAY)
call SetCameraTargetController(CamUnit[i],0,0,false)
endif
endif
set i = i + 1
endloop
call EnumItemsInRect(bj_mapInitialPlayableArea,null, function ShowAllItems)
set rec = null
endfunction
function ReleaseCameraUnit takes player p returns nothing
if CamUnit[GetPlayerId(p)] != null then
set CamUnit[GetPlayerId(p)] = null
call ResetToGameCameraForPlayer(p,0)
if GetLocalPlayer() == p then
call CameraSetSmoothingFactor(0)
endif
set active = active - 1
if active == 0 then
call PauseTimer(tim)
endif
endif
endfunction
function SetCameraUnit takes unit u, player owner returns nothing
if CamUnit[GetPlayerId(owner)] != null then
call ReleaseCameraUnit(owner)
endif
set CamUnit[GetPlayerId(owner)] = u
set active = active + 1
if active == 1 then
call TimerStart(tim,INTERVAL,true,function Actions)
endif
endfunction
function SetCamDefaultAngleOfAttack takes player p, real a returns nothing
set Aoa[GetPlayerId(p)] = a
endfunction
function SetCamMaxDistance takes player p, real d returns nothing
set Dist[GetPlayerId(p)] = d
endfunction
function SetCamMaxZCheckDistance takes player p, real d returns nothing
set CheckDist[GetPlayerId(p)] = d
endfunction
function GetCameraUnit takes player pl returns unit
return CamUnit[GetPlayerId(pl)]
endfunction
private function Init takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= bj_MAX_PLAYERS
set CamUnit[i] = null
set Aoa[i] = DEFAULT_ANGLE_OF_ATTACK
set Dist[i] = DEFAULT_MAX_DISTANCE
set CheckDist[i] = DEFAULT_MAX_Z_CHECK_DISTANCE
set i = i + 1
endloop
set ite = CreateItem( 'wolg', 0,0 )
call SetItemVisible(ite,false)
endfunction
endlibrary
//TESH.scrollpos=147
//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=162
//TESH.alwaysfold=0
library ArrowKeyMovement initializer Init requires KeyboardSystem, ArrowKeyMovementPlugins
// Arrow key movement by The_Witcher
// this system allows each player to control 1 unit
// with his arrow keys even if he doesn't own the unit!
// It features turning on the left and right arrow, walking foreward
// by pressing the up arrow and walking backwards by pressing the down arrow...
//
// You can improve this system with plugins but you need vJass knowledge for that!
//
// --> The TurnRate of a unit inside the object editor STILL influences the turn rate from this system <--
//
// Included functions:
//
// SetMovementUnit ( whichunit, forWhichPlayer, walkAnimationIndex )
// unit player integer
// this gives the player the arrow key movement control over the unit
// while the unit moves the animation of the given index is played
// (just try around to find the index... start at 0 and increase
// by 1 until you find the walk index of that unit)
//
//
// ReleaseMovementUnit ( fromWhichPlayer )
// player
// this function removes the control from a player
//
//
// GetMovementUnit ( fromWhichPlayer ) returns unit
// player
// I think its self explaining...
//
//
// SetMovementUnitAnimation ( fromWhichPlayer, animation )
// player integer
// this function allows ingame changing of the played animation of a unit
// ------- SETUP PART ---------
globals
// the timer interval... increase if laggy
private constant real INTERVAL = 0.01
// the facing change in degrees each interval (must be a positive value)
private constant real DEFAULT_VIEW_CHANGE = 4
// when you move backwards you move slower than normal...
private constant real BACKWARDS_MOVING_FACTOR = 0.7
// if the unit turns it will turn faster the longer it does...
// some people may need that but then it should be 1.02 (1.0 means disabled)
private constant real TURN_ACCELERATION = 1
// (can only be 1 or -1) if you walk backwards you have 2 ways of turning
// 1. way: pressing left will make the char turn left
// 2. way: pressing left will make the char turn so he moves to the left
private constant integer REVERSED_BACKWARDS_MOVING = 1
endglobals
// whenever this function returns false for a unit it won't be moved even if the player
// presses the keys! change to create your own "No Movement" conditions
private function MoveConditions takes unit u returns boolean
return not IsUnitType(u,UNIT_TYPE_SLEEPING) and not IsUnitType(u,UNIT_TYPE_STUNNED)
endfunction
// --------- don't modify anything below this line ------------
struct ArrowKeyMovement
private static ArrowKeyMovement array all [12] // = bj_MAX_PLAYERS
private static timer tim
integer walking
unit u
integer animation
real SpeedFactor
real ViewChange
real SpecialDirection
boolean SpecialDirectionActive
static method operator [] takes player p returns ArrowKeyMovement
local integer i = GetPlayerId(p)
if .all[i] == 0 then
set .all[i] = ArrowKeyMovement.create()
set .all[i].SpeedFactor = 1
set .all[i].SpecialDirection = 0
set .all[i].SpecialDirectionActive = false
set .all[i].ViewChange = DEFAULT_VIEW_CHANGE
endif
return .all[i]
endmethod
private static method Walking takes nothing returns nothing
local integer i = 0
local real x
local real y
local real X
local real Y
local boolean boolX
local boolean boolY
local boolean left
local boolean right
local boolean up
local boolean down
local ArrowKeyMovement mov
loop
exitwhen i >= 12 // = bj_MAX_PLAYERS
set mov = .all[i]
if mov.u != null and MoveConditions(mov.u) then
// special movement <-- plugins
if mov.SpecialDirectionActive then
if mov.walking != 1 then
call SetUnitTimeScale(mov.u,mov.SpeedFactor)
call SetUnitAnimationByIndex(mov.u,mov.animation)
set mov.walking = 1
else
call SetUnitTimeScale(mov.u,mov.SpeedFactor)
endif
set x = GetUnitX(mov.u)
set y = GetUnitY(mov.u)
set X = x + GetUnitMoveSpeed(mov.u)*INTERVAL * Cos(mov.SpecialDirection*bj_DEGTORAD) * mov.SpeedFactor
set Y = y + GetUnitMoveSpeed(mov.u)*INTERVAL * Sin(mov.SpecialDirection*bj_DEGTORAD) * mov.SpeedFactor
call SetUnitPosition(mov.u,X,Y)
if (RAbsBJ(GetUnitX(mov.u)-X)>0.5)or(RAbsBJ(GetUnitY(mov.u)-Y)>0.5)then
call SetUnitPosition(mov.u,X,y)
set boolX = RAbsBJ(GetUnitX(mov.u)-X)<=0.5
call SetUnitPosition(mov.u,x,Y)
set boolY = RAbsBJ(GetUnitY(mov.u)-Y)<=0.5
if boolX then
call SetUnitPosition(mov.u,X,y)
elseif boolY then
call SetUnitPosition(mov.u,x,Y)
else
call SetUnitPosition(mov.u,x,y)
endif
endif
else
// Normal movement
set left = IsKeyDown(KEY_LEFT,Player(i))
set right = IsKeyDown(KEY_RIGHT,Player(i))
set up = IsKeyDown(KEY_UP,Player(i))
set down = IsKeyDown(KEY_DOWN,Player(i))
//right down
if right then
if down then
call SetUnitFacing(mov.u,GetUnitFacing(mov.u)-mov.ViewChange * -REVERSED_BACKWARDS_MOVING)
else
call SetUnitFacing(mov.u,GetUnitFacing(mov.u)-mov.ViewChange)
endif
set mov.ViewChange = mov.ViewChange * TURN_ACCELERATION
elseif not left then
set mov.ViewChange = DEFAULT_VIEW_CHANGE
endif
//left down
if left then
if down then
call SetUnitFacing(mov.u,GetUnitFacing(mov.u)+mov.ViewChange * -REVERSED_BACKWARDS_MOVING)
else
call SetUnitFacing(mov.u,GetUnitFacing(mov.u)+mov.ViewChange)
endif
set mov.ViewChange = mov.ViewChange * TURN_ACCELERATION
elseif not right then
set mov.ViewChange = DEFAULT_VIEW_CHANGE
endif
//up down
if up then
if mov.walking != 1 then
call SetUnitTimeScale(mov.u,mov.SpeedFactor)
call SetUnitAnimationByIndex(mov.u,mov.animation)
set mov.walking = 1
else
call SetUnitTimeScale(mov.u,mov.SpeedFactor)
endif
set x = GetUnitX(mov.u)
set y = GetUnitY(mov.u)
set X = x + GetUnitMoveSpeed(mov.u)*INTERVAL * Cos(GetUnitFacing(mov.u)*bj_DEGTORAD) * mov.SpeedFactor
set Y = y + GetUnitMoveSpeed(mov.u)*INTERVAL * Sin(GetUnitFacing(mov.u)*bj_DEGTORAD) * mov.SpeedFactor
//down down
elseif down then
if mov.walking != 2 then
call SetUnitTimeScale(mov.u,-BACKWARDS_MOVING_FACTOR * mov.SpeedFactor)
call SetUnitAnimationByIndex(mov.u,mov.animation)
set mov.walking = 2
else
call SetUnitTimeScale(mov.u,-BACKWARDS_MOVING_FACTOR * mov.SpeedFactor)
endif
set x = GetUnitX(mov.u)
set y = GetUnitY(mov.u)
set X = x - GetUnitMoveSpeed(mov.u) * INTERVAL * Cos(GetUnitFacing(mov.u)*bj_DEGTORAD) * BACKWARDS_MOVING_FACTOR * mov.SpeedFactor
set Y = y - GetUnitMoveSpeed(mov.u) * INTERVAL * Sin(GetUnitFacing(mov.u)*bj_DEGTORAD) * BACKWARDS_MOVING_FACTOR * mov.SpeedFactor
endif
//move
if down or up then
call SetUnitPosition(mov.u,X,Y)
if (RAbsBJ(GetUnitX(mov.u)-X)>0.5)or(RAbsBJ(GetUnitY(mov.u)-Y)>0.5)then
call SetUnitPosition(mov.u,X,y)
set boolX = RAbsBJ(GetUnitX(mov.u)-X)<=0.5
call SetUnitPosition(mov.u,x,Y)
set boolY = RAbsBJ(GetUnitY(mov.u)-Y)<=0.5
if boolX then
call SetUnitPosition(mov.u,X,y)
elseif boolY then
call SetUnitPosition(mov.u,x,Y)
else
call SetUnitPosition(mov.u,x,y)
endif
endif
else
if mov.walking != 0 then
call SetUnitAnimation(mov.u,"stand")
call SetUnitTimeScale(mov.u,1)
set mov.walking = 0
endif
endif
endif
endif
set i = i + 1
endloop
endmethod
static method onInit takes nothing returns nothing
set .tim = CreateTimer()
call TimerStart(.tim,INTERVAL,true,function ArrowKeyMovement.Walking)
endmethod
endstruct
function GetMovementUnit takes player p returns unit
return ArrowKeyMovement[p].u
endfunction
function SetMovementUnitAnimation takes player p, integer animation returns nothing
set ArrowKeyMovement[p].animation = animation
endfunction
function ReleaseMovementUnit takes player p returns nothing
if ArrowKeyMovement[p].u != null then
set ArrowKeyMovement[p].walking = 0
call SetUnitAnimation(ArrowKeyMovement[p].u,"stand")
call SetUnitTimeScale(ArrowKeyMovement[p].u,1)
set ArrowKeyMovement[p].u = null
endif
endfunction
function SetMovementUnit takes unit u, player p, integer anim returns nothing
if u == null then
call ReleaseMovementUnit(p)
return
endif
if ArrowKeyMovement[p].u != null then
call ReleaseMovementUnit(p)
endif
call SetUnitAnimation(ArrowKeyMovement[p].u,"stand")
set ArrowKeyMovement[p].u = u
set ArrowKeyMovement[p].animation = anim
endfunction
//! runtextmacro ArrowKeyMovement_Plugins_Functions()
private function Init takes nothing returns nothing
//! runtextmacro Init_ArrowKeyMovement_Plugins()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library ArrowKeyMovementPlugins
// code your own plugins for my Arrow key movement system!
// how you do that is explained in detail in the "How to use the Movement System Plugins"
// comment included in this map
//
//
// the plugins I coded for the test map are:
// 1. running fast/dashing when double pressing up
// 2. turning around (180°) when double pressing down
// 3. moving left without changing face direction when double pressing left
// 4. moving right without changing face direction when double pressing right
//! textmacro Init_ArrowKeyMovement_Plugins
local trigger t
// This is the initialization for turning around on double down press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleDownPress)
call TriggerRegisterKeyDoublePressEvent(t,KEY_DOWN)
// This is the initialization for dashing on double up press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleUpPress)
call TriggerRegisterKeyDoublePressEvent(t,KEY_UP)
// This is the initialization for sliding left on double left press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleLeftPress)
call TriggerRegisterKeyDoublePressEvent(t,KEY_LEFT)
// This is the initialization for sliding right on double right press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleRightPress)
call TriggerRegisterKeyDoublePressEvent(t,KEY_RIGHT)
// This is the initialization for stoping the dash of double up press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleUpRelease)
call TriggerRegisterKeyDoubleInterruptEvent(t,KEY_UP)
// This is the initialization for stoping slide of double left press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleLeftRelease)
call TriggerRegisterKeyDoubleInterruptEvent(t,KEY_LEFT)
// This is the initialization for stoping slide of double right press
set t = CreateTrigger()
call TriggerAddAction(t, function OnDoubleRightRelease)
call TriggerRegisterKeyDoubleInterruptEvent(t,KEY_RIGHT)
//! endtextmacro
//! textmacro ArrowKeyMovement_Plugins_Functions
// This is the function for turning around on double down press
private function OnDoubleDownPress takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = false
call SetUnitFacing(mov.u,GetUnitFacing(mov.u)-180)
endfunction
// This is the function for dashing on double up press
private function OnDoubleUpPress takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = false
set mov.SpeedFactor = 2
endfunction
// This is the function for sliding left on double left press
private function OnDoubleLeftPress takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = true
set mov.SpecialDirection = GetUnitFacing(mov.u) + 90
set mov.SpeedFactor = 0.6
endfunction
// This is the function for sliding right on double right press
private function OnDoubleRightPress takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = true
set mov.SpecialDirection = GetUnitFacing(mov.u) - 90
set mov.SpeedFactor = 0.6
endfunction
// This is the function for stoping the dash of double up press
private function OnDoubleUpRelease takes nothing returns nothing
set ArrowKeyMovement[GetTriggerPlayer()].SpeedFactor = 1
endfunction
// This is the function for stoping slide of double left press
private function OnDoubleLeftRelease takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = false
set mov.SpeedFactor = 1
endfunction
// This is the function for stoping slide of double right press
private function OnDoubleRightRelease takes nothing returns nothing
local ArrowKeyMovement mov = ArrowKeyMovement[GetTriggerPlayer()]
set mov.SpecialDirectionActive = false
set mov.SpeedFactor = 1
endfunction
//! endtextmacro
endlibrary