User:AL

From Soldat2 Wiki
Revision as of 14:37, 17 January 2023 by AL (talk | contribs)
Jump to navigation Jump to search

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.

Messaging

  • Debug.Log() print to debug console, accepts any number of printable arguments
  • GameChat.ChatOrLog(string message) print a chat message
  • HUD.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.

  • 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 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/writable
  • controls.transform.position returns a Vector3 of the current position of the player
  • controls.GetComponent<StandardObject>().Master_Death() kill the player

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