Methods

abs(v:Float):Float

Get the absolute value of v.

Parameters:

v

Returns:

Float

addFoes(foes:Array<{z:Int, u:UnitKind, nb:Int}>):Void

Allow to quickly add a number of foes in a specific zone. Example : addFoes([ {z:198, u:Unit.Death, nb:2}, // Add 2 Draugr in zone 198 {z:201, u.Unit.Wolf, nb:3}, // Add 3 wolves in zone 201 ]);

Parameters:

null

foes

addRule(id:RuleKind):Void

Add a Conquest rule to the game.

Parameters:

null

id

allowTrade(from:Player, with:Faction, allow:Bool):Void

Allow or forbid trade from a player to a faction.

Parameters:

from
with
allow

true to allow, false to forbid.

@:value({ duration : 1. })blackWindow(b:Bool, duration:Float = 1.):Void

Fade the screen to or from black with a duration.

Parameters:

b

true to show a black screen, false to show the game.

duration

[Optional] The fade duration in seconds. A duration of 0 immediately show the black screen. Default at 1.

customDefeat(reason:String):Void

Immediately make the main player lose the game with a custom reason. Will make the Host lose in case of multiplayer. Use Player.customDefeat() for other players.

Parameters:

reason

The reason of the defeat.

debug(s:String, ?color:Int):Void

Print a string on the ingame console.

Parameters:

s

The string to print

color

The text color as an hexadecimal value (ex : 0xFF4040)

defeat():Void

Immediately make the main player lose the game. Will make the Host lose in case of multiplayer. Use Player.defeat() for other players.

drakkar(owner:Player, targetZone:Zone, spawnZone:Zone, dx:Float, dy:Float, ?units:Array<UnitKind>, ?speed:Float):Void

[HostOnly] Spawn a drakkar full of units to unload. Example: // summon a rather quick drakkar with 3 warriors on board. drakkar(player, getZone(103), getZone(105), 8, -4, [Unit.Warrior, Unit.Warrior, Unit.Warrior], 0.2);

Parameters:

owner

The owner of the spawned units

targetZone

The zone where the drakkar will unload its cargo, preferably a beach.

spawnZone

The zone from which the drakkar comes, preferably a high sea zone.

dx

Spawn offset on x coordinates

dy

Spawn offset on y coordinates

units

[Optional] The units to unload. If empty, will unload 4 mercenaries.

speed

[Optional] The speed of the drakkar.
Default at 0.05.

fmax(a:Float, b:Float):Float

Get the smaller value from a and b.

Parameters:

a
b

Returns:

Float

fmin(a:Float, b:Float):Float

Get the higher value from a and b.

Parameters:

a
b

Returns:

Float

followUnit(unit:Unit):Void

Make the camera follow a unit. Set to null to stop the follow.

Parameters:

null

unit

getFaction(name:String):Faction

Get a faction by its name. To use to retrieve neutral factions.

Parameters:

name

Returns:

Faction

getPlayer(name:String):Player

Get a player by its clan identifier or ingame name

Parameters:

name

Returns:

Player

getZone(id:Int):Zone

Get a zone by its id.

Parameters:

id

Returns:

Zone

hasAnyRule():Bool

Returns true if the game has any Conquest rule.

Returns:

Bool

hasRule(id:RuleKind):Void

Check if the game has the given Conquest rule.

Parameters:

null

id

invoke(p:Player, id:String, args:Array<Dynamic>):Void

[HostOnly] Used by the host to execute a function on a client or himself.

Parameters:

p

The player to execute the function on.

id

The function name.

args

A list of argument. Must match the list of parameters of the function.

invokeAll(id:String, args:Array<Dynamic>):Void

[HostOnly] Used by the host to execute the same function on everyone.

Parameters:

id

The function name.

args

A list of argument. Must match the list of parameters of the function.

invokeHost(id:String, args:Array<Dynamic>):Void

Used by the client to execute a function on the host.

Parameters:

id

The function name.

args

A list of argument. Must match the list of parameters of the function.

isHost():Bool

Tells if the script is executed on the Host in multiplayer, a.k.a is the one managing the gameplay logic for the clients. Always true for offline scripts.

Returns:

Bool

killAllUnits(zones:Array<Zone>):Void

Kill all the units and foes from the given zones.

Parameters:

null

zones

killFoes(arr:Array<{z:Int, u:UnitKind, nb:Int}>):Void

Allow to quickly remove a number of foes in a specific zone. Example : addFoes([ {z:198, u:Unit.Death, nb:2}, // Remove 2 Draugr in zone 198 {z:201, u.Unit.Wolf, nb:3}, // Remove 3 wolves in zone 201 ]);

Parameters:

null

arr

launchAttack(units:Array<Unit>, targetZones:Array<Int>, ?isRandom:Bool):Bool

[HostOnly] Tell all the specified units to attack one of the given zones.

Parameters:

units
targetZones

The ZoneId of each target zones.

isRandom

Set to true to attack the zones in a random order, false, to start by the first one.

Returns:

Bool True if the units could find a path to attack one of the given zones, else false.

launchAttackPlayer(units:Array<Unit>, player:Player):Bool

[HostOnly] Tell the specified units to attack a player's zone randomly.

Parameters:

units
player

Returns:

Bool

max(a:Int, b:Int):Int

Get the smaller value from a and b.

Parameters:

a
b

Returns:

Int

me():Player

Return the player on the local device, either the main player during a single game or the local player on a multiplayer game.

Returns:

Player

min(a:Int, b:Int):Int

Get the higher value from a and b.

Parameters:

a
b

Returns:

Int

moveCamera(target:{y:Float, x:Float}, ?speed:Float):Void

[Blocking] Pan the camera to a target's coordinates at a certain speed.

Parameters:

target

Target can be an entity or an anonymous structure with a x and y coordinate.

speed

[Optional] The speed at which the camera move, in coordinate units per seconds. Default at 3.

moveCameraDelta(dx:Float, dy:Float, ?speed:Float):Void

[Blocking] Pan the camera over time by a set distance on x and y.

Parameters:

dx

Pan on x coordinates

dy

Pan on y coordinates

speed

[Optional] The speed at which the camera move, in coordinate units per second. Default at 1.

@:value({ walk : false })moveUnit(unit:Unit, dx:Float, dy:Float, walk:Bool = false):Void

Move a unit a certain coordinate offset.

Parameters:

unit
dx

The offset on x coordinates.

dy

The offset on y coordinates.

walk

[Optional] true to have the unit walk instead of running. false by default.

@:value({ competitiveOnly : false })noEvent(competitiveOnly:Bool = false):Void

Forbid any ingame event (Rats, Earthquake, Blizzard, etc...) to be automatically triggered for the remaining of the game. Must be called each launch.

Parameters:

competitiveOnly

If true, only competitive events will be disabled.

@:value({ forceLoop : false, backToIdle : true })playAnim(unit:Unit, animName:String, backToIdle:Bool = true, forceLoop:Bool = false):Void

Have the unit play a specific animation. The animation name is a simple action word taken from the animation files. One name can regroup multiple animations to be played randomly. Some common animation names are : action_floor, building, death, drakkar_stand, fear, fishing, forge, heal, hurt, inkeeper, kick, mender_heal, mender_rune, mine, negociation, pickup, plow, pray, run, scout, selling, skald, spawn, stance, stand, standfear, victory, wait, walk, woodcut Warchiefs also has : agony, aye, submit_cutscene

Parameters:

unit
animName
backToIdle

If the anim don't loop, the unit will play the "stand" anim after the specified one.

forceLoop

Force the animation to be looped, even if it is not made to be looped.

pow(v:Float, exp:Float):Float

Get a base raised to a power exp.

Parameters:

v
exp

Returns:

Float

@:value({ max : 1. })random(max:Float = 1.):Float

Generate a random float number between 0. included and max excluded.

Parameters:

max

[Optional] The maximum number to random. 1. by default.

Returns:

Float

@:value({ max : 1 })randomInt(max:Int = 1):Int

Generate a random int number between 0 included and max excluded;

Parameters:

max

Returns:

Int

removeRule(id:RuleKind):Void

Remove a Conquest rule from the game.

Parameters:

null

id

resetRelations(p:Player):Void

Reset all the relations of this player.

Parameters:

null

p

resetState():Void

Reset the time to the beginning of the current year, just after winter.

setAlly(player:Player, leader:Player):Void

Set the alliance of a player. An alliance is represented by its leader. Allies needs to have a common leader.

Parameters:

player
null

leader

setCamera(e:Entity):Void

Immediately center the camera on a specific entity

Parameters:

null

e

setCameraPos(x:Float, y:Float):Void

Immediately set the camera's position to the given coordinates.

Parameters:

x
null

y

setPause(b:Bool):Void

Pause or unpause the game locally. This is a separate behaviour from multiplayer pause.

Parameters:

null

b

setZoom(coef:Float):Void

Set the zoom of the camera.

Parameters:

null

coef

setupUnit(zone:Zone, owner:Player, type:UnitKind, ox:Float, oy:Float, ?tx:Float, ?ty:Float):Unit

[HostOnly] Create a static unit in a zone. Used for cinematic purposes.

Parameters:

zone

The zone the units is created in.

owner

The owner of the unit.

type

The UnitKind of the unit.

ox

The x coordinate of the unit's position.

oy

The y coordinates of the unit's position.

tx

[Optional] The x coordinates of the direction the unit look at.

ty

[Optional] The y coordinates of the direction the unit look at.

Returns:

Unit

sfx(name:UiSfxKind, ?volumeScale:Float):Void

Play one of the sfx defined in the database's uiSfx tab.

Parameters:

name
volumeScale

A volume factor, 1 plays the sound as intended, 10 increase the volume tenfold. Default at 1.

@:value({ big : false })shakeCamera(big:Bool = false):Void

Shake the camera for a short duration, like during an earthquake.

Parameters:

big

[Optional] Do we want a bigger shake? Default at false.

shuffleArray<T>(array:Array<T>):Array<T>

Randomly shuffle the content of an array

Parameters:

array

Returns:

Array

summonWarchief(owner:Player, zone:Zone, x:Float, y:Float):Unit

[HostOnly] Get the main warchief of the current player's clan and move him on the given position. If the warchief isn't already created, it will create a new one.

Parameters:

owner
zone
x
y

Returns:

Unit

talk(text:String, ?options:Null<DialogOptions>, ?focus:Entity, ?time:Float):Void

[Blocking] Display a dialog box showing text in a fancy manner. Can be decorated with dialog options.

Parameters:

text

The dialog to show.

options

Options to customize the dialog.

focus

The unit to focus on when the dialog is on.

time

A delay in seconds just after focusing the unit.

toInt(v:Float):Int

Convert a float value to an int, removing all decimals

Parameters:

v

Returns:

Int

tradingWith(player:Player, factionName:String):Bool

Tells if the player si trading with the named faction (Giant, Kobold, Myrkalfar, etc...).

Parameters:

player
factionName

Returns:

Bool

wait(duration:Float):Void

[Blocking] Wait a number of seconds before executing the next line.

Parameters:

null

duration