Skip to content

Developer Quick Reference

Kevin Hoddinott edited this page Jul 7, 2020 · 7 revisions

These functions are to help developers (they will not work as they are shown below in the unit.c)

New Player Action

GetHeroesAndBandits().NewPlayerAction(PlayerID, ActionName) 

Adds an action to the player, adding an action to the player will update the stat, update the player's humanity, action must exist in the config or it will consider the action to give 0 humanity

Get Player Affinity

GetHeroesAndBandits().GetPlayerAffinity(PlayerID) 

This will return the players Affinity in a string Ussaly bambi, hero, bandit but this can be configured by the server admins will return bambi(Default Level Affinity) if the player can't be found

Get Player Humanity

GetHeroesAndBandits().GetPlayerHumanity(PlayerID) 

This will return the players Humanity in a float value, it will return 0 if the player can't be found

Get Player Level

GetHeroesAndBandits().GetPlayerLevel(PlayerID) 

Returns the habLevel object will return the default level if player can't be found

Get Player Level Name

GetHeroesAndBandits().GetPlayerLevelName(PlayerID) 

Returns the HabLevel Name in a string it will the default level's name usally Bambi if the player can't be found

Get Player Stat

GetHeroesAndBandits().GetPlayerStat(PlayerID, StatName) 

Returns INT of the player stat, if player or the player's stat doesn't exist it returns 0

Get Player Object

GetHeroesAndBandits().GetPlayer(PlayerID)

This return the object type HeroesAndBanditsPlayer On the client use the variable

HeroesAndBanditsPlayer g_HeroesAndBanditsPlayer

HeroesAndBanditsPlayer Class Outline

class HeroesAndBanditsPlayer
{
	string PlayerID
	ref array< ref habStat > Stats
	ref array< ref habPlayerAffinity > Affinities
	
	// If called as new will attempt to load the player from the database if the player doesn't exist it will create the player.
	void HeroesAndBanditsPlayer(string pID = "")
    
	// Returns the level object of the highest point total level if none match the it returns the default level
	habLevel getLevel()
	
	// Returns the Affinity object for the highest point total affinity with a valid level if none exsit returns the default affinity
	habAffinity getAffinity()
	
	// Returns the current point total for the specified affinity
	float getAffinityPoints( string name )
	
	// Adds the specified points to the specified affinity
	void addAffinityPoints( string name, float points )
	
	// Returns the highest point total affinity with a valid level, if none exsit return default affinity name
	string getAffinityName()
	
	// Returns whether the player is a hero, bandit or bambi
	string getHeroOrBandit()
	
	// Saves the player data back to the JSON file
	void saveData()
	
	//Returns the players humanity, (hero minus bandit)
	float getHumanity()
	
	//Returns the stat total for a given stat name
	float getStat(string statName){
	
	// Updates the player stat and increases the affinity total, and will return true if player leveled up from the action
	bool NewAction(string actionName){
	
	//Will recalculate all the of the players affinities based the current action amounts
	void recalculateTotals()
	
}

habStat class outline

class habStat
{
	string Name
	int Stat
	
	// Increments the stat by one
	void updateStat()
}

habPlayerAffinity class outline

class habPlayerAffinity
{
	string Name
	float Points

	//Returns the point value
	float getPoints()
	
	//Updates the points by a the specified amount
	void updatePoints(float amount)
	
	//Set the value of the points
	void setPoints(float amount)
}

habLevel class outline

class habLevel
{
	string Name
	string Affinity
	string LevelImage
	float MinPoints
	float MaxPoints
}

habAffinity class outline

class habAffinity
{
	string Name
	string DisplayName
}