Merge pull request #589 from Zuhayr/master

Ports aiming rewrite.
This commit is contained in:
Neerti
2015-12-15 20:57:54 -05:00
30 changed files with 478 additions and 885 deletions
-1
View File
@@ -38,7 +38,6 @@
icons.Add(usr.gun_setting_icon)
icons.Add(usr.item_use_icon)
icons.Add(usr.gun_move_icon)
icons.Add(usr.gun_run_icon)
icons.Add(usr.radio_use_icon)
var/icon/ic = all_ui_styles[UI_style_new]
@@ -851,7 +851,6 @@
return 0
// AIs are a bit slower than regular and ignore move intent.
wearer.last_move_intent = world.time + ai_controlled_move_delay
wearer_move_delay = world.time + ai_controlled_move_delay
var/tickcomp = 0
@@ -5,8 +5,8 @@
slot = "utility"
var/obj/item/holstered = null
/obj/item/clothing/accessory/holster/proc/holster(obj/item/I, mob/user as mob)
if(holstered)
/obj/item/clothing/accessory/holster/proc/holster(var/obj/item/I, var/mob/living/user)
if(holstered && istype(user))
user << "<span class='warning'>There is already \a [holstered] holstered here!</span>"
return
@@ -14,6 +14,8 @@
user << "<span class='warning'>[I] won't fit in [src]!</span>"
return
if(istype(user))
user.stop_aiming(no_message=1)
holstered = I
user.drop_from_inventory(holstered)
holstered.loc = src
+1
View File
@@ -165,6 +165,7 @@ var/list/slot_equipment_priority = list( \
// Removes an item from inventory and places it in the target atom.
// If canremove or other conditions need to be checked then use unEquip instead.
/mob/proc/drop_from_inventory(var/obj/item/W, var/atom/Target = null)
if(W)
if(!Target)
Target = loc
@@ -49,6 +49,8 @@
if(shock_stage >= 10) tally += 3
if(aiming && aiming.aiming_at) tally += 5 // Iron sights make you slower, it's a well-known fact.
if(FAT in src.mutations)
tally += 1.5
if (bodytemperature < 283.222)
@@ -429,17 +429,6 @@ var/global/list/damage_icon_parts = list()
overlays_standing[MUTATIONS_LAYER] = null
if(update_icons) update_icons()
//Call when target overlay should be added/removed
/mob/living/carbon/human/update_targeted(var/update_icons=1)
if (targeted_by && target_locked)
overlays_standing[TARGETED_LAYER] = target_locked
else if (!targeted_by && target_locked)
qdel(target_locked)
if (!targeted_by)
overlays_standing[TARGETED_LAYER] = null
if(update_icons) update_icons()
/* --------------------------------------- */
//For legacy support.
/mob/living/carbon/human/regenerate_icons()
@@ -703,14 +703,6 @@
icon_state = module_sprites[icontype]
return
//Call when target overlay should be added/removed
/mob/living/silicon/robot/update_targeted()
if(!targeted_by && target_locked)
qdel(target_locked)
updateicon()
if (targeted_by && target_locked)
overlays += target_locked
/mob/living/silicon/robot/proc/installed_modules()
if(weapon_lock)
src << "\red Weapon lock active, unable to use modules! Count:[weaponlock_time]"
@@ -365,14 +365,6 @@
return (0)
return 1
//Call when target overlay should be added/removed
/mob/living/simple_animal/update_targeted()
if(!targeted_by && target_locked)
qdel(target_locked)
overlays = null
if (targeted_by && target_locked)
overlays += target_locked
/mob/living/simple_animal/say(var/message)
var/verb = "says"
if(speak_emote.len)
+2 -3
View File
@@ -39,7 +39,6 @@
pain = null
item_use_icon = null
gun_move_icon = null
gun_run_icon = null
gun_setting_icon = null
spell_masters = null
zone_sel = null
@@ -765,8 +764,8 @@
if(lying)
density = 0
drop_l_hand()
drop_r_hand()
if(l_hand) unEquip(l_hand)
if(r_hand) unEquip(r_hand)
else
density = initial(density)
+1 -1
View File
@@ -265,7 +265,7 @@
return 0
move_delay = world.time//set move delay
mob.last_move_intent = world.time + 10
switch(mob.m_intent)
if("run")
if(mob.drowsyness > 0)
+11 -11
View File
@@ -107,7 +107,7 @@
if(process_projectile(P, user, user, pick("l_foot", "r_foot")))
handle_post_fire(user, user)
user.visible_message(
"<span class='danger'>[user] shoots \himself in the foot with \the [src]!</span>",
"<span class='danger'>\The [user] shoots \himself in the foot with \the [src]!</span>",
"<span class='danger'>You shoot yourself in the foot with \the [src]!</span>"
)
M.drop_item()
@@ -123,17 +123,17 @@
/obj/item/weapon/gun/afterattack(atom/A, mob/living/user, adjacent, params)
if(adjacent) return //A is adjacent, is the user, or is on the user's person
//decide whether to aim or shoot normally
var/aiming = 0
if(user && user.client && !(A in aim_targets))
if(user.client.gun_mode)
aiming = PreFire(A,user,params) //They're using the new gun system, locate what they're aiming at.
if(!user.aiming)
user.aiming = new(user)
if (!aiming)
if(user && user.a_intent == I_HELP) //regardless of what happens, refuse to shoot if help intent is on
user << "\red You refrain from firing your [src] as your intent is set to help."
else
Fire(A,user,params) //Otherwise, fire normally.
if(user && user.client && user.aiming && user.aiming.active && user.aiming.aiming_at != A)
PreFire(A,user,params) //They're using the new gun system, locate what they're aiming at.
return
if(user && user.a_intent == I_HELP) //regardless of what happens, refuse to shoot if help intent is on
user << "<span class='warning'>You refrain from firing your [src] as your intent is set to help.</span>"
else
Fire(A,user,params) //Otherwise, fire normally.
/obj/item/weapon/gun/attack(atom/A, mob/living/user, def_zone)
if (A == user && user.zone_sel.selecting == "mouth" && !mouthshoot)
-407
View File
@@ -1,407 +0,0 @@
/obj/item/weapon/gun/verb/toggle_firerate()
set name = "Toggle Continue Aiming"
set category = "Object"
keep_aim = !keep_aim
if (keep_aim)
loc << "You will now continue firing when your target moves."
else
loc << "You will now only fire once, then lower your aim, when your target moves."
/obj/item/weapon/gun/verb/lower_aim()
set name = "Lower Aim"
set category = "Object"
if(aim_targets)
stop_aim()
usr.visible_message("<span class='notice'> \The [usr] lowers \the [src]...</span>")
//Removing the lock and the buttons.
/obj/item/weapon/gun/dropped(mob/user as mob)
stop_aim()
if(user && user.client)
user.client.remove_gun_icons()
return ..()
/obj/item/weapon/gun/equipped(var/mob/user, var/slot)
if (slot != slot_l_hand && slot != slot_r_hand)
stop_aim()
if (user.client)
user.client.remove_gun_icons()
return ..()
//Removes lock from all targets
/obj/item/weapon/gun/proc/stop_aim()
if(aim_targets)
for(var/mob/living/M in aim_targets)
if(M)
M.NotTargeted(src) //Untargeting people.
aim_targets = null
//Compute how to fire.....
//Return 1 if a target was found, 0 otherwise.
/obj/item/weapon/gun/proc/PreFire(atom/A as mob|obj|turf|area, mob/living/user as mob|obj, params)
//Lets not spam it.
if(lock_time > world.time - 2) return
user.set_dir(get_cardinal_dir(src, A))
if(isliving(A) && !(A in aim_targets))
Aim(A) //Clicked a mob, aim at them
return 1
//Didn't click someone, check if there is anyone along that guntrace
var/mob/living/M = GunTrace(usr.x,usr.y,A.x,A.y,usr.z,usr) //Find dat mob.
if(isliving(M) && (M in view(user)) && !(M in aim_targets))
Aim(M) //Aha! Aim at them!
return 1
return 0
//Aiming at the target mob.
/obj/item/weapon/gun/proc/Aim(var/mob/living/M)
if(!aim_targets || !(M in aim_targets))
admin_attack_log(usr, M, "Pointed a [src] at [M]", "Had a [src] aimed at them, by [usr]", "aims a gun ([src]) (MODE: [src.mode_name]) at")
lock_time = world.time
if(aim_targets && !multi_aim) //If they're targeting someone and they have a non multi_aim weapon.
for(var/mob/living/L in aim_targets)
if(L)
L.NotTargeted(src)
aim_targets = null
usr.visible_message("<span class='danger'><b>[usr] turns \the [src] on [M]!</b></span>")
else
usr.visible_message("<span class='danger'><b>[usr] aims \a [src] at [M]!</b></span>")
M.Targeted(src)
//HE MOVED, SHOOT HIM!
/obj/item/weapon/gun/proc/TargetActed(var/mob/living/T)
var/mob/living/M = loc
if(M == T) return
if(!istype(M)) return
if(src != M.get_active_hand())
stop_aim()
return
//reflex firing is disabled when help intent is set
if (M.a_intent == I_HELP)
M << "<span class='danger'>You refrain from firing your [src] as your intent is set to help.</span>"
return
M.last_move_intent = world.time
var/firing_check = can_hit(T,usr) //0 if it cannot hit them, 1 if it is capable of hitting, and 2 if a special check is preventing it from firing.
if(firing_check > 0)
if(firing_check == 1)
Fire(T,usr, reflex = 1)
else if(!told_cant_shoot)
M << "<span class='danger'>They can't be hit from here!</span>"
told_cant_shoot = 1
spawn(30)
told_cant_shoot = 0
usr.set_dir(get_cardinal_dir(src, T))
if (!keep_aim) // If keep_aim is set to lower aim after one shot, untarget the target
T.NotTargeted(src)
//Yay, math!
#define SIGN(X) ((X<0)?-1:1)
/proc/GunTrace(X1,Y1,X2,Y2,Z=1,exc_obj,PX1=16,PY1=16,PX2=16,PY2=16)
//bluh << "Tracin' [X1],[Y1] to [X2],[Y2] on floor [Z]."
var/turf/T
var/mob/living/M
if(X1==X2)
if(Y1==Y2) return 0 //Light cannot be blocked on same tile
else
var/s = SIGN(Y2-Y1)
Y1+=s
while(1)
T = locate(X1,Y1,Z)
if(!T) return 0
M = locate() in T
if(M) return M
M = locate() in orange(1,T)-exc_obj
if(M) return M
Y1+=s
else
var
m=(32*(Y2-Y1)+(PY2-PY1))/(32*(X2-X1)+(PX2-PX1))
b=(Y1+PY1/32-0.015625)-m*(X1+PX1/32-0.015625) //In tiles
signX = SIGN(X2-X1)
signY = SIGN(Y2-Y1)
if(X1<X2) b+=m
while(1)
var/xvert = round(m*X1+b-Y1)
if(xvert) Y1+=signY //Line exits tile vertically
else X1+=signX //Line exits tile horizontally
T = locate(X1,Y1,Z)
if(!T) return 0
M = locate() in T
if(M) return M
M = locate() in orange(1,T)-exc_obj
if(M) return M
return 0
//Targeting management procs
/mob/var
list/targeted_by
target_time = -100
last_move_intent = -100
last_target_click = -5
target_locked = null
last_target_radio = -5;
/mob/living/proc/Targeted(var/obj/item/weapon/gun/I) //Self explanitory.
if(!I.aim_targets)
I.aim_targets = list(src)
else if(I.multi_aim && I.aim_targets.len < 5) //multi_aim weapon, they can hold down a room.
I.aim_targets += src
else if(I.aim_targets.len >= 5)
if(ismob(I.loc))
I.loc << "You can only target 5 people at once!"
return
else
return
for(var/mob/living/K in viewers(usr))
K << 'sound/weapons/TargetOn.ogg'
if(!targeted_by) targeted_by = list()
targeted_by += I
I.lock_time = world.time + 20 //Target has 2 second to realize they're targeted and stop (or target the opponent).
src << "((<span class='danger'><b>Your character is being targeted. They have 2 seconds to stop any click or move actions.</b></span> While targeted, they may \
drag and drop items in or into the map, speak, and click on interface buttons. Clicking on the map objects (floors and walls are fine), their items \
(other than a weapon to de-target), moving, or talking into a radio will result in being fired upon. <span class='danger'>The aggressor may also fire manually, \
so try not to get on their bad side.</span>))"
if(targeted_by.len == 1)
spawn(0)
target_locked = image("icon" = 'icons/effects/Targeted.dmi', "icon_state" = "locking")
overlays += target_locked
spawn(0)
sleep(20)
if(target_locked)
target_locked = image("icon" = 'icons/effects/Targeted.dmi', "icon_state" = "locked")
update_targeted()
//Adding the buttons to the controller person
var/mob/living/T = I.loc
if(T)
if(T.client)
T.client.add_gun_icons()
else
I.lower_aim()
return
if(iscarbon(src) && m_intent == "run" && T.client.target_can_move == 1 && T.client.target_can_run == 0)
src << "<span class='danger'>Your move intent is now set to walk, as your targeter permits it.</span>" //Self explanitory.
set_m_intent("walk")
//Processing the aiming. Should be probably in separate object with process() but lasy.
while(targeted_by && T.client)
if(last_move_intent > I.lock_time + 10 && !T.client.target_can_move) //If target moved when not allowed to
I.TargetActed(src)
if(I.last_moved_mob == src) //If they were the last ones to move, give them more of a grace period, so that an automatic weapon can hold down a room better.
I.lock_time = world.time + 5
I.lock_time = world.time + 5
I.last_moved_mob = src
else if(last_move_intent > I.lock_time + 10 && !T.client.target_can_run && m_intent == "run") //If the target ran while targeted
I.TargetActed(src)
if(I.last_moved_mob == src) //If they were the last ones to move, give them more of a grace period, so that an automatic weapon can hold down a room better.
I.lock_time = world.time + 5
I.lock_time = world.time + 5
I.last_moved_mob = src
if(last_target_click > I.lock_time + 10 && !T.client.target_can_click) //If the target clicked the map to pick something up/shoot/etc
I.TargetActed(src)
if(I.last_moved_mob == src) //If they were the last ones to move, give them more of a grace period, so that an automatic weapon can hold down a room better.
I.lock_time = world.time + 5
I.lock_time = world.time + 5
I.last_moved_mob = src
if(last_target_radio > I.lock_time + 10 && !T.client.target_can_radio)
I.TargetActed(src)
if(I.last_moved_mob == src) //If they were the last ones to move, give them more of a grace period, so that an automatic weapon can hold down a room better.
I.lock_time = world.time + 5
I.lock_time = world.time + 5
I.last_moved_mob = src
sleep(1)
/mob/living/proc/NotTargeted(var/obj/item/weapon/gun/I)
if(!I.silenced)
for(var/mob/living/M in viewers(src))
M << 'sound/weapons/TargetOff.ogg'
targeted_by -= I
I.aim_targets.Remove(src) //De-target them
if(!I.aim_targets.len)
I.aim_targets = null
var/mob/living/T = I.loc //Remove the targeting icons
if(T && ismob(T) && !I.aim_targets && T.client)
T.client.remove_gun_icons()
if(!targeted_by.len)
qdel(target_locked) //Remove the overlay
targeted_by.Cut()
spawn(1) update_targeted()
/mob/living/Move()
. = ..()
for(var/obj/item/weapon/gun/G in targeted_by) //Handle moving out of the gunner's view.
var/mob/living/M = G.loc
if(!(M in view(src)))
NotTargeted(G)
for(var/obj/item/weapon/gun/G in src) //Handle the gunner loosing sight of their target/s
if(G.aim_targets)
for(var/mob/living/M in G.aim_targets)
if(M && !(M in view(src)))
M.NotTargeted(G)
//If you move out of range, it isn't going to still stay locked on you any more.
/client/var
target_can_move = 0
target_can_run = 0
target_can_click = 0
target_can_radio = 0
gun_mode = 0
//These are called by the on-screen buttons, adjusting what the victim can and cannot do.
/client/proc/add_gun_icons()
if(!usr) return 1 // This can runtime if someone manages to throw a gun out of their hand before the proc is called.
screen += usr.item_use_icon
screen += usr.gun_move_icon
screen += usr.radio_use_icon
if (target_can_move)
screen += usr.gun_run_icon
/client/proc/remove_gun_icons()
if(!usr) return 1 // Runtime prevention on N00k agents spawning with SMG
screen -= usr.item_use_icon
screen -= usr.gun_move_icon
screen -= usr.radio_use_icon
if (target_can_move)
screen -= usr.gun_run_icon
/client/verb/ToggleGunMode()
set name = "Toggle Gun Mode"
set hidden = 1
gun_mode = !gun_mode
if(gun_mode)
usr << "You will now take people captive."
else
usr << "You will now shoot where you target."
for(var/obj/item/weapon/gun/G in usr)
G.stop_aim()
remove_gun_icons()
if(usr.gun_setting_icon)
usr.gun_setting_icon.icon_state = "gun[gun_mode]"
/client/verb/AllowTargetMove()
set hidden=1
//Changing client's permissions
target_can_move = !target_can_move
if(target_can_move)
usr << "Target may now walk."
//usr.gun_run_icon = new /obj/screen/gun/run(null) //adding icon for running permission
screen += usr.gun_run_icon
else
usr << "Target may no longer move."
target_can_run = 0
qdel(usr.gun_run_icon) //no need for icon for running permission
//Updating walking permission button
if(usr.gun_move_icon)
usr.gun_move_icon.icon_state = "no_walk[target_can_move]"
usr.gun_move_icon.name = "[target_can_move ? "Disallow" : "Allow"] Walking"
//Handling change for all the guns on client
for(var/obj/item/weapon/gun/G in usr)
G.lock_time = world.time + 5
if(G.aim_targets)
for(var/mob/living/M in G.aim_targets)
if(target_can_move)
M << "Your character may now <b>walk</b> at the discretion of their targeter."
if(!target_can_run)
M << "<span class='danger'>Your move intent is now set to walk, as your targeter permits it.</span>"
M.set_m_intent("walk")
else
M << "<span class='danger'><b>Your character will now be shot if they move.</b></span>"
/mob/living/proc/set_m_intent(var/intent)
if (intent != "walk" && intent != "run")
return 0
m_intent = intent
if(hud_used)
if (hud_used.move_intent)
hud_used.move_intent.icon_state = intent == "walk" ? "walking" : "running"
client/verb/AllowTargetRun()
set hidden=1
//Changing client's permissions
target_can_run = !target_can_run
if(target_can_run)
usr << "Target may now run."
else
usr << "Target may no longer run."
//Updating running permission button
if(usr.gun_run_icon)
usr.gun_run_icon.icon_state = "no_run[target_can_run]"
usr.gun_run_icon.name = "[target_can_run ? "Disallow" : "Allow"] Running"
//Handling change for all the guns on client
for(var/obj/item/weapon/gun/G in src)
G.lock_time = world.time + 5
if(G.aim_targets)
for(var/mob/living/M in G.aim_targets)
if(target_can_run)
M << "Your character may now <b>run</b> at the discretion of their targeter."
else
M << "<span class='danger'><b>Your character will now be shot if they run.</b></span>"
/client/verb/AllowTargetClick()
set hidden=1
//Changing client's permissions
target_can_click = !target_can_click
if(target_can_click)
usr << "Target may now use items."
else
usr << "Target may no longer use items."
if(usr.item_use_icon)
usr.item_use_icon.icon_state = "no_item[target_can_click]"
usr.item_use_icon.name = "[target_can_click ? "Disallow" : "Allow"] Item Use"
//Handling change for all the guns on client
for(var/obj/item/weapon/gun/G in src)
G.lock_time = world.time + 5
if(G.aim_targets)
for(var/mob/living/M in G.aim_targets)
if(target_can_click)
M << "Your character may now <b>use items</b> at the discretion of their targeter."
else
M << "<span class='danger'><b>Your character will now be shot if they use items.</b></span>"
/client/verb/AllowTargetRadio()
set hidden=1
target_can_radio = !target_can_radio
if(target_can_radio)
usr << "Target may now use radio."
else
usr << "Target may no longer use radio."
if(usr.radio_use_icon)
usr.radio_use_icon.icon_state = "no_radio[target_can_radio]"
usr.radio_use_icon.name = "[target_can_radio ? "Disallow" : "Allow"] Radio Use"
//Handling change for all the guns on client
for(var/obj/item/weapon/gun/G in src)
G.lock_time = world.time + 5
if(G.aim_targets)
for(var/mob/living/M in G.aim_targets)
if(target_can_radio)
M << "Your character may now <b>use the radio</b> at the discretion of their targeter."
else
M << "<span class='danger'><b>Your character will now be shot if they use the radio.</b></span>"
@@ -0,0 +1,12 @@
//These are called by the on-screen buttons, adjusting what the victim can and cannot do.
/client/proc/add_gun_icons()
if(!usr) return 1 // This can runtime if someone manages to throw a gun out of their hand before the proc is called.
screen |= usr.item_use_icon
screen |= usr.gun_move_icon
screen |= usr.radio_use_icon
/client/proc/remove_gun_icons()
if(!usr) return 1 // Runtime prevention on N00k agents spawning with SMG
screen -= usr.item_use_icon
screen -= usr.gun_move_icon
screen -= usr.radio_use_icon
@@ -0,0 +1,21 @@
//Removing the lock and the buttons.
/obj/item/weapon/gun/dropped(var/mob/living/user)
if(istype(user))
user.stop_aiming(src)
return ..()
/obj/item/weapon/gun/equipped(var/mob/living/user, var/slot)
if(istype(user) && (slot != slot_l_hand && slot != slot_r_hand))
user.stop_aiming(src)
return ..()
//Compute how to fire.....
//Return 1 if a target was found, 0 otherwise.
/obj/item/weapon/gun/proc/PreFire(var/atom/A, var/mob/living/user, var/params)
if(!user.aiming)
user.aiming = new(user)
user.face_atom(A)
if(ismob(A) && user.aiming)
user.aiming.aim_at(A, src)
return 1
return 0
@@ -0,0 +1,52 @@
/mob/living/var/obj/aiming_overlay/aiming
/mob/living/var/list/aimed = list()
/mob/living/proc/stop_aiming(var/obj/item/thing, var/no_message = 0)
if(!aiming)
aiming = new(src)
if(thing && aiming.aiming_with != thing)
return
aiming.cancel_aiming(no_message)
/mob/living/death(gibbed,deathmessage="seizes up and falls limp...")
if(..())
stop_aiming(no_message=1)
/mob/living/update_canmove()
..()
if(lying)
stop_aiming(no_message=1)
/mob/living/Weaken(amount)
stop_aiming(no_message=1)
..()
/mob/living/Destroy()
if(aiming)
qdel(aiming)
aiming = null
aimed.Cut()
return ..()
/turf/Enter(var/mob/living/mover)
. = ..()
if(istype(mover))
if(mover.aiming && mover.aiming.aiming_at)
mover.aiming.update_aiming()
if(mover.aimed.len)
mover.trigger_aiming(TARGET_CAN_MOVE)
/mob/living/forceMove(var/atom/destination)
. = ..()
if(aiming && aiming.aiming_at)
aiming.update_aiming()
if(aimed.len)
trigger_aiming(TARGET_CAN_MOVE)
/mob/living/proc/set_m_intent(var/intent)
if (intent != "walk" && intent != "run")
return 0
m_intent = intent
if(hud_used)
if (hud_used.move_intent)
hud_used.move_intent.icon_state = intent == "walk" ? "walking" : "running"
@@ -0,0 +1,213 @@
/obj/aiming_overlay
name = "target indicator"
desc = "Stick 'em up!"
icon = 'icons/effects/Targeted.dmi'
icon_state = "locking"
anchored = 1
density = 0
opacity = 0
layer = FLY_LAYER
simulated = 0
var/mob/living/aiming_at // Who are we currently targeting, if anyone?
var/obj/item/aiming_with // What are we targeting with?
var/mob/owner // Who do we belong to?
var/locked = 0 // Have we locked on?
var/lock_time = 0 // When -will- we lock on?
var/active = 0 // Is our owner intending to take hostages?
var/target_permissions = 0 // Permission bitflags.
/obj/aiming_overlay/New(var/newowner)
..()
owner = newowner
loc = null
/obj/aiming_overlay/proc/toggle_permission(var/perm)
if(target_permissions & perm)
target_permissions &= ~perm
else
target_permissions |= perm
// Update HUD icons.
if(owner.gun_move_icon)
if(!(target_permissions & TARGET_CAN_MOVE))
owner.gun_move_icon.icon_state = "no_walk0"
owner.gun_move_icon.name = "Allow Movement"
else
owner.gun_move_icon.icon_state = "no_walk1"
owner.gun_move_icon.name = "Disallow Movement"
if(owner.item_use_icon)
if(!(target_permissions & TARGET_CAN_CLICK))
owner.item_use_icon.icon_state = "no_item0"
owner.item_use_icon.name = "Allow Item Use"
else
owner.item_use_icon.icon_state = "no_item1"
owner.item_use_icon.name = "Disallow Item Use"
if(owner.radio_use_icon)
if(!(target_permissions & TARGET_CAN_RADIO))
owner.radio_use_icon.icon_state = "no_radio0"
owner.radio_use_icon.name = "Allow Radio Use"
else
owner.radio_use_icon.icon_state = "no_radio1"
owner.radio_use_icon.name = "Disallow Radio Use"
var/message = "no longer permitted to "
var/use_span = "warning"
if(target_permissions & perm)
message = "now permitted to "
use_span = "notice"
switch(perm)
if(TARGET_CAN_MOVE)
message += "move"
if(TARGET_CAN_CLICK)
message += "use items"
if(TARGET_CAN_RADIO)
message += "use a radio"
else
return
owner << "<span class='[use_span]'>[aiming_at ? "\The [aiming_at] is" : "Your targets are"] [message].</span>"
if(aiming_at)
aiming_at << "<span class='[use_span]'>You are [message].</span>"
/obj/aiming_overlay/process()
if(!owner)
qdel(src)
return
..()
update_aiming()
/obj/aiming_overlay/Destroy()
if(aiming_at)
aiming_at.aimed -= src
aiming_at = null
owner = null
aiming_with = null
processing_objects -= src
return ..()
obj/aiming_overlay/proc/update_aiming_deferred()
set waitfor = 0
sleep(0)
update_aiming()
/obj/aiming_overlay/proc/update_aiming()
if(!owner)
qdel(src)
return
if(!aiming_at)
cancel_aiming()
return
if(!locked && lock_time >= world.time)
locked = 1
update_icon()
var/cancel_aim = 1
if(!(aiming_with in owner) || (owner.l_hand != aiming_with && owner.r_hand != aiming_with))
owner << "<span class='warning'>You must keep hold of your weapon!</span>"
else if(!aiming_at || !istype(aiming_at.loc, /turf))
owner << "<span class='warning'>You have lost sight of your target!</span>"
else if(owner.incapacitated() || owner.lying || owner.restrained())
owner << "<span class='warning'>You must be conscious and standing to keep track of your target!</span>"
else if(aiming_at.alpha == 0 || (aiming_at.invisibility > owner.see_invisible))
owner << "<span class='warning'>Your target has become invisible!</span>"
else if(get_dist(get_turf(owner), get_turf(aiming_at)) > 7) // !(owner in viewers(aiming_at, 7))
owner << "<span class='warning'>Your target is too far away to track!</span>"
else
cancel_aim = 0
forceMove(get_turf(aiming_at))
if(cancel_aim)
cancel_aiming()
return
if(!owner.incapacitated() && owner.client)
spawn(0)
owner.set_dir(get_dir(get_turf(owner), get_turf(src)))
/obj/aiming_overlay/proc/aim_at(var/mob/target, var/obj/thing)
if(!owner)
return
if(owner.incapacitated())
owner << "<span class='warning'>You cannot aim a gun in your current state.</span>"
return
if(owner.lying)
owner << "<span class='warning'>You cannot aim a gun while prone.</span>"
return
if(owner.restrained())
owner << "<span class='warning'>You cannot aim a gun while handcuffed.</span>"
return
if(aiming_at)
if(aiming_at == target)
return
aiming_at.aimed -= src
owner.visible_message("<span class='danger'>\The [owner] turns \the [thing] on \the [target]!</span>")
else
owner.visible_message("<span class='danger'>\The [owner] aims \the [thing] at \the [target]!</span>")
if(owner.client)
owner.client.add_gun_icons()
target << "<span class='danger'>You now have a gun pointed at you. No sudden moves!</span>"
aiming_with = thing
aiming_at = target
if(istype(aiming_with, /obj/item/weapon/gun))
playsound(get_turf(owner), 'sound/weapons/TargetOn.ogg', 50,1)
forceMove(get_turf(target))
processing_objects |= src
aiming_at.aimed |= src
toggle_active(1)
locked = 0
update_icon()
lock_time = world.time + 35
/obj/aiming_overlay/update_icon()
if(locked)
icon_state = "locked"
else
icon_state = "locking"
/obj/aiming_overlay/proc/toggle_active(var/force_state = null)
if(!isnull(force_state))
if(active == force_state)
return
active = force_state
else
active = !active
if(!active)
cancel_aiming()
if(owner.client)
if(active)
owner << "<span class='notice'>You will now aim rather than fire.</span>"
owner.client.add_gun_icons()
else
owner << "<span class='notice'>You will no longer aim rather than fire.</span>"
owner.client.remove_gun_icons()
/obj/aiming_overlay/proc/cancel_aiming(var/no_message = 0)
if(!aiming_with || !aiming_at)
return
if(istype(aiming_with, /obj/item/weapon/gun))
playsound(get_turf(owner), 'sound/weapons/TargetOff.ogg', 50,1)
if(!no_message)
owner.visible_message("<span class='notice'>\The [owner] lowers \the [aiming_with].</span>")
aiming_with = null
aiming_at.aimed -= src
aiming_at = null
loc = null
processing_objects -= src
@@ -0,0 +1,29 @@
/mob/living/proc/trigger_aiming(var/trigger_type)
if(!aimed.len)
return
for(var/obj/aiming_overlay/AO in aimed)
if(AO.aiming_at == src)
AO.update_aiming()
if(AO.aiming_at == src)
AO.trigger(trigger_type)
AO.update_aiming_deferred()
/obj/aiming_overlay/proc/trigger(var/perm)
if(!owner || !aiming_with || !aiming_at || !locked)
return
if(perm && (target_permissions & perm))
return
if(!owner.canClick())
return
owner.setClickCooldown(5) // Spam prevention, essentially.
if(owner.a_intent == I_HELP)
owner << "<span class='warning'>You refrain from firing \the [aiming_with] as your intent is set to help.</span>"
return
owner.visible_message("<span class='danger'>\The [owner] pulls the trigger reflexively!</span>")
var/obj/item/weapon/gun/G = aiming_with
if(istype(G))
G.Fire(aiming_at, owner)
/mob/living/ClickOn(var/atom/A, var/params)
. = ..()
trigger_aiming(TARGET_CAN_CLICK)
+28 -26
View File
@@ -116,7 +116,7 @@
if (GM.client)
GM.client.perspective = EYE_PERSPECTIVE
GM.client.eye = src
GM.loc = src
GM.forceMove(src)
for (var/mob/C in viewers(src))
C.show_message("\red [GM.name] has been placed in the [src] by [user].", 3)
qdel(G)
@@ -132,7 +132,7 @@
user.drop_item()
if(I)
I.loc = src
I.forceMove(src)
user << "You place \the [I] into the [src]."
for(var/mob/M in viewers(src))
@@ -177,7 +177,8 @@
if (target.client)
target.client.perspective = EYE_PERSPECTIVE
target.client.eye = src
target.loc = src
target.forceMove(src)
for (var/mob/C in viewers(src))
if(C == user)
@@ -201,7 +202,7 @@
if (user.client)
user.client.eye = user.client.mob
user.client.perspective = MOB_PERSPECTIVE
user.loc = src.loc
user.forceMove(src.loc)
update()
return
@@ -310,7 +311,7 @@
// eject the contents of the disposal unit
/obj/machinery/disposal/proc/eject()
for(var/atom/movable/AM in src)
AM.loc = src.loc
AM.forceMove(src.loc)
AM.pipe_eject(0)
update()
@@ -443,7 +444,7 @@
for(var/atom/movable/AM in H)
target = get_offset_target_turf(src.loc, rand(5)-rand(5), rand(5)-rand(5))
AM.loc = src.loc
AM.forceMove(src.loc)
AM.pipe_eject(0)
if(!istype(AM,/mob/living/silicon/robot/drone)) //Poor drones kept smashing windows and taking system damage being fired out of disposals. ~Z
spawn(1)
@@ -459,7 +460,7 @@
if(istype(I, /obj/item/projectile))
return
if(prob(75))
I.loc = src
I.forceMove(src)
for(var/mob/M in viewers(src))
M.show_message("\The [I] lands in \the [src].", 3)
else
@@ -508,7 +509,7 @@
// now everything inside the disposal gets put into the holder
// note AM since can contain mobs or objs
for(var/atom/movable/AM in D)
AM.loc = src
AM.forceMove(src)
if(istype(AM, /obj/structure/bigDelivery) && !hasmob)
var/obj/structure/bigDelivery/T = AM
src.destinationTag = T.sortTag
@@ -528,7 +529,7 @@
D.expel(src) // no trunk connected, so expel immediately
return
loc = D.trunk
forceMove(D.trunk)
active = 1
set_dir(DOWN)
spawn(1)
@@ -585,7 +586,7 @@
// used when a a holder meets a stuck holder
proc/merge(var/obj/structure/disposalholder/other)
for(var/atom/movable/AM in other)
AM.loc = src // move everything in other holder to this one
AM.forceMove(src) // move everything in other holder to this one
if(ismob(AM))
var/mob/M = AM
if(M.client) // if a client mob, update eye to follow this holder
@@ -671,7 +672,7 @@
// this is unlikely, but just dump out everything into the turf in case
for(var/atom/movable/AM in H)
AM.loc = T
AM.forceMove(T)
AM.pipe_eject(0)
qdel(H)
..()
@@ -702,9 +703,9 @@
if(H2 && !H2.active)
H.merge(H2)
H.loc = P
H.forceMove(P)
else // if wasn't a pipe, then set loc to turf
H.loc = T
H.forceMove(T)
return null
return P
@@ -746,6 +747,7 @@
H.active = 0
H.loc = src
return
if(!T.is_plating() && istype(T,/turf/simulated/floor)) //intact floor, pop the tile
var/turf/simulated/floor/F = T
F.break_tile()
@@ -760,7 +762,7 @@
playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0)
if(H)
for(var/atom/movable/AM in H)
AM.loc = T
AM.forceMove(T)
AM.pipe_eject(direction)
spawn(1)
if(AM)
@@ -775,7 +777,7 @@
for(var/atom/movable/AM in H)
target = get_offset_target_turf(T, rand(5)-rand(5), rand(5)-rand(5))
AM.loc = T
AM.forceMove(T)
AM.pipe_eject(0)
spawn(1)
if(AM)
@@ -808,7 +810,7 @@
// this is unlikely, but just dump out everything into the turf in case
for(var/atom/movable/AM in H)
AM.loc = T
AM.forceMove(T)
AM.pipe_eject(0)
qdel(H)
return
@@ -929,7 +931,7 @@
// this is unlikely, but just dump out everything into the turf in case
for(var/atom/movable/AM in H)
AM.loc = T
AM.forceMove(T)
AM.pipe_eject(0)
qdel(H)
..()
@@ -990,7 +992,7 @@
if(nextdir == 12)
T = GetAbove(src)
if(!T)
H.loc = loc
H.forceMove(loc)
return
else
for(var/obj/structure/disposalpipe/down/F in T)
@@ -1006,9 +1008,9 @@
if(H2 && !H2.active)
H.merge(H2)
H.loc = P
H.forceMove(P)
else // if wasn't a pipe, then set loc to turf
H.loc = T
H.forceMove(T)
return null
return P
@@ -1040,7 +1042,7 @@
if(nextdir == 11)
T = GetBelow(src)
if(!T)
H.loc = src.loc
H.forceMove(src.loc)
return
else
for(var/obj/structure/disposalpipe/up/F in T)
@@ -1056,9 +1058,9 @@
if(H2 && !H2.active)
H.merge(H2)
H.loc = P
H.forceMove(P)
else // if wasn't a pipe, then set loc to turf
H.loc = T
H.forceMove(T)
return null
return P
@@ -1249,9 +1251,9 @@
if(H2 && !H2.active)
H.merge(H2)
H.loc = P
H.forceMove(P)
else // if wasn't a pipe, then set loc to turf
H.loc = T
H.forceMove(T)
return null
return P
@@ -1439,7 +1441,7 @@
if(H)
for(var/atom/movable/AM in H)
AM.loc = src.loc
AM.forceMove(src.loc)
AM.pipe_eject(dir)
if(!istype(AM,/mob/living/silicon/robot/drone)) //Drones keep smashing windows from being fired out of chutes. Bad for the station. ~Z
spawn(5)