One of the player in a game of northgard. Can be both a human or AI player. Any player manage a clan nand own one TownHall and a territory.
Variables
clan:ClanKind
[HostOnly] Current clan of the player. Can be set to change the clan. Won't remove clan specific buildings.
read onlycurrentHappiness:Float
The current happiness at the beginning of the regular update. Contrary to getHappiness(), currentHappiness stay consistent during the whole update process.
Methods
addBonus(data:BonusSave):Void
Add a Conquest bonus for a player. Example : addBonus({id:Bonus.BMineral, resId:Resource.Stone, isAdvanced:true});
Parameters:
data | The bonus data. |
---|
addFreeTech(amount:Int = 1):Void
[HostOnly] Add a free tech to choose to the player.
Parameters:
amount | Number of free tech to give. |
---|
addPingFlag(x:Float, y:Float, type:PingFlagType):Void
Add a ping on the map and a flag in the world to notify of a location. Position are in world coordinates.
Parameters:
x | |
---|---|
y | |
type | Choose between InterestPoint or Team. InterestPoint will ping the player only, while Team will ping his whole team. Team pings have a limitation of 10 at a time. |
addResource(kind:ResourceKind, amount:Float, produced:Bool = true):Void
[HostOnly] Immediately give an amount of a specific resource to the player. Doesn't count into the production.
Parameters:
kind | |
---|---|
amount | |
produce | [Optional] true to set this resource as produced. |
allowColonize(zone:Zone, b:Bool):Void
Allow or forbid the playze to colonize a specific zone.
Parameters:
zone | |
---|---|
b | true to allow, false to forbid. |
coverAll(?exceptZone:Zone):Void
[HostOnly] Restore the fog of war for the whole map.
Parameters:
exceptZone | [Optional] A zone to keep discovered. |
---|
coverZone(zone:Zone):Void
[HostOnly] Restore the fog of war on the specified zone.
Parameters:
null | zone |
---|
customDefeat(loseReason:String):Void
[HostOnly] Instantly make this player lose the game.
Parameters:
null | loseReason |
---|
customVictory(winReason:String, loseReason:String):Void
[HostOnly] Instantly make this player and his team win the game.
Parameters:
winReason | The reason the player won. |
---|---|
loseReason | The reason the other players lose. |
customVictoryKind(kind:String):Void
[HostOnly] Instantly make this player and his team win the game from the specified kind. This will be displayed as "You achieved a [custom kind] victory !"
Parameters:
kind | The custom victory kind. |
---|
discoverZone(zone:Zone):Bool
[HostOnly] Try to remove the fog of war from the specified zone.
Parameters:
zone |
---|
Returns:
Bool true if the zone was successfully discovered, else false.
equipArrows(arrowKind:AbilityKind, ignoreCooldown:Bool = false):Bool
[HostOnly] Allow to change the type of arrow used by the trackers. Specific to Lynx clan.
Parameters:
arrowKind |
---|
Returns:
Bool return false if a wrong ability kind was passed.
genericNotify(text:String, ?target:Entity):Void
Display a custom top left notification to the player.
Parameters:
text | |
---|---|
target | A target entity to pan the camera to the player click on the notification. |
getActiveArrowType():AbilityKind
Return the type of arrows currently used by the trackers. Specific to Lynx clan.
Returns:
AbilityKind
getAvailableWarchiefs():Array<UnitKind>
Gives all the unit kind used as Warchiefs for this player's clan.
Returns:
Array
getBonus(id:BonusKind, ?unitId:UnitKind, ?buildingId:BuildingKind, ?resId:ResourceKind):PlayerBonus
Return the specified bonus' data.
Parameters:
id | |
---|---|
unitId | |
buildingId | |
resId |
Returns:
PlayerBonus The bonus data if found, else null.
getBuilding(kind:BuildingKind):Building
Get the first instance of a building the player has. Return null if none were found.
Parameters:
kind | The kind of building to get. |
---|
Returns:
Building
getBuildings(kind:BuildingKind, ?withConstruction:Bool, ?ignoreCreator:Bool):Array<Building>
Get all the buildings of a certain kind.
Parameters:
kind | The kind of building to get. |
---|---|
withConstruction | Do we include buildings under construction. |
ignoreCreator | Do we ignore building exclusive to the player but under enemy control, like relics or the altar of kings. |
Returns:
Array
getCooldownHero(kind:UnitKind):Float
Get the time at which the warchief can be hired again.
Parameters:
kind |
---|
Returns:
Float
getHappiness():Float
Get the player's happiness at the given time. For a more consistent happiness value during script execution, use currentHappiness
Returns:
Float
getMax(kind:ResourceKind):Int
Tell the maximum amount of one resource the player can hold.
Parameters:
kind |
---|
Returns:
Int
getMilitaryCount(?zone:Zone, withHeroes:Bool = false, atRestOnly:Bool = false):Int
Count all the player's military units.
Parameters:
zone | [Optional] Count units only in this zone |
---|---|
withHeroes | [Optional] Include the Heroes in the count |
atRestOnly | [Optional] Only count military units without orders |
Returns:
Int
getResource(kind:ResourceKind):Float
Tell the current amount of resource owned by the player.
Parameters:
kind |
---|
Returns:
Float
getSlaves(?kind:UnitKind, ?zone:Zone):Array<Unit>
Dragon specific, get all the slaves a player has, of a certain kind or in a zone. Return an empty array of none were found.
Parameters:
kind | The job of the slaves to get. |
---|---|
zone | The zone where to get the slaves. |
Returns:
Array
getTradingPosts(withConstruction:Bool = false):Array<TradingPost>
Give a list of all the trading posts owned by the player.
Parameters:
withConstruction | Include trading posts being built. |
---|
Returns:
Array
getUnit(kind:UnitKind):Unit
Get the first instance of UnitKind under control of a player. Return null if none were found.
Parameters:
kind |
---|
Returns:
Unit
getUnits(?kind:UnitKind, ?zone:Zone):Array<Unit>
Get all the units of a player, of a certain kind or in a zone. Return an empty array of none were found.
Parameters:
kind | The kind of units to get. |
---|---|
zone | The zone where to get the units. |
Returns:
Array
getWarchief():Unit
Get the first warchief spawned in the player's army.
Returns:
Unit The first warchief, else null.
getWarchiefs():Array<Unit>
Get all the present warchiefs from the player's army. Usefull for multiple warchiefs clans like Horse and Bear.
Returns:
Array
hasBonus(id:BonusKind, ?unitId:UnitKind, ?buildingId:BuildingKind, ?resId:ResourceKind):Bool
Check if a player has a given bonus.
Parameters:
id | |
---|---|
unitId | |
buildingId | |
resId |
Returns:
Bool
hasBuilding(kind:BuildingKind, ?withConstruction:Bool, ?upgraded:Bool, ?withExtension:Bool, ?specialCond:Building ‑> Bool):Bool
Tell if the player possess at least one of the given kind of building.
Parameters:
kind | |
---|---|
withConstruction | [Optional] Do we count buildings being built |
upgraded | [Optional] Do we count upgraded buildings only |
withExtension | [Optional] Do we count buildings with extensions only (Harbour with Lighthouse) |
specialCond | [Optional] A callback for more specific test cases. |
Returns:
Bool
hasDiscovered(zone:Zone):Bool
Tell if the player already discovered the given zone.
Parameters:
zone |
---|
Returns:
Bool
hasDiscoveredOne(zones:Array<Zone>):Bool
Does the player discovered at least one of the given zones.
Parameters:
zones |
---|
Returns:
Bool
hasTech(tech:TechKind):Bool
Tell if the player unlocked the specified tech.
Parameters:
tech |
---|
Returns:
Bool
hasTrophy(kind:AbilityKind):Bool
Tells if a hunting trophy has been unlocked. Specific to Lynx clan.
Parameters:
kind |
---|
Returns:
Bool
lockTech(kind:TechKind, isFree:Bool = false, refund:Bool = false):Void
[HostOnly] Toggle a tech off. This ask the player to purchase it again to unlock next techs. Doesn't check for already unlocked blessings or effects.
Parameters:
kind | |
---|---|
isFree | Remove the tech from the unlocked free techs. |
refund | Give back the spent lore to unlock the tech, or give back a free tech if it was free. |
removeBonus(id:BonusKind, ?unitId:UnitKind, ?buildingId:BuildingKind, ?resId:ResourceKind):Bool
Remove a Conquest bonus from a player.
Parameters:
id | |
---|---|
unitId | |
buildingId | |
resId |
Returns:
Bool True if the bonus was removed, else false.
setAILevel(level:Int):Bool
[HostOnly] Set the difficulty level of the AI of this player.
Parameters:
level |
---|
Returns:
Bool true if the player is an IA.
setFlag(flag:PlayerFlag, toSet:Bool = true):Void
[HostOnly] Set or unset a player flag.
Parameters:
flag | |
---|---|
null | toSet |
setTech(techs:Array<TechKind>):Void
[Obsolete] Unlock the given techs for the player. This simply toggle the tech on/off and don't trigger effects for certain techs. Obsolete, use unlockTech instead.
Parameters:
techs | |
---|---|
isFree | Is the tech added to the price calculation toward the next tech. |
takeControl(zone:Zone, alert:Bool = false):Void
[HostOnly] Immediately take control of the given zone.
Parameters:
zone | |
---|---|
alert | [Optional] Do we send an alert to the previous owner of the zone. |
triggerVictory(kind:VictoryKind):Void
[HostOnly] Instantly make this player and his team win the game. Use an existing VictoryKind for the victory reason.
Parameters:
null | kind |
---|
unlockTech(kind:TechKind, isFree:Bool = false):Void
[HostOnly] Unlock a tech and apply any related effect. Check for Blessing unlocks. To use during gameplay.
Parameters:
kind | |
---|---|
isFree | Is the tech added to the price calculation toward the next tech. |
unlockTrophy(kind:AbilityKind, free:Bool = false):Void
[HostOnly] Try to unlock a trophy by spending resources, unless it is set as free trophy. Specific to Lynx clan.
Parameters:
kind | |
---|---|
null | free |
unlockedForFree(kind:TechKind):Bool
Tell if a tech was unlocked for free. Return false if the player don't have the tech at all.
Parameters:
kind |
---|
Returns:
Bool