//TESH.scrollpos=0
//TESH.alwaysfold=0
function GetAngleDifference takes real a1, real a2 returns real
local real x
set a1=ModuloReal(a1,360)
set a2=ModuloReal(a2,360)
if a1>a2 then
set x=a1
set a1=a2
set a2=x
endif
set x=a2-360
if a2-a1 > a1-x then
set a2=x
endif
return RAbsBJ(a1-a2)
endfunction
Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library DroneSystem requires Table, LinkedListModule /*
//==============================================================================
//========================== Drone System ==================================
//==============================================================================
This system allows you to add drones to a unit which follow/surround it.
Examples: Space maps: Use this system to add weapons to ships. The weapons will fire even if the ship moves!
Pokemon maps: Pikachu will always follow the trainer ;)
~~ Usage ~~
To create a new, static drone use
call droneList[yourUnit].add( DroneRawcode, DistanceToTarget, AngleToTarget, IsDroneAttackable) returns drone
integer real real boolean
To create a new rotating drone use
call droneList[yourUnit].addEx( DroneRawcode, DistanceToTarget, InitialAngleToTarget, AnglePerSecond, IsDroneAttackable) returns drone
integer real real real boolean
To clear all drones of a parent use
call droneList[yourUnit].destroy()
To remove a specific drone use
call drone[droneUnit].destroy()
You can modify the following values of a drone:
set drone[droneUnit].angle = newAngle <- the angle relative to the parents facing
set drone[droneUnit].distance = newDistance <- the distance to the parent
set drone[droneUnit].anglePerSecond = new <- the angle the rotating drone travels per second
*/
// Setup Part:
globals
private constant real TIMER_INTERVAL = 0.01
endglobals
/* How to implement this system in your map??
just copy and paste this trigger into your map
*/
//==============================================================================
//========================== System Code ====================================
//==============================================================================
globals
private Table table
endglobals
struct drone extends array
readonly unit unit
real distance
private real a
private real s
implement LinkedList
static method operator [] takes unit u returns drone
return table[GetHandleId(u)]
endmethod
method operator angle= takes real v returns nothing
set .a = angle * bj_DEGTORAD
endmethod
method operator angle takes nothing returns real
return .a
endmethod
method operator anglePerSecond= takes real v returns nothing
set .s = v * TIMER_INTERVAL * bj_DEGTORAD
endmethod
method operator anglePerSecond takes nothing returns real
return .s * bj_RADTODEG / TIMER_INTERVAL
endmethod
method destroy takes nothing returns nothing
call table.remove(GetHandleId(.unit))
call .removeNode()
call .deallocate()
endmethod
method update takes unit parent returns nothing
if IsUnitType(.unit, UNIT_TYPE_DEAD) or GetUnitTypeId(.unit) == 0 then
call .destroy()
else
set .a = .a + .s
call SetUnitX(.unit, GetUnitX(parent) + .distance * Cos(GetUnitFacing(parent) * bj_DEGTORAD + .a))
call SetUnitY(.unit, GetUnitY(parent) + .distance * Sin(GetUnitFacing(parent) * bj_DEGTORAD + .a))
if GetUnitCurrentOrder(.unit) == OrderId("move") then
call IssueImmediateOrder(.unit, "stop")
endif
endif
endmethod
method add takes unit u, real d, real a, real s returns drone
local thistype new = .allocate()
set new.unit = u
set new.distance = d
set new.a = a
set new.s = s
call SetUnitPathing(u, false)
set table[GetHandleId(u)] = new
call .insertNode(new)
return new
endmethod
endstruct
struct droneList extends array
private static timer tim
private drone list
readonly unit parent
implement LinkedList
static method operator [] takes unit u returns droneList
local droneList this
if table.has(GetHandleId(u)) then
set this = table[GetHandleId(u)]
else
set this = droneList.allocate()
set .list = drone.createNode()
set .parent = u
set table[GetHandleId(u)] = this
if .base.next.head then
call TimerStart(.tim, TIMER_INTERVAL, true, function thistype.periodic)
endif
call .base.insertNode(this)
endif
return this
endmethod
method destroy takes nothing returns nothing
local drone node = .list.next
loop
exitwhen node.head
call RemoveUnit(node.unit)
call node.destroy()
set node = node.next
endloop
call table.remove(GetHandleId(.parent))
call .list.removeNode()
call .list.deallocate()
call .removeNode()
call .deallocate()
endmethod
private static method periodic takes nothing returns nothing
local droneList this = .base.next
local drone node
local real x
local real y
local real f
local boolean dead
loop
exitwhen .head
set dead = IsUnitType(.parent, UNIT_TYPE_DEAD) or GetUnitTypeId(.parent) == 0
if not dead then
set node = .list.next
loop
exitwhen node.head
call node.update(.parent)
set node = node.next
endloop
endif
if dead or .list.next.head then
call .destroy()
endif
set this = .next
endloop
if .base.next.head then
call PauseTimer(.tim)
endif
endmethod
method addEx takes integer droneId, real distance, real angle, real anglePerSecond, boolean attackable returns drone
local real x = GetUnitX(parent) + distance * Cos((GetUnitFacing(parent) + angle) * bj_DEGTORAD)
local real y = GetUnitY(parent) + distance * Sin((GetUnitFacing(parent) + angle) * bj_DEGTORAD)
local drone new = .list.add(CreateUnit(GetOwningPlayer(parent), droneId, x, y, GetUnitFacing(parent)), distance, angle * bj_DEGTORAD, anglePerSecond * TIMER_INTERVAL * bj_DEGTORAD)
call SetUnitInvulnerable(new.unit, not attackable)
return new
endmethod
method add takes integer droneId, real distance, real angle, boolean attackable returns drone
return .addEx(droneId, distance, angle, 0, attackable)
endmethod
private static method onInit takes nothing returns nothing
set table = Table.create()
set .tim = CreateTimer()
endmethod
endstruct
endlibrary
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
One map, one hashtable. Welcome to NewTable 3.1
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key)
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb)
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
endlibrary
//TESH.scrollpos=20
//TESH.alwaysfold=0
library LinkedListModule /* v2.2.0
Easy implementation of linked lists into structs.
***********************************************************************
*
* module LinkedList
*
* - Implement at the top of your struct, must extend array
*
* thistype next
* thistype prev
* boolean head
*
* readonly static thistype base
* - Precreated head, useful for non-dynamic lists.
*
* static method allocate takes nothing returns thistype
* method deallocate takes nothing returns nothing
*
* static method createNode takes nothing returns thistype
* - Allocates a new node pointing towards itself.
* - These nodes are considered "heads" therefore it's head
* - boolean member is set to true.
* method insertNode takes thistype toInsert returns thistype
* - Inserts the node into the list after 'this' node.
* method removeNode takes nothing returns nothing
* - Removes the node from the list.
* method clearNode takes nothing returns nothing
* - Deallocates all the instances within the node's range
* method flushNode takes nothing returns nothing
* - Clears and deallocates the node.
*
********************************************************************* */
module LinkedList
//private static integer instanceCount = 0
readonly static integer instanceCount = 0
boolean head
thistype next
thistype prev
static method operator base takes nothing returns thistype
return 8190
endmethod
static method allocate takes nothing returns thistype
local thistype this=thistype(0).prev
if this == 0 then
debug if instanceCount == 8190 then
debug call BJDebugMsg("[LinkedList] Error: attempted to allocate too many instances.")
debug return 0
debug endif
set instanceCount=instanceCount+1
return instanceCount
endif
set thistype(0).prev=this.prev
return this
endmethod
method deallocate takes nothing returns nothing
set this.prev=thistype(0).prev
set thistype(0).prev=this
set this.head=false
endmethod
static method createNode takes nothing returns thistype
local thistype this=allocate()
set this.next=this
set this.prev=this
set this.head=true
return this
endmethod
method clearNode takes nothing returns nothing
if this != this.next then
set this.next.prev=thistype(0).prev
set thistype(0).prev=this.prev
set this.next=this
set this.prev=this
endif
endmethod
method flushNode takes nothing returns nothing
set this.next.prev=thistype(0).prev
set thistype(0).prev=this
set head=false
endmethod
method insertNode takes thistype toInsert returns nothing
set this.prev.next=toInsert
set toInsert.prev=this.prev
set this.prev=toInsert
set toInsert.next=this
endmethod
method removeNode takes nothing returns nothing
set this.prev.next=this.next
set this.next.prev=this.prev
endmethod
private static method onInit takes nothing returns nothing
set thistype(8190).next=8190
set thistype(8190).prev=8190
set thistype(8190).head=true
endmethod
static if DEBUG_MODE then
method print takes nothing returns nothing
local string s=""
local thistype exit=this
set this=this.next
loop
set s=s+I2S(this)
set this=this.next
exitwhen this == exit
set s=s+" - "
endloop
call BJDebugMsg("[ "+s+" ]")
endmethod
endif
endmodule
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope Initialize initializer Init
globals
unit car
boolean WEAPON_ACTIVE = false
endglobals
function InitGame takes nothing returns nothing
set car = gg_unit_h001_0001
call SetCameraTargetController(car, 0, 0, false)
call FogEnable( false )
call SetSkyModel( "Environment\\Sky\\Sky\\SkyLight.mdl" )
//call EnableWeatherEffect( GetLastCreatedWeatherEffect(), true )
call FogMaskEnable( false )
call SetUnitAnimationByIndex(car,3)
call CinematicModeBJ( true, bj_FORCE_ALL_PLAYERS )
call EnableUserControl(true)
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 12)
call SuspendTimeOfDay( true )
call DisplayTimedTextToPlayer(Player(0),0,0,500,"|cffFF1084D|r|cffF21387r|r|cffE5168Ao|r|cffD8198Dn|r|cffCB1C90e|r |cffB12296S|r|cffA42599y|r|cff97289Cs|r|cff8A2B9Ft|r|cff7D2EA2e|r|cff7031A5m|r |cff5637ABb|r|cff493AAEy|r |cff364E9DT|r|cff325295h|r|cff2E568De|r|cff2A5A85_|r|cff265E7DW|r|cff226275i|r|cff1E666Dt|r|cff1A6A65c|r|cff166E5Dh|r|cff127255e|r|cff0E764Dr|r")
call DisplayTimedTextToPlayer(Player(0),0,0,500,"")
call DisplayTimedTextToPlayer(Player(0),0,0,500,"|cffFFE608v|r|cffEED90Ei|r|cffDDCC14s|r|cffCCBF1Ai|r|cffBBB220t|r |cff99982Cw|r|cff888B32w|r|cff777E38w|r|cff66713E.|r|cff556444h|r|cff44574Ai|r|cff334A50v|r|cff223D56e|r|cff2E295Dw|r|cff41295Ao|r|cff542957r|r|cff672954k|r|cff7A2951s|r|cff8D294Eh|r|cffA0294Bo|r|cffB32948p|r|cffC62945.|r|cffD92942c|r|cffEC293Fo|r|cffFF293Cm|r")
endfunction
//===========================================================================
function Init takes nothing returns nothing
call TimerStart(CreateTimer(),0,false, function InitGame)
endfunction
endscope
//TESH.scrollpos=12
//TESH.alwaysfold=0
scope weapons initializer Init
private function action takes nothing returns boolean
local integer i = GetRandomInt(0, 100)
if GetTriggerUnit() != car then
return false
endif
call SetUnitState(car, UNIT_STATE_MANA, GetUnitState(car, UNIT_STATE_MAX_MANA))
call droneList[car].destroy()
set WEAPON_ACTIVE = true
if i > 66 then
call droneList[car].add('h000', 100, 90, false)
call droneList[car].add('h000', 100, -90, false)
call DisplayTimedTextToPlayer( Player(0), 0, 0, 1, "Fast Weapons activated!" )
elseif i > 33 then
call droneList[car].addEx('h003', 200, 180, 90, false)
call DisplayTimedTextToPlayer( Player(0), 0, 0, 1, "Fire Weapon activated!" )
else
call droneList[car].add('h002', 200, 180, false)
call DisplayTimedTextToPlayer( Player(0), 0, 0, 1, "Sniper activated!" )
endif
set i = GetRandomInt(1, 100)
if i > 66 then
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "RATATATATATATATA !!!!", bj_TIMETYPE_ADD, 0, true )
elseif i > 33 then
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "MUAHAHA armed and ready!!", bj_TIMETYPE_ADD, 0, true )
else
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "This is fun !!", bj_TIMETYPE_ADD, 0, true )
endif
return false
endfunction
private function Mana takes nothing returns nothing
if WEAPON_ACTIVE then
call SetUnitState(car, UNIT_STATE_MANA, GetUnitState(car, UNIT_STATE_MANA) - 0.1)
if GetUnitState(car, UNIT_STATE_MANA) <= 0.1 then
set WEAPON_ACTIVE = false
call droneList[car].destroy()
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "Ahh... Out of Ammo...", bj_TIMETYPE_ADD, 0, true )
endif
endif
endfunction
private function Init takes nothing returns nothing
local region rectRegion = CreateRegion()
local trigger t = CreateTrigger()
call RegionAddRect(rectRegion, gg_rct_Gebiet_000)
call RegionAddRect(rectRegion, gg_rct_Gebiet_001)
call RegionAddRect(rectRegion, gg_rct_Gebiet_002)
call TriggerRegisterEnterRegion(t, rectRegion, null)
call TriggerAddCondition( t, Condition( function action ) )
call TimerStart(CreateTimer(), 1, true, function Mana)
endfunction
endscope
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
//TESH.scrollpos=18
//TESH.alwaysfold=0
scope arrowMove initializer Init
globals
private item ite
private boolean left
private boolean right
endglobals
private function IsCoordPathable takes real x, real y returns boolean
local real xx
local real yy
call SetItemVisible(ite, true)
call SetItemPosition(ite, x, y)
set xx = GetItemX( ite ) - x
set yy = GetItemY( ite ) - y
call SetItemVisible(ite, false)
return xx < 1 and xx > -1 and yy < 1 and yy > -1
endfunction
private function move takes nothing returns nothing
local real r = GetUnitFacing(car)
local real x = GetUnitX(car) + 5 * Cos(r * bj_DEGTORAD)
local real y = GetUnitY(car) + 5 * Sin(r * bj_DEGTORAD)
call SetCameraField( CAMERA_FIELD_ROTATION, r, 0.25 )
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, 340, 0.25)
if IsCoordPathable(x, y) then
call SetUnitX(car, x)
call SetUnitY(car, y)
endif
if left then
call SetUnitFacing(car, r + 2)
elseif right then
call SetUnitFacing(car, r - 2)
endif
endfunction
private function keyAction takes nothing returns nothing
if GetTriggerEventId() == EVENT_PLAYER_ARROW_LEFT_DOWN then
set left = true
elseif GetTriggerEventId() == EVENT_PLAYER_ARROW_LEFT_UP then
set left = false
elseif GetTriggerEventId() == EVENT_PLAYER_ARROW_RIGHT_DOWN then
set right = true
elseif GetTriggerEventId() == EVENT_PLAYER_ARROW_RIGHT_UP then
set right = false
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
set ite = CreateItem( 'wolg', 0, 0 )
call SetItemVisible(ite, false)
call TimerStart(CreateTimer(), 0.01, true, function move)
call TriggerRegisterPlayerEvent( t, Player(0), EVENT_PLAYER_ARROW_LEFT_DOWN )
call TriggerRegisterPlayerEvent( t, Player(0), EVENT_PLAYER_ARROW_RIGHT_DOWN )
call TriggerRegisterPlayerEvent( t, Player(0), EVENT_PLAYER_ARROW_LEFT_UP )
call TriggerRegisterPlayerEvent( t, Player(0), EVENT_PLAYER_ARROW_RIGHT_UP )
call TriggerAddAction( t, function keyAction )
endfunction
endscope
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope kill initializer Init
private function action takes nothing returns boolean
local integer i = GetRandomInt(0, 100)
if i > 66 then
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "Rest in pieces!!", bj_TIMETYPE_ADD, 0, true )
elseif i > 33 then
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "Your mother does strange things with vegetables!!", bj_TIMETYPE_ADD, 0, true )
else
call TransmissionFromUnitWithNameBJ( GetPlayersAll(), car, "Driver:", null, "Fool...", bj_TIMETYPE_ADD, 0, true )
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerUnitEvent(t, Player(1), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition( t, Condition( function action ) )
endfunction
endscope
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com