Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream 3dz49 #7

Merged
merged 7 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions addons/sourcemod/scripting/entwatch/function.inc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum struct class_ItemList
int Team; // Integer: Which team owns the item (-1 - No Team, 1 - Spec, 2 - T, 3 - CT)
bool LockButton; // Bool: Item cannot be used
float WaitTime; // Float: Timestamp when the button is rolled back
bool IsRegisterButton; // Bool: Is the button registered in the array

// Parameters for the entity activating the second ability
char ButtonClass2[32];
Expand Down Expand Up @@ -195,11 +196,14 @@ enum struct class_Scheme
// Structure for client settings
enum struct class_ClientSettings_Hud
{
bool Display; // Bool: Show HUD on client
int Color[4]; // Array: Color of HUD on client
float Pos_X; // Float: HUD position in X on client
float Pos_Y; // Float: HUD position in Y on client
bool Name; // Bool: Show player nicknames on items
bool Display; // Bool: Show HUD on client
int Type; // Integer: Type of HUD 0 = KeyHintText, 1 = HUD
int Color[4]; // Array: Color of HUD on client
float Pos_X; // Float: HUD position in X on client
float Pos_Y; // Float: HUD position in Y on client
bool Name; // Bool: Show player nicknames on items
int ItemsCount; // Integer: Number of items to show in HUD
int RotationTime; // Integer: Time in seconds to switch HUD page
}

// Structure for player e-ban information
Expand Down Expand Up @@ -232,6 +236,15 @@ enum struct class_Offline_Eban
char LastItem[32]; // String: The last item picked up by the disconnected player
}

// Used to readmap name without any uppercase characters
void StringToLowerCase(char[] input)
{
for (int i = 0; i < strlen(input); i++)
{
input[i] = CharToLower(input[i]);
}
}

// Checks the player for validity
stock bool IsValidClient(int iClient)
{
Expand All @@ -255,17 +268,17 @@ stock void FixedEquipPlayerWeapon(int iClient, int iWeapon)

// Correctly getting the value in the math_counter
stock int GetCounterValue(int counter) {
char szType[64];
GetEntityClassname(counter, szType, sizeof(szType));
char szType[64];
GetEntityClassname(counter, szType, sizeof(szType));

if(!StrEqual(szType, "math_counter", false)) {
return -1;
}
if(strcmp(szType, "math_counter", false) != 0) {
return -1;
}

if(g_iOutValueOffset == -1)
g_iOutValueOffset = FindDataMapInfo(counter, "m_OutValue");
return RoundFloat(GetEntDataFloat(counter, g_iOutValueOffset));
if(g_iOutValueOffset == -1)
g_iOutValueOffset = FindDataMapInfo(counter, "m_OutValue");
return RoundFloat(GetEntDataFloat(counter, g_iOutValueOffset));
}

// Kludge, Getting a weapon slot without using a gamedata
Expand Down
532 changes: 289 additions & 243 deletions addons/sourcemod/scripting/entwatch/module_eban.inc

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions addons/sourcemod/scripting/entwatch/module_forwards.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ stock void EWM_Forwards_OnPluginStart()
g_hOnAdminSpawnItem = CreateGlobalForward("EntWatch_OnAdminSpawnItem", ET_Ignore, Param_Cell, Param_String, Param_Cell);
g_hOnAdminTransferedAllItems = CreateGlobalForward("EntWatch_OnAdminTransferedAllItems", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
g_hOnAdminTransferedItem = CreateGlobalForward("EntWatch_OnAdminTransferedItem", ET_Ignore, Param_Cell, Param_String, Param_Cell);
}

stock void Forward_OnUseItem(char sItemName[32], int iActivator, int iAbility) {
Call_StartForward(g_hOnUseItem);
Call_PushString(sItemName);
Call_PushCell(iActivator);
Call_PushCell(iAbility);
Call_Finish();
}
185 changes: 116 additions & 69 deletions addons/sourcemod/scripting/entwatch/module_glow.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ int g_iGlow_Spawn_Type = 0,
g_iGlow_Drop_Type = 0;

bool g_bMapRunning = false;
bool g_bThinkPostHooked[2048] = { false, ... };

stock void EWM_Glow_OnPluginStart()
{
Expand Down Expand Up @@ -70,85 +71,131 @@ stock void EWM_Glow_GlowWeapon(class_ItemList ItemTest, int index, bool bSpawn)
{
if(g_bGlow && g_bMapRunning)
{
//WESKER EDIT -- Set drop type negative to disable glow on dropped items
if (!bSpawn && g_iGlow_Drop_Type < 0)
switch (g_evGameEngine)
{
if (ItemTest.GlowEnt != INVALID_ENT_REFERENCE && IsValidEdict(ItemTest.GlowEnt)) AcceptEntityInput(ItemTest.GlowEnt, "Kill");
return;
} else if (bSpawn && g_iGlow_Spawn_Type < 0) //WESKER EDIT -- Set spawn type negative to disable glow on new items
return;

// Create a new entity or glow an existing one
if(ItemTest.GlowEnt == INVALID_ENT_REFERENCE || !IsValidEdict(ItemTest.GlowEnt))
{
char sModelPath[PLATFORM_MAX_PATH];
// Get the original model path
GetEntPropString(ItemTest.WeaponID, Prop_Data, "m_ModelName", sModelPath, sizeof(sModelPath));
ReplaceString(sModelPath, sizeof(sModelPath), "_dropped", "", false);

// Find the location of the weapon
float fWOrigin[3], fWAngle[3];
float fForward[3], fRight[3], fUp[3];
float fOffset[3] = {0.0, -5.0, 0.0};

GetEntPropVector(ItemTest.WeaponID, Prop_Send, "m_vecOrigin", fWOrigin);
GetEntPropVector(ItemTest.WeaponID, Prop_Send, "m_angRotation", fWAngle);
GetAngleVectors(fWAngle, fForward, fRight, fUp);

fWOrigin[0] += fRight[0]*fOffset[0]+fForward[0]*fOffset[1]+fUp[0]*fOffset[2];
fWOrigin[1] += fRight[1]*fOffset[0]+fForward[1]*fOffset[1]+fUp[1]*fOffset[2];
fWOrigin[2] += fRight[2]*fOffset[0]+fForward[2]*fOffset[1]+fUp[2]*fOffset[2];

// Create & set dynamic glow entity and give properties
ItemTest.GlowEnt = CreateEntityByName("prop_dynamic");

DispatchKeyValue(ItemTest.GlowEnt, "model", sModelPath);
DispatchKeyValue(ItemTest.GlowEnt, "disablereceiveshadows", "1");
DispatchKeyValue(ItemTest.GlowEnt, "disableshadows", "1");
DispatchKeyValue(ItemTest.GlowEnt, "solid", "0");
DispatchKeyValue(ItemTest.GlowEnt, "spawnflags", "256");
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_CollisionGroup", 11);

// Spawn and teleport the entity
DispatchSpawn(ItemTest.GlowEnt);
TeleportEntity(ItemTest.GlowEnt, fWOrigin, fWAngle, NULL_VECTOR);

// Give glowing effect to the entity
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_bShouldGlow", true, true);
SetEntPropFloat(ItemTest.GlowEnt, Prop_Send, "m_flGlowMaxDist", 10000000.0);
if(bSpawn)
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Spawn_Type);
else SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Drop_Type);

SetVariantColor(ItemTest.GlowColor);
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowColor");

// Set the activator and group the entity
SetVariantString("!activator");
AcceptEntityInput(ItemTest.GlowEnt, "SetParent", ItemTest.WeaponID);

AcceptEntityInput(ItemTest.GlowEnt, "TurnOn");
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowEnabled");
// Save ItemTest
g_ItemList.SetArray(index, ItemTest, sizeof(ItemTest));
} else
{
if(g_bGlow_Spawn) SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Drop_Type);
AcceptEntityInput(ItemTest.GlowEnt, "TurnOn");
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowEnabled");
case Engine_CSS:
{
SetEntProp(ItemTest.WeaponID, Prop_Send, "m_fEffects", GetEntProp(ItemTest.WeaponID, Prop_Send, "m_fEffects") & ~256);
SetEntityRenderColor(ItemTest.WeaponID, 255, 255, 255, 255);

if (!g_bThinkPostHooked[ItemTest.WeaponID])
{
SDKHook(ItemTest.WeaponID, SDKHook_ThinkPost, EWM_Glow_SDKHook_OnThinkPost);
g_bThinkPostHooked[ItemTest.WeaponID] = true;
}
}
case Engine_CSGO:
{
//WESKER EDIT -- Set drop type negative to disable glow on dropped items
if (!bSpawn && g_iGlow_Drop_Type < 0)
{
if (ItemTest.GlowEnt != INVALID_ENT_REFERENCE && IsValidEdict(ItemTest.GlowEnt)) AcceptEntityInput(ItemTest.GlowEnt, "Kill");
return;
} else if (bSpawn && g_iGlow_Spawn_Type < 0) //WESKER EDIT -- Set spawn type negative to disable glow on new items
return;

// Create a new entity or glow an existing one
if(ItemTest.GlowEnt == INVALID_ENT_REFERENCE || !IsValidEdict(ItemTest.GlowEnt))
{
// Give glowing effect to the entity
char sModelPath[PLATFORM_MAX_PATH];
// Get the original model path
GetEntPropString(ItemTest.WeaponID, Prop_Data, "m_ModelName", sModelPath, sizeof(sModelPath));
ReplaceString(sModelPath, sizeof(sModelPath), "_dropped", "", false);

// Find the location of the weapon
float fWOrigin[3], fWAngle[3];
float fForward[3], fRight[3], fUp[3];
float fOffset[3] = {0.0, -5.0, 0.0};

GetEntPropVector(ItemTest.WeaponID, Prop_Send, "m_vecOrigin", fWOrigin);
GetEntPropVector(ItemTest.WeaponID, Prop_Send, "m_angRotation", fWAngle);
GetAngleVectors(fWAngle, fForward, fRight, fUp);

fWOrigin[0] += fRight[0]*fOffset[0]+fForward[0]*fOffset[1]+fUp[0]*fOffset[2];
fWOrigin[1] += fRight[1]*fOffset[0]+fForward[1]*fOffset[1]+fUp[1]*fOffset[2];
fWOrigin[2] += fRight[2]*fOffset[0]+fForward[2]*fOffset[1]+fUp[2]*fOffset[2];

// Create & set dynamic glow entity and give properties
ItemTest.GlowEnt = CreateEntityByName("prop_dynamic");

DispatchKeyValue(ItemTest.GlowEnt, "model", sModelPath);
DispatchKeyValue(ItemTest.GlowEnt, "disablereceiveshadows", "1");
DispatchKeyValue(ItemTest.GlowEnt, "disableshadows", "1");
DispatchKeyValue(ItemTest.GlowEnt, "solid", "0");
DispatchKeyValue(ItemTest.GlowEnt, "spawnflags", "256");
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_CollisionGroup", 11);

// Spawn and teleport the entity
DispatchSpawn(ItemTest.GlowEnt);
TeleportEntity(ItemTest.GlowEnt, fWOrigin, fWAngle, NULL_VECTOR);

SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_bShouldGlow", true, true);
SetEntPropFloat(ItemTest.GlowEnt, Prop_Send, "m_flGlowMaxDist", 10000000.0);
if(bSpawn)
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Spawn_Type);
else SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Drop_Type);

SetVariantColor(ItemTest.GlowColor);
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowColor");

// Set the activator and group the entity
SetVariantString("!activator");
AcceptEntityInput(ItemTest.GlowEnt, "SetParent", ItemTest.WeaponID);

AcceptEntityInput(ItemTest.GlowEnt, "TurnOn");
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowEnabled");
}
else
{
if (g_bGlow_Spawn)
SetEntProp(ItemTest.GlowEnt, Prop_Send, "m_nGlowStyle", g_iGlow_Drop_Type);

AcceptEntityInput(ItemTest.GlowEnt, "TurnOn");
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowEnabled");
}
}
}
}
}

// Disable glow
stock void EWM_Glow_DisableGlow(class_ItemList ItemTest)
{
if(g_bGlow)
if (!g_bGlow)
return;

switch (g_evGameEngine)
{
if (ItemTest.GlowEnt != INVALID_ENT_REFERENCE && IsValidEdict(ItemTest.GlowEnt))
case Engine_CSS:
{
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowDisabled");
AcceptEntityInput(ItemTest.GlowEnt, "TurnOff");
if (g_bThinkPostHooked[ItemTest.WeaponID])
{
SDKUnhook(ItemTest.WeaponID, SDKHook_ThinkPost, EWM_Glow_SDKHook_OnThinkPost);
g_bThinkPostHooked[ItemTest.WeaponID] = false;
}
}
case Engine_CSGO:
{
if (ItemTest.GlowEnt != INVALID_ENT_REFERENCE && IsValidEdict(ItemTest.GlowEnt))
{
AcceptEntityInput(ItemTest.GlowEnt, "SetGlowDisabled");
AcceptEntityInput(ItemTest.GlowEnt, "TurnOff");
}
}
}
}

stock void EWM_Glow_GlowWeapon_Internal(class_ItemList ItemTest, int index, bool bSpawn)
{

}

//----------------------------------------------------------------------------------------------------
// Purpose: Source 2009 Blinking effect
//----------------------------------------------------------------------------------------------------
public void EWM_Glow_SDKHook_OnThinkPost(int entity)
{
SetEntProp(entity, Prop_Send, "m_fEffects", GetEntProp(entity, Prop_Send, "m_fEffects") | 256);
SetEntityRenderColor(entity, 255, 165, 0, 255);
}
Loading
Loading