| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "robotfire.h"cxx . . $ `<file>/Descent3/robotfire.h`/ |
| 20 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 21 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 22 | |
| 23 | #include "config.h"cxx . . $ `<file>/Descent3/config.h`/ // for game toggles. |
| 24 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 25 | #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/ |
| 26 | #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/ |
| 27 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 28 | #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/ |
| 29 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 30 | #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/ |
| 31 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 32 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 33 | #include "demofile.h"cxx . . $ `<file>/lib/demofile.h`/ |
| 34 | #include "SmallViews.h"cxx . . $ `<file>/Descent3/SmallViews.h`/ |
| 35 | #include "physics.h"cxx . . $ `<file>/physics/physics.h`/ |
| 36 | #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/ |
| 37 | |
| 38 | #include <stdlib.h> |
| 39 | |
| 40 | #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/ |
| 41 | // Fires a multiplayer and AI on/off weapon |
| 42 | void FireOnOffWeaponcxx . . $ FireOnOffWeapon(419c470199a90a97).(objectcxx . . $ object# *objp) { |
| 43 | if (objp->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 44 | int slot = objp->idcxx . . $ object#id.; |
| 45 | |
| 46 | int ship_index = Playerscxx . . $ Players.[slot].ship_indexcxx . . $ player#ship_index.; |
| 47 | int wb_index = Playerscxx . . $ Players.[slot].weaponcxx . . $ player#weapon.[PW_PRIMARYcxx . . $ `Descent3/player_external.h:108:9`!].indexcxx . . $ player_weapon#index.; |
| 48 | |
| 49 | if (WBIsBatteryReadycxx . . $ WBIsBatteryReady(ad7a19887510094c).(objp, &Shipscxx . . $ Ships.[ship_index].static_wbcxx . . $ ship#static_wb.[wb_index], wb_index)) { |
| 50 | WBFireBatterycxx . . $ WBFireBattery(721350389efbb479).(objp, &Shipscxx . . $ Ships.[ship_index].static_wbcxx . . $ ship#static_wb.[wb_index], 0, wb_index); |
| 51 | } |
| 52 | } else if (objp->ai_infocxx . . $ object#ai_info.) { |
| 53 | char wb_index = objp->ai_infocxx . . $ object#ai_info.->last_special_wb_firingcxx . . $ ai_frame#last_special_wb_firing.; |
| 54 | if (wb_index > MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!) { // DAJ |
| 55 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(2, "FireOnOffWeapon wb_index %d > MAX_WBS_PER_OBJ\n", wb_index); |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | if (WBIsBatteryReadycxx . . $ WBIsBatteryReady(ad7a19887510094c).(objp, &Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].static_wbcxx . . $ object_info#static_wb.[wb_index], wb_index)) { |
| 60 | WBFireBatterycxx . . $ WBFireBattery(721350389efbb479).(objp, &Object_infocxx . . $ Object_info.[objp->idcxx . . $ object#id.].static_wbcxx . . $ object_info#static_wb.[wb_index], 0, wb_index); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void WBSetupFireAnimcxx . . $ WBSetupFireAnim(cccf09a4825b46a4).(objectcxx . . $ object# *obj, otype_wb_infocxx . . $ otype_wb_info# *static_wb, int wb_index) { |
| 66 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &obj->dynamic_wbcxx . . $ object#dynamic_wb.[wb_index]; |
| 67 | |
| 68 | p_dwb->wb_anim_maskcxx . . $ dynamic_wb_info#wb_anim_mask. = p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.; |
| 69 | |
| 70 | if (static_wb->anim_start_framecxx . . $ otype_wb_info#anim_start_frame. != static_wb->anim_end_framecxx . . $ otype_wb_info#anim_end_frame.) { |
| 71 | p_dwb->flagscxx . . $ dynamic_wb_info#flags. |= DWBF_ANIMATINGcxx . . $ `lib/robotfirestruct_external.h:45:9`!; |
| 72 | p_dwb->wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. = static_wb->anim_start_framecxx . . $ otype_wb_info#anim_start_frame.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.]; |
| 73 | } |
| 74 | |
| 75 | if (static_wb->anim_start_framecxx . . $ otype_wb_info#anim_start_frame.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.] == static_wb->anim_fire_framecxx . . $ otype_wb_info#anim_fire_frame.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.]) { |
| 76 | WBFireBatterycxx . . $ WBFireBattery(cccf09a4825b46a4).(obj, static_wb, wb_index); |
| 77 | p_dwb->flagscxx . . $ dynamic_wb_info#flags. |= DWBF_ANIM_FIREDcxx . . $ `lib/robotfirestruct_external.h:46:9`!; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | void WBFireAnimFramecxx . . $ WBFireAnimFrame(cccf09a4825b46a4).(objectcxx . . $ object# *obj, otype_wb_infocxx . . $ otype_wb_info# *static_wb, int wb_index) { |
| 82 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &obj->dynamic_wbcxx . . $ object#dynamic_wb.[wb_index]; |
| 83 | const int cur_mask = p_dwb->wb_anim_maskcxx . . $ dynamic_wb_info#wb_anim_mask.; |
| 84 | |
| 85 | p_dwb->wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. += Frametimecxx . . $ Frametime. * ((static_wb->anim_end_framecxx . . $ otype_wb_info#anim_end_frame.[cur_mask] - static_wb->anim_start_framecxx . . $ otype_wb_info#anim_start_frame.[cur_mask]) / |
| 86 | static_wb->anim_timecxx . . $ otype_wb_info#anim_time.[cur_mask]); |
| 87 | |
| 88 | if ((p_dwb->flagscxx . . $ dynamic_wb_info#flags. & DWBF_ANIM_FIREDcxx . . $ `lib/robotfirestruct_external.h:46:9`!) == 0) { |
| 89 | if (p_dwb->wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. >= static_wb->anim_fire_framecxx . . $ otype_wb_info#anim_fire_frame.[cur_mask]) { |
| 90 | WBFireBatterycxx . . $ WBFireBattery(cccf09a4825b46a4).(obj, static_wb, wb_index); |
| 91 | p_dwb->flagscxx . . $ dynamic_wb_info#flags. |= DWBF_ANIM_FIREDcxx . . $ `lib/robotfirestruct_external.h:46:9`!; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if (p_dwb->wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. >= static_wb->anim_end_framecxx . . $ otype_wb_info#anim_end_frame.[cur_mask]) { |
| 96 | p_dwb->wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. = 0.0; |
| 97 | p_dwb->flagscxx . . $ dynamic_wb_info#flags. &= ~(DWBF_ANIM_FIREDcxx . . $ `lib/robotfirestruct_external.h:46:9`! | DWBF_ANIMATINGcxx . . $ `lib/robotfirestruct_external.h:45:9`!); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | bool WBIsBatteryReadycxx . . $ WBIsBatteryReady(ad7a19887510094c).(objectcxx . . $ object# *obj, otype_wb_infocxx . . $ otype_wb_info# *static_wb, int wb_index) { |
| 102 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &obj->dynamic_wbcxx . . $ object#dynamic_wb.[wb_index]; |
| 103 | float scalar = 1.0; |
| 104 | float quad_time = 0.0f; |
| 105 | |
| 106 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) |
| 107 | scalar = Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].weapon_recharge_scalarcxx . . $ player#weapon_recharge_scalar.; |
| 108 | |
| 109 | if (p_dwb->flagscxx . . $ dynamic_wb_info#flags. & DWBF_QUADcxx . . $ `lib/robotfirestruct_external.h:47:9`!) { |
| 110 | // Add 25% on the firing time of quaded weapons |
| 111 | quad_time = static_wb->gp_fire_waitcxx . . $ otype_wb_info#gp_fire_wait.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.] * 0.25f; |
| 112 | } |
| 113 | |
| 114 | if (!(p_dwb->flagscxx . . $ dynamic_wb_info#flags. & DWBF_ANIMATINGcxx . . $ `lib/robotfirestruct_external.h:45:9`!) && |
| 115 | (p_dwb->last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. + (static_wb->gp_fire_waitcxx . . $ otype_wb_info#gp_fire_wait.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.] * scalar) + quad_time) < Gametimecxx . . $ Gametime.) { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 123 | |
| 124 | // Allows for multiple configurations of a single wb |
| 125 | void WBFireBatterycxx . . $ WBFireBattery(721350389efbb479).(objectcxx . . $ object# *obj, otype_wb_infocxx . . $ otype_wb_info# *static_wb, int poly_wb_index, int dynamic_wb_index, |
| 126 | float damage_scalar) { |
| 127 | int cur_m_bit; |
| 128 | poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.]; |
| 129 | vectorcxx . . $ vector# ave_pos; |
| 130 | int num_fired = 0; |
| 131 | vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&ave_pos); |
| 132 | pos_statecxx . . $ pos_state# cur_pos; |
| 133 | dynamic_wb_infocxx . . $ dynamic_wb_info# *p_dwb = &obj->dynamic_wbcxx . . $ object#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_tcxx . . $ uint8_t# fire_mask; |
| 140 | |
| 141 | if (p_dwb->flagscxx . . $ dynamic_wb_info#flags. & DWBF_QUADcxx . . $ `lib/robotfirestruct_external.h:47:9`!) |
| 142 | fire_mask = static_wb->gp_quad_fire_maskcxx . . $ otype_wb_info#gp_quad_fire_mask.; |
| 143 | else |
| 144 | fire_mask = static_wb->gp_fire_maskscxx . . $ otype_wb_info#gp_fire_masks.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.]; |
| 145 | |
| 146 | for (cur_m_bit = 0; cur_m_bit < pm->poly_wbcxx . . $ poly_model#poly_wb.[poly_wb_index].num_gpscxx . . $ poly_wb_info#num_gps.; cur_m_bit++) { |
| 147 | if (fire_mask & (0x01 << cur_m_bit)) { |
| 148 | saved_weapon_id = static_wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit]; |
| 149 | weapon_obj = FireWeaponFromObjectcxx . . $ FireWeaponFromObject(3c611958fe04e279).( |
| 150 | obj, static_wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit], pm->poly_wbcxx . . $ poly_model#poly_wb.[poly_wb_index].gp_indexcxx . . $ poly_wb_info#gp_index.[cur_m_bit], |
| 151 | (static_wb->flagscxx . . $ otype_wb_info#flags. & WBF_FIRE_FVECcxx . . $ `lib/robotfirestruct_external.h:37:9`!) != 0, (static_wb->flagscxx . . $ otype_wb_info#flags. & WBF_FIRE_TARGETcxx . . $ `lib/robotfirestruct_external.h:39:9`!) != 0); |
| 152 | |
| 153 | if (first) { |
| 154 | first = 0; |
| 155 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num. && |
| 156 | Weaponscxx . . $ Weapons.[static_wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit]].recoil_forcecxx . . $ weapon#recoil_force. > 0) { |
| 157 | vectorcxx . . $ vector# force_vec = obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(252247219a31502c). -Weaponscxx . . $ Weapons.[static_wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit]].recoil_forcecxx . . $ weapon#recoil_force.; |
| 158 | phys_apply_forcecxx . . $ phys_apply_force(1d7af1ec00c1f7ea).(obj, &force_vec); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (weapon_obj >= 0) { |
| 163 | ave_pos +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). Objectscxx . . $ Objects.[weapon_obj].poscxx . . $ object#pos.; |
| 164 | Objectscxx . . $ Objects.[weapon_obj].ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..multipliercxx . . $ laser_info_s#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_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`! && (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!)) |
| 169 | Objectscxx . . $ Objects.[weapon_obj].flagscxx . . $ object#flags. |= OF_PING_ACCELERATEcxx . . $ `Descent3/object_external.h:292:9`!; |
| 170 | |
| 171 | if (Weaponscxx . . $ Weapons.[Objectscxx . . $ Objects.[weapon_obj].idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_COUNTERMEASUREcxx . . $ `Descent3/weapon.h:241:9`!) |
| 172 | must_send = 1; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (num_fired) { |
| 178 | ave_pos /=cxx . . $ `operator/=`(f132838b2cd11d6). num_fired; |
| 179 | |
| 180 | cur_pos.roomnumcxx . . $ pos_state#roomnum. = obj->roomnumcxx . . $ object#roomnum.; |
| 181 | cur_pos.positioncxx . . $ pos_state#position. = &ave_pos; |
| 182 | cur_pos.orientcxx . . $ pos_state#orient. = &obj->orientcxx . . $ object#orient.; // chrishack -- incorrect for directional sounds |
| 183 | // chrishack -- actually we only need an fvec (direction of fire -- NOT OBJECT) |
| 184 | |
| 185 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) { |
| 186 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 187 | if (obj->control_typecxx . . $ object#control_type. == CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) { |
| 188 | // Stuff the sound |
| 189 | MultiSendRobotFireSoundcxx . . $ MultiSendRobotFireSound(10c3cfb854788893).(static_wb->fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.], OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj)); |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | if (Demo_flagscxx . . $ Demo_flags. == DF_RECORDINGcxx . . $ `lib/demofile.h:122:9`!) { |
| 194 | DemoWrite3DSoundcxx . . $ DemoWrite3DSound(c29d531f7e56abb1).(static_wb->fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.], OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj), SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!); |
| 195 | } |
| 196 | if (obj == Viewer_objectcxx . . $ Viewer_object.) |
| 197 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(cbd2c6aa1db9fc8a).(static_wb->fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.], SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!, &cur_pos, |
| 198 | MAX_GAME_VOLUMEcxx . . $ `sndlib/ssl_lib.h:265:9`!, SIF_NO_3D_EFFECTScxx . . $ `sndlib/ssl_lib.h:382:9`!); |
| 199 | else |
| 200 | Sound_systemcxx . . $ Sound_system..Play3dSoundcxx . . $ hlsSystem#Play3dSound(cbd2c6aa1db9fc8a).(static_wb->fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.], SND_PRIORITY_HIGHESTcxx . . $ `sndlib/ssl_lib.h:282:9`!, &cur_pos); |
| 201 | |
| 202 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 203 | ain_hearcxx . . $ ain_hear# hear; |
| 204 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 205 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 1.0f; |
| 206 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.0f; |
| 207 | hear.max_distcxx . . $ ain_hear#max_dist. = Soundscxx . . $ Sounds.[static_wb->fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.]].max_distancecxx . . $ sound_info#max_distance.; |
| 208 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(obj, AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | if ((static_wb->flagscxx . . $ otype_wb_info#flags. & WBF_GUIDEDcxx . . $ `lib/robotfirestruct_external.h:32:9`!) && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 213 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_fired <= 1); // Only one guided can be fired at a time |
| 214 | if (num_fired > 0) { |
| 215 | if (Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].guided_objcxx . . $ player#guided_obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) // if there already is a guided, release it |
| 216 | { |
| 217 | ReleaseGuidedMissilecxx . . $ ReleaseGuidedMissile(d4f767463ce0a6b3).(obj->idcxx . . $ object#id.); |
| 218 | } |
| 219 | |
| 220 | Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].guided_objcxx . . $ player#guided_obj. = &Objectscxx . . $ Objects.[weapon_obj]; |
| 221 | Objectscxx . . $ Objects.[weapon_obj].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. |= (PF_HOMINGcxx . . $ `Descent3/object_external.h:334:9`! | PF_GUIDEDcxx . . $ `Descent3/object_external.h:335:9`!); |
| 222 | |
| 223 | // draw guided view in small window |
| 224 | if (!Game_togglescxx . . $ Game_toggles..guided_mainviewcxx . . $ tGameToggles#guided_mainview. && obj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num.) { |
| 225 | int window = (Missile_camera_windowcxx . . $ Missile_camera_window. < 0) ? SVW_LEFTcxx . . $ `Descent3/SmallViews.h:72:9`! : Missile_camera_windowcxx . . $ Missile_camera_window.; |
| 226 | CreateSmallViewcxx . . $ CreateSmallView(114097c446ee1c3e).(window, Objectscxx . . $ Objects.[weapon_obj].handlecxx . . $ object#handle., SVF_POPUPcxx . . $ `Descent3/SmallViews.h:77:9`! + SVF_BIGGERcxx . . $ `Descent3/SmallViews.h:78:9`! + SVF_CROSSHAIRScxx . . $ `Descent3/SmallViews.h:81:9`!, 0.0, |
| 227 | D3_DEFAULT_ZOOMcxx . . $ `Descent3/descent.h:178:9`!, -1, TXT_HUD_GUIDEDcxx . . $ `Descent3/stringtable.h:578:9`!); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | if ((static_wb->flagscxx . . $ otype_wb_info#flags. & WBF_USER_TIMEOUTcxx . . $ `lib/robotfirestruct_external.h:36:9`!) && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 233 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_fired <= 1); // Only one guided can be fired at a time |
| 234 | if (num_fired > 0) { |
| 235 | if (Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].user_timeout_objcxx . . $ player#user_timeout_obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) // if there already is a guided, release it |
| 236 | { |
| 237 | ReleaseUserTimeoutMissilecxx . . $ ReleaseUserTimeoutMissile(d4f767463ce0a6b3).(obj->idcxx . . $ object#id.); |
| 238 | } |
| 239 | |
| 240 | Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].user_timeout_objcxx . . $ player#user_timeout_obj. = &Objectscxx . . $ Objects.[weapon_obj]; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | if (num_fired >= 1 && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num. && (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && |
| 245 | !(Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!)) { |
| 246 | shipcxx . . $ ship# *ship = &Shipscxx . . $ Ships.[Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].ship_indexcxx . . $ player#ship_index.]; |
| 247 | otype_wb_infocxx . . $ otype_wb_info# *wb = &ship->static_wbcxx . . $ ship#static_wb.[dynamic_wb_index]; |
| 248 | int on_off_weapon = (wb->flagscxx . . $ otype_wb_info#flags. & WBF_ON_OFFcxx . . $ `lib/robotfirestruct_external.h:34:9`!); |
| 249 | |
| 250 | if (!on_off_weapon) // Normal projectile weapon |
| 251 | { |
| 252 | MultiSendFirePlayerWBcxx . . $ MultiSendFirePlayerWB(1ddd52152094ffbc).(Player_numcxx . . $ Player_num., dynamic_wb_index, p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask., must_send, damage_scalar); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // Don't do any of this if its the local client and a permissable netgame |
| 257 | if (!((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num. && Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!)) { |
| 258 | p_dwb->last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. = Gametimecxx . . $ Gametime.; |
| 259 | |
| 260 | if (num_fired >= 1 && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) { |
| 261 | Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].last_fire_weapon_timecxx . . $ player#last_fire_weapon_time. = Gametimecxx . . $ Gametime.; |
| 262 | } |
| 263 | |
| 264 | if (static_wb->flagscxx . . $ otype_wb_info#flags. & WBF_RANDOM_FIRE_ORDERcxx . . $ `lib/robotfirestruct_external.h:31:9`!) { |
| 265 | p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask. = ((float)ps_randcxx . . $ ps_rand(b126dc7c1de90089).() / (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!) * static_wb->num_maskscxx . . $ otype_wb_info#num_masks.; |
| 266 | } else { |
| 267 | p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.++; |
| 268 | } |
| 269 | |
| 270 | if (p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask. >= static_wb->num_maskscxx . . $ otype_wb_info#num_masks.) |
| 271 | p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask. = 0; |
| 272 | } |
| 273 | |
| 274 | if (obj->ai_infocxx . . $ object#ai_info.) { |
| 275 | for (cur_m_bit = 0; cur_m_bit < pm->poly_wbcxx . . $ poly_model#poly_wb.[poly_wb_index].num_gpscxx . . $ poly_wb_info#num_gps.; cur_m_bit++) { |
| 276 | if (static_wb->gp_fire_maskscxx . . $ otype_wb_info#gp_fire_masks.[p_dwb->cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask.] & (0x01 << cur_m_bit)) { |
| 277 | int weapon_id = static_wb->gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[cur_m_bit]; |
| 278 | |
| 279 | if (Weaponscxx . . $ Weapons.[weapon_id].phys_infocxx . . $ weapon#phys_info..flagscxx . . $ physics_info#flags. & PF_FIXED_VELOCITYcxx . . $ `Descent3/object_external.h:324:9`!) |
| 280 | obj->ai_infocxx . . $ object#ai_info.->weapon_speedcxx . . $ ai_frame#weapon_speed. = Weaponscxx . . $ Weapons.[weapon_id].phys_infocxx . . $ weapon#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.; |
| 281 | else if (Weaponscxx . . $ Weapons.[weapon_id].phys_infocxx . . $ weapon#phys_info..flagscxx . . $ physics_info#flags. & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) |
| 282 | obj->ai_infocxx . . $ object#ai_info.->weapon_speedcxx . . $ ai_frame#weapon_speed. = Weaponscxx . . $ Weapons.[weapon_id].phys_infocxx . . $ weapon#phys_info..full_thrustcxx . . $ physics_info#$anonymous_type_3#full_thrust. / Weaponscxx . . $ Weapons.[weapon_id].phys_infocxx . . $ weapon#phys_info..dragcxx . . $ physics_info#drag.; |
| 283 | else |
| 284 | obj->ai_infocxx . . $ object#ai_info.->weapon_speedcxx . . $ ai_frame#weapon_speed. = 0.0; |
| 285 | break; |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | // RType Code... |
| 291 | if (!((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!))) { |
| 292 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->idcxx . . $ object#id. >= 0) { |
| 293 | objectcxx . . $ object# *bobj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(Buddy_handlecxx . . $ Buddy_handle.[obj->idcxx . . $ object#id.]); |
| 294 | if (bobj && bobj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! && (bobj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. & AIF_GB_MIMIC_PLAYER_FIRING_HACKcxx . . $ `Descent3/aistruct_external.h:351:9`!)) { |
| 295 | if (dynamic_wb_index != OMEGA_INDEXcxx . . $ `Descent3/weapon_external.h:31:9`! && dynamic_wb_index != NAPALM_INDEXcxx . . $ `Descent3/weapon_external.h:29:9`! && dynamic_wb_index < 10) { |
| 296 | FireWeaponFromObjectcxx . . $ FireWeaponFromObject(3c611958fe04e279).(bobj, saved_weapon_id, 0, true, false); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | void WBFireBatterycxx . . $ WBFireBattery(cccf09a4825b46a4).(objectcxx . . $ object# *obj, otype_wb_infocxx . . $ otype_wb_info# *static_wb, int wb_index) { |
| 304 | WBFireBatterycxx . . $ WBFireBattery(721350389efbb479).(obj, static_wb, wb_index, wb_index); |
| 305 | } |
| 306 | |
| 307 | void WBClearInfocxx . . $ WBClearInfo(419c470199a90a97).(objectcxx . . $ object# *obj) { |
| 308 | int i, j; |
| 309 | poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.]; |
| 310 | int num_wbs = pm->num_wbscxx . . $ poly_model#num_wbs.; |
| 311 | |
| 312 | if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) |
| 313 | num_wbs = MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!; |
| 314 | |
| 315 | for (i = 0; i < num_wbs; i++) { |
| 316 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. = -1.0f; |
| 317 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].cur_firing_maskcxx . . $ dynamic_wb_info#cur_firing_mask. = 0; |
| 318 | |
| 319 | for (j = 0; j < MAX_WB_TURRETScxx . . $ `lib/robotfirestruct_external.h:24:9`!; j++) { |
| 320 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].norm_turret_anglecxx . . $ dynamic_wb_info#norm_turret_angle.[j] = 0.0f; |
| 321 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].turret_directioncxx . . $ dynamic_wb_info#turret_direction.[j] = WB_MOVE_STILLcxx . . $ `lib/robotfirestruct.h:79:9`!; |
| 322 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].turret_next_think_timecxx . . $ dynamic_wb_info#turret_next_think_time.[j] = 0.0f; |
| 323 | } |
| 324 | |
| 325 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].wb_anim_maskcxx . . $ dynamic_wb_info#wb_anim_mask. = 0; |
| 326 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame. = 0.0f; |
| 327 | |
| 328 | vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].cur_targetcxx . . $ dynamic_wb_info#cur_target.); |
| 329 | |
| 330 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].flagscxx . . $ dynamic_wb_info#flags. = DWBF_ENABLEDcxx . . $ `lib/robotfirestruct_external.h:43:9`! | DWBF_AUTOMATICcxx . . $ `lib/robotfirestruct_external.h:44:9`!; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | void WBClearInfocxx . . $ WBClearInfo(35337aada7327cb).(otype_wb_infocxx . . $ otype_wb_info# static_wb[]) { |
| 335 | int i; |
| 336 | int j; |
| 337 | |
| 338 | if (static_wb == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 339 | return; |
| 340 | |
| 341 | for (i = 0; i < MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!; i++) { |
| 342 | static_wb[i].aiming_gp_indexcxx . . $ otype_wb_info#aiming_gp_index. = 0; |
| 343 | for (j = 0; j < MAX_WB_GUNPOINTScxx . . $ `lib/robotfirestruct_external.h:22:9`!; j++) { |
| 344 | static_wb[i].gp_weapon_indexcxx . . $ otype_wb_info#gp_weapon_index.[j] = LASER_INDEXcxx . . $ `Descent3/weapon_external.h:22:9`!; |
| 345 | } |
| 346 | |
| 347 | for (j = 0; j < MAX_WB_FIRING_MASKScxx . . $ `lib/robotfirestruct_external.h:23:9`!; j++) { |
| 348 | static_wb[i].fm_fire_sound_indexcxx . . $ otype_wb_info#fm_fire_sound_index.[j] = SOUND_NONE_INDEXcxx . . $ `Descent3/sounds.h:105:9`!; |
| 349 | static_wb[i].anim_start_framecxx . . $ otype_wb_info#anim_start_frame.[j] = 0.0; |
| 350 | static_wb[i].anim_fire_framecxx . . $ otype_wb_info#anim_fire_frame.[j] = 0.0; |
| 351 | static_wb[i].anim_end_framecxx . . $ otype_wb_info#anim_end_frame.[j] = 0.0; |
| 352 | static_wb[i].anim_timecxx . . $ otype_wb_info#anim_time.[j] = 0.0; |
| 353 | } |
| 354 | |
| 355 | static_wb[i].num_maskscxx . . $ otype_wb_info#num_masks. = 1; |
| 356 | |
| 357 | for (j = 0; j < MAX_WB_GUNPOINTScxx . . $ `lib/robotfirestruct_external.h:22:9`!; j++) { |
| 358 | static_wb[i].gp_fire_maskscxx . . $ otype_wb_info#gp_fire_masks.[j] = 0; |
| 359 | static_wb[i].gp_fire_waitcxx . . $ otype_wb_info#gp_fire_wait.[j] = 1.0f; |
| 360 | } |
| 361 | // Makes sure a robot with a weapon bank can fire it even if the artist forget to set the weapon info for |
| 362 | // this robot |
| 363 | static_wb[i].gp_fire_maskscxx . . $ otype_wb_info#gp_fire_masks.[0] = 1; |
| 364 | |
| 365 | static_wb[i].flagscxx . . $ otype_wb_info#flags. = 0; |
| 366 | static_wb[i].aiming_flagscxx . . $ otype_wb_info#aiming_flags. = 0; |
| 367 | static_wb[i].aiming_3d_dotcxx . . $ otype_wb_info#aiming_3d_dot. = 0.9f; |
| 368 | static_wb[i].aiming_3d_distcxx . . $ otype_wb_info#aiming_3d_dist. = 1000.0f; |
| 369 | static_wb[i].aiming_XZ_dotcxx . . $ otype_wb_info#aiming_XZ_dot. = 0.9f; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // If the wb_index is negative, all wbs are enabled/disabled |
| 374 | void WBEnablecxx . . $ WBEnable(4c9c8bdefc88d3a5).(objectcxx . . $ object# *obj, int wb_index, bool f_enable) { |
| 375 | poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.]; |
| 376 | int i; |
| 377 | |
| 378 | if (wb_index < 0) { |
| 379 | for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) { |
| 380 | WBEnablecxx . . $ WBEnable(4c9c8bdefc88d3a5).(obj, i, f_enable); |
| 381 | } |
| 382 | } else { |
| 383 | if ((obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && wb_index < pm->num_wbscxx . . $ poly_model#num_wbs.) || (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)) { |
| 384 | if (f_enable) |
| 385 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[wb_index].flagscxx . . $ dynamic_wb_info#flags. |= DWBF_ENABLEDcxx . . $ `lib/robotfirestruct_external.h:43:9`!; |
| 386 | else |
| 387 | obj->dynamic_wbcxx . . $ object#dynamic_wb.[wb_index].flagscxx . . $ dynamic_wb_info#flags. &= ~DWBF_ENABLEDcxx . . $ `lib/robotfirestruct_external.h:43:9`!; |
| 388 | } |
| 389 | } |
| 390 | } |