From 0d5f00a159e0bedc5f9a451a592aa458319c90b1 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Thu, 18 Sep 2003 00:05:06 +0000 Subject: [PATCH] Lens flares. Opendoor trigger_multiple fixes --- reaction/game/g_misc.c | 70 ++++++++++++++++++++++++++++++++++++--- reaction/game/g_mover.c | 5 ++- reaction/game/g_spawn.c | 5 +++ reaction/game/g_target.c | 28 +++++++++++----- reaction/game/g_trigger.c | 37 +++++++++++++++------ reaction/game/game.plg | 16 ++++----- 6 files changed, 129 insertions(+), 32 deletions(-) diff --git a/reaction/game/g_misc.c b/reaction/game/g_misc.c index fbb0f60d..a260a668 100644 --- a/reaction/game/g_misc.c +++ b/reaction/game/g_misc.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.78 2003/09/18 00:05:05 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.77 2003/09/10 22:46:05 makro // Cooler breath puffs. Locked r_fastSky on maps with global fog. // Some other things I can't remember. @@ -415,6 +418,68 @@ void G_RunDlight(gentity_t * ent) */ +/*QUAKED misc_lens_flare (0 1 0) (-8 -8 -8) (8 8 8) ? +*/ + +void Think_Flare_Target(gentity_t *ent) +{ + char info[MAX_INFO_STRING]={0}; + vec3_t dir; + + ent->think = 0; + ent->nextthink = 0; + if (ent->target) { + ent->target_ent = G_PickTarget(ent->target); + if (!ent->target_ent) { + G_Printf(S_COLOR_YELLOW"Warning: misc_lens_flare with bad target at %s\n", vtos(ent->s.origin)); + } else { + VectorSubtract(ent->s.origin, ent->target_ent->s.origin, dir); + } + } else { + VectorCopy(ent->s.origin2, dir); + } + trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info)); + VectorNormalize(dir); + + Info_SetValueForKey(info, "ln", va("%d", ent->count)); + Info_SetValueForKey(info, "lx", va("%f", dir[0])); + Info_SetValueForKey(info, "ly", va("%f", dir[1])); + Info_SetValueForKey(info, "lz", va("%f", dir[2])); + Info_SetValueForKey(info, "lamin", va("%f", ent->health/1000.0f)); + Info_SetValueForKey(info, "lamax", va("%f", ent->health_saved/1000.0f)); + Info_SetValueForKey(info, "lsmin", va("%d", ent->damage)); + Info_SetValueForKey(info, "lsmax", va("%d", ent->damage_radius)); + trap_SetConfigstring(CS_SKYPORTAL, info); + + G_FreeEntity(ent, __LINE__, __FILE__); +} + +void SP_misc_lens_flare(gentity_t *ent) +{ + float f; + if (ent->count <= 0) { + G_Printf(S_COLOR_YELLOW"Warning: misc_lens_flare with count <=0 at %s\n", vtos(ent->s.origin)); + ent->count = 4; + } + G_SpawnInt("minsize", "16", &ent->damage); + G_SpawnInt("maxsize", "128", &ent->damage_radius); + + G_SpawnFloat("alphamin", "0.5", &f); + ent->health = f * 1000; + + G_SpawnFloat("alphamax", "1", &f); + ent->health_saved = f * 1000; + + if (!ent->target) { + if (!G_SpawnVector("direction", "0 0 1", ent->s.origin2)) { + AngleVectors(ent->s.angles, ent->s.origin2, NULL, NULL); + } + } + + ent->think = Think_Flare_Target; + ent->nextthink = level.time + FRAMETIME; +} + /*QUAKED func_shadow (0 1 0) (-8 -8 -8) (8 8 8) ? */ @@ -644,7 +709,7 @@ void SP_misc_portal_camera(gentity_t * ent) //Makro - sky portals void Think_SetupSkyPortal(gentity_t *ent) { - char info[MAX_INFO_STRING]; + char info[MAX_INFO_STRING]={0}; trap_GetConfigstring(CS_SKYPORTAL, info, sizeof(info)); if (!info[0]) { @@ -653,7 +718,6 @@ void Think_SetupSkyPortal(gentity_t *ent) //G_Printf("^1 SKY PORTAL !!!\n"); if (skyportal) { - memset(info, 0, sizeof(info)); Info_SetValueForKey(info, "x", va("%f", skyportal->s.origin[0])); Info_SetValueForKey(info, "y", va("%f", skyportal->s.origin[1])); Info_SetValueForKey(info, "z", va("%f", skyportal->s.origin[2])); @@ -666,7 +730,6 @@ void Think_SetupSkyPortal(gentity_t *ent) //ent->r.svFlags |= SVF_BROADCAST; } else { G_Printf(S_COLOR_YELLOW "WARNING: misc_sky_portal entity with bad target at %s\n", vtos(ent->s.origin)); - trap_SetConfigstring(CS_SKYPORTAL, ""); G_FreeEntity(ent, __LINE__, __FILE__); } } else { @@ -676,7 +739,6 @@ void Think_SetupSkyPortal(gentity_t *ent) ent->r.ownerNum = atoi(Info_ValueForKey(info, "n")); } - ent->nextthink = 0; ent->think = 0; } diff --git a/reaction/game/g_mover.c b/reaction/game/g_mover.c index 56f3a52a..499395aa 100644 --- a/reaction/game/g_mover.c +++ b/reaction/game/g_mover.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.67 2003/09/18 00:05:05 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.66 2003/09/16 23:25:32 makro // trigger_multiple - new spawnflag, 3 new keys // @@ -1564,7 +1567,7 @@ void SP_func_door(gentity_t * ent) */ //Makro - added - G_SpawnInt("reach", "0", &ent->mass); + G_SpawnInt("reach", "100", &ent->mass); // default speed of 400 if (!ent->speed) diff --git a/reaction/game/g_spawn.c b/reaction/game/g_spawn.c index f09bea3f..d6f117e9 100644 --- a/reaction/game/g_spawn.c +++ b/reaction/game/g_spawn.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.49 2003/09/18 00:05:05 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.48 2003/09/10 22:46:05 makro // Cooler breath puffs. Locked r_fastSky on maps with global fog. // Some other things I can't remember. @@ -301,6 +304,7 @@ void SP_target_push(gentity_t * ent); void SP_light(gentity_t * self); void SP_dlight(gentity_t * self); // Elder: dlight entity +void SP_misc_lens_flare(gentity_t *ent); //Makro - lens flare void SP_func_shadow(gentity_t *ent); //Makro - fake shadow void SP_info_null(gentity_t * self); void SP_info_notnull(gentity_t * self); @@ -392,6 +396,7 @@ spawn_t spawns[] = { {"func_dlite", SP_dlight}, // Elder: dlight entity {"light_d", SP_dlight}, //Makro - for compatibility with older maps {"func_shadow", SP_func_shadow}, //Makro - fake shadow + {"misc_lens_flare", SP_misc_lens_flare}, //Makro - lens flare {"path_corner", SP_path_corner}, {"misc_teleporter_dest", SP_misc_teleporter_dest}, diff --git a/reaction/game/g_target.c b/reaction/game/g_target.c index b974a859..c5d2c6d6 100644 --- a/reaction/game/g_target.c +++ b/reaction/game/g_target.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.15 2003/09/18 00:05:06 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.14 2003/09/08 19:19:20 makro // New code for respawning entities in TP // @@ -216,19 +219,27 @@ Multiple identical looping sounds will just increase volume without any speed co "wait" : Seconds between auto triggerings, 0 = don't auto trigger "random" wait variance, default is 0 */ + +#define SF_TARGET_SPEAKER_LOOPEDON 1 +#define SF_TARGET_SPEAKER_LOOPEDOFF 2 +#define SF_TARGET_SPEAKER_GLOBAL 4 +#define SF_TARGET_SPEAKER_ACTIVATOR 8 +#define SF_TARGET_SPEAKER_NOPVS 16 + void reset_target_speaker(gentity_t *ent) { //looped on - if (ent->spawnflags & 1) + if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDON) ent->s.loopSound = ent->noise_index; //looped off - else if (ent->spawnflags & 2) + else if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDOFF) ent->s.loopSound = 0; } void Use_Target_Speaker(gentity_t * ent, gentity_t * other, gentity_t * activator) { - if (ent->spawnflags & 3) { // looping sound toggles + // looping sound toggles + if (ent->spawnflags & (SF_TARGET_SPEAKER_LOOPEDON | SF_TARGET_SPEAKER_LOOPEDOFF)) { //Makro - check the pathtarget of the triggering entity if (other->pathtarget) { if (!Q_stricmp(other->pathtarget, "on")) { @@ -244,9 +255,9 @@ void Use_Target_Speaker(gentity_t * ent, gentity_t * other, gentity_t * activato else ent->s.loopSound = ent->noise_index; // start it } else { // normal sound - if (ent->spawnflags & 8) { + if (ent->spawnflags & SF_TARGET_SPEAKER_ACTIVATOR) { G_AddEvent(activator, EV_GENERAL_SOUND, ent->noise_index); - } else if (ent->spawnflags & 4) { + } else if (ent->spawnflags & SF_TARGET_SPEAKER_GLOBAL) { G_AddEvent(ent, EV_GLOBAL_SOUND, ent->noise_index); } else { G_AddEvent(ent, EV_GENERAL_SOUND, ent->noise_index); @@ -284,20 +295,21 @@ void SP_target_speaker(gentity_t * ent) ent->s.frame = ent->wait * 10; ent->s.clientNum = ent->random * 10; //Makro - added - if ((ent->spawnflags & 3) && (ent->spawnflags & 16)) + if ((ent->spawnflags & (SF_TARGET_SPEAKER_LOOPEDON | SF_TARGET_SPEAKER_LOOPEDOFF)) + && (ent->spawnflags & SF_TARGET_SPEAKER_NOPVS)) ent->s.weapon = 1; else ent->s.weapon = 0; // check for prestarted looping sound - if (ent->spawnflags & 1) { + if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDON) { ent->s.loopSound = ent->noise_index; } ent->reset = reset_target_speaker; ent->use = Use_Target_Speaker; - if (ent->spawnflags & 4) { + if (ent->spawnflags & SF_TARGET_SPEAKER_GLOBAL) { ent->r.svFlags |= SVF_BROADCAST; } diff --git a/reaction/game/g_trigger.c b/reaction/game/g_trigger.c index 0ee876bc..99fd5fb1 100644 --- a/reaction/game/g_trigger.c +++ b/reaction/game/g_trigger.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.30 2003/09/18 00:05:06 makro +// Lens flares. Opendoor trigger_multiple fixes +// // Revision 1.29 2003/09/16 23:25:32 makro // trigger_multiple - new spawnflag, 3 new keys // @@ -123,17 +126,25 @@ void multi_trigger(gentity_t * ent, gentity_t * activator) if (ent->nextthink) { return; // can't retrigger until the wait is over } - //Makro - inactive trigger ? - if (ent->inactive) { - if (ent->soundInactive) - G_AddEvent(ent, EV_GENERAL_SOUND, ent->soundInactive); - if (ent->targetInactive) - G_UseEntities(ent, ent->targetInactive, activator); - return; - } - if (ent->spawnflags & SF_TRIGGER_MULTIPLE_DOOR) + if (ent->spawnflags & SF_TRIGGER_MULTIPLE_DOOR) { if (!activator || !activator->client || !activator->client->openDoor) return; + if (activator->client->openDoorTime <= ent->timestamp) + return; + ent->timestamp = activator->client->openDoorTime; + } + //Makro - inactive trigger ? + if (ent->inactive) { + //note - since the trigger is not sent to the clients, we cannot send the event + //either, so we'll just play the sound locally + if (ent->soundInactive) + G_AddEvent(ent->activator, EV_GENERAL_SOUND, ent->soundInactive); + if (ent->targetInactive) + G_UseEntities(ent->activator, ent->targetInactive, activator); + ent->think = multi_wait; + ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000; + return; + } //Makro - added check; Q3 crashed in archives when playing //with .dll's and shooting one of the barrels if (activator != NULL) { @@ -148,7 +159,7 @@ void multi_trigger(gentity_t * ent, gentity_t * activator) } if (ent->sound1to2) - G_AddEvent(ent, EV_GENERAL_SOUND, ent->sound1to2); + G_AddEvent(ent->activator, EV_GENERAL_SOUND, ent->sound1to2); G_UseTargets(ent, ent->activator); if (ent->wait > 0) { @@ -165,7 +176,10 @@ void multi_trigger(gentity_t * ent, gentity_t * activator) ent->nextthink = level.time + FRAMETIME; ent->think = G_RealFreeEntity; */ - ent->inactive = 1; + //On second thought, now that I've added those soundInactive/targetInactive keys + //I think just setting touch to 0 will do + //ent->inactive = 1; + ent->touch = 0; } } @@ -187,6 +201,7 @@ void Reset_Multi(gentity_t *ent) ent->inactive = ent->unbreakable; ent->think = 0; ent->nextthink = 0; + ent->touch = Touch_Multi; } void SP_trigger_multiple(gentity_t * ent) diff --git a/reaction/game/game.plg b/reaction/game/game.plg index 750a7ed2..6d76b4ab 100644 --- a/reaction/game/game.plg +++ b/reaction/game/game.plg @@ -6,13 +6,13 @@ --------------------Configuration: game - Win32 Release--------------------

Command Lines

-Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP53.tmp" with contents +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP322.tmp" with contents [ /nologo /G6 /ML /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR"c:\reactionoutput/" /Fp"c:\reactionoutput/game.pch" /YX /Fo"c:\reactionoutput/" /Fd"c:\reactionoutput/" /FD /c -"C:\Games\Quake3\rq3source\reaction\game\g_trigger.c" +"C:\Games\Quake3\rq3source\reaction\game\g_misc.c" ] -Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP53.tmp" -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP54.tmp" with contents +Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP322.tmp" +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP323.tmp" with contents [ kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows /dll /incremental:no /pdb:"c:\reactionoutput/qagamex86.pdb" /map:"c:\reactionoutput/qagamex86.map" /machine:I386 /def:".\game.def" /out:"..\Release/qagamex86.dll" /implib:"c:\reactionoutput/qagamex86.lib" \reactionoutput\ai_chat.obj @@ -56,13 +56,13 @@ kernel32.lib user32.lib winmm.lib /nologo /base:"0x20000000" /subsystem:windows \reactionoutput\zcam.obj \reactionoutput\zcam_target.obj ] -Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP54.tmp" +Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP323.tmp"

Output Window

Compiling... -g_trigger.c +g_misc.c Linking... Creating library c:\reactionoutput/qagamex86.lib and object c:\reactionoutput/qagamex86.exp -Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP58.tmp" with contents +Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP327.tmp" with contents [ /nologo /o"c:\reactionoutput/game.bsc" \reactionoutput\ai_chat.sbr @@ -105,7 +105,7 @@ Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP58.tmp" with conten \reactionoutput\rxn_game.sbr \reactionoutput\zcam.sbr \reactionoutput\zcam_target.sbr] -Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP58.tmp" +Creating command line "bscmake.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP327.tmp" Creating browse info file...

Output Window