Commit graph

17 commits

Author SHA1 Message Date
BjossiAlfreds
55cfb537a3 Fixed monsters not changing state when enemy goes away 2019-09-25 20:14:52 +00:00
Yamagi Burmeister
501ed1e71a Try to fix monsters getting stuck by waiting forever for their enemy.
44472722e added some sanity checks to the AI code. The checks in
ai_run() are likely wrong because the enemy entity might be already
NULL if we arrive their. By aborting early the code is unable to
determine a new enemy or return the monster to idle state, so the
monster will wait forever for an enemy that'll never come.

This happens only in monster vs. monster fights. Never in monster vs.
player, that game ends if the player dies.

In theory this change should be harmless, because if the enemy entity is
gone it won't generate sound targets now be visible. If the game crashes
by self->enemy being NULL we've got a problem elsewere.

This was reported by @BjossiAlfreds in #483. He also suggested the fix
2019-08-31 11:11:04 +02:00
Yamagi Burmeister
02942e9544 Fix a potential crash in ai_run_melee() and ai_run_missile().
This was found and fixed by Maraakate.
2017-09-07 18:11:10 +02:00
Yamagi Burmeister
7720887274 Make sure that a monsters enemy is still alive when deciding to attack.
When the monster was already killed by another monster or a coop player
some references may be NULL and the game was crashed. This was observed
by maraakte, who reported it in issue #164. I've just merged his fix
from q2dos.
2016-12-30 10:23:32 +01:00
Yamagi Burmeister
ff4c00e5e6 Reorder conditionals to please unoptimizing compilers
This was requested by Maraakate. This is likely a noop, since even
early compilers from th 1970th supported simple optimiziations like
this.
2016-12-20 15:18:32 +01:00
Yamagi Burmeister
1c70fd8840 Change edict_s->show_hostile from qboolean to int and add casts
This variable is used as an integer. Defining it as a qbooblean is
just wrong. Add some explicit float -> int casts while at it.
2016-12-18 09:23:04 +01:00
Yamagi Burmeister
88617fac09 Rename teleport_time to last_sound time
teleport_time has nothing to do with teleports, it's just the time
since the last player sound. Rename it accordingly. This was suggest
by maraakate in yquake2 issue #162.
2016-12-18 09:22:02 +01:00
Yamagi Burmeister
a389a36844 Fix monsters ignoring the player under certain circumstances
In ai_checkattack() is a check against AI_SOUND_TARGET. If the player
made a noice and the the monster noticed this noise it's true. If
that noice was more than 5 seconds ago the monster forgets that event
and continues with it's search for the player. Otherwise it informs
the surrounding monsters that something interesting has happened and
then returns false. So the problem is: Even if the monster heard the
player and can see him, it aborts at this point.

Fix this by adding an additional visibility check. Do the sound
checking only if the player is not visible, otherwise just continue.

This was reported by shoober420 and debbuged by maraakate. This fix
was DanielGibons idea. This commit fixes yquake2 issue #162.
2016-12-18 09:21:17 +01:00
Daniel Gibson
08404e0949 Apply fix from 2009 for ai_run() and ai_checkattack(), but w/o old bug
To fix some bug, in baseq2 and xatrix
if(coop->value)
{
	if(FindTargeget(self))
	{
		return;
	}
}
was moved from ai_run() to ai_checkattack().
Do the same here, but without the bug from yquake2/#151
2016-10-23 18:27:31 +02:00
Yamagi Burmeister
bac51c8d95 Whitespace cleanup 2014-02-22 13:20:22 +01:00
Yamagi Burmeister
8a89578a2d Cleanup g_ai.c and add sanity checks 2013-05-01 10:25:53 +02:00
Yamagi Burmeister
489ab02814 Rearrange source and rework Makefile 2011-10-11 11:40:43 +00:00
Yamagi Burmeister
08340b71b1 Behebt einen potentiellen Nullpointer beim Herausfinden, ob der Spieler
vor einem Monster steht.
2011-01-23 14:40:50 +00:00
Yamagi Burmeister
ae3ae9e72c - Prüfe ob "run" im Target-Code NULL ist
- Prüfe ob "plane" beim Anheften der Proxy-Mine NULL ist
2010-12-27 15:47:09 +00:00
Yamagi Burmeister
f171e29266 No-Op Änderung. Entfernt sinnlosen Code 2010-01-28 16:57:21 +00:00
Yamagi Burmeister
ebfd333fab g_ai.c aufgeräumt 2009-03-30 14:11:48 +00:00
Yamagi Burmeister
ae4db9289f Gorund zero eingefügt 2009-03-12 20:03:41 +00:00