|
76 | 76 | M.Targeted(src)
|
77 | 77 |
|
78 | 78 | //HE MOVED, SHOOT HIM!
|
79 |
| -/obj/item/weapon/gun/proc/TargetActed(var/mob/living/T) |
80 |
| - var/mob/living/M = loc |
81 |
| - if(M == T) |
| 79 | +/obj/item/weapon/gun/proc/TargetMoved(mob/living/mover) |
| 80 | + TargetActed(mover) //alias just so events work |
| 81 | + |
| 82 | +/obj/item/weapon/gun/proc/TargetActed(mob/living/user,modifiers,atom/target) |
| 83 | + if(world.time <= lock_time) |
82 | 84 | return
|
83 |
| - if(!istype(M)) |
| 85 | + if(target && (isturf(target) || istype(target,/obj/abstract/screen))) // these are okay to click |
84 | 86 | return
|
85 |
| - if(src != M.get_active_hand()) |
| 87 | + lock_time = world.time + 15 |
| 88 | + //if(last_moved_mob == user) //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. |
| 89 | + //lock_time = world.time + 15 //just look at the logic of this... it did nothing!!! uncomment if you want this to work again too. be sure to add the variable back. |
| 90 | + var/mob/living/M = loc |
| 91 | + if(M == user || !istype(M)) |
| 92 | + return |
| 93 | + if(!M.client || src != M.get_active_hand()) |
86 | 94 | stop_aim()
|
87 | 95 | return
|
88 |
| - M.last_move_intent = world.time |
| 96 | + if(M.client.target_can_click && target) // this var only gets filled in from the click event calls, so that's a way of knowing |
| 97 | + return |
| 98 | + if(M.client.target_can_move) |
| 99 | + if(!M.client.target_can_run && !user.locked_to && user.m_intent != "run") // if the user is relaymoving i'm pretty sure that's NOT walking |
| 100 | + return |
| 101 | + else if(!target) |
| 102 | + return |
89 | 103 | if(canbe_fired())
|
90 |
| - 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. |
| 104 | + var/firing_check = can_hit(user,M) //0 if it cannot hit them, 1 if it is capable of hitting, and 2 if a special check is preventing it from firing. |
91 | 105 | if(firing_check > 0)
|
92 | 106 | if(firing_check == 1)
|
93 |
| - Fire(T,usr, reflex = 1) |
| 107 | + Fire(user,M, reflex = 1) |
94 | 108 | else if(!told_cant_shoot)
|
95 | 109 | to_chat(M, "<span class='warning'>They can't be hit from here!</span>")
|
96 | 110 | told_cant_shoot = 1
|
|
99 | 113 | else
|
100 | 114 | click_empty(M)
|
101 | 115 |
|
102 |
| - usr.dir = get_cardinal_dir(src, T) |
| 116 | + M.dir = get_cardinal_dir(src, user) |
103 | 117 |
|
104 | 118 | if (!firerate) // If firerate is set to lower aim after one shot, untarget the target
|
105 |
| - T.NotTargeted(src) |
| 119 | + user.NotTargeted(src) |
106 | 120 |
|
107 | 121 | /proc/GunTrace(X1,Y1,X2,Y2,Z=1,exc_obj,PX1=16,PY1=16,PX2=16,PY2=16)
|
108 | 122 | // to_chat(bluh, "Tracin' [X1],[Y1] to [X2],[Y2] on floor [Z].")
|
|
153 | 167 | //Targeting management procs
|
154 | 168 | /mob
|
155 | 169 | var/list/targeted_by
|
156 |
| - var/target_time = -100 |
157 |
| - var/last_move_intent = -100 |
158 |
| - var/last_target_click = -5 |
159 | 170 | var/target_locked = null
|
160 | 171 |
|
161 | 172 | /mob/living/proc/Targeted(var/obj/item/weapon/gun/I) //Self explanitory.
|
|
176 | 187 | targeted_by = list()
|
177 | 188 | targeted_by += I
|
178 | 189 | I.lock_time = world.time + 20 //Target has 2 second to realize they're targeted and stop (or target the opponent).
|
179 |
| - to_chat(src, "((<span class='danger'>Your character is being targeted. They have 2 seconds to stop any click or move actions. </span>While targeted, they may \ |
180 |
| - 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 \ |
181 |
| - (other than a weapon to de-target), or moving will result in being fired upon. <span class='warning'>The aggressor may also fire manually, </span>\ |
182 |
| - so try not to get on their bad side.\black ))") |
183 | 190 |
|
184 | 191 | if(targeted_by.len == 1)
|
185 | 192 | spawn(0)
|
|
199 | 206 | else
|
200 | 207 | I.lower_aim()
|
201 | 208 | return
|
202 |
| - if(m_intent == "run" && T.client.target_can_move == 1 && T.client.target_can_run == 0 && (ishuman(T))) |
203 |
| - to_chat(src, "<spanclass='warning'>Your captive is allowing you to walk. Make sure to change your move intent to walk before trying to move, or you will be fired upon.</span>")//Self explanitory. |
204 |
| - |
| 209 | + var/msg = "" |
| 210 | + if(!T.client.target_can_click) |
| 211 | + msg += "While targeted, they may drag and drop items in or into the map, speak, and click on interface buttons. \ |
| 212 | + Clicking on the map objects (floors and walls are fine), their items (other than a weapon to de-target) will result in being fired upon.\n" |
| 213 | + if(!T.client.target_can_move) |
| 214 | + msg += "Moving will result in being fired upon.\n" |
| 215 | + else if(m_intent == "run" && !T.client.target_can_run && (ishuman(T))) //Self explanitory. |
| 216 | + msg += "<span class='warning'>Your captive is allowing you to walk. \ |
| 217 | + Make sure to change your move intent to walk before trying to move, or you will be fired upon.</span>\n" |
| 218 | + to_chat(src, "<span class='danger'>Your character is being targeted. They have 2 seconds to stop any of the following actions: </span>\n \ |
| 219 | + [msg]\n \ |
| 220 | + <span class='warning'>The aggressor may also fire manually, so try not to get on their bad side.</span>") |
| 221 | + |
205 | 222 | //set_m_intent("walk") -there's a real fucked up exploit behind this, so it's been removed. Needs testing. -Angelite-
|
206 |
| - |
207 |
| - //Processing the aiming. Should be probably in separate object with process() but lasy. |
208 |
| - while(targeted_by && T.client) |
209 |
| - if((last_move_intent > I.lock_time + 10) && !T.client.target_can_move) //If target moved when not allowed to |
210 |
| - I.TargetActed(src) |
211 |
| - 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. |
212 |
| - I.lock_time = world.time + 5 |
213 |
| - I.lock_time = world.time + 5 |
214 |
| - I.last_moved_mob = src |
215 |
| - else if((last_move_intent > I.lock_time + 10) && !T.client.target_can_run && m_intent == "run") //If the target ran while targeted |
216 |
| - I.TargetActed(src) |
217 |
| - 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. |
218 |
| - I.lock_time = world.time + 5 |
219 |
| - I.lock_time = world.time + 5 |
220 |
| - I.last_moved_mob = src |
221 |
| - 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 |
222 |
| - I.TargetActed(src) |
223 |
| - 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. |
224 |
| - I.lock_time = world.time + 5 |
225 |
| - I.lock_time = world.time + 5 |
226 |
| - I.last_moved_mob = src |
227 |
| - sleep(1) |
| 223 | + |
| 224 | + if(!T.client.target_can_move || !T.client.target_can_run) |
| 225 | + register_event(/event/moved, I, nameof(I::TargetMoved())) |
| 226 | + register_event(/event/relaymoved, I, nameof(I::TargetMoved())) |
| 227 | + if(!T.client.target_can_click) |
| 228 | + register_event(/event/clickon, I, nameof(I::TargetActed())) |
| 229 | + register_event(/event/logout, T, nameof(src::TargeterLogout())) |
| 230 | + |
| 231 | +/mob/living/proc/TargeterLogout(mob/living/user) |
| 232 | + for(var/obj/item/weapon/gun/G in user) |
| 233 | + NotTargeted(G) |
| 234 | + unregister_event(/event/logout, user, nameof(src::TargeterLogout())) |
228 | 235 |
|
229 | 236 | /mob/living/proc/NotTargeted(var/obj/item/weapon/gun/I)
|
| 237 | + unregister_event(/event/moved, I, nameof(I::TargetMoved())) |
| 238 | + unregister_event(/event/relaymoved, I, nameof(I::TargetMoved())) |
| 239 | + unregister_event(/event/clickon, I, nameof(I::TargetActed())) |
230 | 240 | if(!I.silenced)
|
231 | 241 | for(var/mob/living/M in viewers(src))
|
232 | 242 | M << 'sound/weapons/TargetOff.ogg'
|
|
0 commit comments