mirror of
https://git.code.sf.net/p/quake/prozac-qfcc
synced 2024-11-24 05:01:48 +00:00
cleanup field generation in preperation for non-axis-aligned fields.
Only real difference so far should be that the bottom of the field isn't on the ground, and that was an intentional tweak. Oh, and now it's *many* less lines :)
This commit is contained in:
parent
25446fd860
commit
20e9fe09ae
1 changed files with 38 additions and 88 deletions
102
field.qc
102
field.qc
|
@ -507,6 +507,11 @@ void() Field_touch =
|
||||||
Field_touch_SUB();
|
Field_touch_SUB();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float(float a, float b) avg =
|
||||||
|
{
|
||||||
|
return a + (b - a) / 2;
|
||||||
|
};
|
||||||
|
|
||||||
//===================================================================================
|
//===================================================================================
|
||||||
// creates the force field between the 2 generators (only if none currently on)
|
// creates the force field between the 2 generators (only if none currently on)
|
||||||
|
|
||||||
|
@ -547,91 +552,32 @@ void(entity gen1, entity gen2) Create_Field =
|
||||||
tfield.nextthink = time + 0.25;
|
tfield.nextthink = time + 0.25;
|
||||||
|
|
||||||
// set pos and size
|
// set pos and size
|
||||||
tfield.origin = gen1.origin + '0 0 32';
|
|
||||||
tfield.absmin_z = gen1.origin_z - 32;
|
|
||||||
tfield.absmax_z = gen1.origin_z + 32;
|
|
||||||
|
|
||||||
tfield.mins_z = 0 - 32;
|
|
||||||
tfield.maxs_z = 32;
|
|
||||||
tfield.size_z = 64;
|
|
||||||
|
|
||||||
local float diff;
|
|
||||||
|
|
||||||
if (gen1.origin_x == gen2.origin_x)
|
if (gen1.origin_x == gen2.origin_x)
|
||||||
{
|
{
|
||||||
tfield.cnt = 0;
|
tfield.cnt = 0;
|
||||||
|
|
||||||
tfield.origin_x = gen1.origin_x;
|
|
||||||
tfield.absmin_x = gen1.origin_x - 2;
|
|
||||||
tfield.absmax_x = gen1.origin_x + 2;
|
|
||||||
|
|
||||||
tfield.maxs_x = 2;
|
|
||||||
tfield.mins_x = 0 - 2;
|
|
||||||
tfield.size_x = 4;
|
tfield.size_x = 4;
|
||||||
|
tfield.size_y = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
if (gen1.origin_y > gen2.origin_y)
|
|
||||||
{
|
|
||||||
diff = (gen1.origin_y - gen2.origin_y)/2;
|
|
||||||
|
|
||||||
tfield.origin_y = gen1.origin_y - diff;
|
|
||||||
tfield.absmin_y = gen2.origin_y;
|
|
||||||
tfield.absmax_y = gen1.origin_y;
|
|
||||||
|
|
||||||
tfield.maxs_y = diff;
|
|
||||||
tfield.mins_y = 0 - diff;
|
|
||||||
tfield.size_y = diff * 2;
|
|
||||||
}
|
}
|
||||||
else
|
else /* if (gen1.origin_y == gen2.origin_y) */
|
||||||
{
|
|
||||||
diff = (gen2.origin_y - gen1.origin_y)/2;
|
|
||||||
|
|
||||||
tfield.origin_y = gen2.origin_y - diff;
|
|
||||||
tfield.absmin_y = gen1.origin_y;
|
|
||||||
tfield.absmax_y = gen2.origin_y;
|
|
||||||
|
|
||||||
tfield.maxs_y = diff;
|
|
||||||
tfield.mins_y = 0 - diff;
|
|
||||||
tfield.size_y = diff * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
tfield.cnt = 1;
|
tfield.cnt = 1;
|
||||||
|
tfield.size_x = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
tfield.origin_y = gen1.origin_y;
|
|
||||||
tfield.absmin_y = gen1.origin_y - 2;
|
|
||||||
tfield.absmax_y = gen1.origin_y + 2;
|
|
||||||
|
|
||||||
tfield.maxs_y = 2;
|
|
||||||
tfield.mins_y = 0 - 2;
|
|
||||||
tfield.size_y = 4;
|
tfield.size_y = 4;
|
||||||
|
}
|
||||||
if (gen1.origin_x > gen2.origin_x)
|
/* else // for rotation. not currently used.
|
||||||
{
|
{
|
||||||
diff = (gen1.origin_x - gen2.origin_x)/2;
|
tfield.cnt = 2;
|
||||||
|
tfield.size_x = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
tfield.origin_x = gen1.origin_x - diff;
|
tfield.size_y = 4;
|
||||||
tfield.absmin_x = gen2.origin_x;
|
} */
|
||||||
tfield.absmax_x = gen1.origin_x;
|
tfield.size_z = 48; // was 64, but this looks more realistic
|
||||||
|
tfield.maxs = tfield.size * 0.5; // FIXME: / 2 is broken
|
||||||
tfield.maxs_x = diff;
|
tfield.mins = tfield.maxs * -1; // FIXME: -1 * only did first float
|
||||||
tfield.mins_x = 0 - diff;
|
tfield.origin = gen1.origin + (gen2.origin - gen1.origin) * 0.5;
|
||||||
tfield.size_x = diff * 2;
|
tfield.origin_z = avg (gen1.absmax_z, gen2.absmax_z) - tfield.maxs_z;
|
||||||
|
tfield.absmax = tfield.origin + tfield.maxs;
|
||||||
}
|
tfield.absmin = tfield.origin + tfield.mins;
|
||||||
else
|
// tfield.angles = gen2.origin - gen1.origin; // for rotation?
|
||||||
{
|
|
||||||
diff = (gen2.origin_x - gen1.origin_x)/2;
|
|
||||||
|
|
||||||
tfield.origin_x = gen2.origin_x - diff;
|
|
||||||
tfield.absmin_x = gen1.origin_x;
|
|
||||||
tfield.absmax_x = gen2.origin_x;
|
|
||||||
|
|
||||||
tfield.maxs_x = diff;
|
|
||||||
tfield.mins_x = 0 - diff;
|
|
||||||
tfield.size_x = diff * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply stuff
|
// apply stuff
|
||||||
tfield.movetype = MOVETYPE_NONE;
|
tfield.movetype = MOVETYPE_NONE;
|
||||||
|
@ -972,6 +918,7 @@ float(entity fieldgen1, entity fieldgen2) FieldGens_CanLink =
|
||||||
if (fieldgen1.origin_z != fieldgen2.origin_z)
|
if (fieldgen1.origin_z != fieldgen2.origin_z)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
// FIXME: comment out if we allow rotation
|
||||||
if (fieldgen1.origin_x != fieldgen2.origin_x && fieldgen1.origin_y != fieldgen2.origin_y)
|
if (fieldgen1.origin_x != fieldgen2.origin_x && fieldgen1.origin_y != fieldgen2.origin_y)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -1031,6 +978,9 @@ entity(entity fieldgen) Find_OtherGen =
|
||||||
|
|
||||||
vector(vector place) WhereGen =
|
vector(vector place) WhereGen =
|
||||||
{
|
{
|
||||||
|
// FIXME: remove function if we allow rotation
|
||||||
|
// return place;
|
||||||
|
|
||||||
// if we have no field generator currently, it can be placed anywhere
|
// 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 place;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue