mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-09 13:01:29 -10:00
Follow-up to #7635. Pass the firing bank explicitly through weapon_create() and beam_fire() instead of searching the ship's banks by weapon class, which could attribute substitution patterns to the wrong bank. Factor the substitution logic into get_weapon_substitution_tuple() and only apply linked/dual-fire pairing to ship-level fire, not turret fire. Skip substitution on multiplayer clients, since the server already resolved it. Derive turret bank indices from the weapon slot being fired rather than the turret's bank cursor, so ammo and substitution state are tracked on the bank that actually fired. Previously a single-selection turret could consume ammo from a bank it never fired, and non-ammo turrets (whose cursors stay at -1) would have skipped substitution entirely. Use the Player_ship object flag rather than Player_obj in ship_secondary_bank_can_dual_fire() so the server and clients agree on dual fire for remote players, and guard ship_secondary_has_ammo() against a negative bank index. Co-Authored-By: Claude Fable 5.1 <[email protected]>
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FREESPACE_SWARM_H__
|
|
#define __FREESPACE_SWARM_H__
|
|
|
|
#include "globalincs/pstypes.h"
|
|
|
|
class object;
|
|
class ship_subsys;
|
|
struct weapon_info;
|
|
|
|
typedef struct turret_swarm_info {
|
|
int flags;
|
|
int weapon_class;
|
|
int num_to_launch;
|
|
int parent_objnum;
|
|
int parent_sig;
|
|
int target_objnum;
|
|
int target_sig;
|
|
ship_subsys* turret;
|
|
ship_subsys* target_subsys;
|
|
int time_to_fire;
|
|
int weapon_num;
|
|
int swp_pbank;
|
|
int swp_sbank;
|
|
} turret_swarm_info;
|
|
|
|
struct swarm_info {
|
|
int change_timestamp;
|
|
vec3d current_target;
|
|
vec3d offset;
|
|
int homing_objnum; // object number that swarm missile is homing on, -1 if not homing
|
|
float zig_direction;
|
|
};
|
|
|
|
#define SWARM_DEFAULT_NUM_MISSILES_FIRED 4 // number of swarm missiles that launch when fired
|
|
|
|
#define MAX_TURRET_SWARM_INFO 100
|
|
extern turret_swarm_info Turret_swarm_info[MAX_TURRET_SWARM_INFO];
|
|
|
|
void swarm_level_init();
|
|
void swarm_create(object* objp, swarm_info* swarmp);
|
|
void swarm_update_direction(object *objp, swarm_info* swarmp);
|
|
void swarm_maybe_fire_missile(int shipnum);
|
|
|
|
int turret_swarm_create();
|
|
void turret_swarm_delete(int i);
|
|
void turret_swarm_set_up_info(int parent_objnum, ship_subsys *turret, const weapon_info *wip, int weapon_num, int swp_pbank, int swp_sbank, bool no_tracking_object = false);
|
|
void turret_swarm_check_validity();
|
|
|
|
#endif /* __FREESPACE_SWARM_H__ */
|