// ===========================
function H2I takes handle h returns integer
return h
return 0
endfunction
// ===========================
function LocalVars takes nothing returns gamecache
// Replace InitGameCache("jasslocalvars.w3v") with a global variable!!
return udg_JonnyCache
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
if value==null then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
endif
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
if value==false then
call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
else
call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleString takes handle subject, string name, string value returns nothing
if value==null then
call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
else
call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleUnit takes handle subject, string name returns unit
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
Name | Type | is_array | initial_value |
CannonPoint | location | Yes | |
Dist | real | Yes | |
Down | boolean | Yes | |
GunAngle | real | Yes | |
GunPivot | real | Yes | 340.00 |
Indicator | unit | Yes | |
JonnyCache | gamecache | No | |
Left | boolean | Yes | |
Player | player | No | |
RandomPoint | location | No | |
Right | boolean | Yes | |
Roll | integer | No | |
TankCam | boolean | Yes | |
TanksAlive | integer | No | |
Unit | unit | Yes | |
Up | boolean | Yes |
function Trig_Handlevars_Actions takes nothing returns nothing
call FlushGameCache(InitGameCache("cache.x"))
set udg_JonnyCache=InitGameCache("cache.x")
endfunction
//===========================================================================
function InitTrig_Handlevars takes nothing returns nothing
set gg_trg_Handlevars = CreateTrigger( )
call TriggerAddAction( gg_trg_Handlevars, function Trig_Handlevars_Actions )
endfunction
function movegun takes nothing returns nothing
local location temp
set temp = GetUnitLoc(udg_Unit[1])
call SetUnitPositionLocFacingBJ( udg_Unit[2], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[1])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[1])) * -100.00 )), ( udg_GunAngle[2] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[3])
call SetUnitPositionLocFacingBJ( udg_Unit[4], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[3])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[3])) * -100.00 )), ( udg_GunAngle[4] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[5])
call SetUnitPositionLocFacingBJ( udg_Unit[6], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[5])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[5])) * -100.00 )), ( udg_GunAngle[6] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[7])
call SetUnitPositionLocFacingBJ( udg_Unit[8], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[7])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[7])) * -100.00 )), ( udg_GunAngle[8] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[9])
call SetUnitPositionLocFacingBJ( udg_Unit[10], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[9])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[9])) * -100.00 )), ( udg_GunAngle[10] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[11])
call SetUnitPositionLocFacingBJ( udg_Unit[12], OffsetLocation( temp, ( CosBJ(GetUnitFacing(udg_Unit[11])) * -100.00 ), ( SinBJ(GetUnitFacing(udg_Unit[11])) * -100.00 )), ( udg_GunAngle[12] - 55.00 ) )
set temp = null
set temp = GetUnitLoc(udg_Unit[2])
set udg_Dist[2] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[2] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[2] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[2], PolarProjectionBJ(GetUnitLoc(udg_Unit[2]), udg_Dist[2], udg_GunAngle[2]), 0.00 )
set temp = null
set temp = GetUnitLoc(udg_Unit[4])
set udg_Dist[4] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[4] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[4] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[4], PolarProjectionBJ(GetUnitLoc(udg_Unit[4]), udg_Dist[4], udg_GunAngle[4]), 0.00 )
set temp = null
set temp = GetUnitLoc(udg_Unit[6])
set udg_Dist[6] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[6] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[6] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[6], PolarProjectionBJ(GetUnitLoc(udg_Unit[6]), udg_Dist[6], udg_GunAngle[6]), 0.00 )
set temp = null
set temp = GetUnitLoc(udg_Unit[8])
set udg_Dist[8] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[8] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[8] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[8], PolarProjectionBJ(GetUnitLoc(udg_Unit[8]), udg_Dist[8], udg_GunAngle[8]), 0.00 )
set temp = null
set temp = GetUnitLoc(udg_Unit[10])
set udg_Dist[10] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[10] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[10] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[10], PolarProjectionBJ(GetUnitLoc(udg_Unit[10]), udg_Dist[10], udg_GunAngle[10]), 0.00 )
set temp = null
set temp = GetUnitLoc(udg_Unit[12])
set udg_Dist[12] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[12] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[12] - 340.00 ) ) ) )
call SetUnitPositionLocFacingBJ( udg_Indicator[12], PolarProjectionBJ(GetUnitLoc(udg_Unit[12]), udg_Dist[12], udg_GunAngle[12]), 0.00 )
set temp = null
call RemoveLocation(temp)
endfunction
function Trig_Gun_Attach_Actions takes nothing returns nothing
local timer go = CreateTimer()
call TimerStart( go, 0.01, TRUE, function movegun )
endfunction
//===========================================================================
function InitTrig_Gun_Attach takes nothing returns nothing
set gg_trg_Gun_Attach = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Gun_Attach, 2.00 )
call TriggerAddAction( gg_trg_Gun_Attach, function Trig_Gun_Attach_Actions )
endfunction
function turnleft takes nothing returns nothing
local timer go = GetExpiredTimer()
local integer index = GetHandleInt(go, "index")
if (udg_Left[index]) then
set udg_GunAngle[index] = ( udg_GunAngle[index] + 0.4 )
else
call DestroyTimer(go)
call FlushHandleLocals(go)
endif
endfunction
function Trig_AngleLeft_Actions takes nothing returns nothing
local timer go = CreateTimer()
local integer index = GetConvertedPlayerId(GetTriggerPlayer())
set udg_Left[index] = true
call SetHandleInt( go, "index", index )
call TimerStart( go, 0.01, TRUE, function turnleft )
endfunction
//===========================================================================
function InitTrig_AngleLeft takes nothing returns nothing
set gg_trg_AngleLeft = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(3), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(5), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(7), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(9), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleLeft, Player(11), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction( gg_trg_AngleLeft, function Trig_AngleLeft_Actions )
endfunction
function turnright takes nothing returns nothing
local timer go = GetExpiredTimer()
local integer index = GetHandleInt(go, "index")
if (udg_Right[index]) then
set udg_GunAngle[index] = ( udg_GunAngle[index] - 0.4 )
else
call DestroyTimer(go)
call FlushHandleLocals(go)
endif
endfunction
function Trig_AngleRight_Actions takes nothing returns nothing
local timer go = CreateTimer()
local integer index = GetConvertedPlayerId(GetTriggerPlayer())
set udg_Right[index] = true
call SetHandleInt( go, "index", index )
call TimerStart( go, 0.01, TRUE, function turnright )
endfunction
//===========================================================================
function InitTrig_AngleRight takes nothing returns nothing
set gg_trg_AngleRight = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(3), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(5), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(7), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(9), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleRight, Player(11), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
call TriggerAddAction( gg_trg_AngleRight, function Trig_AngleRight_Actions )
endfunction
function turnup takes nothing returns nothing
local timer go = GetExpiredTimer()
local integer index = GetHandleInt(go, "index")
if (udg_Up[index]) then
set udg_Dist[index] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[index] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[index] - 340.00 ) ) ) )
if ( udg_GunPivot[index] < 345.00 ) then
set udg_GunPivot[index] = ( udg_GunPivot[index] + 0.25 )
endif
else
call DestroyTimer(go)
call FlushHandleLocals(go)
endif
endfunction
function Trig_AngleUp_Actions takes nothing returns nothing
local timer go = CreateTimer()
local integer index = GetConvertedPlayerId(GetTriggerPlayer())
set udg_Up[index] = true
call SetHandleInt( go, "index", index )
call TimerStart( go, 0.05, TRUE, function turnup )
endfunction
//===========================================================================
function InitTrig_AngleUp takes nothing returns nothing
set gg_trg_AngleUp = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(3), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(5), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(7), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(9), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleUp, Player(11), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerAddAction( gg_trg_AngleUp, function Trig_AngleUp_Actions )
endfunction
function turndown takes nothing returns nothing
local timer go = GetExpiredTimer()
local integer index = GetHandleInt(go, "index")
if (udg_Down[index]) then
set udg_Dist[index] = ( 900.00 + ( ( 4.00 * Pow(( udg_GunPivot[index] - 334.00 ), 2.00) ) + ( 60.00 * ( udg_GunPivot[index] - 340.00 ) ) ) )
if ( udg_GunPivot[index] > 335.00 ) then
set udg_GunPivot[index] = ( udg_GunPivot[index] - 0.25 )
endif
else
call DestroyTimer(go)
set index = 0
call FlushHandleLocals(go)
endif
endfunction
function Trig_AngleDown_Actions takes nothing returns nothing
local timer go = CreateTimer()
local integer index = GetConvertedPlayerId(GetTriggerPlayer())
set udg_Down[index] = true
call SetHandleInt( go, "index", index )
call TimerStart( go, 0.05, TRUE, function turndown )
endfunction
//===========================================================================
function InitTrig_AngleDown takes nothing returns nothing
set gg_trg_AngleDown = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(3), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(5), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(7), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(9), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerRegisterPlayerKeyEventBJ( gg_trg_AngleDown, Player(11), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
call TriggerAddAction( gg_trg_AngleDown, function Trig_AngleDown_Actions )
endfunction
function Trig_Fire_Cannon_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction
function Trig_Fire_Cannon_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local location orig = GetUnitLoc(caster)
local location target = PolarProjectionBJ(orig, udg_Dist[GetConvertedPlayerId(GetOwningPlayer(caster))], udg_GunAngle[GetConvertedPlayerId(GetOwningPlayer(caster))])
local unit dummy1 = CreateUnitAtLoc(GetOwningPlayer(caster), 'u001', target, 0)
local unit dummy2 = CreateUnitAtLoc(GetOwningPlayer(caster), 'u000', orig, udg_GunAngle[GetConvertedPlayerId(GetOwningPlayer(caster))])
if ( GetUnitStateSwap(UNIT_STATE_MANA, caster) >= 1.00 ) then
call IssueTargetOrderBJ(dummy2, "attackonce", dummy1)
call SetUnitManaBJ( caster, ( GetUnitStateSwap(UNIT_STATE_MANA, caster) - 1 ) )
else
call DisplayTextToPlayer( GetOwningPlayer(caster), 0, 0, "Out of Ammo!" )
call RemoveUnit( dummy1 )
endif
call TriggerSleepAction( 0.10 )
call RemoveUnit( dummy2 )
set orig = null
call RemoveLocation(orig)
set target = null
call RemoveLocation(target)
set caster = null
set dummy1 = null
set dummy2 = null
endfunction
//===========================================================================
function InitTrig_Fire_Cannon takes nothing returns nothing
set gg_trg_Fire_Cannon = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Cannon, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Fire_Cannon, Condition( function Trig_Fire_Cannon_Conditions ) )
call TriggerAddAction( gg_trg_Fire_Cannon, function Trig_Fire_Cannon_Actions )
endfunction
function Trig_UseMine_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A002' ) ) then
return false
endif
return true
endfunction
function Trig_UseMine_Actions takes nothing returns nothing
local location temp = GetUnitLoc(GetTriggerUnit())
local location temp2 = PolarProjectionBJ( temp, 200,(GetUnitFacing(GetTriggerUnit()) - 180))
call IssueImmediateOrder(GetTriggerUnit(), "stop" )
if ( GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) >= 1.00 ) then
call CreateUnitAtLoc( GetOwningPlayer(GetTriggerUnit()), 'n000', temp2, 0)
call SetUnitManaBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) - 1 ) )
else
call DisplayTextToPlayer( GetOwningPlayer(GetTriggerUnit()), 0, 0, "Out of Mines!" )
endif
set temp = null
set temp2 = null
call RemoveLocation(temp)
call RemoveLocation(temp2)
endfunction
//===========================================================================
function InitTrig_UseMine takes nothing returns nothing
set gg_trg_UseMine = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_UseMine, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_UseMine, Condition( function Trig_UseMine_Conditions ) )
call TriggerAddAction( gg_trg_UseMine, function Trig_UseMine_Actions )
endfunction