Definitions and borg2-elevator

Updated more definitions
Started to work on an entity that manages the 2-part-elevator
Spawnfunc on that works fine (including failsafes)
but thinkfunc buggs out on me (can't say I'm surprised, first time I'm working on trajectories in this way)
I think the problem lies in transfering the hardcoded vectorized speed to the entity.

spawn-nextthink is set to -1 for now.

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2012-11-16 02:10:01 +01:00
parent 27ae701260
commit 404b94b520
4 changed files with 337 additions and 46 deletions

View file

@ -5,17 +5,29 @@
#define SPARK_STARTOFF 1
/*QUAKED fx_spark (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF
Emits sparks at the specified point in the specified direction
-----DESCRIPTION-----
Emits sparks at the specified point in the specified direction.
"target" - ( optional ) direction to aim the sparks in, otherwise, uses the angles set in the editor.
"wait(2000)" - interval between events (randomly twice as long)
Can be toggled by being used, but use with caution as updates every second instead of every 10 seconds,
which means it sends 10 times the information that an untoggleable steam will send.
-----SPAWNFLAGS-----
1: STARTOFF - Effect will be off at spawn.
-----KEYS-----
"targetname" - toggles on/off whenever used
"target" - ( optional ) direction to aim the sparks in, otherwise, uses the angles set in the editor.
"wait(2000)" - interval between events (randomly twice as long)
*/
//------------------------------------------
void spark_think( gentity_t *ent )
{
G_AddEvent( ent, EV_FX_SPARK, 0 );
ent->nextthink = level.time + 10000.0; // send a refresh message every 10 seconds
if(ent->targetname) //toggleable effect needs to be updated more often
ent->nextthink = level.time + 1000;
else
ent->nextthink = level.time + 10000.0; // send a refresh message every 10 seconds
}
//T3h TiM-zor was here
@ -104,13 +116,16 @@ void SP_fx_spark( gentity_t *ent )
/*QUAKED fx_steam (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF
Emits steam at the specified point in the specified direction. will point at a target if one is specified.
-----DESCRIPTION-----
Emits steam at the specified point in the specified direction. Will point at a target if one is specified.
Use toggleable steam with caution as updates every second instead of every 10 seconds,
Can be toggled but use with caution as updates every second instead of every 10 seconds,
which means it sends 10 times the information that an untoggleable steam will send.
STARTOFF steam is of at spawn
-----SPAWNFLAGS-----
1: STARTOFF - steam is of at spawn
-----KEYS-----
"targetname" - toggles on/off whenever used
"damage" - damage to apply when caught in steam vent, default - zero damage (no damage). Don't add this unless you really have to.
*/
@ -123,11 +138,11 @@ STARTOFF steam is of at spawn
void steam_think( gentity_t *ent )
{
G_AddEvent( ent, EV_FX_STEAM, 0 );
if(ent->targetname) { //toggleable steam needs to be updated more often
if(ent->targetname) //toggleable effect needs to be updated more often
ent->nextthink = level.time + 1000;
} else {
else
ent->nextthink = level.time + 10000.0; // send a refresh message every 10 seconds
}
// FIXME: This may be a bit weird for steam bursts*/
// If a fool gets in the bolt path, zap 'em
@ -247,14 +262,23 @@ void SP_fx_steam( gentity_t *ent )
}
/*QUAKED fx_bolt (0 0 1) (-8 -8 -8) (8 8 8) SPARKS BORG TAPER SMOOTH
-----DESCRIPTION-----
Emits blue ( or borg green ) electric bolts from the specified point to the specified point
SPARKS - create impact sparks, probably best used for time delayed bolts
BORG - Make the bolts green
Can be toggled by being used, but use with caution as updates every second instead of every 10 seconds,
which means it sends 10 times the information that an untoggleable steam will send.
"wait" - seconds between bolts (0 is always on, default is 2.0, -1 for random number between 0 and 5), bolts are always on for 0.2 seconds
"damage" - damage per server frame (default 0)
"random" - bolt chaos (0.1 = too calm, 0.5 = default, 1.0 or higher = pretty wicked)
-----SPAWNFLAGS-----
1: SPARKS - create impact sparks, probably best used for time delayed bolts
2: BORG - Make the bolts green
4: TAPER
8: SMOOTH
-----KEYS-----
"targetname" - toggles on/off whenever used
"wait" - seconds between bolts (0 is always on, default is 2.0, -1 for random number between 0 and 5), bolts are always on for 0.2 seconds
"damage" - damage per server frame (default 0)
"random" - bolt chaos (0.1 = too calm, 0.5 = default, 1.0 or higher = pretty wicked)
*/
@ -269,7 +293,11 @@ void bolt_think( gentity_t *ent )
G_AddEvent( ent, EV_FX_BOLT, ent->spawnflags );
ent->s.time2 = ent->wait;
ent->nextthink = level.time + 10000;
if(ent->targetname) //toggleable effect needs to be updated more often
ent->nextthink = level.time + 1000;
else
ent->nextthink = level.time + 10000.0; // send a refresh message every 10 seconds
// If a fool gets in the bolt path, zap 'em
if ( ent->damage )
@ -382,8 +410,15 @@ void SP_fx_bolt( gentity_t *ent )
//--------------------------------------------------
/*QUAKED fx_transporter (0 0 1) (-8 -8 -8) (8 8 8)
-----DESCRIPTION-----
Emits transporter pad effect at the specified point. just rest it flush on top of the pad.
-----SPAWNFLAGS-----
none
-----KEYS-----
none
*/
void transporter_link( gentity_t *ent )
@ -406,9 +441,19 @@ void SP_fx_transporter(gentity_t *ent)
/*QUAKED fx_drip (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF
-----DESCRIPTION-----
Drips of a fluid that fall down from this point.
"damage" -- type of drips. 0 = water, 1 = oil, 2 = green
"random" -- (0...1) degree of drippiness. 0 = one drip, 1 = Niagara Falls
Can be toggled by being used, but use with caution as updates every second instead of every 10 seconds,
which means it sends 10 times the information that an untoggleable steam will send.
-----SPAWNFLAGS-----
1: STARTOFF - effect is off at spawn
-----KEYS-----
"targetname" - toggles on/off whenever used
"damage" - type of drips. 0 = water, 1 = oil, 2 = green
"random" - (0...1) degree of drippiness. 0 = one drip, 1 = Niagara Falls
*/
//------------------------------------------
@ -442,11 +487,18 @@ void SP_fx_drip( gentity_t *ent )
//***********************************************************************************
/*QUAKED fx_fountain (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF
-----DESCRIPTION-----
Fountain-Effect as seen iin the Garden of Scilence holodeck Programm.
This is just one single strain of the original effect (which had all four strains hardcoded)
STARTOFF - Effect spawns in an off state
Use with caution as this refreshes 10 times a second.
-----SPAWNFLAGS-----
1: STARTOFF - Effect spawns in an off state
-----KEYS-----
"targetname" - name of entity when used turns this ent on/off
"target" - link to a notnull entity to position where the end point of this FX is
"target" - link to an info_notnull entity or similar to position where the end point of this FX is
*/
void fountain_think( gentity_t *ent )
@ -510,16 +562,20 @@ void SP_fx_fountain ( gentity_t *ent ) {
}
/*QUAKED fx_surface_explosion (0 0 1) (-8 -8 -8) (8 8 8) NO_SMOKE LOUDER NODAMAGE
-----DESCRIPTION-----
Creates a triggerable explosion aimed at a specific point. Always oriented towards viewer.
LOUDER - Cheap hack to make the explosion sound louder.
NODAMAGE - Does no damage
-----SPAWNFLAGS-----
1: NO_SMOKE - Does not create smoke after explosion
2: LOUDER - Cheap hack to make the explosion sound louder.
4: NODAMAGE - Does no damage
"target" (optional) If no target is specified, the explosion is oriented up
"damage" - Damage per blast, default is 50. Damage falls off based on proximity.
"radius" - blast radius (default 20)
"speed" - camera shake speed (default 12). Set to zero to turn camera shakes off
"targetname" - triggers explosion when used
-----KEYS-----
"target" (optional) If no target is specified, the explosion is oriented up
"damage" - Damage per blast, default is 50. Damage falls off based on proximity.
"radius" - blast radius (default 20)
"speed" - camera shake speed (default 12). Set to zero to turn camera shakes off
"targetname" - triggers explosion when used
*/
//------------------------------------------
@ -528,9 +584,7 @@ void surface_explosion_use( gentity_t *self, gentity_t *other, gentity_t *activa
G_AddEvent( self, EV_FX_SURFACE_EXPLOSION, 0 );
if ( self->splashDamage )
{
G_RadiusDamage( self->r.currentOrigin, self, self->splashDamage, self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION );
}
}
//------------------------------------------
@ -563,8 +617,7 @@ void surface_explosion_link( gentity_t *ent )
//------------------------------------------
void SP_fx_surface_explosion( gentity_t *ent )
{
if ( !(ent->spawnflags&4) )
{
if ( !(ent->spawnflags&4) ){
G_SpawnInt( "damage", "50", &ent->splashDamage );
G_SpawnFloat( "radius", "20", &ent->distance ); // was: ent->radius
ent->splashRadius = 160;
@ -589,21 +642,23 @@ void SP_fx_surface_explosion( gentity_t *ent )
}
/*QUAKED fx_blow_chunks (0 0 1) (-8 -8 -8) (8 8 8)
-----DESCRIPTION-----
Creates a triggerable chunk spewer that can be aimed at a specific point.
"target" - (required) Target to spew chunks at
"targetname" - triggers chunks when used
"radius" - Average size of a chunk (default 65)
-----SPAWNFLAGS-----
none
-----KEYS-----
"target" - (required) Target to spew chunks at
"targetname" - triggers chunks when used
"radius" - Average size of a chunk (default 65)
"material" - default is "metal" - choose from this list:
None = 0,
Metal = 1
Glass = 2
Glass Metal = 3
Wood = 4
Stone = 5
(there will be more eventually lol.. I hope)
*/
//"count" - Number of chunks to spew (default 5)

View file

@ -3399,3 +3399,230 @@ void SP_func_stasis_door( gentity_t *ent )
trap_LinkEntity (ent);
}
/*
-------------------------------------------
func_borg_elevator
by Ubergames Harry Young
to get the 2-Part-Elevator on borg2 back into buissness (map will die using lua)
-------------------------------------------
*/
/*
Presets
upper->count current motion indicator
1 = both moving up
2 = upper moving up, spawn spark in between, spawn beam-fx
3 = upper moving down
4 = spawn spark in between
5 = both moving down
upper->n00bCount end motion indicator (1)
*/
/*QUAKED func_borg_elevator (0 .5 .8)
-----DESCRIPTION-----
DO NOT USE!
This entity is hardcoded to get the 2-part elevator on borg2 back to work.
If this type of entity is found on any other map or the entity is not part of that #specific
elevator (checked by bmodel-number) it will automatically be turned into a func_static.
-----SPAWNFLAGS-----
none
-----KEYS-----
none
-----LUA-----
This entity needs to be set up using Lua:
ent = entity.FindBModel(52)
ent:SetClassname("func_borg_elevator");
entity.CallSpawn(ent);
ent = entity.FindBModel(54)
ent:SetClassname("func_borg_elevator");
entity.CallSpawn(ent);
*/
void borg_elevator_think( gentity_t *upper ) //only the upper can think about this
{
gentity_t *lower = G_Find(NULL, FOFS(model), "54");
vec3_t destination;
int snd;
if(upper->n00bCount == 1){ //stop and play stop sound
snd = G_SoundIndex("sound/movers/doors/largedoorstop.mp3");
G_AddEvent(upper, EV_SCRIPT_SOUND, snd + (0 << 8));
BG_EvaluateTrajectory(&upper->s.pos, level.time, upper->r.currentOrigin);
VectorCopy(upper->r.currentOrigin, upper->s.pos.trBase);
upper->s.pos.trType = TR_STATIONARY;
upper->s.pos.trTime = level.time;
trap_LinkEntity(upper);
if(upper->count == 1 || upper->count == 2) //the lower part has moved so do here as well
G_AddEvent(lower, EV_SCRIPT_SOUND, snd + (0 << 8));
BG_EvaluateTrajectory(&lower->s.pos, level.time, lower->r.currentOrigin);
VectorCopy(lower->r.currentOrigin, lower->s.pos.trBase);
lower->s.pos.trType = TR_STATIONARY;
lower->s.pos.trTime = level.time;
trap_LinkEntity(lower);
upper->n00bCount = 0; //play stop-sound
upper->nextthink = level.time + 1000; //always pause 1 sec
return;
}
//set X and Y-Coorinates, they won't change
destination[0] = 786;
destination[1] = -1984;
snd = G_SoundIndex("sound/movers/doors/largedoorstart.mp3");
switch(upper->count){
case 0: //going from lowest point to sep-point
destination[2] = 30;
upper->count = 1;
upper->n00bCount = 1; //play stop-sound
upper->nextthink = level.time + 4000; //motion takes 4 secs
BG_EvaluateTrajectory(&upper->s.pos, level.time, upper->s.pos.trBase);
upper->s.pos.trDuration = 4000;
upper->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);//I likely got a bug in this line
upper->s.pos.trType = TR_LINEAR_STOP;
upper->moverState = MOVER_LUA;
trap_LinkEntity(upper);
G_AddEvent(upper, EV_SCRIPT_SOUND, snd + (0 << 8));
BG_EvaluateTrajectory(&lower->s.pos, level.time, lower->s.pos.trBase);
lower->s.pos.trDuration = 4000;
lower->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);//I likely got a bug in this line
lower->s.pos.trType = TR_LINEAR_STOP;
lower->moverState = MOVER_LUA;
trap_LinkEntity(lower);
G_AddEvent(lower, EV_SCRIPT_SOUND, snd + (0 << 8));
break;
case 1: //going from sep-point to top
destination[2] = 12;
upper->count = 2;
upper->n00bCount = 1; //play stop-sound
upper->nextthink = level.time + 4000; //motion takes 4 secs
BG_EvaluateTrajectory(&upper->s.pos, level.time, upper->s.pos.trBase);
upper->s.pos.trDuration = 4000;
upper->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);//I likely got a bug in this line
upper->s.pos.trType = TR_LINEAR_STOP;
upper->moverState = MOVER_LUA;
trap_LinkEntity(upper);
G_AddEvent(upper, EV_SCRIPT_SOUND, snd + (0 << 8));
break;
// TODO: spawn beam effect and short-lived spark
case 2: //going from top to sep-point
destination[2] = -12;
upper->count = 4; //skip 3 for now, reserved for spark-spawn
upper->n00bCount = 1; //play stop-sound, set 0 once spawn-spark comes
upper->nextthink = level.time + 4000; //motion takes 4 secs, reduce correctly once spark is added
BG_EvaluateTrajectory(&upper->s.pos, level.time, upper->s.pos.trBase);
upper->s.pos.trDuration = 4000;
upper->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);//I likely got a bug in this line
upper->s.pos.trType = TR_LINEAR_STOP;
upper->moverState = MOVER_LUA;
trap_LinkEntity(upper);
G_AddEvent(upper, EV_SCRIPT_SOUND, snd + (0 << 8));
break;
case 3: //spawn spark for closing
upper->count = 4; //skip 3 for now, reserved for spark-spawn
upper->n00bCount = 1; //play stop-sound, set 0 once spawn-spark comes
upper->nextthink = level.time + 0; //effect killtime
// TODO: Spark stuff
break;
case 4: //going from sep-point to lowest point
destination[2] = -30;
upper->count = 0;
upper->n00bCount = 1; //play stop-sound
upper->nextthink = level.time + 4000; //motion takes 4 secs
BG_EvaluateTrajectory(&upper->s.pos, level.time, upper->s.pos.trBase);
upper->s.pos.trDuration = 4000;
upper->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);//I likely got a bug in this line
upper->s.pos.trType = TR_LINEAR_STOP;
upper->moverState = MOVER_LUA;
trap_LinkEntity(upper);
G_AddEvent(upper, EV_SCRIPT_SOUND, snd + (0 << 8));
BG_EvaluateTrajectory(&lower->s.pos, level.time, lower->s.pos.trBase);
lower->s.pos.trDuration = 4000;
lower->s.pos.trTime = level.time;
VectorCopy(destination, upper->s.pos.trDelta);
lower->s.pos.trType = TR_LINEAR_STOP;
lower->moverState = MOVER_LUA;
trap_LinkEntity(lower);
G_AddEvent(lower, EV_SCRIPT_SOUND, snd + (0 << 8));
break;
default:
break;
}
}
void SP_func_borg_elevator( gentity_t *ent )
{
gentity_t *upper, *lower;
char serverInfo[MAX_TOKEN_CHARS];
vec3_t initOrigin;
trap_GetServerinfo( serverInfo, sizeof( serverInfo ) );
//let's make sure we're on borg2, if not make ent func_static, call spawn and return.
if(Q_stricmp(Info_ValueForKey( serverInfo, "mapname" ), "borg2")){ //this is not borg2
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] func_borg_elevator found but map is not borg2, turning entity into func_static.\n"););
ent->classname = "func_static";
G_CallSpawn(ent);
return;
}
//So we are on borg2. Let's make sure these are only the correct entities.
if( Q_stricmp(ent->model, "*52") && Q_stricmp(ent->model, "*54")){// this is not part of the elevator
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] entity is not part of the elevator, turning entity into func_static.\n"););
ent->classname = "func_static";
G_CallSpawn(ent);
return;
}
upper = G_Find(NULL, FOFS(model), "*52");
lower = G_Find(NULL, FOFS(model), "*54");
//setting both entities up as statics
//upper
trap_SetBrushModel( upper, upper->model );
G_SetOrigin(upper, upper->s.origin);
G_SetAngles(upper, upper->s.angles);
VectorCopy( upper->s.origin, upper->pos1);
InitMover( upper );
VectorCopy( upper->s.origin, upper->s.pos.trBase );
VectorCopy( upper->s.origin, upper->r.currentOrigin );
//lower
trap_SetBrushModel( lower, lower->model );
G_SetOrigin(lower, lower->s.origin);
G_SetAngles(lower, lower->s.angles);
VectorCopy( lower->s.origin, lower->pos1);
InitMover( lower );
VectorCopy( lower->s.origin, lower->s.pos.trBase );
VectorCopy( lower->s.origin, lower->r.currentOrigin );
level.numBrushEnts++;
level.numBrushEnts++;
//Let us send the entities to their init-origin (both down)
initOrigin[0] = 786;
initOrigin[1] = -1984;
initOrigin[2] = 104;
G_SetOrigin(upper, initOrigin);
G_SetOrigin(lower, initOrigin);
//Only one of these entities needs to think/monitoring
upper->count = 0;
upper->think = borg_elevator_think;
upper->nextthink = -1;
trap_LinkEntity (upper);
trap_LinkEntity (lower);
}

View file

@ -143,6 +143,7 @@ void SP_func_brushmodel(gentity_t *ent); // for brushmodel hijacking :D
void SP_func_lightchange(gentity_t *ent); // "toggling" light
void SP_func_targetmover(gentity_t *ent);
void SP_func_stasis_door(gentity_t *ent);
void SP_func_borg_elevator(gentity_t *ent);
void SP_trigger_always (gentity_t *ent);
void SP_trigger_multiple (gentity_t *ent);
@ -324,6 +325,7 @@ spawn_t spawns[] = {
{"func_lightchange", SP_func_lightchange},
{"func_targetmover", SP_func_targetmover},
{"func_stasis_door", SP_func_stasis_door},
{"func_borg_elevator", SP_func_borg_elevator},
// Triggers are brush objects that cause an effect when contacted
// by a living player, usually involving firing targets.

View file

@ -1,16 +1,16 @@
//files that hold this stuff in game. Please update them as required:
//g_breakable.c - func_breakable, misc_model_breakable, misc_ammo_station, target_repair;
//g_cinamatic.c - cinematic_camera
//g_client.c - info_player_deathmatch, info_player_start, info_player_intermission
//g_forcefield2.c - func_forcefield2
//g_cinamatic.c - cinematic_camera;
//g_client.c - info_player_deathmatch, info_player_start, info_player_intermission;
//g_forcefield2.c - func_forcefield2;
//g_fx.c
//g_items.c - item_botroam
//g_items.c - item_botroam;
//g_misc.c
//g_mover.c
//g_roff.c
//g_roff.c - func_roff_mover;
//g_spawn.c - worldspawn;
//g_target.c
//g_team.c - team_CTF_redplayer, team_CTF_blueplayer, team_CTF_redspawn, team_CTF_bluespawn
//g_team.c - team_CTF_redplayer, team_CTF_blueplayer, team_CTF_redspawn, team_CTF_bluespawn;
//g_trigger.c - trigger_multiple, trigger_always, trigger_push, target_push, trigger_teleport, trigger_hurt, func_timer, trigger_transporter, trigger_radiation;
//g_turrets.c - misc_turret, misc_laser_arm;
//g_ui.c - ui_transporter, ui_holodeck;
@ -1577,10 +1577,17 @@ In the unlikely event that we do have an origin brush this is the code:
// RPG-X fx_*
/*QUAKED fx_spark (0 0 1) (-8 -8 -8) (8 8 8) STARTOFF
Emits sparks at the specified point in the specified direction
-----DESCRIPTION-----
Emits sparks at the specified point in the specified direction.
Can be toggled off by being used.
"target" - ( optional ) direction to aim the sparks in, otherwise, uses the angles set in the editor.
"wait(2000)" - interval between events (randomly twice as long)
-----SPAWNFLAGS-----
1: STARTOFF - Effect will be off at spawn.
-----KEYS-----
"targetname" - toggles on/off whenever used
"target" - ( optional ) direction to aim the sparks in, otherwise, uses the angles set in the editor.
"wait(2000)" - interval between events (randomly twice as long)
*/