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

Function WBFireBattery

Descent3/robotfire.cpp:125–301  ·  view source on GitHub ↗

Allows for multiple configurations of a single wb

Source from the content-addressed store, hash-verified

123
124// Allows for multiple configurations of a single wb
125void WBFireBattery(object *obj, otype_wb_info *static_wb, int poly_wb_index, int dynamic_wb_index,
126 float damage_scalar) {
127 int cur_m_bit;
128 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
129 vector ave_pos;
130 int num_fired = 0;
131 vm_MakeZero(&ave_pos);
132 pos_state cur_pos;
133 dynamic_wb_info *p_dwb = &obj->dynamic_wb[dynamic_wb_index];
134 int weapon_obj;
135 int must_send = 0;
136 int first = 1;
137 int saved_weapon_id = 0;
138
139 uint8_t fire_mask;
140
141 if (p_dwb->flags & DWBF_QUAD)
142 fire_mask = static_wb->gp_quad_fire_mask;
143 else
144 fire_mask = static_wb->gp_fire_masks[p_dwb->cur_firing_mask];
145
146 for (cur_m_bit = 0; cur_m_bit < pm->poly_wb[poly_wb_index].num_gps; cur_m_bit++) {
147 if (fire_mask & (0x01 << cur_m_bit)) {
148 saved_weapon_id = static_wb->gp_weapon_index[cur_m_bit];
149 weapon_obj = FireWeaponFromObject(
150 obj, static_wb->gp_weapon_index[cur_m_bit], pm->poly_wb[poly_wb_index].gp_index[cur_m_bit],
151 (static_wb->flags & WBF_FIRE_FVEC) != 0, (static_wb->flags & WBF_FIRE_TARGET) != 0);
152
153 if (first) {
154 first = 0;
155 if (obj->type == OBJ_PLAYER && obj->id == Player_num &&
156 Weapons[static_wb->gp_weapon_index[cur_m_bit]].recoil_force > 0) {
157 vector force_vec = obj->orient.fvec * -Weapons[static_wb->gp_weapon_index[cur_m_bit]].recoil_force;
158 phys_apply_force(obj, &force_vec);
159 }
160 }
161
162 if (weapon_obj >= 0) {
163 ave_pos += Objects[weapon_obj].pos;
164 Objects[weapon_obj].ctype.laser_info.multiplier = damage_scalar;
165 num_fired++;
166
167 // If this is a permissable game, accelerate this object for one frame by the client ping time
168 if ((Game_mode & GM_MULTI) && Netgame.local_role == LR_CLIENT && (Netgame.flags & NF_PERMISSABLE))
169 Objects[weapon_obj].flags |= OF_PING_ACCELERATE;
170
171 if (Weapons[Objects[weapon_obj].id].flags & WF_COUNTERMEASURE)
172 must_send = 1;
173 }
174 }
175 }
176
177 if (num_fired) {
178 ave_pos /= num_fired;
179
180 cur_pos.roomnum = obj->roomnum;
181 cur_pos.position = &ave_pos;
182 cur_pos.orient = &obj->orient; // chrishack -- incorrect for directional sounds

Callers 10

MultiDoFirePlayerWBFunction · 0.85
MultiDoPermissionToFireFunction · 0.85
do_ranged_attackFunction · 0.85
ai_fireFunction · 0.85
AIDoFrameFunction · 0.85
FireOnOffWeaponFunction · 0.85
WBSetupFireAnimFunction · 0.85
WBFireAnimFrameFunction · 0.85
FireWeaponFromPlayerFunction · 0.85
FireFlareFromPlayerFunction · 0.85

Calls 13

vm_MakeZeroFunction · 0.85
FireWeaponFromObjectFunction · 0.85
phys_apply_forceFunction · 0.85
MultiSendRobotFireSoundFunction · 0.85
DemoWrite3DSoundFunction · 0.85
AINotifyFunction · 0.85
ReleaseGuidedMissileFunction · 0.85
CreateSmallViewFunction · 0.85
MultiSendFirePlayerWBFunction · 0.85
ps_randFunction · 0.85
ObjGetFunction · 0.85

Tested by

no test coverage detected