Fixup, Stufe 1

This commit is contained in:
Yamagi Burmeister 2009-03-12 17:11:31 +00:00
parent e901f7c2cd
commit 635f0728f8
6 changed files with 68 additions and 127 deletions

View file

@ -1,3 +1,22 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// g_ai.c
#include "g_local.h"
@ -399,7 +418,6 @@ qboolean FindTarget (edict_t *self)
return false;
}
//FIXME look for monsters?
return false;
}
@ -407,12 +425,12 @@ qboolean FindTarget (edict_t *self)
if (self->monsterinfo.aiflags & AI_COMBAT_POINT)
return false;
// if the first spawnflag bit is set, the monster will only wake up on
// really seeing the player, not another monster getting angry or hearing
// something
// if the first spawnflag bit is set, the monster will only wake up on
// really seeing the player, not another monster getting angry or hearing
// something
// revised behavior so they will wake up if they "see" a player make a noise
// but not weapon impact/explosion noises
// revised behavior so they will wake up if they "see" a player make a noise
// but not weapon impact/explosion noises
heardit = false;
if ((level.sight_entity_framenum >= (level.framenum - 1)) && !(self->spawnflags & 1) )
@ -474,8 +492,6 @@ qboolean FindTarget (edict_t *self)
if (r == RANGE_FAR)
return false;
// this is where we would check invisibility
// is client in an spot too dark to be seen?
if (client->light_level <= 5)
return false;
@ -552,9 +568,9 @@ qboolean FindTarget (edict_t *self)
self->enemy = client;
}
//
// got one
//
//
// got one
//
FoundTarget (self);
if (!(self->monsterinfo.aiflags & AI_SOUND_TARGET) && (self->monsterinfo.sight))
@ -619,7 +635,7 @@ qboolean M_CheckAttack (edict_t *self)
return true;
}
// missile attack
// missile attack
if (!self->monsterinfo.attack)
return false;
@ -711,7 +727,7 @@ void ai_run_missile(edict_t *self)
self->monsterinfo.attack (self);
self->monsterinfo.attack_state = AS_STRAIGHT;
}
};
}
/*
@ -764,11 +780,12 @@ qboolean ai_checkattack (edict_t *self, float dist)
{
if ((level.time - self->enemy->teleport_time) > 5.0)
{
if (self->goalentity == self->enemy)
if (self->goalentity == self->enemy) {
if (self->movetarget)
self->goalentity = self->movetarget;
else
self->goalentity = NULL;
}
self->monsterinfo.aiflags &= ~AI_SOUND_TARGET;
if (self->monsterinfo.aiflags & AI_TEMP_STAND_GROUND)
self->monsterinfo.aiflags &= ~(AI_STAND_GROUND | AI_TEMP_STAND_GROUND);
@ -783,7 +800,7 @@ qboolean ai_checkattack (edict_t *self, float dist)
enemy_vis = false;
// see if the enemy is dead
// see if the enemy is dead
hesDeadJim = false;
if ((!self->enemy) || (!self->enemy->inuse))
{
@ -814,7 +831,7 @@ qboolean ai_checkattack (edict_t *self, float dist)
if (hesDeadJim)
{
self->enemy = NULL;
// FIXME: look all around for other targets
// FIXME: look all around for other targets
if (self->oldenemy && self->oldenemy->health > 0)
{
self->enemy = self->oldenemy;
@ -843,7 +860,7 @@ qboolean ai_checkattack (edict_t *self, float dist)
self->show_hostile = level.time + 1; // wake up other monsters
// check knowledge of enemy
// check knowledge of enemy
enemy_vis = visible(self, self->enemy);
if (enemy_vis)
{
@ -851,12 +868,11 @@ qboolean ai_checkattack (edict_t *self, float dist)
VectorCopy (self->enemy->s.origin, self->monsterinfo.last_sighting);
}
// look for other coop players here
// if (coop && self->monsterinfo.search_time < level.time)
// {
// if (FindTarget (self))
// return true;
// }
if (coop && self->monsterinfo.search_time < level.time)
{
if (FindTarget (self))
return true;
}
enemy_infront = infront(self, self->enemy);
enemy_range = range(self, self->enemy);
@ -864,8 +880,6 @@ qboolean ai_checkattack (edict_t *self, float dist)
enemy_yaw = vectoyaw(temp);
// JDC self->ideal_yaw = enemy_yaw;
if (self->monsterinfo.attack_state == AS_MISSILE)
{
ai_run_missile (self);
@ -884,7 +898,6 @@ qboolean ai_checkattack (edict_t *self, float dist)
return self->monsterinfo.checkattack (self);
}
/*
=============
ai_run
@ -939,8 +952,6 @@ void ai_run (edict_t *self, float dist)
if (enemy_vis)
{
// if (self.aiflags & AI_LOST_SIGHT)
// dprint("regained sight\n");
M_MoveToGoal (self, dist);
self->monsterinfo.aiflags &= ~AI_LOST_SIGHT;
VectorCopy (self->enemy->s.origin, self->monsterinfo.last_sighting);
@ -948,18 +959,10 @@ void ai_run (edict_t *self, float dist)
return;
}
// coop will change to another enemy if visible
if (coop->value)
{ // FIXME: insane guys get mad with this, which causes crashes!
if (FindTarget (self))
return;
}
if ((self->monsterinfo.search_time) && (level.time > (self->monsterinfo.search_time + 20)))
{
M_MoveToGoal (self, dist);
self->monsterinfo.search_time = 0;
// dprint("search timeout\n");
return;
}
@ -972,7 +975,6 @@ void ai_run (edict_t *self, float dist)
if (!(self->monsterinfo.aiflags & AI_LOST_SIGHT))
{
// just lost sight of the player, decide where to go first
// dprint("lost sight of player, last seen at "); dprint(vtos(self.last_sighting)); dprint("\n");
self->monsterinfo.aiflags |= (AI_LOST_SIGHT | AI_PURSUIT_LAST_SEEN);
self->monsterinfo.aiflags &= ~(AI_PURSUE_NEXT | AI_PURSUE_TEMP);
new = true;
@ -981,14 +983,12 @@ void ai_run (edict_t *self, float dist)
if (self->monsterinfo.aiflags & AI_PURSUE_NEXT)
{
self->monsterinfo.aiflags &= ~AI_PURSUE_NEXT;
// dprint("reached current goal: "); dprint(vtos(self.origin)); dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); dprint(ftos(vlen(self.origin - self.last_sighting))); dprint("\n");
// give ourself more time since we got this far
self->monsterinfo.search_time = level.time + 5;
if (self->monsterinfo.aiflags & AI_PURSUE_TEMP)
{
// dprint("was temp goal; retrying original\n");
self->monsterinfo.aiflags &= ~AI_PURSUE_TEMP;
marker = NULL;
VectorCopy (self->monsterinfo.saved_goal, self->monsterinfo.last_sighting);
@ -1009,9 +1009,6 @@ void ai_run (edict_t *self, float dist)
VectorCopy (marker->s.origin, self->monsterinfo.last_sighting);
self->monsterinfo.trail_time = marker->timestamp;
self->s.angles[YAW] = self->ideal_yaw = marker->s.angles[YAW];
// dprint("heading is "); dprint(ftos(self.ideal_yaw)); dprint("\n");
// debug_drawline(self.origin, self.last_sighting, 52);
new = true;
}
}
@ -1028,8 +1025,6 @@ void ai_run (edict_t *self, float dist)
if (new)
{
// gi.dprintf("checking for course correction\n");
tr = gi.trace(self->s.origin, self->mins, self->maxs, self->monsterinfo.last_sighting, self, MASK_PLAYERSOLID);
if (tr.fraction < 1)
{
@ -1057,7 +1052,6 @@ void ai_run (edict_t *self, float dist)
{
VectorSet(v, d2 * left * 0.5, -16, 0);
G_ProjectSource (self->s.origin, v, v_forward, v_right, left_target);
// gi.dprintf("incomplete path, go part way and adjust again\n");
}
VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
@ -1065,8 +1059,6 @@ void ai_run (edict_t *self, float dist)
VectorCopy (left_target, self->monsterinfo.last_sighting);
VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
// gi.dprintf("adjusted left\n");
// debug_drawline(self.origin, self.last_sighting, 152);
}
else if (right >= center && right > left)
{
@ -1074,7 +1066,6 @@ void ai_run (edict_t *self, float dist)
{
VectorSet(v, d2 * right * 0.5, 16, 0);
G_ProjectSource (self->s.origin, v, v_forward, v_right, right_target);
// gi.dprintf("incomplete path, go part way and adjust again\n");
}
VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
@ -1082,11 +1073,8 @@ void ai_run (edict_t *self, float dist)
VectorCopy (right_target, self->monsterinfo.last_sighting);
VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
// gi.dprintf("adjusted right\n");
// debug_drawline(self.origin, self.last_sighting, 152);
}
}
// else gi.dprintf("course was fine\n");
}
M_MoveToGoal (self, dist);
@ -1096,3 +1084,4 @@ void ai_run (edict_t *self, float dist)
if (self)
self->goalentity = save;
}

View file

@ -23,7 +23,6 @@ char *ClientTeam (edict_t *ent)
return value;
}
// if ((int)(dmflags->value) & DF_SKINTEAMS)
return ++p;
}
@ -139,7 +138,7 @@ void Cmd_Give_f (edict_t *ent)
qboolean give_all;
edict_t *it_ent;
if (deathmatch->value && !sv_cheats->value)
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
@ -290,7 +289,7 @@ void Cmd_God_f (edict_t *ent)
{
char *msg;
if (deathmatch->value && !sv_cheats->value)
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
@ -319,7 +318,7 @@ void Cmd_Notarget_f (edict_t *ent)
{
char *msg;
if (deathmatch->value && !sv_cheats->value)
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
@ -346,7 +345,7 @@ void Cmd_Noclip_f (edict_t *ent)
{
char *msg;
if (deathmatch->value && !sv_cheats->value)
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
@ -374,7 +373,6 @@ Cmd_Use_f
Use an inventory item
==================
*/
void Cmd_Use_f (edict_t *ent)
{
int index;
@ -393,7 +391,6 @@ void Cmd_Use_f (edict_t *ent)
gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
return;
}
index = ITEM_INDEX(it);
if (!ent->client->pers.inventory[index])
{
@ -455,7 +452,6 @@ void Cmd_Drop_f (edict_t *ent)
gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
return;
}
index = ITEM_INDEX(it);
if (!ent->client->pers.inventory[index])
{
@ -554,7 +550,6 @@ void Cmd_InvUse_f (edict_t *ent)
Cmd_WeapPrev_f
=================
*/
void Cmd_WeapPrev_f (edict_t *ent)
{
gclient_t *cl;
@ -591,7 +586,6 @@ void Cmd_WeapPrev_f (edict_t *ent)
Cmd_WeapNext_f
=================
*/
#if 0
void Cmd_WeapNext_f (edict_t *ent)
{
gclient_t *cl;
@ -622,38 +616,6 @@ void Cmd_WeapNext_f (edict_t *ent)
return; // successful
}
}
#endif
void Cmd_WeapNext_f (edict_t *ent)
{
gclient_t *cl;
int i, index;
gitem_t *it;
int selected_weapon;
cl = ent->client;
if (!cl->pers.weapon)
return;
selected_weapon = ITEM_INDEX(cl->pers.weapon);
// scan for the next valid one
for (i=1 ; i<=MAX_ITEMS ; i++)
{
index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS;
if (!cl->pers.inventory[index])
continue;
it = &itemlist[index];
if (!it->use)
continue;
if (! (it->flags & IT_WEAPON) )
continue;
it->use (ent, it);
if (cl->pers.weapon == it)
return; // successful
}
}
/*
=================
@ -715,7 +677,8 @@ Cmd_Kill_f
*/
void Cmd_Kill_f (edict_t *ent)
{
if((level.time - ent->client->respawn_time) < 5)
if((level.time - ent->client->respawn_time) < 5 ||
(ent->client->resp.spectator))
return;
ent->flags &= ~FL_GODMODE;
ent->health = 0;
@ -956,7 +919,7 @@ void Cmd_PlayerList_f(edict_t *ent)
e2->client->ping,
e2->client->resp.score,
e2->client->pers.netname,
e2->client->pers.spectator ? " (spectator)" : "");
e2->client->resp.spectator ? " (spectator)" : "");
if (strlen(text) + strlen(st) > sizeof(text) - 50) {
sprintf(text+strlen(text), "And more...\n");
gi.cprintf(ent, PRINT_HIGH, "%s", text);
@ -1058,3 +1021,4 @@ void ClientCommand (edict_t *ent)
else // anything that doesn't match a command will be a chat
Cmd_Say_f (ent, false, true);
}

View file

@ -15,7 +15,7 @@ qboolean CanDamage (edict_t *targ, edict_t *inflictor)
vec3_t dest;
trace_t trace;
// bmodels need special checking because their origin is 0,0,0
// bmodels need special checking because their origin is 0,0,0
if (targ->movetype == MOVETYPE_PUSH)
{
VectorAdd (targ->absmin, targ->absmax, dest);
@ -79,7 +79,6 @@ void Killed (edict_t *targ, edict_t *inflictor, edict_t *attacker, int damage, v
if ((targ->svflags & SVF_MONSTER) && (targ->deadflag != DEAD_DEAD))
{
// targ->svflags |= SVF_DEADMONSTER; // now treat as a different content type
if (!(targ->monsterinfo.aiflags & AI_GOOD_GUY))
{
level.killed_monsters++;
@ -118,7 +117,6 @@ void SpawnDamage (int type, vec3_t origin, vec3_t normal, int damage)
damage = 255;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (type);
// gi.WriteByte (damage);
gi.WritePosition (origin);
gi.WriteDir (normal);
gi.multicast (origin, MULTICAST_PVS);
@ -163,6 +161,8 @@ static int CheckPowerArmor (edict_t *ent, vec3_t point, vec3_t normal, int damag
if (!damage)
return 0;
index = 0;
client = ent->client;
if (dflags & DAMAGE_NO_ARMOR)
@ -181,12 +181,14 @@ static int CheckPowerArmor (edict_t *ent, vec3_t point, vec3_t normal, int damag
{
power_armor_type = ent->monsterinfo.power_armor_type;
power = ent->monsterinfo.power_armor_power;
index = 0;
}
else
return 0;
if (power_armor_type == POWER_ARMOR_NONE)
return 0;
if (!power)
return 0;
@ -399,14 +401,14 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
VectorNormalize(dir);
// bonus damage for suprising a monster
// bonus damage for suprising a monster
if (!(dflags & DAMAGE_RADIUS) && (targ->svflags & SVF_MONSTER) && (attacker->client) && (!targ->enemy) && (targ->health > 0))
damage *= 2;
if (targ->flags & FL_NO_KNOCKBACK)
knockback = 0;
// figure momentum add
// figure momentum add
if (!(dflags & DAMAGE_NO_KNOCKBACK))
{
if ((knockback) && (targ->movetype != MOVETYPE_NONE) && (targ->movetype != MOVETYPE_BOUNCE) && (targ->movetype != MOVETYPE_PUSH) && (targ->movetype != MOVETYPE_STOP))
@ -464,7 +466,7 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
if (!(dflags & DAMAGE_NO_PROTECTION) && CheckTeamDamage (targ, attacker))
return;
// do the damage
// do the damage
if (take)
{
if ((targ->svflags & SVF_MONSTER) || (client))

View file

@ -239,7 +239,7 @@ void plat_CalcAcceleratedMove(moveinfo_t *moveinfo)
}
moveinfo->decel_distance = decel_dist;
};
}
void plat_Accelerate (moveinfo_t *moveinfo)
{
@ -310,7 +310,7 @@ void plat_Accelerate (moveinfo_t *moveinfo)
// we are at constant velocity (move_speed)
return;
};
}
void Think_AccelMove (edict_t *ent)
{
@ -434,9 +434,9 @@ void plat_spawn_inside_trigger (edict_t *ent)
edict_t *trigger;
vec3_t tmin, tmax;
//
// middle trigger
//
//
// middle trigger
//
trigger = G_Spawn();
trigger->touch = Touch_Plat_Center;
trigger->movetype = MOVETYPE_NONE;
@ -627,8 +627,6 @@ void SP_func_rotating (edict_t *ent)
if (!ent->dmg)
ent->dmg = 2;
// ent->moveinfo.sound_middle = "doors/hydro1.wav";
ent->use = rotating_use;
if (ent->dmg)
ent->blocked = rotating_blocked;
@ -956,7 +954,7 @@ void door_use (edict_t *self, edict_t *other, edict_t *activator)
ent->touch = NULL;
door_go_up (ent, activator);
}
};
}
void Touch_DoorTrigger (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
@ -1074,8 +1072,8 @@ void door_blocked (edict_t *self, edict_t *other)
return;
// if a door has a negative wait, it would never come back if blocked,
// so let it just squash the object to death real fast
// if a door has a negative wait, it would never come back if blocked,
// so let it just squash the object to death real fast
if (self->moveinfo.wait >= 0)
{
if (self->moveinfo.state == STATE_DOWN)
@ -1517,7 +1515,6 @@ void train_next (edict_t *self)
again:
if (!self->target)
{
// gi.dprintf ("train_next: no next target\n");
return;
}
@ -1683,7 +1680,6 @@ void trigger_elevator_use (edict_t *self, edict_t *other, edict_t *activator)
if (self->movetarget->nextthink)
{
// gi.dprintf("elevator busy\n");
return;
}

View file

@ -416,8 +416,6 @@ void Use_Breather (edict_t *ent, gitem_t *item)
ent->client->breather_framenum += 300;
else
ent->client->breather_framenum = level.framenum + 300;
// gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
}
//======================================================================
@ -431,8 +429,6 @@ void Use_Envirosuit (edict_t *ent, gitem_t *item)
ent->client->enviro_framenum += 300;
else
ent->client->enviro_framenum = level.framenum + 300;
// gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
}
//======================================================================
@ -457,8 +453,6 @@ void Use_Silencer (edict_t *ent, gitem_t *item)
ent->client->pers.inventory[ITEM_INDEX(item)]--;
ValidateSelectedItem (ent);
ent->client->silencer_shots += 30;
// gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
}
//======================================================================

View file

@ -446,10 +446,6 @@ extern spawn_temp_t st;
extern int sm_meat_index;
extern int snd_fry;
extern int jacket_armor_index;
extern int combat_armor_index;
extern int body_armor_index;
// means of death
#define MOD_UNKNOWN 0
@ -501,10 +497,10 @@ extern int meansOfDeath;
extern edict_t *g_edicts;
#define FOFS(x) (int)&(((edict_t *)0)->x)
#define STOFS(x) (int)&(((spawn_temp_t *)0)->x)
#define LLOFS(x) (int)&(((level_locals_t *)0)->x)
#define CLOFS(x) (int)&(((gclient_t *)0)->x)
#define FOFS(x) (size_t)&(((edict_t *)NULL)->x)
#define STOFS(x) (size_t)&(((spawn_temp_t *)NULL)->x)
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))