- fix the fieldgen placement warnings

- remove the ALIGNED_FIELDGENS define, since it's kinda pointless
- Add some waypoint files, which use obscure datastructures in the
  host entity, rather than a new entitiy for each waypoint like
  current soldier waypoints do.  Not use yet.
This commit is contained in:
Adam Olsen 2001-08-12 12:40:29 +00:00
parent 6c46c123cf
commit 78f349961e
8 changed files with 174 additions and 64 deletions

8
TODO
View file

@ -5,16 +5,16 @@ M = more testing
I = in progress
W = waiting on other work
I make changing skin/color force the proper color instead of kicking
I make sure team/color is cleared when a client connects
M make changing skin/color force the proper color instead of kicking
M make sure team/color is cleared when a client connects
o allow lay mode if purchased
o various drop items
X move from *preqcc to cpp
o add more variety to tinkering
o add a way to edit the respawn ammo entities
o add localinfo string for bottom half of the MOTD
X add localinfo string for bottom half of the MOTD
o add a define to disable abusive admin commands (eg stuffcmd)
o the thief skill should set the "invisible" face
X the thief skill should set the "invisible" face
o "slave teslas"
o instead of not allowing two fastest legs when upgraded, restrict the health/armor you're allowed when you have fast legs
o make a seperate menu for detonating engineer buildings

View file

@ -1,4 +1,8 @@
#include "options.qh"
// because I want a boolean type :)
#define boolean integer
//
// constants
//

View file

@ -544,10 +544,7 @@ void(float objtobuild) TeamFortress_Build =
v_forward_z = 0;
v_forward = normalize(v_forward) * 64;
if (objtobuild == BUILD_FIELDGEN) //- OfN - Field generators must be lined up to work
obj.origin = WhereGen(self.origin + v_forward);
else
obj.origin = self.origin + v_forward;
obj.origin = self.origin + v_forward;
//WK Cheat Fix
if (self.is_feigning) {
@ -734,6 +731,9 @@ void(float objtobuild) TeamFortress_Build =
TeamFortress_SetSpeed(self);
}
if (objtobuild == BUILD_FIELDGEN)
WhereGen(obj.origin);
};
void() DispenserThink =
@ -1079,8 +1079,6 @@ void() TeamFortress_FinishedBuilding =
oldself.solid = SOLID_BBOX;
oldself.angles = '0 0 0';
setmodel(oldself, oldself.mdl);
oldself.spawnflags = 4; //CH cause extensive checks for height

View file

@ -25,6 +25,7 @@
#define FIELDGEN_CELLSCOST 2 // cells cost for each "FIELDGEN_ISWORKING" pass
#define FIELDGEN_DMG 80 // normal damag when touching
#define FIELDGEN_DMGINSIDE 120 // damage when trapped inside field
#define FIELDGEN_MAXZ 10
/*===============================================================================================
@ -956,14 +957,9 @@ float(entity fieldgen1, entity fieldgen2) FieldGens_CanLink =
if (r > FIELDGEN_RANGE && !(fieldgen1.num_mines & IMPROVED_FOUR || fieldgen2.num_mines & IMPROVED_FOUR))
return FALSE;
if (fieldgen1.origin_z != fieldgen2.origin_z)
if (fabs(fieldgen1.origin_z - fieldgen2.origin_z) > FIELDGEN_MAXZ)
return FALSE;
#ifdef ALIGNED_FIELDGENS
if (fieldgen1.origin_x != fieldgen2.origin_x && fieldgen1.origin_y != fieldgen2.origin_y)
return FALSE;
#endif
if (fieldgen1.fieldgen_status == FIELDGEN_ISDISABLED || fieldgen2.fieldgen_status == FIELDGEN_ISDISABLED)
return FALSE;
@ -1018,80 +1014,65 @@ entity(entity fieldgen) Find_OtherGen =
//=========================================================================================
// returns the place where field gen could be built related to player current pos and yaw
// called on engineer.qc, place is the origin passed where other kind of buildings are built
// FIXME: changed to allow placing anywhere. comments need updating
vector(vector place) WhereGen =
void (vector place) WhereGen =
{
#ifndef ALIGNED_FIELDGENS
return place;
#endif
// if we have no field generator currently, it can be placed anywhere
if (self.has_fieldgen == 0) return place;
if (self.has_fieldgen == 0)
return;
local vector retval;
local float r, distx, disty, foundit;
local entity te;
local float r, foundit;
local entity te = world;
foundit = FALSE;
// find the other generator
te = find(world, classname, "building_fieldgen");
do {
te = find (te, classname, "building_fieldgen");
if (te.real_owner == self)
foundit = TRUE;
} while (te != world && foundit == FALSE);
/*
te = find (world, classname, "building_fieldgen");
while (te != world && foundit == FALSE)
{
if (te.real_owner == self) // is it ours?
foundit = TRUE; // yeah, found it
if (foundit == FALSE) // our search must continue...
te = find(te, classname, "building_fieldgen");
}
te = find (te, classname, "building_fieldgen");
}*/
// check for error getting the other gen
if (te == world || te.classname != "building_fieldgen" || foundit == FALSE)
{
RPrint("BUG: Error on field generator placement routine. 'WhereGen()'\n");
return place;
return;
}
// calculate the new generator pos
distx = fabs(place_x - te.origin_x);
disty = fabs(place_y - te.origin_y);
retval = place;
if (distx < disty)
{
retval_x = te.origin_x; // adjust it in line
r = vlen(self.origin - retval); // get distance from us (player)
if (r > 200) // we r too far away?
retval = place; // then bypass the calc
}
else
{
retval_y = te.origin_y; // adjust line up
r = vlen(self.origin - retval); // get distance from us (player)
if (r > 200) // we r too far away?
retval = place; // then bypass the calc
}
// print message if they wont link
if (!vis2orig(te.origin,retval))
sprint(self, PRINT_HIGH, "Your field generators won't link, there are obstacles between them!\n");
if (!vis2orig (te.origin,place))
sprint (self, PRINT_HIGH,
"Your field generators won't link, there are obstacles between them!\n");
r = vlen(te.origin - retval); // get distance between generators
if (te.num_mines & IMPROVED_FOUR && r > FIELDGEN_HACKEDRANGE)
sprint(self, PRINT_HIGH, "Your field generators are too far away to link, even hacked\n");
r = vlen(te.origin - place); // get distance between generators
if (r > FIELDGEN_HACKEDRANGE && te.num_mines & IMPROVED_FOUR)
sprint (self, PRINT_HIGH,
"Your field generators are too far away to link, even hacked\n");
if (r > FIELDGEN_RANGE && !(te.num_mines & IMPROVED_FOUR))
sprint(self, PRINT_HIGH, "Your field generators are too far away to link\n");
/*else if (retval_z != te.origin_z)
sprint(self, PRINT_HIGH, "Your field generators are at different heights, they won't link\n");*/
if (retval_x != te.origin_x && retval_y != te.origin_y)
sprint(self, PRINT_HIGH, "Your field generators are not lined up, they won't link\n");
sprint (self, PRINT_HIGH,
"Your field generators are too far away to link\n");
if (fabs (place_z - te.origin_z) > FIELDGEN_MAXZ)
sprint (self, PRINT_HIGH,
"Your field generators are at different heights, they won't link\n");
dprint (ftos (place_z) + " " + ftos (te.origin_z) + "\n");
// return the final building place
return retval;
return;
};
//======================================================================

View file

@ -12,7 +12,6 @@ Defines for the compilable options within TF.
//#define BOTS // doesn't do anything yet
//#define DEMO_STUFF
#define STATUSBAR
#undef ALIGNED_FIELDGENS
//#pragma PROGS_DAT "qwprogs.dat"

View file

@ -78,3 +78,5 @@ mtfents.qc
rotate.qc
spectate.qc
ofnents.qc
waypoint.qc

119
waypoint.qc Normal file
View file

@ -0,0 +1,119 @@
#include "defs.qh"
#include "waypoint.qh"
/*
Generic WayPoint code
The datastructures are intentionally obscured so that they can be
changed when we have more powerful stuff.
*/
// is adding fields in individual files bad practice? well, it's not
// like they're supposed to be accessed externally
.vector waypoint0;
.vector waypoint1;
.vector waypoint2;
.vector waypoint3;
.integer waypoint_count;
#define MAX_WAYPOINTS 4
#define WAYPOINT_TOUCHDIST 50
/* private functions */
vector (entity ent, integer index) _Waypoint_Get;
void (entity ent, integer index, vector loc) _Waypoint_Set;
/* end private functions */
boolean (entity ent, integer index) Waypoint_IsValid =
{
return index > 0 && index < ent.waypoint_count;
};
vector (entity ent, integer index) Waypoint_Get =
{
if (!Waypoint_IsValid (ent, index))
error ("Waypoint_Get: invalid waypoint.\n");
return _Waypoint_Get (ent, index);
};
void (entity ent, integer index, vector loc) Waypoint_Set =
{
if (!Waypoint_IsValid (ent, index))
error ("Waypoint_Set: invalid waypoint.\n");
_Waypoint_Set (ent, index, loc);
};
void (entity ent, vector loc) Waypoint_Append =
{
Waypoint_Add (ent, ent.waypoint_count, loc);
};
boolean (entity ent, integer index) Waypoint_IsTouching =
{
return vlen(Waypoint_Get (ent, index) - ent.origin) < WAYPOINT_TOUCHDIST;
};
void (entity ent, integer index, vector loc) Waypoint_Add =
{
local integer i;
if (ent.waypoint_count >= MAX_WAYPOINTS)
error ("Waypoint_Add: maximum waypoints hit!\n");
// I error here because I want ent.waypoint_count to be used when
// appending, not MAX_WAYPOINTS
if (index > ent.waypoint_count)
error ("Waypoint_Add: index past end of array.\n");
// Make room for new waypoint
for (i = ent.waypoint_count; i >= index; i -= 1)
_Waypoint_Set (ent, i + 1, _Waypoint_Get (ent, i));
_Waypoint_Set (ent, index, loc);
ent.waypoint_count += 1;
};
void (entity ent, integer index) Waypoint_Remove =
{
local integer i;
if (!Waypoint_IsValid (ent, index))
error ("Waypoint_Remove: bad index number.\n");
ent.waypoint_count -= 1;
for (i = index; i < ent.waypoint_count; i += 1)
_Waypoint_Set (ent, i, _Waypoint_Get (ent, i + 1));
_Waypoint_Set (ent, i, '0 0 0'); // pointless, but what the hell..
};
/* Internally used functions. Don't call them from outside this file. */
vector (entity ent, integer index) _Waypoint_Get =
{
if (index == 0)
return ent.waypoint0;
else if (index == 1)
return ent.waypoint1;
else if (index == 2)
return ent.waypoint2;
else if (index == 3)
return ent.waypoint3;
else
error ("_Waypoint_Get: bad waypoint index!\n");
};
void (entity ent, integer index, vector loc) _Waypoint_Set =
{
if (index == 0)
ent.waypoint0 = loc;
else if (index == 1)
ent.waypoint1 = loc;
else if (index == 2)
ent.waypoint2 = loc;
else if (index == 3)
ent.waypoint3 = loc;
else
error ("_Waypoint_Set: bad waypoint index!\n");
};

7
waypoint.qh Normal file
View file

@ -0,0 +1,7 @@
boolean (entity ent, integer index) Waypoint_IsValid;
vector (entity ent, integer index) Waypoint_Get;
void (entity ent, integer index, vector loc) Waypoint_Set;
void (entity ent, vector loc) Waypoint_Append;
boolean (entity ent, integer index) Waypoint_IsTouching;
void (entity ent, integer index, vector loc) Waypoint_Add;
void (entity ent, integer index) Waypoint_Remove;