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
126
field.qc
126
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)
|
||||||
|
|
||||||
|
@ -546,92 +551,33 @@ void(entity gen1, entity gen2) Create_Field =
|
||||||
tfield.touch = Field_touch;
|
tfield.touch = Field_touch;
|
||||||
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';
|
if (gen1.origin_x == gen2.origin_x)
|
||||||
tfield.absmin_z = gen1.origin_z - 32;
|
{
|
||||||
tfield.absmax_z = gen1.origin_z + 32;
|
tfield.cnt = 0;
|
||||||
|
tfield.size_x = 4;
|
||||||
tfield.mins_z = 0 - 32;
|
tfield.size_y = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
tfield.maxs_z = 32;
|
}
|
||||||
tfield.size_z = 64;
|
else /* if (gen1.origin_y == gen2.origin_y) */
|
||||||
|
{
|
||||||
local float diff;
|
tfield.cnt = 1;
|
||||||
|
tfield.size_x = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
if (gen1.origin_x == gen2.origin_x)
|
tfield.size_y = 4;
|
||||||
{
|
}
|
||||||
tfield.cnt = 0;
|
/* else // for rotation. not currently used.
|
||||||
|
{
|
||||||
tfield.origin_x = gen1.origin_x;
|
tfield.cnt = 2;
|
||||||
tfield.absmin_x = gen1.origin_x - 2;
|
tfield.size_x = vlen (gen1.origin - gen2.origin) - 10;
|
||||||
tfield.absmax_x = gen1.origin_x + 2;
|
tfield.size_y = 4;
|
||||||
|
} */
|
||||||
tfield.maxs_x = 2;
|
tfield.size_z = 48; // was 64, but this looks more realistic
|
||||||
tfield.mins_x = 0 - 2;
|
tfield.maxs = tfield.size * 0.5; // FIXME: / 2 is broken
|
||||||
tfield.size_x = 4;
|
tfield.mins = tfield.maxs * -1; // FIXME: -1 * only did first float
|
||||||
|
tfield.origin = gen1.origin + (gen2.origin - gen1.origin) * 0.5;
|
||||||
if (gen1.origin_y > gen2.origin_y)
|
tfield.origin_z = avg (gen1.absmax_z, gen2.absmax_z) - tfield.maxs_z;
|
||||||
{
|
tfield.absmax = tfield.origin + tfield.maxs;
|
||||||
diff = (gen1.origin_y - gen2.origin_y)/2;
|
tfield.absmin = tfield.origin + tfield.mins;
|
||||||
|
// tfield.angles = gen2.origin - gen1.origin; // for rotation?
|
||||||
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
|
|
||||||
{
|
|
||||||
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.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;
|
|
||||||
|
|
||||||
if (gen1.origin_x > gen2.origin_x)
|
|
||||||
{
|
|
||||||
diff = (gen1.origin_x - gen2.origin_x)/2;
|
|
||||||
|
|
||||||
tfield.origin_x = gen1.origin_x - diff;
|
|
||||||
tfield.absmin_x = gen2.origin_x;
|
|
||||||
tfield.absmax_x = gen1.origin_x;
|
|
||||||
|
|
||||||
tfield.maxs_x = diff;
|
|
||||||
tfield.mins_x = 0 - diff;
|
|
||||||
tfield.size_x = diff * 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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,8 +918,9 @@ 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;
|
||||||
|
|
||||||
if (fieldgen1.origin_x != fieldgen2.origin_x && fieldgen1.origin_y != fieldgen2.origin_y)
|
// FIXME: comment out if we allow rotation
|
||||||
return FALSE;
|
if (fieldgen1.origin_x != fieldgen2.origin_x && fieldgen1.origin_y != fieldgen2.origin_y)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (fieldgen1.fieldgen_status == FIELDGEN_ISDISABLED || fieldgen2.fieldgen_status == FIELDGEN_ISDISABLED)
|
if (fieldgen1.fieldgen_status == FIELDGEN_ISDISABLED || fieldgen2.fieldgen_status == FIELDGEN_ISDISABLED)
|
||||||
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