Skip to content
Permalink
Browse files

Add exojump as traitor item

  • Loading branch information
Bara committed May 1, 2019
1 parent b1dee08 commit 03b184d3d4147d7a70092c4e18669076a817dda7
Showing with 103 additions and 0 deletions.
  1. +103 −0 addons/sourcemod/scripting/ttt/ttt_exojump.sp
@@ -0,0 +1,103 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <ttt>
#include <ttt_shop>

#define PLUGIN_NAME TTT_PLUGIN_NAME ... " - Exojump"
#define SHORT_NAME "exojump"

ConVar g_cPrice = null;
ConVar g_cPrio = null;
ConVar g_cLongName = null;

public Plugin myinfo =
{
name = PLUGIN_NAME,
author = TTT_PLUGIN_AUTHOR,
description = TTT_PLUGIN_DESCRIPTION,
version = TTT_PLUGIN_VERSION,
url = TTT_PLUGIN_URL
};

public void OnPluginStart()
{
TTT_IsGameCSGO();

TTT_LoadTranslations();

TTT_StartConfig("exojump");
CreateConVar("ttt2_exojump_version", TTT_PLUGIN_VERSION, TTT_PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD | FCVAR_REPLICATED);
g_cLongName = AutoExecConfig_CreateConVar("exojump_name", "Exojump", "The name of this in Shop");
g_cPrice = AutoExecConfig_CreateConVar("exojump_price", "3000", "The amount of credits exojump costs as detective. 0 to disable.");
g_cPrio = AutoExecConfig_CreateConVar("exojump_sort_prio", "0", "The sorting priority of the exojump in the shop menu.");
TTT_EndConfig();

HookEvent("player_spawn", Event_PlayerSpawn);
}

public void TTT_OnLatestVersion(const char[] version)
{
TTT_CheckVersion(TTT_PLUGIN_VERSION, TTT_GetCommitsCount());
}

public void TTT_OnShopReady()
{
RegisterItem();
}

void RegisterItem()
{
char sName[MAX_ITEM_LENGTH];
g_cLongName.GetString(sName, sizeof(sName));
TTT_RegisterCustomItem(SHORT_NAME, sName, g_cPrice.IntValue, SHOP_ITEM_4ALL, g_cPrio.IntValue);
}

public void OnClientDisconnect(int client)
{
ResetExojump(client);
}

public Action TTT_OnItemPurchased(int client, const char[] itemshort, bool count, int price)
{
if (TTT_IsClientValid(client) && IsPlayerAlive(client))
{
if (StrEqual(itemshort, SHORT_NAME, false))
{
if (GetClientExojump(client))
{
return Plugin_Stop;
}

SetClientExojump(client, true);
}
}
return Plugin_Continue;
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));

if (TTT_IsClientValid(client))
{
ResetExojump(client);
}
}

void ResetExojump(int client)
{
SetClientExojump(client, false);
}

bool GetClientExojump(int client)
{
return view_as<bool>(GetEntProp(client, Prop_Send, "m_passiveItems", 1, 1));
}

bool SetClientExojump(int client, bool status)
{
SetEntProp(client, Prop_Send, "m_passiveItems", status, 1, 1);
return GetClientExojump(client);
}

1 comment on commit 03b184d

@Bara

This comment has been minimized.

Copy link
Owner Author

Bara commented on 03b184d May 1, 2019

CVars for this feature:

  • "sv_exojump_jumpbonus_forward" = "0.4" client replicated - ExoJump forwards velocity bonus when duck jumping
  • "sv_exojump_jumpbonus_up" = "0.58" client replicated - ExoJump upwards bonus when holding the jump button
  • "sv_exostaminajumpcost" = ".040" min. 0.000000 client replicated - Stamina penalty for jumping with exo legs
  • "sv_exostaminalandcost" = ".015" min. 0.000000 client replicated - Stamina penalty for landing with exo legs
  • "sv_falldamage_exojump_multiplier" = "0.4" client replicated - ExoJump fall damage multiplier
  • "sv_jump_impulse_exojump_multiplier" = "1.05" client replicated - ExoJump impulse multiplier
Please sign in to comment.
You can’t perform that action at this time.