Difference between revisions of "Script Modding Guide"
Line 16: | Line 16: | ||
=== Send network trajectory info to client without showing it to players=== | === Send network trajectory info to client without showing it to players=== | ||
− | Similar to drawFirearmTrajectories, this will send the trajectory data from server to client. Unlike the aforementioned command, this will NOT display it to the player, but the mod will still be recieving the data. Enable this only if you're planning on using the "OnShotInfo" on a client side, for server side mods, this isn't required. | + | Similar to [[Remote_Console_Commands#Game_Settings|drawFirearmTrajectories]], this will send the trajectory data from server to client. Unlike the aforementioned command, this will NOT display it to the player, but the mod will still be recieving the data. Enable this only if you're planning on using the "OnShotInfo" on a client side, for server side mods, this isn't required. |
rc set drawFirearmTajectoriesInfo <true/false> | rc set drawFirearmTajectoriesInfo <true/false> |
Revision as of 15:51, 16 July 2021
SDK Modding Script Documentation
Basic knowledge of C# and Unity is required.
To start with script modding in holdfast, create a new mod and in this mod’s folder create a new script. This script should implement the shared interface IHoldfastSharedMethods.
For example, here’s a mod that’s called “LineFormer” that has the script called “LineFormer.cs” which implements the IHoldfastSharedMethods interface.
New RC commands specific for modding use
Make carbon player bots not do any auto input
If you plan on modifying bots position or rotation, call the following script to force bots to not auto move or rotate. Note: this is different than setting the carbonplayer forceInputAxis/forceInputRotation, since thoses ones will lock ALL the bots in the action, whereas this will allow you to individually control bots's facing rotation and movement system.
rc carbonPlayers ignoreAutoControls <true/false>
Send network trajectory info to client without showing it to players
Similar to drawFirearmTrajectories, this will send the trajectory data from server to client. Unlike the aforementioned command, this will NOT display it to the player, but the mod will still be recieving the data. Enable this only if you're planning on using the "OnShotInfo" on a client side, for server side mods, this isn't required.
rc set drawFirearmTajectoriesInfo <true/false>
Quiet Messages
These messages will not shown to the player anywhere. The intended use for them is for a server-side mod to be able to communicate to a client side mod.
For example;
You have a mod that every time a player presses a button on your mod custom ui, you want to slap a player for 5 damage and they will be shown the message `haha you got slapped by <playername>` on their end of the mod. You are be able to do this by creating a mod that on the player's client side [ie player 3], you have a custom ui panel with a button, which when the button is pressed will send a message to the server (multiple ways of doing this, for example using rc system). This message is than read by the server side mod (could be the same mod, just need conditional logic using the "OnIsServer" and "OnIsClient" to split the mod up) and slaps the targetted player [ie player 5]. Than the server would send a quietPrivateMessage to the slapped target [player 5] informing him that he just got slapped by player 3. The client side of player 5 will than read the quiet private message (using OnTextMessage) and handle it appriopiately.
rc serverAdmin quietPrivateMessage <player_id> <message> rc serverAdmin quietBroadcastMessage <message>
///using UnityEngine;
namespace HoldfastSharedMethods {
/// <summary> /// Main Interface, implement this script and place the script in the root of your mod. /// </summary> public interface IHoldfastSharedMethods { /// <summary> /// The game will share an int when the mod loads. A random synchronized value (same on client and server), for example useful if you need a seed for a map generator. /// </summary> void OnSyncValueState(int value);
/// <summary> /// The game will share the current synchronized time (same on client and server) on every frame of the game. /// </summary> void OnUpdateSyncedTime(double time);
/// <summary> /// The game will return the seconds since the round started on every frame of the game. /// </summary> void OnUpdateElapsedTime(float time);
/// <summary> /// The game will share the current remaining time on every frame of the game. /// </summary> void OnUpdateTimeRemaining(float time);
/// <summary> /// The game will return if the mod is loaded on a server. /// </summary> void OnIsServer(bool server);
/// <summary> /// The game will return if the mod is loaded on a client, if it is, you'll retrieve the current player's steam id. /// </summary> void OnIsClient(bool client, ulong steamId);
/// <summary> /// The game will call this on round start with details regarding the current round. /// </summary> void OnRoundDetails(int roundId, string serverName, string mapName, FactionCountry attackingFaction, FactionCountry defendingFaction, GameplayMode gameplayMode, GameType gameType);
/// <summary> /// The game will call this once with all the config variables set on the config file of the server. /// Note: you will receive all variables, so make sure to filter only the ones you care about. /// </summary> void PassConfigVariables(string[] value);
/// <summary> /// The game will call this when a player or a bot joins the round. /// </summary> void OnPlayerJoined(int playerId, ulong steamId, string name, string regimentTag, bool isBot);
/// <summary> /// The game will call this when a player leaves the round. /// Note: Bots cannot leave, they'll keep respawning once dead. /// </summary> void OnPlayerLeft(int playerId);
/// <summary> /// The game will call this when a player spawns in game. /// </summary> void OnPlayerSpawned(int playerId, int spawnSectionId, FactionCountry playerFaction, PlayerClass playerClass, int uniformId, GameObject playerObject);
/// <summary> /// The game will call this when a player is hurt in game. /// </summary> void OnPlayerHurt(int playerId, byte oldHp, byte newHp, EntityHealthChangedReason reason);
/// <summary> /// The game will call this when a player is killed by another player. /// </summary> void OnPlayerKilledPlayer(int killerPlayerId, int victimPlayerId, EntityHealthChangedReason reason, string details);
/// <summary> /// The game will call this when a player receives any score. /// </summary> void OnScorableAction(int playerId, int score, ScorableActionType reason);
/// <summary> /// The game will call this when a player shoots his gun. /// </summary> void OnPlayerShoot(int playerId, bool dryShot);
/// <summary> /// The game will call this when a bullet. /// Note: This requires `rc set drawFirearmTajectories true` or `rc set drawFirearmTajectoriesInfo true`. /// </summary> void OnShotInfo(int playerId, int shotCount, Vector3[][] shotsPointsPositions, float[] trajectileDistances, float[] distanceFromFiringPositions, float[] horizontalDeviationAngles, float[] maxHorizontalDeviationAngles, float[] muzzleVelocities, float[] gravities, float[] damageHitBaseDamages, float[] damageRangeUnitValues, float[] damagePostTraitAndBuffValues, float[] totalDamages, Vector3[] hitPositions, Vector3[] hitDirections, int[] hitPlayerIds, int[] hitDamageableObjectIds, int[] hitShipIds, int[] hitVehicleIds);
/// <summary> /// The game will call this when a player successfully blocks another player. /// </summary> void OnPlayerBlock(int attackingPlayerId, int defendingPlayerId);
/// <summary> /// The game will call this when a player starts a secondary attack (shove). /// </summary> void OnPlayerMeleeStartSecondaryAttack(int playerId);
/// <summary> /// The game will call this when a player swaps their weapon. /// </summary> void OnPlayerWeaponSwitch(int playerId, string weapon);
/// <summary> /// The game will call this when a player starts carrying an object. /// </summary> void OnPlayerStartCarry(int playerId, CarryableObjectType carryableObject);
/// <summary> /// The game will call this when a player stops carrying an object. /// </summary> void OnPlayerEndCarry(int playerId);
/// <summary> /// The game will call this when a player shouts using the ingame voice commands(not voip). /// </summary> void OnPlayerShout(int playerId, CharacterVoicePhrase voicePhrase);
/// <summary> /// The game will call this when the console command is used. /// Note: This will be only called on the client, or on the server that is executing the console command. /// </summary> void OnConsoleCommand(string input, string output, bool success);
/// <summary> /// The game will call this when a player requests a remote console login. /// Note: This will be called on the client that is executing the request, and the server. Not other people. /// </summary> void OnRCLogin(int playerId, string inputPassword, bool isLoggedIn);
/// <summary> /// The game will call this when a player requests a remote console command. /// Note: This will be called on the client that is doing the request, and the server. Not other people. /// </summary> void OnRCCommand(int playerId, string input, string output, bool success);
/// <summary> /// The game will call this when a message is received in the chat system. /// </summary> void OnTextMessage(int playerId, TextChatChannel channel, string text);
/// <summary> /// The game will call this when an administrator does an admin action using the rc commands or the P menu. /// </summary> void OnAdminPlayerAction(int playerId, int adminId, ServerAdminAction action, string reason);
/// <summary> /// The game will call this when an object is damaged. /// </summary> void OnDamageableObjectDamaged(GameObject damageableObject, int damageableObjectId, int shipId, int oldHp, int newHp);
/// <summary> /// The game will call this when an object is interacted with. /// </summary> void OnInteractableObjectInteraction(int playerId, int interactableObjectId, GameObject interactableObject, InteractionActivationType interactionActivationType, int nextActivationStateTransitionIndex);
/// <summary> /// The game will call this when an emplacement (sapper object) is initially placed. /// </summary> void OnEmplacementPlaced(int itemId, GameObject objectBuilt, EmplacementType emplacementType);
/// <summary> /// The game will call this when an emplacement (sapper object) is fully constructed. /// </summary> void OnEmplacementConstructed(int itemId);
/// <summary> /// The game will call this when a capture point is fully captured. /// </summary> void OnCapturePointCaptured(int capturePoint);
/// <summary> /// The game will call this when a capture point changes owner. /// </summary> void OnCapturePointOwnerChanged(int capturePoint, FactionCountry factionCountry);
/// <summary> /// The game will call this when a capture data changes. /// </summary> void OnCapturePointDataUpdated(int capturePoint, int defendingPlayerCount, int attackingPlayerCount);
/// <summary> /// The game will call this when a buff is applied to a player. /// Note: Buffs that already exist on a player may stack, so this call will be called multiple times even if a player already has the buff. /// </summary> void OnBuffStart(int playerId, BuffType buff);
/// <summary> /// The game will call this when a buff is removed from a player. /// </summary> void OnBuffStop(int playerId, BuffType buff);
/// <summary> /// The game will call this when a faction vs faction round is over. /// Note: Most of them except for Army Deathmatch. /// </summary> void OnRoundEndFactionWinner(FactionCountry factionCountry, FactionRoundWinnerReason reason);
/// <summary> /// The game will call this when a free for all round is over. /// Note: Only Army Deathmatch. /// </summary> void OnRoundEndPlayerWinner(int playerId);
/// <summary> /// The game will call this when a vehicle(horse) is spawned. /// </summary> void OnVehicleSpawned(int vehicleId, FactionCountry vehicleFaction, PlayerClass vehicleClass, GameObject vehicleObject, int ownerPlayerId);
/// <summary> /// The game will call this when a vehicle(horse) is hurt. /// </summary> void OnVehicleHurt(int vehicleId, byte oldHp, byte newHp, EntityHealthChangedReason reason);
/// <summary> /// The game will call this when a vehicle(horse) is killed by a player. /// </summary> void OnPlayerKilledVehicle(int killerPlayerId, int victimVehicleId, EntityHealthChangedReason reason, string details);
/// <summary> /// The game will call this when a ship is spawned. /// </summary> void OnShipSpawned(int shipId, GameObject shipObject, FactionCountry shipfaction, ShipType shipType, int shipName);
/// <summary> /// The game will call this when a ship takes damage. /// </summary> void OnShipDamaged(int shipId, int oldHp, int newHp); }
}///