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

Function FireOnOffWeapon

Descent3/robotfire.cpp:42–63  ·  view source on GitHub ↗

Fires a multiplayer and AI on/off weapon

Source from the content-addressed store, hash-verified

40#include "psrand.h"
41// Fires a multiplayer and AI on/off weapon
42void FireOnOffWeapon(object *objp) {
43 if (objp->type == OBJ_PLAYER) {
44 int slot = objp->id;
45
46 int ship_index = Players[slot].ship_index;
47 int wb_index = Players[slot].weapon[PW_PRIMARY].index;
48
49 if (WBIsBatteryReady(objp, &Ships[ship_index].static_wb[wb_index], wb_index)) {
50 WBFireBattery(objp, &Ships[ship_index].static_wb[wb_index], 0, wb_index);
51 }
52 } else if (objp->ai_info) {
53 char wb_index = objp->ai_info->last_special_wb_firing;
54 if (wb_index > MAX_WBS_PER_OBJ) { // DAJ
55 mprintf(2, "FireOnOffWeapon wb_index %d > MAX_WBS_PER_OBJ\n", wb_index);
56 return;
57 }
58
59 if (WBIsBatteryReady(objp, &Object_info[objp->id].static_wb[wb_index], wb_index)) {
60 WBFireBattery(objp, &Object_info[objp->id].static_wb[wb_index], 0, wb_index);
61 }
62 }
63}
64
65void WBSetupFireAnim(object *obj, otype_wb_info *static_wb, int wb_index) {
66 dynamic_wb_info *p_dwb = &obj->dynamic_wb[wb_index];

Callers 2

AIDoFrameFunction · 0.85
DoPlayerFrameForOneFunction · 0.85

Calls 2

WBIsBatteryReadyFunction · 0.85
WBFireBatteryFunction · 0.85

Tested by

no test coverage detected