Skip to content

Commit

Permalink
game: sync trigger_gravity
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 5, 2024
1 parent 9bca889 commit b0516fe
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 191 deletions.
77 changes: 2 additions & 75 deletions src/game/g_field.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ extern void SP_misc_teleporter (edict_t *self);

void InitTrigger(edict_t *self);

void InitField(edict_t *self)
void
InitField(edict_t *self)
{
if(!Vec3IsZero(self->s.angles))
{
Expand Down Expand Up @@ -280,80 +281,6 @@ void DamageField_Touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_
G_UseTargets(self, self);
}

//----------------------------------------------------------------------
// Gravity Field
//----------------------------------------------------------------------

void GravityField_Touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);

/*QUAKED trigger_Gravity (.5 .5 .5) ?
Changes the Touching entites Gravity to
the value of "Gravity". 1.0 is standard
Gravity for the level.
*/
void SP_trigger_Gravity(edict_t *self)
{
if (st.gravity == 0)
{
gi.dprintf("trigger_Gravity without gravity set at %s\n", vtos(self->s.origin));
G_FreeEdict (self);
return;
}

InitField(self);
self->gravity = atoi(st.gravity);
self->touch = GravityField_Touch;
}

void GravityField_Touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
other->gravity = self->gravity;
G_UseTargets(self, self);

}

//----------------------------------------------------------------------
// Monster Jump Field
//----------------------------------------------------------------------

void MonsterJumpField_Touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (other->flags & (FL_FLY | FL_SWIM) )
return;
if (other->svflags & SVF_DEADMONSTER)
return;
if ( !(other->svflags & SVF_MONSTER))
return;

VectorMA(other->velocity, self->speed, self->movedir, other->velocity);
other->velocity[2] += self->accel;

other->groundentity = NULL;
}

/*QUAKED trigger_MonsterJump (.5 .5 .5) ?
Walking monsters that Touch this will jump in the direction of the trigger's angle
"speed" default to 200, the speed thrown forward
"height" default to 200, the speed thrown upwards
*/
void SP_trigger_MonsterJump(edict_t *self)
{
if (self->s.angles[YAW] == 0)
self->s.angles[YAW] = 360;

InitField(self);

if (!self->speed)
self->speed = 200;

if (!st.height)
self->accel = 200;
else
self->accel = st.height;

self->touch = MonsterJumpField_Touch;
}

//----------------------------------------------------------------------
// Monster Go to Buoy Trigger
//----------------------------------------------------------------------
Expand Down
73 changes: 35 additions & 38 deletions src/game/g_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,16 +1739,19 @@ rotate_sounds(edict_t *ent)
*
* "speed" determines how fast it moves; default value is 100.
* "dmg" damage to inflict when blocked (2 default)
"sounds"
0 - silent
1 - generic rotate
2 - huge wheel ogles push in cloudlabs
3 - rock crusher which turns at end of conveyor on ogle2
4 - 'spanking' paddles on gauntlet
--------SPAWNFLAGS------------
REVERSE will cause the it to rotate in the opposite direction.
STOP mean it will stop moving instead of pushing entities
*/
* "accel" if specified, is how much the rotation speed will increase per .1sec.
*
* "sounds"
* 0 - silent
* 1 - generic rotate
* 2 - huge wheel ogles push in cloudlabs
* 3 - rock crusher which turns at end of conveyor on ogle2
* 4 - 'spanking' paddles on gauntlet
* --------SPAWNFLAGS------------
* REVERSE will cause the it to rotate in the opposite direction.
* STOP mean it will stop moving instead of pushing entities
* ACCEL means it will accelerate to it's final speed and decelerate when shutting down.
*/
void
rotating_accel(edict_t *self)
{
Expand Down Expand Up @@ -2258,28 +2261,28 @@ SP_func_button(edict_t *ent)
* "lip" lip remaining at end of move (8 default)
* "dmg" damage to inflict when blocked (2 default)
* "sounds"
0) silent
1) generic door
2) heavy stone door
3) for swing arm on palace level
4) for stone bridge in palace level
5) small/medium wood door swinging
6) large/huge wood door swinging
7) medium sized stone/wood door sliding
8) large stone/wood sliding door or portcullis
9) average metal door swinging
10) Fast sliding doors
11) Hive, Metal, Multipaneled sliding
12) Huge stone door swinging
13) Medium/large elevator
14) Crane (warehouse)
15) hammerlike pump in oglemine1
16) sliding metal table in cloudlabs
17) lab table which rotates up to ceiling - cloublabs
18) piston sound
19) short, sharp metal clang
20) something going under water
21) the bam sound
* 0) silent
* 1) generic door
* 2) heavy stone door
* 3) for swing arm on palace level
* 4) for stone bridge in palace level
* 5) small/medium wood door swinging
* 6) large/huge wood door swinging
* 7) medium sized stone/wood door sliding
* 8) large stone/wood sliding door or portcullis
* 9) average metal door swinging
* 10) Fast sliding doors
* 11) Hive, Metal, Multipaneled sliding
* 12) Huge stone door swinging
* 13) Medium/large elevator
* 14) Crane (warehouse)
* 15) hammerlike pump in oglemine1
* 16) sliding metal table in cloudlabs
* 17) lab table which rotates up to ceiling - cloublabs
* 18) piston sound
* 19) short, sharp metal clang
* 20) something going under water
* 21) the bam sound
*/

void
Expand Down Expand Up @@ -4004,12 +4007,6 @@ SP_trigger_elevator(edict_t *self)
self->nextthink = level.time + FRAMETIME;
}

void
SP_trigger_Elevator(edict_t *self)
{
SP_trigger_elevator(self);
}

/* ==================================================================== */

/*
Expand Down
2 changes: 2 additions & 0 deletions src/game/g_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ void Use_Item (edict_t *ent, edict_t *other, edict_t *activator)
gi.linkentity (ent);
}

/* ====================================================================== */

static void
FixObjectPosition(edict_t *ent)
{
Expand Down
1 change: 0 additions & 1 deletion src/game/g_monster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ walkmonster_start(edict_t *self)
}

self->think = walkmonster_start_go;

monster_start(self);
}

Expand Down
Loading

0 comments on commit b0516fe

Please sign in to comment.