-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
264 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#if defined _di_math_included | ||
#endinput | ||
#endif | ||
#define _di_math_included | ||
|
||
#define VECTOR_SIZE 3 | ||
#define METERS_PER_UNIT (2.54 / 100) | ||
#define SQUARED_NO false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if defined _di_menu_included | ||
#endinput | ||
#endif | ||
#define _di_menu_included | ||
|
||
#define ITEM_INFO_MAX_SIZE 32 | ||
#define TEXT_BUFFER_MAX_SIZE (256 * 4) | ||
|
||
#define SHOW_DAMAGE "Show damage" | ||
#define ITEM_SHOW_DAMAGE_IN_CHAT "Show damage in chat" | ||
#define ITEM_SHOW_DAMAGE_ON_SCREEN "Show damage on screen" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#if defined _di_preferences_included | ||
#endinput | ||
#endif | ||
#define _di_preferences_included | ||
|
||
#define COOKIE_VALUE_MAX_SIZE 4 | ||
#define NULL_CHARACTER '\0' | ||
|
||
#define SHOW_DAMAGE_ENABLED "1" | ||
#define SHOW_DAMAGE_DISABLED "0" | ||
|
||
#define SHOW_DAMAGE_IN_CHAT_DEFAULT_VALUE true | ||
#define SHOW_DAMAGE_ON_SCREEN_DEFAULT_VALUE true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if defined _di_use_case_included | ||
#endinput | ||
#endif | ||
#define _di_use_case_included | ||
|
||
#define HIT_GROUP_RIGHT_LEG 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
static ConVar g_pluginEnabled = null; | ||
|
||
void Variable_Create() { | ||
g_pluginEnabled = CreateConVar("sm_damageinfo_show", "1", "Enable (1) or disable (0) damage information"); | ||
} | ||
|
||
bool Variable_IsPluginEnabled() { | ||
return g_pluginEnabled.IntValue == 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
float Math_CalculateDistance(int victim, int attacker) { | ||
float victimPos[VECTOR_SIZE]; | ||
float attackerPos[VECTOR_SIZE]; | ||
|
||
GetClientAbsOrigin(victim, victimPos); | ||
GetClientAbsOrigin(attacker, attackerPos); | ||
|
||
return GetVectorDistance(victimPos, attackerPos, SQUARED_NO) * METERS_PER_UNIT; | ||
} | ||
|
||
int Math_Max(int a, int b) { | ||
return a > b ? a : b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
void Menu_AddToPreferences() { | ||
SetCookieMenuItem(MenuHandler_ShowDamage, 0, SHOW_DAMAGE); | ||
} | ||
|
||
public void MenuHandler_ShowDamage(int client, CookieMenuAction action, any info, char[] buffer, int maxlen) { | ||
if (action == CookieMenuAction_SelectOption) { | ||
Menu_Settings(client); | ||
} else { | ||
Format(buffer, maxlen, "%T", SHOW_DAMAGE, client); | ||
} | ||
} | ||
|
||
public void Menu_Settings(int client) { | ||
Menu menu = new Menu(MenuHandler_Settings); | ||
|
||
menu.SetTitle("%T", SHOW_DAMAGE, client); | ||
|
||
Menu_AddBoolItem(menu, ITEM_SHOW_DAMAGE_IN_CHAT, client, Preferences_IsShowDamageInChat(client)); | ||
Menu_AddBoolItem(menu, ITEM_SHOW_DAMAGE_ON_SCREEN, client, Preferences_IsShowDamageOnScreen(client)); | ||
|
||
menu.ExitBackButton = true; | ||
menu.Display(client, MENU_TIME_FOREVER); | ||
} | ||
|
||
public int MenuHandler_Settings(Menu menu, MenuAction action, int param1, int param2) { | ||
if (action == MenuAction_Select) { | ||
char info[ITEM_INFO_MAX_SIZE]; | ||
|
||
menu.GetItem(param2, info, sizeof(info)); | ||
|
||
if (StrEqual(info, ITEM_SHOW_DAMAGE_IN_CHAT)) { | ||
Preferences_ToggleShowDamageInChat(param1); | ||
} else if (StrEqual(info, ITEM_SHOW_DAMAGE_ON_SCREEN)) { | ||
Preferences_ToggleShowDamageOnScreen(param1); | ||
} | ||
|
||
Menu_Settings(param1); | ||
} else if (action == MenuAction_Cancel) { | ||
if (param2 == MenuCancel_ExitBack) { | ||
ShowCookieMenu(param1); | ||
} | ||
} else if (action == MenuAction_End) { | ||
delete menu; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void Menu_AddBoolItem(Menu menu, char[] phrase, int client, bool enabled) { | ||
char buffer[TEXT_BUFFER_MAX_SIZE]; | ||
|
||
Format(buffer, sizeof(buffer), "%T", phrase, client, enabled ? "Enabled" : "Disabled", client); | ||
|
||
menu.AddItem(phrase, buffer); | ||
} |
Oops, something went wrong.