User:AL
Scripting Notes
The exact limits of what scripting in Soldat 2 can do is not yet known, but it already looks to far exceed what was possible in Soldat 1. The following is a somewhat random assortment of different ways to affect or read the game state from scripting. Note that this list is by no means exhaustive.
Messaging
Debug.Log()
print to debug console, accepts any number of printable argumentsGameChat.ChatOrLog(string message)
print a chat messageHUD.Get.Notify(string message, UnityEngine.Color c)
text printout similar to flag grabbed/returned text
Player
The Teal.Player
object is what we manipulate to read or change data related to players.
public Type type; public string nick; public ushort id; public bool rcon; public int ping; public bool levelLoaded; public bool waitingForSpawn; public SyncedProperties props; public object userData; protected float timeOnJoin; protected float timeOnPing; public float timeOnDeath; public float timeOnSpawn; public Dictionary<string, List<string>> votes = new Dictionary<string, List<string>>(); public bool muted; public bool IsLocal(); public bool IsBot(); public bool IsRemote(); public float GetPlayTime(); public float GetTimeSinceLastPing(); public float GetTimeSinceDeath(); public float GetTimeSinceRespawn(); public bool IsDead(); public int GetTeam(); public bool IsSpectator();
- The
props
member is a dictionary that is both readable and writable. Some potentially useful keys are:- Id
- type
- team
- score
- kills
- deaths
- weapon
- weapon2
It is also possible to add new properties if you want to associate some custom data to players using player.props.Create(string key, object value)
Players
The singleton class Teal.Players
provides many different ways to retrieve relevant player objects:
public List<Player> players; public int PlayersCount; public Player GetLocalPlayer(); public ushort GetLocalPlayerId(); public Controls GetLocalPlayerControlled(); public Player GetPlayerByID(ushort ID); public Player GetPlayerByNick(string nick); public Player GetPlayerByPropertyId(ushort id); public Controls GetPlayerControlledByID(ushort ID); public List<Player> GetPlayersOfTeam(int team); public List<Player> GetPlayersOfTeamExcept(int team, Player player); public List<Player> GetBots(); public List<Player> GetAlive(); public List<Player> GetAliveBots(); public List<Player> GetAliveHumans(); public List<Player> GetHumans(); public List<Player> GetHumansNonSpectator(); public List<Player> GetHumansOnClient(); public List<Player> GetTeam(int team); public List<Player> GetAliveTeam(int team); public List<Player> GetSpecators(); public List<Player> GetPlayersNonSpecators();
Controls
The Teal.Controls
class allows querying some properties like whether the player is dead, is human/bot, and some (limited?) input events. It also allows access to some other classes that affect different aspects of the player.
controls.GetComponent<GostekJets>().jetsAllowed
boolean value, read/writablecontrols.transform.position
returns a Vector3 of the current position of the playercontrols.GetComponent<StandardObject>().Master_Death()
kill the playercontrols.GetComponent<StandardObject>().Master_SetHealth(float hp, Player p = null, NetworkObject unknown = null)
set player health, only works if executed on the server
Misc
- The
Teal.RealTime
class offers a number of different time measures:public static float realtimeSinceStartup;
public static float timeSinceLevelLoad;
public static double SecsSinceStart;
GameCursor.GetWorldPosition()
gets the current position of the local player's cursor, unknown how it will work on a server