Merge pull request #8935 from Cyantime/jetpackfuel

Jetpack cleanup, don't use fuel when unneeded
This commit is contained in:
Novacat
2020-09-01 01:05:04 -04:00
committed by GitHub
4 changed files with 57 additions and 50 deletions
@@ -59,21 +59,27 @@
to_chat(usr, "You toggle the thrusters [on? "on":"off"].")
/obj/item/weapon/tank/jetpack/proc/allow_thrust(num, mob/living/user as mob)
/obj/item/weapon/tank/jetpack/proc/get_gas_supply()
return air_contents
/obj/item/weapon/tank/jetpack/proc/can_thrust(num)
if(!on)
return 0
if((num < 0.005 || air_contents.total_moles < num))
var/datum/gas_mixture/fuel = get_gas_supply()
if(num < 0.005 || !fuel || fuel.total_moles < num)
ion_trail.stop()
return 0
var/datum/gas_mixture/G = air_contents.remove(num)
return 1
var/allgases = G.gas["carbon_dioxide"] + G.gas["nitrogen"] + G.gas["oxygen"] + G.gas["phoron"]
if(allgases >= 0.005)
return 1
/obj/item/weapon/tank/jetpack/proc/do_thrust(num, mob/living/user)
if(!can_thrust(num))
return 0
qdel(G)
return
var/datum/gas_mixture/fuel = get_gas_supply()
fuel.remove(num)
return 1
/obj/item/weapon/tank/jetpack/ui_action_click()
toggle()
@@ -117,24 +123,5 @@
. = ..()
. += "It's a jetpack. If you can see this, report it on the bug tracker."
/obj/item/weapon/tank/jetpack/rig/allow_thrust(num, mob/living/user as mob)
if(!(src.on))
return 0
if(!istype(holder) || !holder.air_supply)
return 0
var/obj/item/weapon/tank/pressure_vessel = holder.air_supply
if((num < 0.005 || pressure_vessel.air_contents.total_moles < num))
src.ion_trail.stop()
return 0
var/datum/gas_mixture/G = pressure_vessel.air_contents.remove(num)
var/allgases = G.gas["carbon_dioxide"] + G.gas["nitrogen"] + G.gas["oxygen"] + G.gas["phoron"]
if(allgases >= 0.005)
return 1
qdel(G)
return
/obj/item/weapon/tank/jetpack/rig/get_gas_supply()
return holder?.air_supply?.air_contents
@@ -183,31 +183,32 @@
// VOREstation Edit End.
#undef HUMAN_LOWEST_SLOWDOWN
/mob/living/carbon/human/get_jetpack()
if(back)
var/obj/item/weapon/rig/rig = get_rig()
if(istype(back, /obj/item/weapon/tank/jetpack))
return back
else if(istype(rig))
for(var/obj/item/rig_module/maneuvering_jets.module in rig.installed_modules)
return module.jets
/mob/living/carbon/human/Process_Spacemove(var/check_drift = 0)
//Can we act?
if(restrained()) return 0
if(..()) //Can move due to other reasons, don't use jetpack fuel
return 1
//Do we have a working jetpack?
var/obj/item/weapon/tank/jetpack/thrust
if(back)
if(istype(back,/obj/item/weapon/tank/jetpack))
thrust = back
else if(istype(get_rig(),/obj/item/weapon/rig))
var/obj/item/weapon/rig/rig = get_rig()
for(var/obj/item/rig_module/maneuvering_jets/module in rig.installed_modules)
thrust = module.jets
break
var/obj/item/weapon/tank/jetpack/thrust = get_jetpack()
if(thrust)
if(((!check_drift) || (check_drift && thrust.stabilization_on)) && (!lying) && (thrust.allow_thrust(0.01, src)))
if(((!check_drift) || (check_drift && thrust.stabilization_on)) && (!lying) && (thrust.do_thrust(0.01, src)))
inertia_dir = 0
return 1
if(flying) //VOREStation Edit. If you're flying, you glide around!
return 0 //VOREStation Edit.
//If no working jetpack then use the other checks
if(..())
return 1
return 0
@@ -215,7 +216,11 @@
//If knocked out we might just hit it and stop. This makes it possible to get dead bodies and such.
if(species.flags & NO_SLIP)
return
return 0
var/obj/item/weapon/tank/jetpack/thrust = get_jetpack()
if(thrust?.can_thrust(0.01))
return 0
if(stat)
prob_slip = 0 // Changing this to zero to make it line up with the comment, and also, make more sense.
@@ -1,16 +1,28 @@
/mob/living/silicon/robot/get_jetpack()
if(module)
for(var/obj/item/weapon/tank/jetpack/J in module.modules)
return J
/mob/living/silicon/robot/Check_Shoegrip()
return module && module.no_slip
/mob/living/silicon/robot/Process_Spaceslipping(var/prob_slip)
var/obj/item/weapon/tank/jetpack/thrust = get_jetpack()
if(thrust?.can_thrust(0.01))
return 0
if(module && module.no_slip)
return 0
..(prob_slip)
/mob/living/silicon/robot/Process_Spacemove()
if(module)
for(var/obj/item/weapon/tank/jetpack/J in module.modules)
if(istype(J, /obj/item/weapon/tank/jetpack))
if(J.allow_thrust(0.01))
return 1
if(..())
/mob/living/silicon/robot/Process_Spacemove(var/check_drift = 0)
if(..())//Can move due to other reasons, don't use jetpack fuel
return 1
var/obj/item/weapon/tank/jetpack/thrust = get_jetpack()
if(thrust && (!check_drift || (check_drift && thrust.stabilization_on)) && thrust.do_thrust(0.01))
inertia_dir = 0
return 1
return 0
//No longer needed, but I'll leave it here incase we plan to re-use it.
+3
View File
@@ -390,6 +390,9 @@
/mob/proc/Post_Incorpmove()
return
/mob/proc/get_jetpack()
return
///Process_Spacemove
///Called by /client/Move()
///For moving in space