Skip to content

Commit 3ca03ed

Browse files
committed
Add lightning storm as a short range hazard avoidance goal to hopefully reduce the number of lightning mage suicides. Also tried to convince bots not to shoot thru allies (also leading to suicide).
1 parent b7bc564 commit 3ca03ed

File tree

6 files changed

+28
-10
lines changed

6 files changed

+28
-10
lines changed

src/ai/ai_class_dmbot.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,10 @@ qboolean BOT_DMclass_CheckShot(edict_t *ent, vec3_t point)
11761176

11771177
//bloqued, don't shoot
11781178
tr = gi.trace( start, vec3_origin, vec3_origin, point, ent, MASK_AISOLID);
1179+
1180+
if (tr.ent && tr.ent->inuse && OnSameTeam(ent, tr.ent))
1181+
return false; //GHz: bots tend to suicide by trying to shoot past allies
1182+
11791183
// trap_Trace( &tr, self->s.origin, vec3_origin, vec3_origin, point, self, MASK_AISOLID);
11801184
if (tr.fraction < 0.3) //just enough to prevent self damage (by now)
11811185
return false;

src/ai/ai_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ void AI_PickShortRangeGoal(edict_t* self)
541541
{
542542
if (!e->inuse)
543543
continue;
544-
if (e->solid == SOLID_NOT)
544+
if (e->solid == SOLID_NOT && e->mtype != M_LIGHTNINGSTORM)
545545
continue;
546546
if (!e->classname)
547547
continue;

src/ai/ai_util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
qboolean AI_IsProjectile(edict_t* ent)
77
{
8+
if (ent->mtype == M_LIGHTNINGSTORM)
9+
return true;
810
return ent->clipmask == MASK_SHOT && (ent->solid == SOLID_BBOX || ent->solid == SOLID_TRIGGER) && ent->s.modelindex && (ent->dmg || ent->radius_dmg);
911
}
1012

src/combat/abilities/lightningstorm.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ void lightningstorm_think (edict_t *self)
6969
return;
7070
}
7171

72-
// calculate randomized firing position
73-
VectorCopy(self->s.origin, start);
72+
// calculate randomized firing position from the ceiling/skybox
73+
VectorCopy(self->pos1, start);
7474
start[0] += GetRandom(0, (int)self->dmg_radius) * crandom();
7575
start[1] += GetRandom(0, (int)self->dmg_radius) * crandom();
76-
tr = gi.trace(self->s.origin, NULL, NULL, start, self, MASK_SOLID);
76+
tr = gi.trace(self->pos1, NULL, NULL, start, self, MASK_SOLID);
7777

7878
// Talent: Chainlightning Storm
7979
int talentLevel = vrx_get_talent_level(self->owner, TALENT_CL_STORM);
@@ -89,7 +89,14 @@ void lightningstorm_think (edict_t *self)
8989
void SpawnLightningStorm (edict_t *ent, vec3_t start, float radius, int duration, int damage)
9090
{
9191
edict_t *storm;
92+
vec3_t end;
93+
trace_t tr;
9294

95+
// trace up to the ceiling/skybox
96+
VectorCopy(start, end);
97+
end[2] = 8192;
98+
tr = gi.trace(start, NULL, NULL, end, ent, MASK_SOLID);
99+
93100
storm = G_Spawn();
94101
storm->classname = "lightning storm";
95102
storm->solid = SOLID_NOT;
@@ -100,8 +107,11 @@ void SpawnLightningStorm (edict_t *ent, vec3_t start, float radius, int duration
100107
storm->think = lightningstorm_think;
101108
VectorCopy(start, storm->s.origin);
102109
VectorCopy(start, storm->s.old_origin);
103-
storm->dmg_radius = radius;
110+
VectorCopy(tr.endpos, storm->pos1); // store the ceiling/skybox position
111+
storm->dmg_radius = radius; // radius of lightning strikes
112+
storm->radius_dmg = damage; // used for bot AI hazard detection
104113
storm->dmg = damage;
114+
storm->mtype = M_LIGHTNINGSTORM; // used for bot AI hazard detection
105115
gi.linkentity(storm);
106116

107117
// Talent: Chainlightning Storm
@@ -146,10 +156,10 @@ void Cmd_LightningStorm_f (edict_t *ent, float skill_mult, float cost_mult)
146156
tr = gi.trace(start, NULL, NULL, end, ent, MASK_SHOT);
147157

148158
// trace up to the ceiling/skybox
149-
VectorCopy(tr.endpos, start);
150-
VectorCopy(tr.endpos, end);
151-
end[2] += 8192;
152-
tr = gi.trace(start, NULL, NULL, end, ent, MASK_SOLID);
159+
//VectorCopy(tr.endpos, start);
160+
//VectorCopy(tr.endpos, end);
161+
//end[2] += 8192;
162+
//tr = gi.trace(start, NULL, NULL, end, ent, MASK_SOLID);
153163

154164
SpawnLightningStorm(ent, tr.endpos, radius, duration, damage);
155165

src/entities/drone/g_monster.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ void monster_fire_20mm(edict_t* self, vec3_t start, vec3_t dir, int damage, int
120120

121121
gi.sound(self, CHAN_WEAPON, gi.soundindex("weapons/sgun1.wav"), 1, ATTN_NORM, 0);
122122

123-
ThrowShell(self, "models/objects/shell1/tris.md2", start);
123+
if (vrx_spawn_nonessential_ent(self->s.origin))
124+
ThrowShell(self, "models/objects/shell1/tris.md2", start);
124125
}
125126

126127
void monster_fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, float damage, int kick, int hspread, int vspread, int count, int flashtype)

src/g_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,7 @@ void Cmd_LaserSight_f(edict_t *ent);
23292329
#define TBI_PLAYERSPAWN 706 // Team Based Invasion PlayerSpawn.
23302330
#define HW_FLAG 707
23312331
#define M_COMBAT_POINT 800 // temporary entity for monster navigation
2332+
#define M_LIGHTNINGSTORM 801 // used by bot AI to ID lightning storm for hazard avoidance
23322333
#define FUNC_DOOR 900
23332334
//4.1 Archer
23342335
#define TOTEM_FIRE 605

0 commit comments

Comments
 (0)