Implement better jetpack action button

This commit is contained in:
Bjorn Neergaard
2016-02-08 17:09:12 -06:00
parent 2b46e8253f
commit eaa6bc7b18
6 changed files with 122 additions and 134 deletions
@@ -1,69 +1,103 @@
/datum/action/item_action/jetpack/cycle
name = "Jetpack Mode"
/datum/action/item_action/jetpack/cycle/Trigger()
if(!Checks())
return
var/obj/item/weapon/tank/jetpack/J = target
J.cycle(owner)
return 1
/datum/action/item_action/jetpack/cycle/suit
name = "Internal Jetpack Mode"
/datum/action/item_action/jetpack/cycle/suit/New()
..()
check_flags &= ~AB_CHECK_INSIDE // The jetpack is inside the suit.
/datum/action/item_action/jetpack/cycle/suit/CheckRemoval(mob/living/user)
return !(target.loc in user) // Check that the suit is on the user.
/datum/action/item_action/jetpack/cycle/suit/IsAvailable()
var/mob/living/carbon/human/H = owner
if(!H.wear_suit)
return
return ..()
/obj/item/weapon/tank/jetpack
name = "jetpack (empty)"
desc = "A tank of compressed gas for use as propulsion in zero-gravity areas. Use with caution."
icon_state = "jetpack"
w_class = 4
item_state = "jetpack"
w_class = 4
distribute_pressure = ONE_ATMOSPHERE * O2STANDARD
action_button_name = "Toggle Jetpack"
var/datum/effect_system/trail_follow/ion/ion_trail
var/gas_type = "o2"
var/on = 0
var/stabilization_on = 0
var/volume_rate = 500 //Needed for borg jetpack transfer
var/datum/effect_system/trail_follow/ion/ion_trail
var/datum/action/item_action/jetpack/cycle/cycle_action
var/cycle_action_type = /datum/action/item_action/jetpack/cycle
/obj/item/weapon/tank/jetpack/New()
..()
ion_trail = new /datum/effect_system/trail_follow/ion()
air_contents.assert_gas(gas_type)
air_contents.gases[gas_type][MOLES] = (6 * ONE_ATMOSPHERE) * volume / (R_IDEAL_GAS_EQUATION * T20C)
ion_trail = new
ion_trail.set_up(src)
cycle_action = new cycle_action_type(src)
/obj/item/weapon/tank/jetpack/verb/toggle_rockets()
set name = "Toggle Jetpack Stabilization"
set category = "Object"
if(usr.stat || !usr.canmove || usr.restrained())
/obj/item/weapon/tank/jetpack/pickup(mob/user)
..()
cycle_action.Grant(user)
/obj/item/weapon/tank/jetpack/dropped(mob/user)
..()
cycle_action.Remove(user)
/obj/item/weapon/tank/jetpack/proc/cycle(mob/user)
if(user.incapacitated())
return
src.stabilization_on = !( src.stabilization_on )
usr << "<span class='notice'>You toggle the stabilization [stabilization_on? "on":"off"].</span>"
return
if(!on && !stabilization_on)
turn_on()
user << "<span class='notice'>You turn the thrusters on.</span>"
else if(on && !stabilization_on)
stabilization_on = TRUE
user << "<span class='notice'>You turn the stabilizers on.</span>"
else if(on && stabilization_on)
turn_off()
stabilization_on = FALSE
user << "<span class='notice'>You turn the thrusters and stabilizers off.</span>"
/obj/item/weapon/tank/jetpack/verb/toggle()
set name = "Toggle Jetpack"
set category = "Object"
if(usr.stat || !usr.canmove || usr.restrained())
return
on = !on
if(on)
icon_state = "[icon_state]-on"
// item_state = "[item_state]-on"
ion_trail.start()
else
icon_state = initial(icon_state)
// item_state = initial(item_state)
ion_trail.stop()
usr << "<span class='notice'>You toggle the jetpack [on? "on":"off"].</span>"
return
/obj/item/weapon/tank/jetpack/proc/turn_on()
on = TRUE
icon_state = "[initial(icon_state)]-on"
ion_trail.start()
/obj/item/weapon/tank/jetpack/proc/turn_off()
on = FALSE
icon_state = initial(icon_state)
ion_trail.stop()
/obj/item/weapon/tank/jetpack/proc/allow_thrust(num, mob/living/user)
if(!(src.on))
return 0
if((num < 0.005 || src.air_contents.total_moles() < num))
src.ion_trail.stop()
return 0
if(!on)
return
if((num < 0.005 || air_contents.total_moles() < num))
turn_off()
return
var/datum/gas_mixture/G = src.air_contents.remove(num)
var/datum/gas_mixture/removed = air_contents.remove(num)
if(removed.total_moles() < 0.005)
turn_off()
return
var/allgases = G.total_moles()
if(allgases >= 0.005)
return 1
qdel(G)
return
/obj/item/weapon/tank/jetpack/ui_action_click()
toggle()
var/turf/T = get_turf(user)
T.assume_air(removed)
return 1
/obj/item/weapon/tank/jetpack/void
name = "void jetpack (oxygen)"
@@ -71,23 +105,12 @@
icon_state = "jetpack-void"
item_state = "jetpack-void"
/obj/item/weapon/tank/jetpack/void/New()
..()
air_contents.assert_gas("o2")
air_contents.gases["o2"][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
/obj/item/weapon/tank/jetpack/oxygen
name = "jetpack (oxygen)"
desc = "A tank of compressed oxygen for use as propulsion in zero-gravity areas. Use with caution."
icon_state = "jetpack"
item_state = "jetpack"
/obj/item/weapon/tank/jetpack/oxygen/New()
..()
air_contents.assert_gas("o2")
air_contents.gases["o2"][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
/obj/item/weapon/tank/jetpack/oxygen/harness
name = "jet harness (oxygen)"
desc = "A lightweight tactical harness, used by those who don't want to be weighed down by traditional jetpacks."
@@ -108,17 +131,10 @@
/obj/item/weapon/tank/jetpack/carbondioxide
name = "jetpack (carbon dioxide)"
desc = "A tank of compressed carbon dioxide for use as propulsion in zero-gravity areas. Painted black to indicate that it should not be used as a source for internals."
distribute_pressure = 0
icon_state = "jetpack-black"
item_state = "jetpack-black"
/obj/item/weapon/tank/jetpack/carbondioxide/New()
..()
ion_trail = new /datum/effect_system/trail_follow/ion()
ion_trail.set_up(src)
air_contents.assert_gas("co2")
air_contents.gases["co2"][MOLES] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)
distribute_pressure = 0
gas_type = "co2"
/obj/item/weapon/tank/jetpack/suit
name = "suit inbuilt jetpack"
@@ -126,51 +142,37 @@
icon_state = "jetpack-void"
item_state = "jetpack-void"
var/obj/item/weapon/tank/internals/tank = null
action_button_name = "Toggle Jetpack"
action_button_internal = 1
cycle_action_type = /datum/action/item_action/jetpack/cycle/suit
/obj/item/weapon/tank/jetpack/suit/New()
..()
SSobj.processing -= src
air_contents = null
/obj/item/weapon/tank/jetpack/suit/toggle()
set name = "Toggle Jetpack"
set category = "Object"
/obj/item/weapon/tank/jetpack/suit/cycle(mob/user)
var/mob/living/carbon/human/H = user
if(!istype(H.s_store, /obj/item/weapon/tank/internals))
user << "<span class='warning'>You need a tank in your suit storage!</span>"
return
..()
if(istype(loc.loc,/mob/living/carbon/human))
var/mob/living/carbon/human/H = loc.loc
/obj/item/weapon/tank/jetpack/suit/turn_on()
if(!ishuman(loc.loc))
return
var/mob/living/carbon/human/H = loc.loc
tank = H.s_store
air_contents = tank.air_contents
SSobj.processing |= src
..()
if(!H.wear_suit)
H << "<span class='warning'>You must be wearing the suit to use the inbuilt jetpack!</span>"
return
if(!istype(H.s_store,/obj/item/weapon/tank/internals))
H << "<span class='warning'>You must have a tank in your suit's storage to use the inbuilt jetpack!</span>"
return
if(usr.stat || !usr.canmove || usr.restrained())
return
on = !on
if(on)
ion_trail.start()
tank = H.s_store
air_contents = tank.air_contents
SSobj.processing |= src
icon_state = "[icon_state]-on"
else
turn_off()
H << "<span class='notice'>You toggle the inbuilt jetpack [on? "on":"off"].</span>"
/obj/item/weapon/tank/jetpack/suit/proc/turn_off()
on = 0
SSobj.processing -= src
ion_trail.stop()
air_contents = null
/obj/item/weapon/tank/jetpack/suit/turn_off()
tank = null
icon_state = initial(icon_state)
air_contents = null
SSobj.processing -= src
..()
/obj/item/weapon/tank/jetpack/suit/process()
if(!istype(loc.loc,/mob/living/carbon/human))
if(!ishuman(loc.loc))
turn_off()
return
var/mob/living/carbon/human/H = loc.loc