MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoConcussiveForce

Function DoConcussiveForce

Descent3/fireball.cpp:1794–1944  ·  view source on GitHub ↗

object *object_create_explosion_sub(object *explode_obj_ptr, int16_t segnum, vms_vector * position, fix size, int vclip_type, fix maxdamage, fix maxdistance, fix maxforce, int parent )

Source from the content-addressed store, hash-verified

1792// object *object_create_explosion_sub(object *explode_obj_ptr, int16_t segnum, vms_vector * position, fix size, int
1793// vclip_type, fix maxdamage, fix maxdistance, fix maxforce, int parent )
1794void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_scalar) {
1795 int objnum;
1796 float max_player_damage = explode_obj_ptr->impact_player_damage;
1797 float max_generic_damage = explode_obj_ptr->impact_generic_damage;
1798 float maxforce = explode_obj_ptr->impact_force;
1799 float maxdistance = explode_obj_ptr->impact_size;
1800 float effect_distance;
1801 int16_t parent;
1802 object *parent_obj;
1803 if (explode_obj_ptr->type == OBJ_SHOCKWAVE) {
1804 effect_distance =
1805 explode_obj_ptr->impact_size * ((Gametime - explode_obj_ptr->creation_time) / explode_obj_ptr->impact_time);
1806 if (effect_distance > explode_obj_ptr->impact_size)
1807 effect_distance = explode_obj_ptr->impact_size;
1808 } else {
1809 effect_distance = explode_obj_ptr->impact_size;
1810 }
1811 parent_obj = ObjGet(parent_handle);
1812 if (parent_obj != NULL)
1813 parent = OBJNUM(parent_obj);
1814 objnum = OBJNUM(explode_obj_ptr);
1815 if (explode_obj_ptr->impact_size <= 0.0)
1816 return;
1817 {
1818 float dist, force;
1819 vector vforce;
1820 float damage;
1821 int i;
1822 object *hit_obj_ptr;
1823
1824 for (i = 0; i <= Highest_object_index; i++) {
1825 // Weapons used to be affected by badass explosions, but this introduces serious problems.
1826 // When a smart bomb blows up, if one of its children goes right towards a nearby wall, it will
1827 // blow up, blowing up all the children. So I remove it. MK, 09/11/94
1828 // if ( (hit_obj_ptr!=explode_obj_ptr) && !(hit_obj_ptr->flags&OF_DEAD) &&
1829 //((hit_obj_ptr->type==OBJ_WEAPON /*&& (hit_obj_ptr->id==PROXIMITY_ID || hit_obj_ptr->id==SUPERPROX_ID ||
1830 // hit_obj_ptr->id==PMINE_ID)*/) || (hit_obj_ptr->type == OBJ_CNTRLCEN) || (hit_obj_ptr->type==OBJ_PLAYER) ||
1831 //((hit_obj_ptr->type==OBJ_ROBOT) && ((Objects[parent].type != OBJ_ROBOT) || (Objects[parent].id !=
1832 // hit_obj_ptr->id))))) {
1833 hit_obj_ptr = &Objects[i];
1834 // Check for types that get concussive force
1835 if (!((hit_obj_ptr->type == OBJ_WEAPON) || (hit_obj_ptr->type == OBJ_ROBOT) ||
1836 (hit_obj_ptr->type == OBJ_BUILDING) || (hit_obj_ptr->type == OBJ_PLAYER) ||
1837 (hit_obj_ptr->type == OBJ_DOOR) || (hit_obj_ptr->type == OBJ_CLUTTER)))
1838 continue;
1839 if ((hit_obj_ptr != explode_obj_ptr) && !(hit_obj_ptr->flags & OF_DEAD)) {
1840 if (hit_obj_ptr->movement_type == MT_PHYSICS || hit_obj_ptr->movement_type == MT_WALKING) {
1841 if (hit_obj_ptr->mtype.phys_info.flags & PF_IGNORE_CONCUSSIVE_FORCES)
1842 continue;
1843 }
1844 if (hit_obj_ptr->movement_type == MT_PHYSICS || hit_obj_ptr->movement_type == MT_WALKING) {
1845 if ((hit_obj_ptr->mtype.phys_info.flags & PF_IGNORE_OWN_CONC_FORCES) &&
1846 ObjGetUltimateParent(hit_obj_ptr) == ObjGetUltimateParent(explode_obj_ptr))
1847 continue;
1848 }
1849 // The distance is actually the objects' centers minus some of the hit object's radius (I set it to 80%)
1850 if ((hit_obj_ptr->flags & OF_POLYGON_OBJECT) && hit_obj_ptr->type != OBJ_WEAPON &&
1851 hit_obj_ptr->type != OBJ_POWERUP && hit_obj_ptr->type != OBJ_DEBRIS) {

Callers 5

DoExplosionFrameFunction · 0.85
MakeShockwaveFunction · 0.85
TimeoutObjectFunction · 0.85
ObjDoFrameFunction · 0.85
PlayerShipExplodeFunction · 0.85

Calls 12

ObjGetFunction · 0.85
ObjGetUltimateParentFunction · 0.85
BOA_IsVisibleFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85
fvi_FindIntersectionFunction · 0.85
phys_apply_forceFunction · 0.85
ApplyDamageToPlayerFunction · 0.85
vm_NormalizeVectorFunction · 0.85
StartCockpitShakeFunction · 0.85
ApplyDamageToGenericFunction · 0.85
vm_VectorDistanceQuickFunction · 0.50
vm_GetNormalizedDirFastFunction · 0.50

Tested by

no test coverage detected