Skip to content

Commit

Permalink
General Fixes & Attributes [M]
Browse files Browse the repository at this point in the history
- Added attribute "boost on damage drain multi"
- Healing is no longer contributed to total score
- Fix minions in rage_cloneattack spawning initially without the minion flag
- Fixed weapon stripping
- Fixed overheal messing with health bar progress
- Fixed modified damage (such as crits) not contributing to damage dealt
  • Loading branch information
Batfoxkid committed Oct 21, 2024
1 parent 3183b90 commit c2a36a9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 67 deletions.
21 changes: 0 additions & 21 deletions addons/sourcemod/gamedata/ff2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@
"windows" "336"
"windows64" "336"
}
"CEconItemView::IterateAttributes"
{
"linux" "19"
"linux64" "19"
"windows" "18"
"windows64" "18"
}
"CTeamplayRoundBasedRules::RoundRespawn"
{
"linux" "231"
Expand Down Expand Up @@ -255,20 +248,6 @@
"return" "void"
"this" "entity"
}
"CEconItemView::IterateAttributes"
{
"offset" "CEconItemView::IterateAttributes"
"hooktype" "raw"
"return" "void"
"this" "address"
"arguments"
{
"IEconItemAttributeIterator"
{
"type" "objectptr"
}
}
}
"CLagCompensationManager::StartLagCompensation"
{
"signature" "CLagCompensationManager::StartLagCompensation"
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/ff2r_default_abilities.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2670,13 +2670,13 @@ void SpawnCloneList(int[] clients, int &amount, int &cap, ConfigData cfg, int ow
if(rivalTeam)
team = (team == 2) ? 3 : 2;

FF2R_SetClientMinion(clients[i], true);

if(cfg)
FF2R_CreateBoss(clients[i], cfg, team);

CloneOwner[clients[i]] = owner;

FF2R_SetClientMinion(clients[i], true);

vel[0] = GetRandomFloat(-500.0, 500.0);
vel[1] = GetRandomFloat(-500.0, 500.0);
vel[2] = GetRandomFloat(300.0, 500.0);
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/freak_fortress_2/attributes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void Attributes_OnHitBoss(int attacker, int victim, int inflictor, float fdamage
{
CreateDataTimer(0.1, Attributes_BoostDrainStack, pack, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
pack.WriteCell(GetClientUserId(attacker));
pack.WriteFloat(fdamage / 1000.0);
pack.WriteFloat(fdamage / 1000.0 * Weapons_GetCustAttrFloat(weapon, "boost on damage drain multi", 1.0));
}
else
{
Expand Down
36 changes: 0 additions & 36 deletions addons/sourcemod/scripting/freak_fortress_2/dhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ static DynamicHook SetWinningTeam;
static DynamicHook GetCaptureValue;
static DynamicHook ApplyOnInjured;
static DynamicHook ApplyPostHit;
static DynamicHook HookItemIterateAttribute;

static ArrayList RawEntityHooks;
static Address CTFGameStats;
static Address CLagCompensationManager;
static int DamageTypeOffset = -1;
static int m_bOnlyIterateItemViewAttributes;
static int m_Item;

static int ChangeTeamPreHook[MAXTF2PLAYERS];
static int ChangeTeamPostHook[MAXTF2PLAYERS];
Expand Down Expand Up @@ -69,10 +65,6 @@ void DHook_Setup()
GetCaptureValue = CreateHook(gamedata, "CTFGameRules::GetCaptureValueForPlayer");
ApplyOnInjured = CreateHook(gamedata, "CTFWeaponBase::ApplyOnInjuredAttributes");
ApplyPostHit = CreateHook(gamedata, "CTFWeaponBase::ApplyPostHitEffects");
HookItemIterateAttribute = CreateHook(gamedata, "CEconItemView::IterateAttributes");

m_Item = FindSendPropInfo("CEconEntity", "m_Item");
FindSendPropInfo("CEconEntity", "m_bOnlyIterateItemViewAttributes", _, _, m_bOnlyIterateItemViewAttributes);

delete gamedata;

Expand Down Expand Up @@ -182,22 +174,6 @@ static void DHook_EntityDestoryedFrame()
}
}

void DHook_HookStripWeapon(int entity)
{
if(m_Item > 0 && m_bOnlyIterateItemViewAttributes > 0)
{
Address pCEconItemView = GetEntityAddress(entity) + view_as<Address>(m_Item);

RawHooks raw;

raw.Ref = EntIndexToEntRef(entity);
raw.Pre = HookItemIterateAttribute.HookRaw(Hook_Pre, pCEconItemView, DHook_IterateAttributesPre);
raw.Post = HookItemIterateAttribute.HookRaw(Hook_Post, pCEconItemView, DHook_IterateAttributesPost);

RawEntityHooks.PushArray(raw);
}
}

void DHook_PluginEnd()
{
for(int client = 1; client <= MaxClients; client++)
Expand Down Expand Up @@ -453,15 +429,3 @@ static MRESReturn DHook_ApplyPostHitPost(int entity, DHookParam param)

return MRES_Ignored;
}

static MRESReturn DHook_IterateAttributesPre(Address pThis, DHookParam hParams)
{
StoreToAddress(pThis + view_as<Address>(m_bOnlyIterateItemViewAttributes), true, NumberType_Int8);
return MRES_Ignored;
}

static MRESReturn DHook_IterateAttributesPost(Address pThis, DHookParam hParams)
{
StoreToAddress(pThis + view_as<Address>(m_bOnlyIterateItemViewAttributes), false, NumberType_Int8);
return MRES_Ignored;
}
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/freak_fortress_2/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ static Action Events_WinPanel(Event event, const char[] name, bool dontBroadcast
{
if(!Client(clients[i]).IsBoss)
{
int damage = Client(clients[i]).TotalDamage + Client(clients[i]).Healing + Client(clients[i]).TotalAssist;
int damage = Client(clients[i]).TotalDamage + Client(clients[i]).TotalAssist;
if(damage > dmg[0])
{
top[2] = top[1];
Expand Down
10 changes: 8 additions & 2 deletions addons/sourcemod/scripting/freak_fortress_2/gamemode.sp
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ void Gamemode_UpdateHUD(int team, bool healing = false, bool nobar = false)
entity = FindEntityByClassname(-1, "monster_resource");
if(!maxcombined)
{
//if(entity != -1)
// RemoveEntity(entity);
if(entity != -1)
SetEntProp(entity, Prop_Send, "m_iBossHealthPercentageByte", 0, 2);
}
else
{
Expand Down Expand Up @@ -996,7 +996,13 @@ void Gamemode_UpdateHUD(int team, bool healing = false, bool nobar = false)
{
amount = combined * 255 / maxcombined;
if(!amount)
{
amount = 1;
}
else if(amount > 255)
{
amount = 255;
}
}

SetEntProp(entity, Prop_Send, "m_iBossHealthPercentageByte", amount, 2);
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/freak_fortress_2/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static any Native_GetClientScore(Handle plugin, int params)
SetNativeCellRef(2, Client(client).TotalDamage);
SetNativeCellRef(3, Client(client).Healing);
SetNativeCellRef(4, Client(client).Assist);
return Client(client).TotalDamage + Client(client).Healing + Client(client).TotalAssist;
return Client(client).TotalDamage + Client(client).TotalAssist;
}

static any Native_GetPluginHandle(Handle plugin, int params)
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/freak_fortress_2/sdkhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void SDKHook_HookClient(int client)
if(!OTDLoaded)
SDKHook(client, SDKHook_OnTakeDamage, SDKHook_TakeDamage);

SDKHook(client, SDKHook_OnTakeDamagePost, SDKHook_TakeDamagePost);
SDKHook(client, SDKHook_OnTakeDamageAlivePost, SDKHook_TakeDamagePost);
SDKHook(client, SDKHook_WeaponSwitchPost, SDKHook_SwitchPost);
}

Expand Down
14 changes: 12 additions & 2 deletions addons/sourcemod/scripting/freak_fortress_2/weapons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,16 @@ stock void Weapons_OnBackstabBoss(int victim, float &damage, int weapon, float &
#endif
}

float Weapons_GetCustAttrFloat(int weapon, const char[] name, float defaul = 1.0)
{
#if defined __tf_custom_attributes_included
if(TCALoaded)
return TF2CustAttr_GetFloat(weapon, name, defaul);
#endif

return defaul;
}

void Weapons_OnInventoryApplication(int userid)
{
RequestFrame(Weapons_OnInventoryApplicationFrame, userid);
Expand Down Expand Up @@ -822,13 +832,13 @@ static void Weapons_SpawnFrame(int ref)
bool found;
if(cfg.GetBool("strip", found, false) && found)
{
char classname[36];
/*char classname[36];
GetEntityClassname(entity, classname, sizeof(classname));
if(!StrContains(classname, "tf_weapon"))
{
DHook_HookStripWeapon(entity);
}
else
else*/
{
SetEntProp(entity, Prop_Send, "m_bOnlyIterateItemViewAttributes", true);
}
Expand Down

0 comments on commit c2a36a9

Please sign in to comment.