Skip to content

Commit

Permalink
momentary_rot_button fix
Browse files Browse the repository at this point in the history
would sometimes get stuck on if spamming +use near the fully opened position, then take about a minute to unwind back to the starting position.

Also reduced console spam from nerf logic.
  • Loading branch information
wootguy committed Nov 20, 2024
1 parent a4ceaba commit b903b37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion dlls/func/CMomentaryRotButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void CMomentaryRotButton::UpdateAllButtons(float value, int start)
}
m_lastProgress = value;

//ALERT(at_console, "ROT: %f %d %f\n", pev->angles.z, m_overflows, value);
//ALERT(at_console, "ROT: %f %d %d %f\n", pev->angles.z, m_direction, m_overflows, value);
}

void CMomentaryRotButton::UpdateSelf(float value)
Expand Down Expand Up @@ -267,6 +267,7 @@ void CMomentaryRotButton::Off(void)

void CMomentaryRotButton::Return(void)
{
m_direction = -1;
float value = GetRotProgress(pev->angles);

UpdateAllButtons(value, 0); // This will end up calling UpdateSelfReturn() n times, but it still works right
Expand Down
18 changes: 9 additions & 9 deletions dlls/monster/CMonsterMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ bool CMonsterMaker::NerfMonsterCounters(string_t target) {
edict_t* ent = NULL;
while (!FNullEnt(ent = FIND_ENTITY_BY_TARGETNAME(ent, STRING(target)))) {
if (strcmp(STRING(ent->v.classname), "game_counter") && strcmp(STRING(ent->v.classname), "trigger_counter")) {
ALERT(at_console, "Not nerfing %d count %s maker (triggers '%s')\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker (triggers '%s')\n",
m_cNumMonsters, STRING(m_iszMonsterClassname), STRING(target));
return false;
}
Expand All @@ -693,27 +693,27 @@ bool CMonsterMaker::NerfMonsterCounters(string_t target) {
if (!strcmp(STRING(ent->v.classname), "game_counter")) {
int trigCount = CountMonsterTriggerNerfs(target);
if (trigCount == -1 || trigCount >= (int)ent->v.health) {
ALERT(at_console, "Not nerfing %d count %s maker because game_counter '%s' would be nerfed into a negative count (%d > %d)\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker because game_counter '%s' would be nerfed into a negative count (%d > %d)\n",
m_cNumMonsters, STRING(m_iszMonsterClassname), STRING(target), trigCount, (int)ent->v.health);
return false;
}

ent->v.health -= reducedCount;
ALERT(at_console, "Reduced game_counter %s limit by %d (%d total)\n",
ALERT(at_aiconsole, "Reduced game_counter %s limit by %d (%d total)\n",
STRING(target), reducedCount, (int)ent->v.health);
}
else if (!strcmp(STRING(ent->v.classname), "trigger_counter")) {
CBaseToggle* trig = (CBaseToggle*)GET_PRIVATE(ent);
if (trig) {
int trigCount = CountMonsterTriggerNerfs(target);
if (trigCount == -1 || trigCount >= trig->m_cTriggersLeft) {
ALERT(at_console, "Not nerfing %d count %s maker because trigger_counter '%s' would be nerfed into a negative count (%d > %d)\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker because trigger_counter '%s' would be nerfed into a negative count (%d > %d)\n",
m_cNumMonsters, STRING(m_iszMonsterClassname), STRING(m_iszTriggerTarget), trigCount, trig->m_cTriggersLeft);
return false;
}

trig->m_cTriggersLeft -= reducedCount;
ALERT(at_console, "Reduced trigger_counter %s limit by %d (%d total)\n",
ALERT(at_aiconsole, "Reduced trigger_counter %s limit by %d (%d total)\n",
STRING(target), reducedCount, (int)trig->m_cTriggersLeft);
}
else {
Expand Down Expand Up @@ -752,7 +752,7 @@ void CMonsterMaker::Nerf() {
if (m_iszTriggerTarget && pev->target) {
// not actually a problem, just lazy.
// Need to be able to undo counter changes if one target fails to update
ALERT(at_console, "Not nerfing %d count %s maker (complicated triggers)\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker (complicated triggers)\n",
m_cNumMonsters, STRING(m_iszMonsterClassname));
shouldNerf = false;
}
Expand All @@ -763,7 +763,7 @@ void CMonsterMaker::Nerf() {
shouldNerf = NerfMonsterCounters(pev->target);
}
else if (pev->spawnflags & (SF_MONSTERMAKER_PRISONER | SF_MONSTERMAKER_WAIT_SCRIPT)) {
ALERT(at_console, "Not nerfing %d count %s maker (prisoner/scripted)\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker (prisoner/scripted)\n",
m_cNumMonsters, STRING(m_iszMonsterClassname));
shouldNerf = false;
}
Expand Down Expand Up @@ -810,12 +810,12 @@ void CMonsterMaker::Nerf() {
}
if (foundRepeatTrigger) {
ALERT(at_console, "Not nerfing %d count %s maker (can be triggered on/off by '%s')\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker (can be triggered on/off by '%s')\n",
m_cNumMonsters, STRING(m_iszMonsterClassname), foundRepeatTrigger);
shouldNerf = false;
}
else if (foundTriggers >= neededTriggers) {
ALERT(at_console, "Not nerfing %d count %s maker (can be triggered %d times as '%s')\n",
ALERT(at_aiconsole, "Not nerfing %d count %s maker (can be triggered %d times as '%s')\n",
m_cNumMonsters, STRING(m_iszMonsterClassname), foundTriggers, STRING(pev->targetname));
shouldNerf = false;
}
Expand Down

0 comments on commit b903b37

Please sign in to comment.