Skip to content

Commit

Permalink
Tweaks/partially refactors small craft repair/refueling modules (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbot16 authored Jun 14, 2024
1 parent 5299cee commit f1daca0
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 36 deletions.
6 changes: 5 additions & 1 deletion nsv13/code/__DEFINES/components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
#define COMSIG_FTL_STATE_CHANGE "ftl_state_change"
#define COMSIG_MOB_ITEM_EQUIPPED "mob_item_equipped" //Used for aiming component, tells you when a mob equips ANY item
#define COMSIG_MOB_ITEM_DROPPED "mob_item_dropped"
#define COMSIG_LOCK_LOST "lock_lost" // When we lost lock on a ship

// Ship targeting signals
#define COMSIG_TARGET_PAINTED "target_painted" //! from base of /obj/structure/overmap/proc/finish_lockon: (target, data_link_origin)
#define COMSIG_TARGET_LOCKED "target_locked" //! from base of /obj/structure/overmap/proc/select_target: (target)
#define COMSIG_LOCK_LOST "lock_lost" //! from base of /obj/structure/overmap/proc/dump_lock: (target)

#define COMSIG_SHIP_RELEASE_BOARDING "release_boarding"
#define COMSIG_SHIP_BLOCKS_RELEASE_BOARDING 1
2 changes: 1 addition & 1 deletion nsv13/code/game/general_quarters/dropship.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

/area/dropship/get_virtual_z(turf/T)
if(linked_dropship)
return linked_dropship.get_virtual_z_level()
return linked_dropship.get_interior_virtual_z()
return ..()

//If we ever want to let them build these things..
Expand Down
2 changes: 1 addition & 1 deletion nsv13/code/game/general_quarters/dropship_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Credit to TGMC for the interior sprites for all these!
starmap.linked = src

// Z override for transports. This returns our aircraft's unique Z.
/obj/structure/overmap/small_craft/transport/get_virtual_z_level()
/obj/structure/overmap/small_craft/transport/proc/get_interior_virtual_z()
return linked_virtual_z != null ? linked_virtual_z : 0;

/datum/map_template/dropship
Expand Down
7 changes: 7 additions & 0 deletions nsv13/code/modules/overmap/fighters/fuel_tank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
var/allow_refuel = FALSE
var/units_per_second = 50

/obj/structure/reagent_dispensers/fueltank/cryogenic_fuel/Destroy()
QDEL_NULL(current_beam)
QDEL_NULL(nozzle)
QDEL_NULL(soundloop)
fuel_target = null
. = ..()

/obj/structure/reagent_dispensers/fueltank/cryogenic_fuel/ui_act(action, params, datum/tgui/ui)
if(..())
return
Expand Down
77 changes: 52 additions & 25 deletions nsv13/code/modules/overmap/fighters/modules/refueling_kit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@
icon_state = "resupply_tier1"
overmap_firing_sounds = list(
'nsv13/sound/effects/fighters/refuel.ogg')
fire_delay = 6 SECONDS
fire_delay = 4 SECONDS
bypass_safety = TRUE
var/datum/beam/current_beam
var/next_fuel = 0
var/is_fuelling = TRUE
var/is_charging = TRUE
var/battery_recharge_amount = 500
var/minimum_fuel_to_keep = 200
var/fuel_transfer_rate = 100
var/minimum_fuel_to_keep = 250
var/fuel_transfer_rate = 50
var/refuel_range = 10

/obj/item/fighter_component/primary/utility/refuel/on_install(obj/structure/overmap/target)
. = ..()
RegisterSignal(target, COMSIG_TARGET_LOCKED, PROC_REF(on_target_lock))

/obj/item/fighter_component/primary/utility/refuel/remove_from(obj/structure/overmap/target)
. = ..()
UnregisterSignal(target, COMSIG_TARGET_LOCKED)

/obj/item/fighter_component/primary/utility/refuel/proc/on_target_lock(obj/structure/overmap/us, obj/structure/overmap/target)
is_fuelling = TRUE
is_charging = TRUE

/obj/item/fighter_component/primary/utility/refuel/get_ammo()
var/obj/structure/overmap/small_craft/F = loc
Expand All @@ -27,21 +42,21 @@
/obj/item/fighter_component/primary/utility/refuel/tier2
name = "upgraded air to air resupply kit"
icon_state = "resupply_tier2"
fire_delay = 5 SECONDS
fire_delay = 3 SECONDS
tier = 2

/obj/item/fighter_component/primary/utility/refuel/tier3
name = "super air to air resupply kit"
icon_state = "resupply_tier3"
fire_delay = 3 SECONDS
fire_delay = 2 SECONDS
tier = 3

/obj/item/fighter_component/primary/utility/refuel/proc/cancel_action(obj/structure/overmap/us, obj/structure/overmap/them, message)
// Remove beam
QDEL_NULL(current_beam)
// Remove targeting
if(us && LAZYFIND(us.target_painted, them))
us.start_lockon(them)
us.dump_lock(them)
if(us && us.gunner && message)
to_chat(us.gunner, message)

Expand All @@ -53,54 +68,66 @@
// The component isn't installed, we're not on that mode, or we have no potential targets
var/obj/structure/overmap/small_craft/us = loc
if(!us || !istype(us) || (us.fire_mode != fire_mode) || !length(us.target_painted))
cancel_action(us)
return
// The target isn't an overmap somehow, we're targeting ourselves, or they're an enemy
var/obj/structure/overmap/small_craft/them = us.target_lock
if(!them || !istype(them) || (them == us) || (them.faction != us.faction))
cancel_action(us, them)
return
// We're out of range
if(overmap_dist(us, them) > refuel_range)
cancel_action(us, them, "<span class='warning'>Target out of range.</span>")
return

// Getting here means we should actually try refueling them
next_fuel = world.time + fire_delay

if(!transfer_fuel(us, them) || jump_battery(us, them))
if(is_fuelling)
var/fuel_message = transfer_fuel(us, them)
if(fuel_message)
to_chat(us.gunner, fuel_message)
is_fuelling = FALSE

if(is_charging)
var/charge_message = jump_battery(us, them)
if(charge_message)
to_chat(us.gunner, charge_message)
is_charging = FALSE

if(!is_fuelling && !is_charging)
cancel_action(us, them, "<span class='notice'>All operations complete. Disconnecting transfer equipment.</span>")
return

// See if we need to make a new beam. Comes after the refuel so we can not do this if we fail any checks.
if(QDELETED(current_beam))
current_beam = new(us,them,beam_icon='nsv13/icons/effects/beam.dmi',time=INFINITY,maxdistance = INFINITY,beam_icon_state="hose",btype=/obj/effect/ebeam/fuel_hose)
INVOKE_ASYNC(current_beam, TYPE_PROC_REF(/datum/beam, Start))

// These procs handle transferring fuel/charge. If a string is returned, it means we're done. If FALSE is returned, we're not done.
/obj/item/fighter_component/primary/utility/refuel/proc/transfer_fuel(obj/structure/overmap/small_craft/us, obj/structure/overmap/small_craft/them)
var/transfer_amount = CLAMP((them.get_max_fuel() - them.get_fuel()), 0, fuel_transfer_rate)
if(transfer_amount <= 0)
cancel_action(us, them, "<span class='notice'>Fuel tank is full.</span>")
return
if(them.get_fuel() <= minimum_fuel_to_keep) // Don't give away ALL our fuel
cancel_action(us, them, "<span class='warning'>Fuel is below minimum safe transfer level.</span>")
return
return "<span class='notice'>Target craft is fully fueled.</span>"
if(us.get_fuel() <= minimum_fuel_to_keep) // Don't give away ALL our fuel
return "<span class='warning'>Fuel levels below minimum safe transfer level.</span>"
var/obj/item/fighter_component/fuel_tank/ourTank = us.loadout.get_slot(HARDPOINT_SLOT_FUEL)
var/obj/item/fighter_component/fuel_tank/theirTank = them.loadout.get_slot(HARDPOINT_SLOT_FUEL)
us.relay('nsv13/sound/effects/fighters/refuel.ogg')
them.relay('nsv13/sound/effects/fighters/refuel.ogg')
ourTank.reagents.trans_to(theirTank, transfer_amount)
return TRUE
return

/obj/item/fighter_component/primary/utility/refuel/proc/jump_battery(obj/structure/overmap/small_craft/us, obj/structure/overmap/small_craft/them)
var/obj/item/fighter_component/battery/ourBattery = us.loadout.get_slot(HARDPOINT_SLOT_BATTERY)
if(!ourBattery || !istype(ourBattery))
cancel_action(us, them, "<span class='warning'>This craft has no battery installed!</span>")
return
return "<span class='warning'>This craft has no battery installed!</span>"
var/obj/item/fighter_component/battery/theirBattery = them.loadout.get_slot(HARDPOINT_SLOT_BATTERY)
if(!theirBattery || !istype(theirBattery))
cancel_action(us, them, "<span class='warning'>The target has no battery installed!</span>")
return
if(!ourBattery.charge < (battery_recharge_amount * 2))
cancel_action(us, them, "<span class='warning'>Battery charge is below minimum safe transfer level.</span>")
return
if(!(theirBattery.charge < battery_recharge_amount))
cancel_action(us, them, "<span class='notice'>Battery levels nominal.</span>")
return
return "<span class='warning'>The target has no battery installed!</span>"
if(ourBattery.charge < (battery_recharge_amount * 2))
return "<span class='warning'>Battery charge is below minimum safe transfer level.</span>"
if(!(theirBattery.charge < theirBattery.maxcharge))
return "<span class='notice'>Target craft is fully charged.</span>"
theirBattery.give(battery_recharge_amount) //Jumpstart their battery
ourBattery.use_power(battery_recharge_amount)
return TRUE
return
20 changes: 14 additions & 6 deletions nsv13/code/modules/overmap/fighters/modules/repair_kit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
bypass_safety = TRUE
var/datum/beam/current_beam = null
var/next_repair = 0
var/foam_consumption = 20
var/repair_range = 10

/obj/item/fighter_component/primary/utility/repairer/get_ammo()
return magazine?.reagents.total_volume
Expand All @@ -20,12 +22,14 @@
icon_state = "repairer_tier2"
tier = 2
fire_delay = 4 SECONDS
foam_consumption = 15

/obj/item/fighter_component/primary/utility/repairer/tier3
name = "super air to air repair kit"
icon_state = "repairer_tier3"
tier = 3
fire_delay = 3 SECONDS
foam_consumption = 10

/obj/item/fighter_component/primary/utility/repairer/load(obj/structure/overmap/target, atom/movable/AM)
if(!istype(AM, accepted_ammo))
Expand All @@ -43,7 +47,7 @@
QDEL_NULL(current_beam)
// Remove targeting
if(us && LAZYFIND(us.target_painted, them))
us.start_lockon(them)
us.dump_lock(them)
if(us && us.gunner && message)
to_chat(us.gunner, message)

Expand All @@ -55,21 +59,24 @@
// The component isn't installed, we're not on that mode, or we have no potential targets
var/obj/structure/overmap/small_craft/us = loc
if(!us || !istype(us) || (us.fire_mode != fire_mode) || !length(us.target_painted))
cancel_action(us)
return
// The target isn't an overmap somehow, we're targeting ourselves, or they're an enemy
var/obj/structure/overmap/small_craft/them = us.target_lock
if(!them || !istype(them) || (them == us) || (them.faction != us.faction))
cancel_action(us, them)
return
// We're out of range
if(overmap_dist(us, them) > repair_range)
cancel_action(us, them, "<span class='warning'>Target out of range.</span>")
return
// We don't have a hull foam tank
var/obj/structure/reagent_dispensers/foamtank/hull_repair_juice/tank = magazine
if(!tank || !istype(tank))
cancel_action(us, them, "<span class='warning'>No tank loaded.</span>")
return
// We're out of juice
if(tank.reagents.get_reagent_amount(/datum/reagent/hull_repair_juice) <= 0)
cancel_action(us, them, "<span class='warning'>Out of repair foam.</span>")
cancel_action(us, them, "<span class='warning'>Repair foam reserves depleted.</span>")
return
// They're fixed
var/obj/item/fighter_component/armour_plating/theirArmour = them.loadout.get_slot(HARDPOINT_SLOT_ARMOUR)
Expand All @@ -85,8 +92,9 @@
INVOKE_ASYNC(current_beam, TYPE_PROC_REF(/datum/beam, Start))
new /obj/effect/temp_visual/heal(get_turf(them), COLOR_CYAN)
// Use some juice
tank.reagents.remove_reagent(/datum/reagent/hull_repair_juice, 5)
//You can repair the main ship too! However at a painfully slow rate. Higher tiers give you vastly better repairs, and bigger ships repair smaller ships way faster.
them.try_repair(0.5+tier-(them.mass-us.mass))
tank.reagents.remove_reagent(/datum/reagent/hull_repair_juice, foam_consumption)
// You can repair the main ship too, but at a much slower rate than normal due to the increased mass.
// For reference: Fighters are repaired at a speed of 25 damage per second if done by hand.
them.try_repair(CEILING(10 * tier - (them.mass - us.mass), 5))
us.relay('sound/items/welder.ogg')
them.relay('sound/items/welder2.ogg')
4 changes: 3 additions & 1 deletion nsv13/code/modules/overmap/overmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ Proc to spool up a new Z-level for a player ship and assign it a treadmill.
to_chat(gunner, "<span class='notice'>Target painted.</span>")
relay('nsv13/sound/effects/fighters/locked.ogg', message=null, loop=FALSE, channel=CHANNEL_IMPORTANT_SHIP_ALERT)
RegisterSignal(target, list(COMSIG_PARENT_QDELETING, COMSIG_FTL_STATE_CHANGE), PROC_REF(dump_lock))
SEND_SIGNAL(src, COMSIG_TARGET_PAINTED, target)
if(autotarget)
select_target(target) //autopaint our target

Expand All @@ -652,13 +653,14 @@ Proc to spool up a new Z-level for a player ship and assign it a treadmill.
update_gunner_cam()
return
target_lock = target
SEND_SIGNAL(src, COMSIG_TARGET_LOCKED, target)

/obj/structure/overmap/proc/dump_lock(obj/structure/overmap/target) // Our locked target got destroyed/moved, dump the lock
SIGNAL_HANDLER
SEND_SIGNAL(src, COMSIG_LOCK_LOST, target)
target_painted -= target
target_last_tracked -= target
UnregisterSignal(target, COMSIG_PARENT_QDELETING)
UnregisterSignal(target, list(COMSIG_PARENT_QDELETING, COMSIG_FTL_STATE_CHANGE))
if(target_lock == target)
update_gunner_cam()
target_lock = null
Expand Down
2 changes: 1 addition & 1 deletion nsv13/code/modules/overmap/radar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Called by add_sensor_profile_penalty if remove_in is used.
if(!target) //Anomalies don't count.
return
if(dradis_targeting && (linked.gunner == usr || linked.pilot == usr))
if(target.faction != linked.faction)
if(target.faction != linked.faction || (linked.can_friendly_fire() && !linked.target_lock))
linked.start_lockon(target)
return
linked.datalink_transmit(target)
Expand Down

0 comments on commit f1daca0

Please sign in to comment.