From 68bcd71e4d296e810bd0a71d7563c584add9cd11 Mon Sep 17 00:00:00 2001 From: uniboi Date: Fri, 18 Feb 2022 15:57:47 +0100 Subject: [PATCH 01/10] added most function types added functions GetPlayerArrayOfTeam_Alive and GetSortedPlayers --- docs/source/reference/respawn/player.rst | 175 ++++++++++++----------- 1 file changed, 89 insertions(+), 86 deletions(-) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index dc3cba0a..8bdacf35 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -11,60 +11,63 @@ Functions for getting player, and methods of the player object .. cpp:function:: array GetPlayerArray() - .. cpp:function:: array GetPlayerArrayOfTeam( int team ) +.. cpp:function:: array GetPlayerArrayOfTeam_Alive( int team ) + .. cpp:function:: array GetPlayerArrayOfEnemies_Alive( int team ) -.. cpp:class:: player : public entity +.. cpp:function:: array GetSortedPlayers( IntFromEntityCompare compareFunc, int team) + +.. cpp:class:: player : public entity - .. cpp:function:: unknown GetActivePilotLoadoutIndex( player ) + .. cpp:function:: int GetActivePilotLoadoutIndex( player ) .. cpp:function:: entity GetActiveWeapon() - .. cpp:function:: unknown GetActiveWeaponPrimaryAmmoLoaded() + .. cpp:function:: int GetActiveWeaponPrimaryAmmoLoaded() - .. cpp:function:: unknown GetAngles() + .. cpp:function:: vector GetAngles() - .. cpp:function:: unknown GetAntiTitanWeapon() + .. cpp:function:: entity GetAntiTitanWeapon() - .. cpp:function:: unknown GetAttachmentAngles() + .. cpp:function:: vector GetAttachmentAngles() - .. cpp:function:: unknown GetAttachmentOrigin() + .. cpp:function:: vector GetAttachmentOrigin() - .. cpp:function:: unknown GetBodyGroupModelCount() + .. cpp:function:: int GetBodyGroupModelCount() - .. cpp:function:: unknown GetBossPlayerName() + .. cpp:function:: string GetBossPlayerName() - .. cpp:function:: unknown GetCinematicEventFlags() + .. cpp:function:: int GetCinematicEventFlags() - .. cpp:function:: unknown GetCockpit() + .. cpp:function:: entity GetCockpit() - .. cpp:function:: unknown GetFirstPersonProxy() + .. cpp:function:: entity GetFirstPersonProxy() - .. cpp:function:: unknown GetForcedDialogueOnly() + .. cpp:function:: bool GetForcedDialogueOnly() - .. cpp:function:: unknown GetGen() + .. cpp:function:: int GetGen() - .. cpp:function:: unknown GetHealthFrac(player) + .. cpp:function:: float GetHealthFrac(player) .. cpp:function:: unknown GetLastPingTime() - .. cpp:function:: unknown GetLevel() + .. cpp:function:: int GetLevel() - .. cpp:function:: unknown GetLifeState() + .. cpp:function:: int GetLifeState() - .. cpp:function:: unknown GetLocalClientPlayer() + .. cpp:function:: entity GetLocalClientPlayer() - .. cpp:function:: unknown GetLocalViewPlayer() + .. cpp:function:: entity GetLocalViewPlayer() - .. cpp:function:: unknown GetMainWeapons() + .. cpp:function:: array GetMainWeapons() - .. cpp:function:: unknown GetMaxHealth() + .. cpp:function:: int GetMaxHealth() - .. cpp:function:: unknown GetModelName() + .. cpp:function:: asset GetModelName() - .. cpp:function:: unknown GetNextTitanRespawnAvailable() + .. cpp:function:: float GetNextTitanRespawnAvailable() .. cpp:function:: unknown GetNumPingsAvailable() @@ -74,41 +77,41 @@ Functions for getting player, and methods of the player object .. cpp:function:: unknown GetObjectiveIndex() - .. cpp:function:: unknown GetObserverMode() + .. cpp:function:: int GetObserverMode() - .. cpp:function:: unknown GetOffhandWeapon(slot) + .. cpp:function:: entity GetOffhandWeapon(slot) - .. cpp:function:: unknown GetOffhandWeapons() + .. cpp:function:: array GetOffhandWeapons() - .. cpp:function:: unknown GetOrigin() + .. cpp:function:: vector GetOrigin() - .. cpp:function:: unknown GetParent() + .. cpp:function:: entity GetParent() - .. cpp:function:: unknown GetPersistentSpawnLoadoutIndex( player, "pilot" ) + .. cpp:function:: int GetPersistentSpawnLoadoutIndex( player, "pilot" ) - .. cpp:function:: unknown GetPetTitan() + .. cpp:function:: entity GetPetTitan() - .. cpp:function:: unknown GetPilotLoadoutFromPersistentData( player, loadoutIndex ) + .. cpp:function:: PilotLoadoutDef GetPilotLoadoutFromPersistentData( player, loadoutIndex ) .. cpp:function:: unknown GetPingGroupAccumulator() .. cpp:function:: unknown GetPingGroupStartTime() - .. cpp:function:: unknown GetPlayerArray() + .. cpp:function:: array GetPlayerArray() - .. cpp:function:: unknown GetPlayerArrayOfEnemies_Alive( int team ) + .. cpp:function:: array GetPlayerArrayOfEnemies_Alive( int team ) - .. cpp:function:: unknown GetPlayerArrayOfTeam( int team ) + .. cpp:function:: array GetPlayerArrayOfTeam( int team ) - .. cpp:function:: unknown GetPlayerClass() + .. cpp:function:: string GetPlayerClass() .. cpp:function:: PGS_ELIMINATED GetPlayerGameStat() - .. cpp:function:: unknown GetPlayerName() + .. cpp:function:: string GetPlayerName() - .. cpp:function:: unknown GetPlayerNameWithClanTag() + .. cpp:function:: string GetPlayerNameWithClanTag() - .. cpp:function:: unknown GetPlayerNetBool( net_bool_name ) + .. cpp:function:: bool GetPlayerNetBool( net_bool_name ) example @@ -116,109 +119,109 @@ Functions for getting player, and methods of the player object GetPlayerNetBool( "shouldShowWeaponFlyout" ) - .. cpp:function:: unknown GetPlayerSettings() + .. cpp:function:: string GetPlayerSettings() .. cpp:function:: unknown GetPlayerSettingsField( "weaponClass" ) - .. cpp:function:: unknown GetShieldHealth() + .. cpp:function:: int GetShieldHealth() - .. cpp:function:: unknown GetShieldHealthFrac( entity ) + .. cpp:function:: float GetShieldHealthFrac( entity ) - .. cpp:function:: unknown GetShieldHealthMax() + .. cpp:function:: int GetShieldHealthMax() .. cpp:function:: int GetTeam() - .. cpp:function:: unknown GetTitanSoul() - + .. cpp:function:: entity GetTitanSoul() + .. code-block:: javascript - + if IsTitan() | player.GetPetTitan().GetTitanSoul() if !IsTitan() .. cpp:function:: vector GetVelocity() - .. cpp:function:: unknown GetViewForward() + .. cpp:function:: vector GetViewForward() - .. cpp:function:: unknown GetViewModelEntity() + .. cpp:function:: entity GetViewModelEntity() - .. cpp:function:: unknown GetViewRight() + .. cpp:function:: vector GetViewRight() - .. cpp:function:: unknown GetViewUp() + .. cpp:function:: vector GetViewUp() - .. cpp:function:: unknown GetViewVector() + .. cpp:function:: vector GetViewVector() - .. cpp:function:: unknown GetWeaponAmmoStockpile() + .. cpp:function:: int GetWeaponAmmoStockpile() .. cpp:function:: unknown GetXP() - .. cpp:function:: float GetZoomFrac() - + .. cpp:function:: float GetZoomFrac() + 0.0 (no zoom) - 1.0 (full zoom) - .. cpp:function:: unknown GiveArmor( player, int amount ) + .. cpp:function:: void GiveArmor( player, int amount ) - .. cpp:function:: unknown GiveOffhandWeapon( name, slot ) + .. cpp:function:: void GiveOffhandWeapon( name, slot ) - .. cpp:function:: unknown GivePilotLoadout( player, loadout ) + .. cpp:function:: void GivePilotLoadout( player, loadout ) - .. cpp:function:: unknown GiveWeapon() + .. cpp:function:: void GiveWeapon() - .. cpp:function:: unknown GiveWeaponPowerUp( player, string newWeapon ) + .. cpp:function:: void GiveWeaponPowerUp( player, string newWeapon ) - .. cpp:function:: unknown TakeOffhandWeapon() + .. cpp:function:: void TakeOffhandWeapon() - .. cpp:function:: unknown TakeWeaponNow() + .. cpp:function:: void TakeWeaponNow() - .. cpp:function:: unknown SetActiveWeaponByName() + .. cpp:function:: void SetActiveWeaponByName() - .. cpp:function:: unknown SetBodygroup() + .. cpp:function:: void SetBodygroup() - .. cpp:function:: unknown SetDodgePowerDelayScale() + .. cpp:function:: void SetDodgePowerDelayScale() - .. cpp:function:: unknown SetHealth() + .. cpp:function:: void SetHealth() - .. cpp:function:: unknown SetLastPingTime() + .. cpp:function:: void SetLastPingTime() - .. cpp:function:: unknown SetMaxHealth() + .. cpp:function:: void SetMaxHealth() - .. cpp:function:: unknown SetNumPingsAvailable() + .. cpp:function:: void SetNumPingsAvailable() - .. cpp:function:: unknown SetNumPingsUsed() + .. cpp:function:: void SetNumPingsUsed() - .. cpp:function:: unknown SetOrigin() + .. cpp:function:: void SetOrigin() - .. cpp:function:: unknown SetPowerRegenRateScale() + .. cpp:function:: void SetPowerRegenRateScale() - .. cpp:function:: unknown SetShieldHealth() + .. cpp:function:: void SetShieldHealth() - .. cpp:function:: unknown SetShieldHealthMax() + .. cpp:function:: void SetShieldHealthMax() - .. cpp:function:: unknown SetTitanDisembarkEnabled( bool ) + .. cpp:function:: void SetTitanDisembarkEnabled( bool ) - .. cpp:function:: unknown AddThreatScopeColorStatusEffect(weaponOwner) + .. cpp:function:: void AddThreatScopeColorStatusEffect(weaponOwner) - .. cpp:function:: unknown CameraPosition() + .. cpp:function:: vector CameraPosition() - .. cpp:function:: unknown CockpitStartDisembark() + .. cpp:function:: void CockpitStartDisembark() - .. cpp:function:: unknown ContextAction_IsActive() + .. cpp:function:: bool ContextAction_IsActive() - .. cpp:function:: unknown ContextAction_IsBusy() + .. cpp:function:: bool ContextAction_IsBusy() - .. cpp:function:: unknown EyeAngles() + .. cpp:function:: vector EyeAngles() - .. cpp:function:: unknown EyePosition() + .. cpp:function:: vector EyePosition() - .. cpp:function:: unknown FindBodyGroup() + .. cpp:function:: int FindBodyGroup() - .. cpp:function:: unknown LookupAttachment() + .. cpp:function:: int LookupAttachment() - .. cpp:function:: unknown Lunge_ClearTarget() + .. cpp:function:: void Lunge_ClearTarget() - .. cpp:function:: unknown Minimap_GetZOrder() + .. cpp:function:: int Minimap_GetZOrder() - .. cpp:function:: unknown RemoveThreatScopeColorStatusEffect(weaponOwner) + .. cpp:function:: int RemoveThreatScopeColorStatusEffect(weaponOwner) .. cpp:function:: bool HasBadReputation() From 884317bc4dff0647f4d729234b1b9bee43837be2 Mon Sep 17 00:00:00 2001 From: uniboi Date: Fri, 18 Feb 2022 15:58:45 +0100 Subject: [PATCH 02/10] added GetSortedPlayers description and example --- docs/source/reference/respawn/player.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index 8bdacf35..9c182f12 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -19,6 +19,18 @@ Functions for getting player, and methods of the player object .. cpp:function:: array GetSortedPlayers( IntFromEntityCompare compareFunc, int team) + returns list of every player in ``team`` sorted by ``compareFunc``. If ``team`` is 0 returns a sorted array of every player. + `squirrel compare function example `_ + .. code-block:: javascript + GetSortedPlayers(function(entity player1, entity player2) { + if(player1.GetPlayerGameStat(PGS_PING)>player2.GetPlayerGameStat(PGS_PING)) + return 1 + + else if(player1.GetPlayerGameStat(PGS_PING) Date: Sun, 20 Feb 2022 13:04:27 +0100 Subject: [PATCH 03/10] add short if explanation --- docs/source/native/functions.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/source/native/functions.rst b/docs/source/native/functions.rst index 2cc5249e..3a22e470 100644 --- a/docs/source/native/functions.rst +++ b/docs/source/native/functions.rst @@ -34,6 +34,14 @@ If statements are also functions however, and can be used to determine true or f if(RandomInt(5)+1 == 5) +You can also use short if statements to simplify your code. However, if not used carefully this can worsen readability. +The Syntax is ``condition ? if_condition_true : if_condition_false``. This is especially useful when declaring variables or passing parameters. + +.. code-block:: javascript + + // shortenedUsername is "longus..."" if username is "longusername" or "short" if username is "short" + string shortenedUsername = username.len() > 9 ? username.slice(0,6) + "..." : username; + Loops ------ Loops fall into a few categories but for our purposes we will be only using ``foreach`` and ``while``. ``foreach`` loops are given a data set, such as a list, and will repeat their asigned script for each entry on that list. From d21ea4fa3ab58c83def562ec7d6eaed118e9e808 Mon Sep 17 00:00:00 2001 From: uniboi Date: Sun, 20 Feb 2022 13:10:36 +0100 Subject: [PATCH 04/10] squirrel treats null and 0 like false adds a bit more info to string and table description --- docs/source/native/intro.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/native/intro.rst b/docs/source/native/intro.rst index 46167bf1..65b9e23b 100644 --- a/docs/source/native/intro.rst +++ b/docs/source/native/intro.rst @@ -42,10 +42,11 @@ Variable types * ``void``: can be used to define functions that do not return a value, but still do things. most of your functions will be void * ``integer``: a whole number * ``float``: any floating-point number. -* ``string``: text +* ``string``: text. Squirrel does not have native chars, so calling an index of a string will return a number in standart ascii format. e.g. "a"[0] = 97 * ``entity``: an entity and all its associated information -* ``bool``: ``true`` or ``false`` (Squirrel does not treat 1 as true or 0 as false) +* ``bool``: ``true`` or ``false`` (Squirrel treats ``null`` and ``0`` as false and every other number or object that's ``!= null`` as true) * ``array``: an ordered list of items indexed from 0, increasing with the number of items such as: 0:"hello",1:1000,2:entity player -* ``table``: a list of items with indexes defined on object entry such as: ``"word":"hello"``, ``"kilo":1000"``, ``"pilot":entity player`` +* | ``table``: a list of items with indexes defined on object entry such as: ``"word":"hello"``, ``"kilo":1000"``, ``"pilot":entity player``. + | You have to create new slots with the ``<-`` operator and overwrite values in slots with ``=``. Tables are explained in more detail in the `squirrel documentation `_ * ``struct``: a series of attributes assigned to a structure and accessed through with ``structname.variablename`` * ``var``: Var typically refers to variables that lack any stated type, this will cause issues with many functions unless you use the ``untyped`` identifier at the start of your file, or if you use ``expect type(variable)`` when passing the variable to that function From 9c8f67a725c2f4bc730b55766c7367f452f739f7 Mon Sep 17 00:00:00 2001 From: uniboi Date: Sun, 20 Feb 2022 13:13:29 +0100 Subject: [PATCH 05/10] remove duplicate methods these are not delegate methods. --- docs/source/reference/respawn/player.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index 9c182f12..eea9992f 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -109,12 +109,6 @@ Functions for getting player, and methods of the player object .. cpp:function:: unknown GetPingGroupStartTime() - .. cpp:function:: array GetPlayerArray() - - .. cpp:function:: array GetPlayerArrayOfEnemies_Alive( int team ) - - .. cpp:function:: array GetPlayerArrayOfTeam( int team ) - .. cpp:function:: string GetPlayerClass() .. cpp:function:: PGS_ELIMINATED GetPlayerGameStat() From 60445c2dfdb20041366af81c2ed34d2521f7e8e7 Mon Sep 17 00:00:00 2001 From: uniboi Date: Sun, 20 Feb 2022 15:32:40 +0100 Subject: [PATCH 06/10] moved independent functions to top IsAlive() and IsValid() aren't delegate functions of entity --- docs/source/reference/respawn/player.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index eea9992f..a0d9521d 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -3,6 +3,10 @@ Player Functions for getting player, and methods of the player object +.. cpp:function:: bool IsAlive( entity ent ) + +.. cpp:function:: bool IsValid( entity ent ) + .. cpp:function:: entity GetLocalViewPlayer() player you're watching (can be replay) @@ -235,8 +239,6 @@ Functions for getting player, and methods of the player object .. cpp:function:: bool InPartyChat() - .. cpp:function:: bool IsAlive(player) - .. cpp:function:: bool IsEjecting() .. cpp:function:: bool IsHologram() @@ -273,8 +275,6 @@ Functions for getting player, and methods of the player object .. cpp:function:: bool IsUsingOffhandWeapon() - .. cpp:function:: bool IsValid( player ) - .. cpp:function:: bool IsWatchingKillReplay() .. cpp:function:: bool IsWatchingReplay() From b0b192e6b8e2fbe6e7612ce55035649ca3f3b57a Mon Sep 17 00:00:00 2001 From: uniboi Date: Sun, 20 Feb 2022 15:35:51 +0100 Subject: [PATCH 07/10] list GetPlayerArrayEx and GetTitanFromPlayer --- docs/source/reference/respawn/player.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index a0d9521d..2549db80 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -15,6 +15,10 @@ Functions for getting player, and methods of the player object .. cpp:function:: array GetPlayerArray() +.. cpp:function:: array GetPlayerArrayEx( string affected, int team, vector origin, float radius ) + + returns a list of every player in radius relative to origin. I only found ``"any"`` to work and assume the first parameter describes the affected types. + .. cpp:function:: array GetPlayerArrayOfTeam( int team ) .. cpp:function:: array GetPlayerArrayOfTeam_Alive( int team ) @@ -35,6 +39,10 @@ Functions for getting player, and methods of the player object return 0 }, 0) +.. cpp:function:: entity GetTitanFromPlayer( entity player) + + if the player is a titan, returns the player. If not, returns the player's pet titan + .. cpp:class:: player : public entity .. cpp:function:: int GetActivePilotLoadoutIndex( player ) From 58e92fb106ada8bdeb5117112ad117e9bb79c8cf Mon Sep 17 00:00:00 2001 From: uniboi Date: Sun, 20 Feb 2022 15:37:47 +0100 Subject: [PATCH 08/10] improve parameters, return values and descriptions --- docs/source/reference/respawn/player.rst | 117 ++++++++++++++--------- 1 file changed, 72 insertions(+), 45 deletions(-) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index 2549db80..50917629 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -21,15 +21,21 @@ Functions for getting player, and methods of the player object .. cpp:function:: array GetPlayerArrayOfTeam( int team ) + array of players from team index + .. cpp:function:: array GetPlayerArrayOfTeam_Alive( int team ) + every player alive in team + .. cpp:function:: array GetPlayerArrayOfEnemies_Alive( int team ) .. cpp:function:: array GetSortedPlayers( IntFromEntityCompare compareFunc, int team) returns list of every player in ``team`` sorted by ``compareFunc``. If ``team`` is 0 returns a sorted array of every player. `squirrel compare function example `_ + .. code-block:: javascript + GetSortedPlayers(function(entity player1, entity player2) { if(player1.GetPlayerGameStat(PGS_PING)>player2.GetPlayerGameStat(PGS_PING)) return 1 @@ -45,7 +51,7 @@ Functions for getting player, and methods of the player object .. cpp:class:: player : public entity - .. cpp:function:: int GetActivePilotLoadoutIndex( player ) + .. cpp:function:: int GetActivePilotLoadoutIndex( entity player ) .. cpp:function:: entity GetActiveWeapon() @@ -53,6 +59,8 @@ Functions for getting player, and methods of the player object .. cpp:function:: vector GetAngles() + direction the entity is facing + .. cpp:function:: entity GetAntiTitanWeapon() .. cpp:function:: vector GetAttachmentAngles() @@ -73,9 +81,9 @@ Functions for getting player, and methods of the player object .. cpp:function:: int GetGen() - .. cpp:function:: float GetHealthFrac(player) + .. cpp:function:: float GetHealthFrac( entity player ) - .. cpp:function:: unknown GetLastPingTime() + .. cpp:function:: float GetLastPingTime() .. cpp:function:: int GetLevel() @@ -93,43 +101,59 @@ Functions for getting player, and methods of the player object .. cpp:function:: float GetNextTitanRespawnAvailable() - .. cpp:function:: unknown GetNumPingsAvailable() + .. cpp:function:: int GetNumPingsAvailable() - .. cpp:function:: unknown GetObjectiveEndTime() + .. cpp:function:: float GetObjectiveEndTime() .. cpp:function:: unknown GetObjectiveEntity() - .. cpp:function:: unknown GetObjectiveIndex() + .. cpp:function:: int GetObjectiveIndex() + + returns the index of the player objective. ObjIndex 0 means no objective .. cpp:function:: int GetObserverMode() - .. cpp:function:: entity GetOffhandWeapon(slot) + returns either ``OBS_MODE_IN_EYE`` (first person) or ``OBS_MODE_CHASE`` (third person) + + .. cpp:function:: entity GetOffhandWeapon( int slot ) .. cpp:function:: array GetOffhandWeapons() .. cpp:function:: vector GetOrigin() + entity position + .. cpp:function:: entity GetParent() - .. cpp:function:: int GetPersistentSpawnLoadoutIndex( player, "pilot" ) + .. cpp:function:: int GetPersistentSpawnLoadoutIndex( entity player, string playerClass ) + + playerClasses: ``"pilot"`` ``"titan"`` (``"spectator"``) .. cpp:function:: entity GetPetTitan() - .. cpp:function:: PilotLoadoutDef GetPilotLoadoutFromPersistentData( player, loadoutIndex ) + auto titan of player + + .. cpp:function:: PilotLoadoutDef GetPilotLoadoutFromPersistentData( entity player, int loadoutIndex ) - .. cpp:function:: unknown GetPingGroupAccumulator() + stored loadout data of player - .. cpp:function:: unknown GetPingGroupStartTime() + .. cpp:function:: int GetPingGroupAccumulator() + + .. cpp:function:: float GetPingGroupStartTime() .. cpp:function:: string GetPlayerClass() + "titan", "spectator" or "pilot" + .. cpp:function:: PGS_ELIMINATED GetPlayerGameStat() .. cpp:function:: string GetPlayerName() + player (origin) username + .. cpp:function:: string GetPlayerNameWithClanTag() - .. cpp:function:: bool GetPlayerNetBool( net_bool_name ) + .. cpp:function:: bool GetPlayerNetBool( string net_bool_name ) example @@ -139,7 +163,9 @@ Functions for getting player, and methods of the player object .. cpp:function:: string GetPlayerSettings() - .. cpp:function:: unknown GetPlayerSettingsField( "weaponClass" ) + .. cpp:function:: string GetPlayerSettingsField( string ) + + some settings: ``"weaponClass"`` ``"gravityscale"`` ``"airSpeed"`` ``"airAcceleration"`` .. cpp:function:: int GetShieldHealth() @@ -169,55 +195,56 @@ Functions for getting player, and methods of the player object .. cpp:function:: int GetWeaponAmmoStockpile() - .. cpp:function:: unknown GetXP() + .. cpp:function:: int GetXP() .. cpp:function:: float GetZoomFrac() 0.0 (no zoom) - 1.0 (full zoom) - .. cpp:function:: void GiveArmor( player, int amount ) - - .. cpp:function:: void GiveOffhandWeapon( name, slot ) + .. cpp:function:: void GiveArmor( entity player, int amount ) - .. cpp:function:: void GivePilotLoadout( player, loadout ) + .. cpp:function:: void GiveOffhandWeapon( string name, int slot ) - .. cpp:function:: void GiveWeapon() + .. cpp:function:: void GivePilotLoadout( entity player, int loadout ) - .. cpp:function:: void GiveWeaponPowerUp( player, string newWeapon ) + .. cpp:function:: void GiveWeapon( string weapon ) - .. cpp:function:: void TakeOffhandWeapon() + .. cpp:function:: void GiveWeaponPowerUp( entity player, string newWeapon ) - .. cpp:function:: void TakeWeaponNow() + .. cpp:function:: void TakeOffhandWeapon( int offhandIndex ) - .. cpp:function:: void SetActiveWeaponByName() + can be used for titans as well. + some constants are: ``OFFHAND_ORDNANCE`` ``OFFHAND_SPECIAL`` ``OFFHAND_LEFT`` ``OFFHAND_INVENTORY`` ``OFFHAND_MELEE`` ``OFFHAND_EQUIPMENT`` ``OFFHAND_ANTIRODEO`` - .. cpp:function:: void SetBodygroup() + .. cpp:function:: void TakeWeaponNow( string weaponToSwitch) - .. cpp:function:: void SetDodgePowerDelayScale() + .. cpp:function:: void SetActiveWeaponByName( string newWeapon ) - .. cpp:function:: void SetHealth() + .. cpp:function:: void SetBodygroup( int bodyGroupIndex, int stateIndex ) - .. cpp:function:: void SetLastPingTime() + .. cpp:function:: void SetDodgePowerDelayScale( float delay ) - .. cpp:function:: void SetMaxHealth() + .. cpp:function:: void SetHealth(int health) - .. cpp:function:: void SetNumPingsAvailable() + .. cpp:function:: void SetLastPingTime( float time) - .. cpp:function:: void SetNumPingsUsed() + .. cpp:function:: void SetMaxHealth( int health ) - .. cpp:function:: void SetOrigin() + .. cpp:function:: void SetNumPingsAvailable( int num ) - .. cpp:function:: void SetPowerRegenRateScale() + .. cpp:function:: void SetNumPingsUsed( int num ) - .. cpp:function:: void SetShieldHealth() + .. cpp:function:: void SetOrigin( vector origin ) - .. cpp:function:: void SetShieldHealthMax() + .. cpp:function:: void SetPowerRegenRateScale( float scale ) - .. cpp:function:: void SetTitanDisembarkEnabled( bool ) + .. cpp:function:: void SetShieldHealth( float health) + .. cpp:function:: void SetShieldHealthMax( float health ) + .. cpp:function:: void SetTitanDisembarkEnabled( bool enabled ) - .. cpp:function:: void AddThreatScopeColorStatusEffect(weaponOwner) + .. cpp:function:: void AddThreatScopeColorStatusEffect( entity weaponOwner ) .. cpp:function:: vector CameraPosition() @@ -231,15 +258,15 @@ Functions for getting player, and methods of the player object .. cpp:function:: vector EyePosition() - .. cpp:function:: int FindBodyGroup() + .. cpp:function:: int FindBodyGroup( string bodyGroup ) - .. cpp:function:: int LookupAttachment() + .. cpp:function:: int LookupAttachment( string attachment = "" ) .. cpp:function:: void Lunge_ClearTarget() .. cpp:function:: int Minimap_GetZOrder() - .. cpp:function:: int RemoveThreatScopeColorStatusEffect(weaponOwner) + .. cpp:function:: int RemoveThreatScopeColorStatusEffect( entity player ) .. cpp:function:: bool HasBadReputation() @@ -253,7 +280,7 @@ Functions for getting player, and methods of the player object .. cpp:function:: bool IsHuman() - .. cpp:function:: bool IsInScoreboard( player ) + .. cpp:function:: bool IsInScoreboard( entity player ) .. cpp:function:: bool IsInThirdPersonReplay() @@ -261,17 +288,17 @@ Functions for getting player, and methods of the player object .. cpp:function:: bool IsPartyLeader() - .. cpp:function:: bool IsPartyMember( player ) + .. cpp:function:: bool IsPartyMember( entity player ) .. cpp:function:: bool IsPhaseShifted() .. cpp:function:: bool IsPlayer() - .. cpp:function:: bool IsPlayerEliminated( player ) + .. cpp:function:: bool IsPlayerEliminated( entity player ) - .. cpp:function:: bool IsPlayerFemale( player ) + .. cpp:function:: bool IsPlayerFemale( entity player ) - .. cpp:function:: bool IsRespawnAvailable( player ) + .. cpp:function:: bool IsRespawnAvailable( entity player ) .. cpp:function:: bool IsScriptMenuOn() @@ -279,7 +306,7 @@ Functions for getting player, and methods of the player object .. cpp:function:: bool IsTitan() - .. cpp:function:: bool IsTitanAvailable( player ) + .. cpp:function:: bool IsTitanAvailable( entity player ) .. cpp:function:: bool IsUsingOffhandWeapon() From 0584996dcd7539ec07e3ef089451c3d66789f64f Mon Sep 17 00:00:00 2001 From: uniboi Date: Mon, 21 Feb 2022 16:16:14 +0100 Subject: [PATCH 09/10] Add ternary operator expression terminology --- docs/source/native/functions.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source/native/functions.rst b/docs/source/native/functions.rst index b6900d2a..52b455f5 100644 --- a/docs/source/native/functions.rst +++ b/docs/source/native/functions.rst @@ -32,10 +32,10 @@ Conditional operators can also be used to make comparisons, such as ``==`` (equa .. code-block:: javascript if(RandomInt(6)+1 == 5) - + Like other languages, if statements can be connected to ``else if`` and ``else`` statements. ``else if`` statements must be used immediately after an ``if`` or ``else if`` and will only check their condition if the preceding statements failed. ``else`` statements behave similarly, but always run if the preceding statements failed and must be last. -You can also use short if statements to simplify your code. However, if not used carefully this can worsen readability. +Squirrel supports ternary operations like most languages. The value of the expression depends if a condition is truthy or not. However, if not used carefully this can worsen readability. The Syntax is ``condition ? if_condition_true : if_condition_false``. This is especially useful when declaring variables or passing parameters. .. code-block:: javascript @@ -56,10 +56,10 @@ This script will repeat endlessly until ``ReturnTrueOrFalse`` returns false. ``for`` loops are similar to ``while`` loops, but also run code once at the start and after every loop. These are primarily used to loop a specific number of times, such as over the length of a list: .. code-block:: javascript - + array somelist = [0, 5, 6, 4, 11] for(int i = 0; i < somelist.len(); i++) - + ``int i = 0`` runs immediately; ``i < somelist.len()`` is the test for the loop, only executing the loop if it is true; ``i++`` runs after every loop iteration. ``foreach`` loops only loop over a set of data, such as a list or table, and will execute for each entry. They don't loop in any order and data should not be added or removed from the set during the loop: @@ -73,14 +73,14 @@ Implicit conditional behavior Conditional statements, such as while loops and if statements, also implictly cast non-boolean inputs to booleans. For numbers, this means 0 is considered false and anything else is considered true. For instance variables like arrays and entities, ``null`` is considered false and anything else is considered true. For example, these inputs are considered true by the if statements: .. code-block:: javascript - + if(2) - + .. code-block:: javascript - + array somelist = [0, 1] if(somelist) - + Be aware that empty arrays and strings, ``[]`` and ``""``, are considered true by this logic. Formatting of actions From 2b6e8c5442282644548bcc2580ce380526ca934b Mon Sep 17 00:00:00 2001 From: uniboi Date: Mon, 21 Feb 2022 16:21:18 +0100 Subject: [PATCH 10/10] Apply review changes - GetPlayerArrayEx accepts "any", "pilot" and "titan" - compare function can't be of type void - GetPersistentSpawnLoadoutIndex playerClass accepts "pilot" "titan" --- docs/source/reference/respawn/player.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/reference/respawn/player.rst b/docs/source/reference/respawn/player.rst index 50917629..7e368e59 100644 --- a/docs/source/reference/respawn/player.rst +++ b/docs/source/reference/respawn/player.rst @@ -15,9 +15,9 @@ Functions for getting player, and methods of the player object .. cpp:function:: array GetPlayerArray() -.. cpp:function:: array GetPlayerArrayEx( string affected, int team, vector origin, float radius ) +.. cpp:function:: array GetPlayerArrayEx( string class, int team, vector origin, float radius ) - returns a list of every player in radius relative to origin. I only found ``"any"`` to work and assume the first parameter describes the affected types. + returns a list of every player of the specified class in radius relative to origin. The parameter ``class`` must be one of these strings: ``titan``, ``pilot`` or ``any``. .. cpp:function:: array GetPlayerArrayOfTeam( int team ) @@ -36,7 +36,7 @@ Functions for getting player, and methods of the player object .. code-block:: javascript - GetSortedPlayers(function(entity player1, entity player2) { + GetSortedPlayers(int function(entity player1, entity player2) { if(player1.GetPlayerGameStat(PGS_PING)>player2.GetPlayerGameStat(PGS_PING)) return 1 @@ -127,7 +127,7 @@ Functions for getting player, and methods of the player object .. cpp:function:: int GetPersistentSpawnLoadoutIndex( entity player, string playerClass ) - playerClasses: ``"pilot"`` ``"titan"`` (``"spectator"``) + playerClasses: ``"pilot"`` ``"titan"``. This returns null for every other string. .. cpp:function:: entity GetPetTitan()