diff --git a/source/a_team.c b/source/a_team.c index b5d03c50d..19268bb78 100644 --- a/source/a_team.c +++ b/source/a_team.c @@ -749,7 +749,7 @@ void SelectKit3(edict_t *ent, pmenu_t *p) // newrand returns n, where 0 >= n < top int newrand (int top) { - return (int) (random () * top); + return rand() % top; } void SelectRandomWeapon(edict_t *ent, pmenu_t *p) @@ -1888,8 +1888,12 @@ void CleanLevel () } CleanBodies(); - // fix glass - CGF_SFX_RebuildAllBrokenGlass (); + // fix glass, objects and walls + if (breakableglass->value){ + CGF_SFX_RebuildAllBrokenGlass (); + //ResetWalls(); + //ResetObjects(); + } } void MakeAllLivePlayersObservers(void); diff --git a/source/a_xgame.h b/source/a_xgame.h index 0407808b4..62b5ccf47 100644 --- a/source/a_xgame.h +++ b/source/a_xgame.h @@ -59,4 +59,7 @@ void ParseSayText(edict_t *ent, char *text, size_t size); void Cmd_SetFlag1_f(edict_t *self); void Cmd_SetFlag2_f(edict_t *self); -void Cmd_SaveFlags_f(edict_t *self); \ No newline at end of file +void Cmd_SaveFlags_f(edict_t *self); + +// void ResetWalls(void); +// void ResetObjects(void); diff --git a/source/cgf_sfx_glass.c b/source/cgf_sfx_glass.c index ae56dc885..56684d6d1 100644 --- a/source/cgf_sfx_glass.c +++ b/source/cgf_sfx_glass.c @@ -44,6 +44,9 @@ extern "C" #include "cgf_sfx_glass.h" #endif +// Set as global externs, so they can be used in other files +// // cvar for breaking glass +// static cvar_t *breakableglass; // Set as global externs, so they can be used in other files // // cvar for breaking glass @@ -258,6 +261,7 @@ CGF_SFX_ShootBreakableGlass (edict_t * aGlassPane, edict_t * anAttacker, int destruct; // depending on mod, destroy window or emit fragments + // Updated in 2024 to include all weapons switch (mod) { // break for ap, shotgun, handcannon, and kick, destory window diff --git a/source/g_misc.c b/source/g_misc.c index 0acf85fcf..9b5971c6c 100644 --- a/source/g_misc.c +++ b/source/g_misc.c @@ -637,6 +637,27 @@ SP_func_wall (edict_t * self) gi.linkentity (self); } +// /* +// Reset walls in the map +// */ +// void ResetWalls(void) +// { +// // iterate over all funcs +// edict_t *wall; +// wall = 0; + +// // Iterate over func_wall objects +// while ((wall = G_Find (wall, FOFS (classname), "func_wall")) != NULL) { +// // Reset wall properties +// wall->solid = SOLID_BSP; +// wall->svflags &= ~SVF_NOCLIENT; +// wall->use = func_wall_use; + +// // Link the wall entity to the game world +// gi.dprintf("Wall restored: %s\n", wall->model); +// //ED_CallSpawn(wall); +// } +// } /*QUAKED func_object (0 .5 .8) ? TRIGGER_SPAWN ANIMATED ANIMATED_FAST This is solid bmodel that will fall if it's support it removed. @@ -710,10 +731,67 @@ SP_func_object (edict_t * self) self->s.effects |= EF_ANIM_ALLFAST; self->clipmask = MASK_MONSTERSOLID; - gi.linkentity (self); } +// void RecreateObjects(void) +// { +// edict_t *object; +// object = 0; + +// // Iterate over func_object objects +// while ((object = G_Find (object, FOFS (classname), "func_object")) != NULL) { +// // Reset object properties + +// // Print all object properties to gi.dprintf +// gi.dprintf("Recreate: Object Properties: classname: %s, model: %s, solid: %d, movetype: %d, spawnflags: %d, dmg: %d, svflags: %d, clipmask: %d, effects: %d\n", object->classname, object->model, object->solid, object->movetype, object->spawnflags, object->dmg, object->svflags, object->clipmask, object->s.effects); + +// gi.dprintf("Recreate: I ran for %s!\n", object->model); +// object->solid = SOLID_NOT; +// object->svflags &= ~SVF_NOCLIENT; +// object->use = func_object_use; +// gi.linkentity(object); + +// } +// } + +/* +Reset objects in the map +*/ +// void ResetObjects(void) +// { +// edict_t *object, *tempobject; +// object = 0; + +// // Iterate over func_object objects +// while ((object = G_Find (object, FOFS (classname), "func_object")) != NULL) { +// memcpy(&tempobject, &object, sizeof(object)); +// // Reset object properties + +// // Print all object properties to gi.dprintf +// //gi.dprintf("Reset: Object Properties: classname: %s, model: %s, solid: %d, movetype: %d, spawnflags: %d, dmg: %d, svflags: %d, clipmask: %d, effects: %d\n", object->classname, object->model, object->solid, object->movetype, object->spawnflags, object->dmg, object->svflags, object->clipmask, object->s.effects); + +// // Detect if object moved (destructible environment) +// if (object->movetype == MOVETYPE_TOSS) { +// // Make object disappear +// gi.dprintf("Reset: I ran for %s!\n", object->model); +// object->movetype = MOVETYPE_PUSH; +// object->solid = SOLID_NOT; +// object->svflags &= ~SVF_NOCLIENT; +// object->use = func_object_use; +// } +// // Copy back its original properties +// memcpy(&object, &tempobject, sizeof(object)); +// // gi.dprintf("Reset: NEWobj Properties: classname: %s, model: %s, solid: %d, movetype: %d, spawnflags: %d, dmg: %d, svflags: %d, clipmask: %d, effects: %d\n", object->classname, object->model, object->solid, object->movetype, object->spawnflags, object->dmg, object->svflags, object->clipmask, object->s.effects); +// // if (object == tempobject) { +// // gi.dprintf("Reset: Objects are the same\n"); +// // } else { +// // gi.dprintf("Reset: Objects are different\n"); +// // } +// ED_CallSpawn(object); +// } +// } + /*QUAKED func_explosive (0 .5 .8) ? Trigger_Spawn ANIMATED ANIMATED_FAST Any brush that you want to explode or break apart. If you want an diff --git a/source/g_save.c b/source/g_save.c index 3cc0de9a7..0583b19ab 100644 --- a/source/g_save.c +++ b/source/g_save.c @@ -530,9 +530,8 @@ void InitGame( void ) //CGF_SFX_InstallGlassSupport(); // william for CGF (glass fx) // Breakable glass support breakableglass = gi.cvar("breakableglass", "0", 0); - glassfragmentlimit = gi.cvar("glassfragmentlimit", "30", 0); - //CGF_SFX_InstallGlassSupport(); // william for CGF (glass fx) - + glassfragmentlimit = gi.cvar("glassfragmentlimit", "30", 0); + g_select_empty = gi.cvar( "g_select_empty", "0", CVAR_ARCHIVE ); run_pitch = gi.cvar( "run_pitch", "0.002", 0 ); diff --git a/source/g_spawn.c b/source/g_spawn.c index 421f1f2c8..c56e81ed4 100644 --- a/source/g_spawn.c +++ b/source/g_spawn.c @@ -406,9 +406,9 @@ void ED_CallSpawn (edict_t * ent) } } - /*if(strcmp (ent->classname, "freed") != 0) { - gi.dprintf ("%s doesn't have a spawn function\n", ent->classname); - }*/ + // if(strcmp (ent->classname, "freed") != 0) { + // gi.dprintf ("%s doesn't have a spawn function\n", ent->classname); + // } G_FreeEdict( ent ); }