-tg- pull refactor

This commit does the following:
 - Overhauls how pull works. It is now based on a mob verb,
   mob/verb/pulled()
 - Makes the pull icon much more responsive. It is now updated whenever a
   mob starts or stops pulling an object, and instantly updates.
   - This required HUD changes. God help me.
This commit is contained in:
Tigercat2000
2015-10-10 11:15:52 -07:00
parent 07770fdda7
commit ccdae149bb
40 changed files with 101 additions and 186 deletions
@@ -230,13 +230,6 @@
else
healths.icon_state = "health6"
if(pullin)
if(pulling)
pullin.icon_state = "pull"
else
pullin.icon_state = "pull0"
if (toxin) toxin.icon_state = "tox[toxins_alert ? 1 : 0]"
if (oxygen) oxygen.icon_state = "oxy[oxygen_alert ? 1 : 0]"
if (fire) fire.icon_state = "fire[fire_alert ? 1 : 0]"
@@ -1289,12 +1289,6 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
if(pressure)
pressure.icon_state = "pressure[pressure_alert]"
if(pullin)
if(pulling) pullin.icon_state = "pull1"
else pullin.icon_state = "pull0"
// if(rest) //Not used with new UI
// if(resting || lying || sleeping) rest.icon_state = "rest1"
// else rest.icon_state = "rest0"
if(toxin)
if(hal_screwyhud == 4 || toxins_alert) toxin.icon_state = "tox1"
else toxin.icon_state = "tox0"
+10
View File
@@ -26,6 +26,16 @@
current << "\red <FONT size = 3><B>The fog clouding your mind clears. You remember nothing from the moment you were implanted until now..(You don't remember who enslaved you)</B></FONT>"
*/
//mob verbs are a lot faster than object verbs
//for more info on why this is not atom/pull, see examinate() in mob.dm
/mob/living/verb/pulled(atom/movable/AM as mob|obj in oview(1))
set name = "Pull"
set category = "Object"
if(AM.Adjacent(src))
src.start_pulling(AM)
return
//same as above
/mob/living/pointed(atom/A as mob|obj|turf in view())
if(src.stat || !src.canmove || src.restrained())
@@ -42,10 +42,6 @@
set src = usr.contents
return 0
/mob/aiEye/pull()
set popup_menu = 0
set src = usr.contents
return 0
// Use this when setting the aiEye's location.
// It will also stream the chunk that the new loc is in.
@@ -65,7 +65,7 @@
for(var/V in components)
var/datum/robot_component/C = components[V]
C.consume_power()
var/amt = Clamp((lamp_intensity - 2) * 2,1,cell.charge) //Always try to use at least one charge per tick, but allow it to completely drain the cell.
cell.use(amt) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick
@@ -287,7 +287,6 @@
src.bodytemp.icon_state = "temp-2"
if(src.pullin) src.pullin.icon_state = "pull[src.pulling ? 1 : 0]"
//Oxygen and fire does nothing yet!!
// if (src.oxygen) src.oxygen.icon_state = "oxy[src.oxygen_alert ? 1 : 0]"
// if (src.fire) src.fire.icon_state = "fire[src.fire_alert ? 1 : 0]"
@@ -30,7 +30,6 @@
/mob/living/simple_animal/bee/New(loc, var/obj/machinery/apiary/new_parent)
..()
parent = new_parent
verbs -= /atom/movable/verb/pull
/mob/living/simple_animal/bee/Destroy()
if(parent)
@@ -38,9 +38,6 @@
if(fire)
if(fire_alert) fire.icon_state = "fire[fire_alert]" //fire_alert is either 0 if no alert, 1 for heat and 2 for cold.
else fire.icon_state = "fire0"
if(pullin)
if(pulling) pullin.icon_state = "pull1"
else pullin.icon_state = "pull0"
if(oxygen)
if(oxygen_alert) oxygen.icon_state = "oxy1"
else oxygen.icon_state = "oxy0"
+26 -31
View File
@@ -844,6 +844,30 @@ var/list/slot_equipment_priority = list( \
if(istype(M,/mob/living/silicon/ai)) return
show_inv(usr)
//this and stop_pulling really ought to be /mob/living procs
/mob/proc/start_pulling(atom/movable/AM)
if ( !AM || !src || src==AM || !isturf(AM.loc) ) //if there's no person pulling OR the person is pulling themself OR the object being pulled is inside something: abort!
return
if (!( AM.anchored ))
AM.add_fingerprint(src)
// If we're pulling something then drop what we're currently pulling and pull this instead.
if(pulling)
// Are we trying to pull something we are already pulling? Then just stop here, no need to continue.
if(AM == pulling)
return
stop_pulling()
src.pulling = AM
AM.pulledby = src
if(pullin)
pullin.update_icon(src)
if(ismob(AM))
var/mob/M = AM
if(!iscarbon(src))
M.LAssailant = null
else
M.LAssailant = usr
/mob/verb/stop_pulling()
@@ -853,37 +877,8 @@ var/list/slot_equipment_priority = list( \
if(pulling)
pulling.pulledby = null
pulling = null
/mob/proc/start_pulling(var/atom/movable/AM)
if ( !AM || !usr || src==AM || !isturf(src.loc) ) //if there's no person pulling OR the person is pulling themself OR the object being pulled is inside something: abort!
return
if (AM.anchored)
usr << "<span class='notice'>It won't budge!</span>"
return
var/mob/M = AM
if(ismob(AM))
if(!iscarbon(src))
M.LAssailant = null
else
M.LAssailant = usr
if(pulling)
var/pulling_old = pulling
stop_pulling()
// Are we pulling the same thing twice? Just stop pulling.
if(pulling_old == AM)
return
src.pulling = AM
AM.pulledby = src
//Attempted fix for people flying away through space when cuffed and dragged.
if(ismob(AM))
var/mob/pulled = AM
pulled.inertia_dir = 0
if(pullin)
pullin.update_icon(src)
/mob/proc/can_use_hands()
return
+22
View File
@@ -447,5 +447,27 @@
/mob/proc/mob_negates_gravity()
return 0
/mob/proc/Move_Pulled(atom/A)
if (!canmove || restrained() || !pulling)
return
if (pulling.anchored)
return
if (!pulling.Adjacent(src))
return
if (A == loc && pulling.density)
return
if (!Process_Spacemove(get_dir(pulling.loc, A)))
return
if (ismob(pulling))
var/mob/M = pulling
var/atom/movable/t = M.pulling
M.stop_pulling()
step(pulling, get_dir(pulling.loc, A))
if(M)
M.start_pulling(t)
else
step(pulling, get_dir(pulling.loc, A))
return
/mob/proc/update_gravity()
return
+1 -15
View File
@@ -1,20 +1,6 @@
/turf/simulated/floor/engine/attack_hand(var/mob/user as mob)
if ((!( user.canmove ) || user.restrained() || !( user.pulling )))
return
if (user.pulling.anchored)
return
if ((user.pulling.loc != user.loc && get_dist(user, user.pulling) > 1))
return
if (ismob(user.pulling))
var/mob/M = user.pulling
var/atom/movable/t = M.pulling
M.stop_pulling()
step(user.pulling, get_dir(user.pulling.loc, src))
M.start_pulling(t)
else
step(user.pulling, get_dir(user.pulling.loc, src))
return
user.Move_Pulled(src)
/turf/simulated/floor/engine/ex_act(severity)
switch(severity)
+1 -15
View File
@@ -124,21 +124,7 @@
// attack with hand, move pulled object onto conveyor
/obj/machinery/conveyor/attack_hand(mob/user as mob)
if ((!( user.canmove ) || user.restrained() || !( user.pulling )))
return
if (user.pulling.anchored)
return
if ((user.pulling.loc != user.loc && get_dist(user, user.pulling) > 1))
return
if (ismob(user.pulling))
var/mob/M = user.pulling
M.stop_pulling()
step(user.pulling, get_dir(user.pulling.loc, src))
user.stop_pulling()
else
step(user.pulling, get_dir(user.pulling.loc, src))
user.stop_pulling()
return
user.Move_Pulled(src)
// make the conveyor broken
@@ -33,7 +33,6 @@
/obj/vehicle/train/ambulance/engine/New()
..()
cell = new /obj/item/weapon/stock_parts/cell/high
verbs -= /atom/movable/verb/pull
key = new()
/obj/vehicle/train/ambulance/engine/Move()
@@ -41,7 +41,6 @@
/obj/vehicle/train/cargo/engine/New()
..()
cell = new /obj/item/weapon/stock_parts/cell/high
verbs -= /atom/movable/verb/pull
key = new()
var/image/I = new(icon = 'icons/obj/vehicles.dmi', icon_state = "cargo_engine_overlay", layer = src.layer + 0.2) //over mobs
overlays += I
@@ -279,10 +278,5 @@
if(!lead && !tow)
anchored = 0
if(verbs.Find(/atom/movable/verb/pull))
return
else
verbs += /atom/movable/verb/pull
else
anchored = 1
verbs -= /atom/movable/verb/pull
anchored = 1