Implemented canReach for verbs, added calls to it to the verbs which needed it

This commit is contained in:
shadowlord13
2008-06-18 21:06:31 +00:00
parent 314f843877
commit 002407ed7a
21 changed files with 981 additions and 681 deletions
+1 -1
View File
@@ -252,7 +252,7 @@ Pipe Valve Status: [ct]<BR>
// Process topic link from interaction window
Topic(href, href_list)
usr.client_mob() << "Topic on canister, usr is [usr], src is [src], usr.client_mob() is [usr.client_mob()], href is ([href]), href_list is ([href_list])."
//debug message: //usr.client_mob() << "Topic on canister, usr is [usr], src is [src], usr.client_mob() is [usr.client_mob()], href is ([href]), href_list is ([href_list])."
..()
if (usr.stat || usr.restrained())
+16 -5
View File
@@ -57,8 +57,11 @@ obj/machinery/computer/atmosphere
verb/siphon_all()
set src in oview(1)
if(stat & NOPOWER) return
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "Starting all siphon systems."
for(var/obj/machinery/atmoalter/siphs/S in src.returnarea())
S.reset(1, 0)
@@ -70,7 +73,9 @@ obj/machinery/computer/atmosphere
verb/stop_all()
set src in oview(1)
if(stat & NOPOWER) return
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "Stopping all siphon systems."
for(var/obj/machinery/atmoalter/siphs/S in src.returnarea())
@@ -83,7 +88,9 @@ obj/machinery/computer/atmosphere
verb/auto_on()
set src in oview(1)
if(stat & NOPOWER) return
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "Starting automatic air control systems."
for(var/obj/machinery/atmoalter/siphs/S in src.returnarea())
@@ -97,7 +104,9 @@ obj/machinery/computer/atmosphere
set src in oview(1)
if(stat & NOPOWER) return
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "Releasing all scrubber toxins."
for(var/obj/machinery/atmoalter/siphs/scrubbers/S in src.returnarea())
@@ -110,7 +119,9 @@ obj/machinery/computer/atmosphere
verb/release_all()
set src in oview(1)
if(stat & NOPOWER) return
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "Releasing all stored air."
for(var/obj/machinery/atmoalter/siphs/S in src.returnarea())
@@ -14,6 +14,10 @@ obj/machinery/computer/communications
verb/call_shuttle()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
if(stat & NOPOWER) return
call_shuttle_proc(usr)
@@ -22,6 +26,10 @@ obj/machinery/computer/communications
verb/cancel_call()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
if(stat & NOPOWER) return
cancel_call_proc(usr)
+16
View File
@@ -19,6 +19,10 @@ obj/machinery/computer/data
verb/display()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
for(var/x in src.topics)
usr.client_mob() << "[x], \..."
@@ -32,6 +36,10 @@ obj/machinery/computer/data
verb/read(topic as text)
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (src.topics[text("[]", topic)])
usr.client_mob() << "<B>[topic]</B>\n\t [src.topics["[topic]"]]"
@@ -80,6 +88,10 @@ obj/machinery/computer/data
display()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "<B>Research Information:</B>"
..()
@@ -107,6 +119,10 @@ obj/machinery/computer/data
display()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.client_mob() << "<B>Research Log:</B>"
..()
+3 -1
View File
@@ -131,7 +131,9 @@ Blue (0-255): <A href='?src=\ref[src];h_b=-300'>\[0\]</A> <A href='?src=\ref[src
else if (href_list["temp"])
src.temp = null
src.updateDialog()
for(var/mob/M in viewers(1, src))
if ((M.client && M.machine == src))
src.show_console(M)
/*
+9 -5
View File
@@ -18,8 +18,9 @@ obj/machinery/computer/prison_shuttle
verb/take_off()
set src in oview(1)
if ((usr.stat || usr.restrained()))
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
@@ -64,12 +65,15 @@ obj/machinery/computer/prison_shuttle
usr.client_mob() << "\blue There is an obstructing shuttle!"
// Restabalize verb
// Restabilize verb
// Set all shuttle locations to standard atmosphere settings
verb/restabalize()
verb/restabilize()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
var/list/observers = viewers(null, null)
for (var/mob/who in observers)
who.client_mob() << "\red <B>Restabilizing prison shuttle atmosphere!</B>"
+10 -2
View File
@@ -16,11 +16,15 @@ obj/machinery/computer/shuttle
access = "2000" // ID card access level needed to authorize
// Restabalize verb
// Restabilize verb
// Set all shuttle locations to standard atmosphere
verb/restabalize()
verb/restabilize()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
world << "\red <B>Restabilizing shuttle atmosphere!</B>"
var/A = locate(/area/shuttle)
@@ -55,6 +59,10 @@ obj/machinery/computer/shuttle
verb/hijack()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if ((!( ticker ) || ticker.shuttle_location != shuttle_z))
return
+11 -6
View File
@@ -155,9 +155,11 @@ obj/machinery/cryo_cell
verb/move_eject()
set src in oview(1)
if (usr.stat != 0)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.go_out()
add_fingerprint(usr)
@@ -168,7 +170,10 @@ obj/machinery/cryo_cell
verb/move_inside()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (usr.stat != 0 || stat & NOPOWER)
return
if (src.occupant)
@@ -227,9 +232,9 @@ obj/machinery/cryo_cell
// AI interact
attack_ai(mob/user)
return src.attack_hand(user)
// Human interact, show status window of machine and occupant
attack_hand(mob/user)
if(stat & NOPOWER)
@@ -347,7 +352,7 @@ obj/machinery/cryo_cell
else
usr.client_mob() << "User too far?"
return
// Called to remove the occupant of a cell
// Reset the view back to normal
+24 -4
View File
@@ -84,7 +84,9 @@ obj/machinery/pod
verb/eject()
set src = usr.loc
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
var/mob/M = usr
M.loc = src.loc
@@ -99,14 +101,16 @@ obj/machinery/pod
verb/board()
set src in oview(1)
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
var/mob/M = usr
if (M.client)
M.client.perspective = EYE_PERSPECTIVE
M.client.eye = src
M.loc = src
return
// Load pod - whatever the player is pulling gets loaded into the pod (including other players)
@@ -125,6 +129,15 @@ obj/machinery/pod
if (ismob(H.pulling))
var/mob/M = H.pulling
var/result = src.canReach(H, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
result = H.pulling.canReach(H, null, 1)
if (result==0)
usr << "You can't reach [H.pulling]."
return
if (M.client)
M.client.perspective = EYE_PERSPECTIVE
M.client.eye = src
@@ -141,8 +154,15 @@ obj/machinery/pod
verb/unload(var/atom/movable/A in src.contents)
set src in oview(1)
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
if (istype(A, /atom/movable))
A.loc = src.loc
for(var/mob/O in viewers(src, null))
+12 -4
View File
@@ -79,7 +79,9 @@ obj/machinery/recon
verb/eject()
set src = usr.loc
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
var/mob/M = usr
M.loc = src.loc
@@ -93,7 +95,9 @@ obj/machinery/recon
verb/board()
set src in oview(1)
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
if (locate(/mob, src))
usr.client_mob() << "There is no room! You can only fit one person."
@@ -111,7 +115,9 @@ obj/machinery/recon
verb/load()
set src in oview(1)
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
if ((( istype(usr, /mob/human) ) && (!( ticker ) || (ticker && ticker.mode != "monkey"))))
var/mob/human/H = usr
@@ -141,7 +147,9 @@ obj/machinery/recon
verb/unload(atom/movable/A in src)
set src in oview(1)
if (usr.stat)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
if (istype(A, /atom/movable))
A.loc = src.loc
+6 -2
View File
@@ -30,7 +30,9 @@ obj/machinery/sleeper
verb/eject()
set src in oview(1)
if (usr.stat != 0)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
src.go_out()
add_fingerprint(usr)
@@ -43,7 +45,9 @@ obj/machinery/sleeper
verb/move_inside()
set src in oview(1)
if (usr.stat != 0)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr << "You can't reach [src]."
return
if (src.occupant)
usr.client_mob() << "\blue <B>The sleeper is already occupied!</B>"
+19 -8
View File
@@ -115,7 +115,7 @@
M.stunned = time
M.stat = 1
for(var/mob/O in viewers(M, null))
if ((!( O.blinded )))
if (O.hasClient() && (!( O.blinded )))
O.client_mob() << text("\red <B>[] has been knocked unconscious!</B>", M)
//Foreach goto(169)
M.client_mob() << text("\red <B>This was a []% hit. Roleplay it! (personality/memory change if the hit was severe enough)</B>", time * 100 / 120)
@@ -1512,7 +1512,11 @@
/obj/stool/chair/e_chair/verb/toggle_power()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if ((usr.stat || usr.restrained() || !( usr.canmove ) || usr.lying))
return
src.on = !( src.on )
@@ -1618,7 +1622,11 @@
/obj/stool/chair/verb/rotate()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.dir = turn(src.dir, 90)
if (src.dir == NORTH)
src.layer = FLY_LAYER
@@ -1661,10 +1669,9 @@
/obj/stool/chair/attack_hand(mob/user as mob)
if (istype(user, /mob/drone))
if (istype(user, /mob/drone))
if (user.equipped())
user.client_mob() << "You need to be using the gripper to buckle someone in."
return
if (user.equipped())
user.client_mob() << "You need to be using the gripper to buckle someone in."
return
for(var/mob/M in src.loc)
if (M.buckled)
if (M != user)
@@ -1957,7 +1964,11 @@
/obj/window/verb/rotate()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (src.anchored)
usr.client_mob() << "It is fastened to the floor; therefore, you can't rotate it!"
return 0
+16 -4
View File
@@ -246,7 +246,11 @@
/obj/machinery/dna_scanner/verb/move_inside()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (usr.stat != 0)
return
if (src.occupant)
@@ -718,7 +722,7 @@
/obj/machinery/restruct/verb/eject()
set src in oview(1)
if (usr.stat != 0)
return
src.go_out()
@@ -727,7 +731,11 @@
/obj/machinery/restruct/verb/operate()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
if ((src.occupant && src.occupant.primary))
switch(src.occupant.primary.spec_identity)
@@ -884,7 +892,11 @@
/obj/machinery/restruct/verb/move_inside()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (usr.stat != 0)
return
if (src.occupant)
+232 -176
View File
@@ -778,7 +778,6 @@
for(var/obj/item/weapon/cloaking_device/S in M)
S.active = 0
S.icon_state = "shield0"
//Foreach goto(72)
if ((get_dist(M, T) <= 2 || src.loc == M.loc || src.loc == M))
flick("e_flash", M.flash)
M.stunned = 10
@@ -928,7 +927,6 @@
for(var/obj/item/weapon/cloaking_device/S in M)
S.active = 0
S.icon_state = "shield0"
//Foreach goto(201)
if (M.hasClient())
var/mob/CM = M.client_mob()
var/safety = null
@@ -4357,24 +4355,43 @@
//Foreach goto(203)
for(var/mob/O in crackle)
O.show_message(text("\icon[] <I>Crackle,Crackle</I>", src), 2)
//Foreach goto(233)
//Foreach goto(233)
var/speakerType = M.type
if (istype(M, /mob/human) || (istype(M, /mob/ai)))
for(var/mob/O in receive)
if (istype(O, /mob/human) || (istype(O, /mob/ai)))
var/mobType = O.type
if (istype(O, /mob/drone))
var/mob/drone/Mdrone = O
var/mob/Mowner = Mdrone.controlledBy
if (Mowner!=null)
mobType = Mowner.type
if (istype(O, /mob/human) || (istype(O, /mob/ai)) || (istype(O, /mob/drone) && mobType==speakerType))
O.show_message(text("<B>[]-\icon[]\[[]\]-broadcasts</B>: <I>[]</I>", M.rname, src, src.freq, msg), 2)
else
O.show_message(text("<B>[]-\icon[]\[[]\]-broadcasts</B>: <I>[]</I>", M.rname, src, src.freq, stars(msg)), 2)
//Foreach goto(284)
if (src.freq == 5)
for(var/mob/O in receive)
if (istype(O, /mob/human) || (istype(O, /mob/ai)))
var/mobType = O.type
if (istype(O, /mob/drone))
var/mob/drone/Mdrone = O
var/mob/Mowner = Mdrone.controlledBy
if (Mowner!=null)
mobType = Mowner.type
if (istype(O, /mob/human) || (istype(O, /mob/ai)) || (istype(O, /mob/drone) && istype(mobType, speakerType)))
O.show_message(text("<B>[]-\icon[]\[[]\]-broadcasts (over PA)</B>: <I>[]</I>", M.rname, src, src.freq, msg), 2)
else
O.show_message(text("<B>[]-\icon[]\[[]\]-broadcasts (over PA)</B>: <I>[]</I>", M.rname, src, src.freq, stars(msg)), 2)
//Foreach goto(393)
else
for(var/mob/O in receive)
if (istype(O, M))
var/mobType = O.type
if (istype(O, /mob/drone))
var/mob/drone/Mdrone = O
var/mob/Mowner = Mdrone.controlledBy
if (Mowner!=null)
mobType = Mowner.type
if (istype(O, M) || (istype(O, /mob/drone) && istype(mobType, speakerType)))
O.show_message(text("<B>The monkey-\icon[]\[[]\]-broadcasts</B>: <I>[]</I>", src, src.freq, msg), 2)
else
O.show_message(text("<B>The monkey-\icon[]\[[]\]-broadcasts</B>: chimpering", src, src.freq), 2)
@@ -4897,7 +4914,7 @@
M.health = 100 - M.oxyloss - M.toxloss - M.fireloss - M.bruteloss
src.amount--
else
usr.client_mob() << text("\red The [] only works on humans.", src)
user.client_mob() << text("\red The [] only works on humans.", src)
return
/obj/item/weapon/brutepack/examine()
@@ -5654,6 +5671,183 @@
return
..()
return
/*
Proc name: canReach
Purpose: To indicate whether something - a turf, a mob, an object, whatever - can be reached from the user's location.
Parameters:
user - the mob who will be doing the attempted touching
usingWeapon - the weapon the mob is using to reach src. This is important if they're actually trying to *shoot* someone.
ignoreNextMoveTime - Normally this would be 0, and if world.time wasn't < next_time, the proc would return 0. If it was < next_time, prev_time and next_time would be changed (next_time being set to world.time + 10).
If, instead, ignoreNextMoveTime is 1, next_time, world.time, and prev_time will not be examined or changed.
Return value:
This returns 0 if, for some reason, the user can't reach src. If not, the return value is a set of 3 bitflags:
1: CANREACH_USINGWEAPON: If set, user is using a "weapon" (passed in as usingWeapon) on src. (This is kind of semi-useless to check, since the only case currently where this would be 0 when you had passed in a weapon would be if the user was a drone, and the weapon was the AI interface, and the drone was controlled by the AI player, in which case if you cared you would already be checking for it anyways because you would need to be changing the user and setting the weapon to null yourself.)
2: CANREACH_CANTOUCH: If set, src can be touched by user (which was called t5 in DblClick). This is set if (get_dist(src, user) <= 1 || src.loc == user), or if the user is the AI, or if the user is a drone controlled by an AI using the AI interface tool.
4: CANREACH_ALLOWED: If set, src is reachable by user, or the attempt is allowed for another reason. This is always set if the return value is valid. This differs from cantouch because this will be set if the user is using a gun on someone distant, whereas cantouch will not be set in that case. It's also theoretically possible to have a return value which contains only 4 for some /obj/screen objects, if the code in /atom/DblClick wasn't just overly paranoid.
Valid combinations of those are: 0, 4, 5, 6, or 7. (You won't ever have 1 or 2 set if 4 isn't set)
Detail on what's checked:
The user has to be able to move unless they are an AI, and their stat has to be 0 (alive and awake).
If the src is not in user's inventory, we MIGHT return 0:
If src is not a turf, and it is not on a turf, and it is inside something else which is not in a turf:
We return 0, it cannot be reached.
If not, if the user is inside some item instead of on a turf, and src is not in the same place as the user, and src is not a screen object, and src is not inside an item in user's inventory:
We return 0, it cannot be reached.
(Otherwise we continue)
And some other difficult to explain stuff is done here.
Either CANREACH_CANTOUCH will be true, or the user must be using a weapon which has flag 16 set, or src is an /obj/screen.
Checks to determine if there are obstacles in the way (windows, etc) are done unless src is an /obj/screen.
*/
#define CANREACH_USINGWEAPON 1
#define CANREACH_CANTOUCH 2
#define CANREACH_ALLOWED 4
/* Note: CANREACH_USINGWEAPON and CANREACH_CANTOUCH are not referenced in canReach because those are set by just a something&1 and a (something&1)<<1 */
/atom/proc/canReach(mob/user, obj/item/weapon/usingWeapon, ignoreNextMoveTime)
if (((!user.canmove) && (!istype(user, /mob/ai))) || user.stat != 0)
return 0
/* This line broke my mental parser. --Stephen001 */
if ((!(src in user.contents) && (((!(isturf(src)) && (!(isturf(src.loc)) && (src.loc && !(isturf(src.loc.loc))))) || !(isturf(user.loc))) && (src.loc != user.loc && (!(istype(src, /obj/screen)) && !(user.contents.Find(src.loc)))))))
return 0
/* Breaks double-clicking on an equipment slot to place an item there, unfortunately. */
/*
//If the dclicked item is not in our inventory
if (!(src in user.contents))
//If the item is not a turf, and it is not on a turf, and it is inside something else which is not in a turf
if (!(isturf(src)) && (!(isturf(src.loc)) && (src.loc && !(isturf(src.loc.loc)))))
return
//If not, if we are inside some item instead of on a turf, and the dclicked item is not in the same place as us, and the dclicked item is not a screen object, and the dclicked item is not inside an item in our inventory.
else if ((!(isturf(user.loc))) && (src.loc != user.loc && (!(istype(src, /obj/screen)) && !(user.contents.Find(src.loc)))))
return
*/
/* That's checking to see if it's being held/worn or something like that, methinks */
var/t5 = (get_dist(src, user) <= 1 || src.loc == user)
if (istype(user, /mob/ai))
t5 = 1
else if (istype(user, /mob/drone))
if (user:selectedTool == user:aiInterface)
if (istype(user:controlledBy, /mob/ai))
t5 = 1
user = user:controlledBy
usingWeapon = null
if ((istype(src, /obj/item/weapon/organ) && src in user.contents))
var/mob/human/H = user
if (istype(user, /mob/human))
if (!(src == H.l_store || src == H.r_store))
return 0
else
return 0
/* Suggested fix by shadowlord13 for Bug #1952091. --Stephen001 */
var/turf/turfLoc = (istype(src, /turf) ? src : src.loc)
/* Seems like a pretty important expression. Dare I fathom what it checks? --Stephen001 */
/* flag 16 in this case apparently disables the distance check and the alternate 'is in contents' check in the var/t5 line.
It's used on guns, for instance. --shadowlord13 */
if (((t5 || (usingWeapon && (usingWeapon.flags & 16))) && !(istype(src, /obj/screen))))
if (ignoreNextMoveTime!=0)
if (user.next_move < world.time)
user.prev_move = user.next_move
user.next_move = world.time + 10
else
return 0
if ((turfLoc && (get_dist(src, user) < 2 || turfLoc == user.loc)))
var/direct = get_dir(user, src)
var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy(user.loc)
var/ok = 0
if ((direct - 1) & direct)
var/turf/T
switch(direct)
if(5.0)
T = get_step(user, NORTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, EAST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(6.0)
T = get_step(user, SOUTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, EAST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(9.0)
T = get_step(user, NORTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, WEST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(10.0)
T = get_step(user, SOUTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, WEST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
else
if (turfLoc.Enter(D, src))
ok = 1
else
if ((src.flags & 512 && get_dir(src, user) & src.dir))
ok = 1
if (user.loc != turfLoc)
for(var/atom/A in user.loc)
if ((!A.CheckExit(user, src.loc)) && A != user)
ok = 0
del(D)
if (!(ok))
return 0
//user << "Debug message: usingWeapon [usingWeapon] t5 [t5] src [src] user [user]"
return (((t5!=0)&1)<<1) | ((usingWeapon!=0)&1) | CANREACH_ALLOWED
else
if (istype(src, /obj/screen))
if (ignoreNextMoveTime!=0)
if (user.next_move < world.time)
user.prev_move = user.next_move
user.next_move = world.time + 10
else
return 0
return (((t5!=0)&1)<<1) | ((usingWeapon!=0)&1) | CANREACH_ALLOWED
return 0
/atom/Click()
if (!usr.disable_one_click)
@@ -5679,197 +5873,53 @@
var/obj/item/weapon/tool = user:checkIsOurTool(src)
if (tool!=null)
if (tool==W)
user.client_mob() << "user clicked their active tool."
//user.client_mob() << "Debug message: user clicked their active tool."
spawn(0)
W.attack_self(user)
user:updateToolIcon(W)
return
else
user.client_mob() << "user switched tools from [W] to [tool]"
//user.client_mob() << "Debug message: user switched tools from [W] to [tool]"
user:selectTool(tool)
return
else
user.client_mob() << "That's not one of our tools"
//user.client_mob() << "Debug message: That's not one of our tools"
user:pressIfDroneButton(src)
if (W == src)
user.client_mob() << "user clicked their active item."
//user.client_mob() << "Debug message: user clicked their active item."
spawn(0) W.attack_self(user)
return
return
if (((!user.canmove) && (!istype(user, /mob/ai))) || user.stat != 0)
return
if ((!(src in user.contents) && (((!(isturf(src)) && (!(isturf(src.loc)) && (src.loc && !(isturf(src.loc.loc))))) || !(isturf(user.loc))) && (src.loc != user.loc && (!(istype(src, /obj/screen)) && !(user.contents.Find(src.loc)))))))
return
/* Breaks double-clicking on an equipment slot to place an item there, unfortunately. */
/*
// If the dclicked item is in our inventory
if (!(src in user.contents))
// If the item is not a turf, and it is not on a turf, and it is inside something else which is not in a turf
if (!(isturf(src)) && (!(isturf(src.loc)) && (src.loc && !(isturf(src.loc.loc)))))
return
// If not, if we are inside some item instead of on a turf, and the dclicked item is not in the same place as us, and the dclicked item is not a screen object,
// and the dclicked item is not inside an item in our inventory.
else if ((!(isturf(user.loc))) && (src.loc != user.loc && (!(istype(src, /obj/screen)) && !(user.contents.Find(src.loc)))))
return
*/
/* That's checking to see if it's being held/worn or something like that, methinks. */
var/t5 = (get_dist(src, user) <= 1 || src.loc == user)
if (istype(user, /mob/ai))
t5 = 1
else if (istype(user, /mob/drone))
var/retval = src.canReach(user, W, 0)
if (retval==0)
return
if (istype(user, /mob/drone))
if (user:selectedTool == user:aiInterface)
if (istype(user:controlledBy, /mob/ai))
t5 = 1
user = user:controlledBy
W = null
if ((istype(src, /obj/item/weapon/organ) && src in user.contents))
var/mob/human/H = user
user.client_mob() << "Betchya think you're really smart trying to remove your own body parts aren't ya!"
if (istype(user, /mob/human))
if (!(src == H.l_store || src == H.r_store))
return
else
return
/* Suggested fix for Bug #1952091. */
var/turf/turfLoc = (istype(src, /turf) ? src : src.loc)
/* flag 16 in this case apparently disables the distance check and the alternate 'is in contents' check in the var/t5 line. It's used on guns, for instance. */
if (((t5 || (W && (W.flags & 16))) && !(istype(src, /obj/screen))))
if (user.next_move < world.time)
user.prev_move = user.next_move
user.next_move = world.time + 10
else
return
if ((turfLoc && (get_dist(src, user) < 2 || turfLoc == user.loc)))
var/direct = get_dir(user, src)
var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy(user.loc)
var/ok = 0
if ((direct - 1) & direct)
var/turf/T
switch(direct)
if(5.0)
T = get_step(user, NORTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, EAST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(6.0)
T = get_step(user, SOUTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, EAST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(9.0)
T = get_step(user, NORTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, WEST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
if(10.0)
T = get_step(user, SOUTH)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
T = get_step(user, WEST)
if (T.Enter(D, src))
D.loc = T
T = turfLoc
if (T.Enter(D, src))
ok = 1
else
else
if (turfLoc.Enter(D, src))
ok = 1
else
if ((src.flags & 512 && get_dir(src, user) & src.dir))
ok = 1
if (user.loc != turfLoc)
for(var/atom/A in user.loc)
if ((!A.CheckExit(user, src.loc)) && A != user)
ok = 0
del(D)
if (!(ok))
return 0
if (!user.restrained())
if (W)
if (t5)
src.attackby(W, user)
if (!(retval & CANREACH_USINGWEAPON))
W = null
//if (((t5 || (usingWeapon && (usingWeapon.flags & 16))) && !(istype(src, /obj/screen))))
if (retval & CANREACH_ALLOWED)
if (!(istype(src, /obj/screen)))
if (!user.restrained())
if (W)
W.afterattack(src, user, (t5 ? 1 : 0))
else
if (istype(user, /mob/human) || istype(user, /mob/drone))
src.attack_hand(user, user.hand)
else
if (istype(user, /mob/monkey))
src.attack_paw(user, user.hand)
else
if (istype(user, /mob/ai))
src.attack_ai(user, user.hand)
else
if (istype(user, /mob/human))
src.hand_h(user, user.hand)
else
if (istype(user, /mob/monkey))
src.hand_p(user, user.hand)
else
if (istype(user, /mob/ai))
src.hand_a(user, user.hand)
else
if (istype(src, /obj/screen))
user.prev_move = user.next_move
if (user.next_move < world.time)
user.next_move = world.time + 10
else
return
if (!( user.restrained() ))
if ((W && !( istype(src, /obj/screen) )))
src.attackby(W, user)
if (retval & CANREACH_CANTOUCH)
src.attackby(W, user)
if (W)
W.afterattack(src, user)
W.afterattack(src, user, ((retval & CANREACH_CANTOUCH) ? 1 : 0))
else
if (istype(user, /mob/human))
if (istype(user, /mob/human) || istype(user, /mob/drone))
src.attack_hand(user, user.hand)
else
if (istype(user, /mob/monkey))
src.attack_paw(user, user.hand)
else
if (istype(user, /mob/human))
src.hand_h(user, user.hand)
else
if (istype(user, /mob/monkey))
src.hand_p(user, user.hand)
return
/obj/proc/updateDialog()
@@ -5893,4 +5943,10 @@
for(var/mob/M in nearby)
if ((M.client && M.machine == src))
src:attack_self(M)
AutoUpdateAI(src, 1)
//Used for infra_sensor, etc
/obj/proc/updateSelfDialog(atom/origin)
var/list/nearby = viewers(1, origin)
for(var/mob/M in nearby)
if (M.client)
src:attack_self(M)
+457 -415
View File
File diff suppressed because it is too large Load Diff
+27 -23
View File
@@ -14,7 +14,7 @@
var/aiRestorePowerRoutine = 0
var/list/laws = list()
flags = 258.0
proc/ai_camera_follow(mob/target as mob in world)
set category = "AI Commands"
if (usr.stat>0)
@@ -25,7 +25,7 @@
usr << "You can't use the follow camera while controlling a drone."
usr:cameraFollow = null
return
usr:cameraFollow = target
usr << text("Follow camera mode is now following [].", target.rname)
if (usr.machine == null)
@@ -116,6 +116,9 @@
b_loss += 30
else
return
src.bruteloss += b_loss
src.fireloss += f_loss
src.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
examine()
set src in oview()
@@ -209,14 +212,14 @@
src.fire.icon_state = "fire1"
else if (src.fire)
src.fire.icon_state = "fire0"
if (src.health <= -100.0)
death()
return
else if (src.health < 0)
src.oxyloss++
if (src.mach)
if (src.machine)
src.mach.icon_state = "mach1"
@@ -257,7 +260,7 @@
spawn(1)
while (src.oxyloss>0 && stat!=2)
sleep(50)
src.oxyloss-=5
src.oxyloss-=1
src.oxyloss = 0
return
else if (src:aiRestorePowerRoutine==3)
@@ -266,13 +269,13 @@
spawn(1)
while (src.oxyloss>0 && stat!=2)
sleep(50)
src.oxyloss-=5
src.oxyloss-=1
src.oxyloss = 0
return
src.toxin.icon_state = "pow0"
else
src.toxin.icon_state = "pow1"
//stage = 6
src.blind.screen_loc = "1,1 to 15,15"
if (src.blind.layer!=18)
@@ -294,7 +297,7 @@
src.addLaw(index, "")
spawn(50)
while ((src:aiRestorePowerRoutine!=0) && stat!=2)
src.oxyloss += 5
src.oxyloss += 1
sleep(50)
spawn(20)
@@ -516,7 +519,7 @@
src.client.screen -= list( src.oxygen, src.i_select, src.m_select, src.toxin, src.internals, src.fire, src.hands, src.healths, src.pullin, src.blind, src.flash, src.rest, src.sleep, src.mach )
src.client.screen -= list( src.zone_sel, src.oxygen, src.i_select, src.m_select, src.toxin, src.internals, src.fire, src.hands, src.healths, src.pullin, src.blind, src.flash, src.rest, src.sleep, src.mach )
src.client.screen += list( src.toxin, src.fire, src.healths )
if (!( isturf(src.loc) ))
src.client.eye = src.loc
src.client.perspective = EYE_PERSPECTIVE
@@ -542,10 +545,10 @@
return
m_delay()
return 0
say(message as text)
if(config.logsay) world.log << "SAY: [src.name]/[src.key] : [message]"
@@ -570,6 +573,7 @@
var/pre = copytext(message, 1, 4)
var/italics = 0
var/obj_range = null
/* //might be used in the future for looking into the bug(s) with hearing/saying things inside objects
var/source = src
//Didn't want to risk infinite recursion if someone somehow was outside the map, if that's possible, but did want to allow people being in closets in pods and such. -shadowlord13
if (!istype(src.loc, /turf))
@@ -578,7 +582,7 @@
source = src.loc
if (!istype(src.loc, /turf))
source = src.loc
*/
if (pre == "\[w\]")
message = copytext(message, 4, length(message) + 1)
L += hearers(1, null)
@@ -658,7 +662,7 @@
attack_paw(mob/M as mob)
src.attack_hand(M)
attack_hand(mob/M as mob)
if (!ticker)
M << "You cannot attack people before the game has started."
@@ -684,7 +688,7 @@
M:UpdateDamageIcon()
M.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
else
var/damage = rand(5, 10)
if (prob(40))
@@ -693,7 +697,7 @@
src.health = 100 - src.oxyloss - src.fireloss - src.bruteloss
for(var/mob/O in viewers(src, null))
O.show_message(text("\red <B>[] is attacking []!</B>", M, src), 1)
meteorhit(obj/O as obj)
for(var/mob/M in viewers(src, null))
@@ -751,7 +755,7 @@
user.machine = null
user.reset_view(null)
return 0
if (t == "Cancel")
user.machine = null
user.reset_view(null)
@@ -767,7 +771,7 @@
spawn( 5 )
attack_ai(user)
return
else if (istype(selected, /mob/drone))
user.machine = null
user.reset_view(null)
@@ -813,8 +817,8 @@
var/total = 0
total += 0.25
return total
switch_hud()
if (src.hud_used == main_hud)
src.fire.icon = 'screen.dmi'
@@ -829,12 +833,12 @@
src.healths.icon = 'screen1.dmi'
src.toxin.icon = 'screen1.dmi'
return
//block the take-off/put-on dialog
show_inv(mob/user as mob)
return
/mob/human/proc/AIize()
if (src.monkeyizing)
@@ -859,7 +863,7 @@
src.toxin.screen_loc = "15,10"
src.fire.screen_loc = "15,8"
src.healths.screen_loc = "15,5"
src.monkeyizing = 1
src.canmove = 0
src.icon = null
+66 -6
View File
@@ -2,8 +2,8 @@
//Todo:
/*
re-test: Drone hears garbled speech.
Add throw button, intent buttons to drone GUI, button for releasing pull
Drone needs meteor damage, explosion damage, and laser damage
Drone pull/grab should only work if gripper is empty
Take-off dialog for taking things off others should work, except humans controlling a drone should have a high chance of failure and harming the person instead.
should lose drone control upon going unconscious (it's already lost upon death), and also if the user is pulled/moves away from the control station
@@ -16,15 +16,17 @@
Held jetpack with flight system turned on doesn't work for drone - appears to be due to lack of internal air
(Before these are implemented, the AI just has a damage bonus applied when it is controlling a drone)
Implement AI-controlled drone precision attacks:
screwdriver to heart? protected by armor (may break screwdriver tool permanently), reduced damage from other suits.
lit welder to eyes? protected by helmets?
crowbar to whack items out of opponents' hands, when there's anything in them, and send them flying. If not, does damage normally to the normal area.
wrench targets kneecaps for bonus damage, knocking down, etc.
when using screwdriver, auto-aim for heart? protected by armor (may break screwdriver tool permanently), reduced damage from other suits.
when using welder, auto-aim for eyes? protected by helmets?
when using crowbar, auto-aim to whack/pull items out of opponents' hands, when there's anything in them, and send them flying. If not, does damage normally to the normal area.
when using wrench, auto-aim for kneecaps for bonus damage, knocking down, etc.
wirecutters don't have a precision attack or even work well for attacking at all (one would think), and are likely to break if used.
If drone gets ahold of a laser gun or loaded revolver, an AI controller will be able to precision aim it as well.
Note to be very clear: If a human is controlling the drone, they do not get any of those precision bonus attacks. Those are only applied if the AI is controlling the drone.
Todo: When attempting to speak while controlling a drone, it should send the speech from the controller, unless you use [d], in which case the drone should say it.
*/
/mob/drone
@@ -397,6 +399,12 @@
abiotic()
return 1
say(message as text)
if (src.controlledBy)
if (istype(src.controlledBy, /mob/human) || istype(src.controlledBy, /mob/monkey) || istype(src.controlledBy, /mob/ai))
usr = src.controlledBy
src.controlledBy.say(message)
proc/takeControl(var/mob/user)
if (user.client)
@@ -673,7 +681,59 @@
show_inv(mob/user as mob)
return
meteorhit(obj/O as obj)
for(var/mob/M in viewers(src, null))
M.show_message(text("\red [] has been hit by []", src, O), 1)
//Foreach goto(19)
if (src.health > 0)
src.bruteloss += 30
if ((O.icon_state == "flaming"))
src.fireloss += 40
src.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
return
las_act(flag)
if (flag == "bullet")
if (src.stat != 2)
src.bruteloss += 60
src.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
src.weakened = 10
if (flag)
if (prob(75))
src.stunned = 15
else
src.weakened = 15
else
if (src.stat != 2)
src.bruteloss += 20
src.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
if (prob(25))
src.stunned = 1
return
ex_act(severity)
flick("flash", src.flash)
var/b_loss = 0
var/f_loss = 0
switch(severity)
if(1.0)
if (src.stat != 2)
b_loss += 100
f_loss += 100
if(2.0)
if (src.stat != 2)
b_loss += 60
f_loss += 60
if(3.0)
if (src.stat != 2)
b_loss += 30
else
return
src.bruteloss += b_loss
src.fireloss += f_loss
src.health = 100 - src.oxyloss - src.toxloss - src.fireloss - src.bruteloss
/obj/item/weapon/drone/aiInterface
name = "AI Interface"
icon = 'drone.dmi'
+9 -1
View File
@@ -94,7 +94,11 @@
/obj/shuttle/door/verb/open()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
if (src.operating)
return
@@ -114,6 +118,10 @@
/obj/shuttle/door/proc/close()
set src in oview(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
src.add_fingerprint(usr)
if (src.operating)
+24 -4
View File
@@ -33,7 +33,11 @@
if(stat & (NOPOWER|BROKEN) )
return
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
var/list/L = list( )
for(var/obj/item/weapon/radio/R in world)
if (R.freq != freq)
@@ -67,6 +71,10 @@
if(stat & (NOPOWER|BROKEN) )
return
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
if (t)
src.id = t
return
@@ -136,7 +144,11 @@
/obj/machinery/teleport/station/verb/engage()
set src in oview(1)
if(stat & NOPOWER) return
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
var/atom/l = src.loc
var/atom/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com)
@@ -151,7 +163,11 @@
/obj/machinery/teleport/station/verb/disengage()
set src in oview(1)
if(stat & NOPOWER) return
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
var/atom/l = src.loc
var/atom/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com)
@@ -166,7 +182,11 @@
set src in oview(1)
if(stat & NOPOWER) return
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
var/atom/l = src.loc
var/obj/machinery/teleport/hub/com = locate(/obj/machinery/teleport/hub, locate(l.x + 1, l.y, l.z))
if (com && !active)
+15 -14
View File
@@ -63,12 +63,12 @@
if (istype(src.loc, /mob))
attack_self(src.loc)
else
src.updateDialog()
src.updateSelfDialog(src)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
src.updateDialog()
src.updateSelfDialog(src.master)
src.add_fingerprint(usr)
else
usr.client_mob() << browse(null, "window=infra_sensor")
@@ -178,15 +178,12 @@
if (istype(src.loc, /mob))
attack_self(src.loc)
else
src.updateDialog()
src.updateSelfDialog(src)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
for(var/mob/M in viewers(1, src.master))
if (M.client)
src.attack_self(M)
//Foreach goto(310)
src.updateSelfDialog(src.master)
else
usr.client_mob() << browse(null, "window=prox")
return
@@ -321,12 +318,12 @@
if (istype(src.loc, /mob))
attack_self(src.loc)
else
src.updateDialog()
src.updateSelfDialog(src)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
src.updateDialog()
src.updateSelfDialog(src.master)
else
usr.client_mob() << browse(null, "window=infra")
return
@@ -407,12 +404,12 @@
if (istype(src.loc, /mob))
attack_self(src.loc)
else
updateDialog()
src.updateSelfDialog(src)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
src.updateDialog()
src.updateSelfDialog(src.master)
else
//If it's not timing, reset the icon so it doesn't look like it's still about to go off.
src.c_state(0)
@@ -507,12 +504,12 @@
if (istype(src.loc, /mob))
attack_self(src.loc)
else
src.updateDialog()
src.updateSelfDialog(src)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
src.updateDialog()
src.updateSelfDialog(src.master)
src.add_fingerprint(usr)
else
usr.client_mob() << browse(null, "window=timer")
@@ -989,7 +986,11 @@
/obj/item/weapon/assembly/m_i_ptank/verb/Arm()
set src in view(1)
var/result = src.canReach(usr, null, 1)
if (result==0)
usr.client_mob() << "You can't reach [src]."
return
usr.show_message("\blue The proximity sensor has been armed with a delay of 15 seconds.", 1)
src.icon_state = "m_i_ptank2"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB