Skip to content

Commit 37d26c1

Browse files
lechuga16KevonLin
authored andcommitted
Fix l4d2_skill_detect (SirPlease#889)
* - Fix Forward OnWitchCrownHurt - Improve witch crown detection with additional debugging messages * Rename OnWitchDrawCrown function to OnWitchCrownHurt in l4d2_playstats.sp
1 parent 3d4eb55 commit 37d26c1

6 files changed

Lines changed: 30 additions & 3 deletions

File tree

37 Bytes
Binary file not shown.
1.56 KB
Binary file not shown.

addons/sourcemod/scripting/include/l4d2_skill_detect.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum CarAlarmTriggerReason
2020
/**
2121
* CarAlarmTriggerReason: the name of the 'reason' in OnCarAlarmTriggered() forward
2222
*/
23-
char sCarAlarmTriggerReason[CarAlarmTrigger_Size][] = {
23+
stock char sCarAlarmTriggerReason[CarAlarmTrigger_Size][] = {
2424
"unknown",
2525
"hit",
2626
"touched",

addons/sourcemod/scripting/l4d2_playstats.sp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ public void OnWitchCrown(int attacker, int damage)
27252725
g_strRoundPlayerData[index][g_iCurTeam][plyCrowns]++;
27262726
}
27272727

2728-
public void OnWitchDrawCrown(int attacker, int damage, int chipdamage)
2728+
public void OnWitchCrownHurt(int attacker, int damage, int chipdamage)
27292729
{
27302730
int index = GetPlayerIndexForClient(attacker);
27312731
if (index == -1) {

addons/sourcemod/scripting/l4d2_skill_detect.sp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public APLRes
449449
g_hForwardLevel = CreateGlobalForward("OnChargerLevel", ET_Ignore, Param_Cell, Param_Cell);
450450
g_hForwardLevelHurt = CreateGlobalForward("OnChargerLevelHurt", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
451451
g_hForwardCrown = CreateGlobalForward("OnWitchCrown", ET_Ignore, Param_Cell, Param_Cell);
452-
g_hForwardDrawCrown = CreateGlobalForward("OnWitchDrawCrown", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
452+
g_hForwardDrawCrown = CreateGlobalForward("OnWitchCrownHurt", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
453453
g_hForwardTongueCut = CreateGlobalForward("OnTongueCut", ET_Ignore, Param_Cell, Param_Cell);
454454
g_hForwardSmokerSelfClear = CreateGlobalForward("OnSmokerSelfClear", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
455455
g_hForwardRockSkeeted = CreateGlobalForward("OnTankRockSkeeted", ET_Ignore, Param_Cell, Param_Cell);

addons/sourcemod/scripting/l4d2_skill_detect/tracking.sp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,11 @@ void CheckWitchCrown(int witch, int attacker, bool bOneShot = false)
13741374
// full crown? unharrassed
13751375
if (!witch_dmg_array[MAXPLAYERS + WTCH_STARTLED] && (bOneShot || witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT] >= iWitchHealth))
13761376
{
1377+
PrintDebug("Witch Crown Check: Full crown detected. Attacker: %N, Damage: %i, Chip Damage: %i",
1378+
attacker,
1379+
witch_dmg_array[attacker],
1380+
chipDamage);
1381+
13771382
// make sure that we don't count any type of chip
13781383
if (g_cvarHideFakeDamage.BoolValue)
13791384
{
@@ -1389,6 +1394,11 @@ void CheckWitchCrown(int witch, int attacker, bool bOneShot = false)
13891394
}
13901395
else if (witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT] >= g_cvarDrawCrownThresh.IntValue)
13911396
{
1397+
PrintDebug("Witch Crown Check: Draw crown detected. Attacker: %N, Crown Shot: %i, Threshold: %i",
1398+
attacker,
1399+
witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT],
1400+
g_cvarDrawCrownThresh.IntValue);
1401+
13921402
// draw crown: harassed + over X damage done by one survivor -- in ONE shot
13931403

13941404
for (int i = 0; i <= MAXPLAYERS; i++)
@@ -1400,6 +1410,8 @@ void CheckWitchCrown(int witch, int attacker, bool bOneShot = false)
14001410
chipDamage += witch_dmg_array[i];
14011411
}
14021412

1413+
PrintDebug("Witch Crown Check: Chip Damage Calculated: %i, Total Health: %i", chipDamage, iWitchHealth);
1414+
14031415
// make sure that we don't count any type of chip
14041416
if (g_cvarHideFakeDamage.BoolValue)
14051417
{
@@ -1411,14 +1423,29 @@ void CheckWitchCrown(int witch, int attacker, bool bOneShot = false)
14111423
}
14121424
else
14131425
witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT] = iWitchHealth - chipDamage;
1426+
1427+
PrintDebug("Witch Crown Check: Adjusted Crown Shot: %i, Adjusted Chip Damage: %i",
1428+
witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT],
1429+
chipDamage);
1430+
14141431
// re-check whether it qualifies as a drawcrown:
14151432
if (witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT] < g_cvarDrawCrownThresh.IntValue)
1433+
{
1434+
PrintDebug("Witch Crown Check: Adjusted Crown Shot below threshold. No draw crown.");
14161435
return;
1436+
}
14171437
}
14181438

14191439
// plus, set final shot as 'damage', and the rest as chip
14201440
HandleDrawCrown(attacker, witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT], chipDamage);
14211441
}
1442+
else
1443+
{
1444+
PrintDebug("Witch Crown Check: No crown detected. Crown Shot: %i, Threshold: %i, Harassed: %i",
1445+
witch_dmg_array[MAXPLAYERS + WTCH_CROWNSHOT],
1446+
g_cvarDrawCrownThresh.IntValue,
1447+
witch_dmg_array[MAXPLAYERS + WTCH_STARTLED]);
1448+
}
14221449

14231450
// remove trie
14241451
}

0 commit comments

Comments
 (0)