Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.72 KB | None | 0 0
  1. /mob/CanPass(atom/movable/mover, turf/target)
  2. return TRUE //There's almost no cases where non /living mobs should be used in game as actual mobs, other than ghosts.
  3.  
  4. //DO NOT USE THIS UNLESS YOU ABSOLUTELY HAVE TO. THIS IS BEING PHASED OUT FOR THE MOVESPEED MODIFICATION SYSTEM.
  5. //See mob_movespeed.dm
  6. /mob/proc/movement_delay() //update /living/movement_delay() if you change this
  7. return cached_multiplicative_slowdown
  8.  
  9. /client/verb/drop_item()
  10. set hidden = 1
  11. if(!iscyborg(mob) && mob.stat == CONSCIOUS)
  12. mob.dropItemToGround(mob.get_active_held_item())
  13. return
  14.  
  15. /client/proc/Move_object(direct)
  16. if(mob && mob.control_object)
  17. if(mob.control_object.density)
  18. step(mob.control_object,direct)
  19. if(!mob.control_object)
  20. return
  21. mob.control_object.setDir(direct)
  22. else
  23. mob.control_object.forceMove(get_step(mob.control_object,direct))
  24.  
  25. #define MOVEMENT_DELAY_BUFFER 0.75
  26. #define MOVEMENT_DELAY_BUFFER_DELTA 1.25
  27.  
  28. /client/Move(n, direct)
  29. if(world.time < move_delay) //do not move anything ahead of this check please
  30. return FALSE
  31. else
  32. next_move_dir_add = 0
  33. next_move_dir_sub = 0
  34. var/old_move_delay = move_delay
  35. move_delay = world.time + world.tick_lag //this is here because Move() can now be called mutiple times per tick
  36. if(!mob || !mob.loc)
  37. return FALSE
  38. if(!n || !direct)
  39. return FALSE
  40. if(mob.notransform)
  41. return FALSE //This is sota the goto stop mobs from moving var
  42. if(mob.control_object)
  43. return Move_object(direct)
  44. if(!isliving(mob))
  45. return mob.Move(n, direct)
  46. if(mob.stat == DEAD)
  47. mob.ghostize()
  48. return FALSE
  49. if(mob.force_moving)
  50. return FALSE
  51.  
  52. var/mob/living/L = mob //Already checked for isliving earlier
  53. if(L.incorporeal_move) //Move though walls
  54. Process_Incorpmove(direct)
  55. return FALSE
  56.  
  57. if(mob.remote_control) //we're controlling something, our movement is relayed to it
  58. return mob.remote_control.relaymove(mob, direct)
  59.  
  60. if(isAI(mob))
  61. return AIMove(n,direct,mob)
  62.  
  63. if(Process_Grab()) //are we restrained by someone's grip?
  64. return
  65.  
  66. if(mob.buckled) //if we're buckled to something, tell it we moved.
  67. return mob.buckled.relaymove(mob, direct)
  68.  
  69. if(!(L.mobility_flags & MOBILITY_MOVE))
  70. return FALSE
  71.  
  72. if(isobj(mob.loc) || ismob(mob.loc)) //Inside an object, tell it we moved
  73. var/atom/O = mob.loc
  74. return O.relaymove(mob, direct)
  75.  
  76. if(!mob.Process_Spacemove(direct))
  77. return FALSE
  78. //We are now going to move
  79. var/add_delay = mob.movement_delay()
  80. if(old_move_delay + (add_delay*MOVEMENT_DELAY_BUFFER_DELTA) + MOVEMENT_DELAY_BUFFER > world.time)
  81. move_delay = old_move_delay
  82. else
  83. move_delay = world.time
  84.  
  85. if(L.confused)
  86. var/newdir = 0
  87. if(L.confused > 40)
  88. newdir = pick(GLOB.alldirs)
  89. else if(prob(L.confused * 1.5))
  90. newdir = angle2dir(dir2angle(direct) + pick(90, -90))
  91. else if(prob(L.confused * 3))
  92. newdir = angle2dir(dir2angle(direct) + pick(45, -45))
  93. if(newdir)
  94. direct = newdir
  95. n = get_step(L, direct)
  96.  
  97. . = ..()
  98.  
  99. if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully
  100. add_delay *= 2
  101. move_delay += add_delay
  102. if(.) // If mob is null here, we deserve the runtime
  103. if(mob.throwing)
  104. mob.throwing.finalize(FALSE)
  105.  
  106. var/atom/movable/P = mob.pulling
  107. if(P && !ismob(P) && P.density)
  108. mob.setDir(turn(mob.dir, 180))
  109.  
  110. ///Process_Grab()
  111. ///Called by client/Move()
  112. ///Checks to see if you are being grabbed and if so attemps to break it
  113. /client/proc/Process_Grab()
  114. if(mob.pulledby)
  115. if((mob.pulledby == mob.pulling) && (mob.pulledby.grab_state == GRAB_PASSIVE)) //Don't autoresist passive grabs if we're grabbing them too.
  116. return
  117. if(mob.incapacitated(ignore_restraints = 1))
  118. move_delay = world.time + 10
  119. return TRUE
  120. else if(mob.restrained(ignore_grab = 1))
  121. move_delay = world.time + 10
  122. to_chat(src, "<span class='warning'>You're restrained! You can't move!</span>")
  123. return TRUE
  124. else
  125. return mob.resist_grab(1)
  126.  
  127. ///Process_Incorpmove
  128. ///Called by client/Move()
  129. ///Allows mobs to run though walls
  130. /client/proc/Process_Incorpmove(direct)
  131. var/turf/mobloc = get_turf(mob)
  132. if(!isliving(mob))
  133. return
  134. var/mob/living/L = mob
  135. switch(L.incorporeal_move)
  136. if(INCORPOREAL_MOVE_BASIC)
  137. var/T = get_step(L,direct)
  138. if(T)
  139. L.forceMove(T)
  140. L.setDir(direct)
  141. if(INCORPOREAL_MOVE_SHADOW)
  142. if(prob(50))
  143. var/locx
  144. var/locy
  145. switch(direct)
  146. if(NORTH)
  147. locx = mobloc.x
  148. locy = (mobloc.y+2)
  149. if(locy>world.maxy)
  150. return
  151. if(SOUTH)
  152. locx = mobloc.x
  153. locy = (mobloc.y-2)
  154. if(locy<1)
  155. return
  156. if(EAST)
  157. locy = mobloc.y
  158. locx = (mobloc.x+2)
  159. if(locx>world.maxx)
  160. return
  161. if(WEST)
  162. locy = mobloc.y
  163. locx = (mobloc.x-2)
  164. if(locx<1)
  165. return
  166. else
  167. return
  168. var/target = locate(locx,locy,mobloc.z)
  169. if(target)
  170. L.loc = target
  171. var/limit = 2//For only two trailing shadows.
  172. for(var/turf/T in getline(mobloc, L.loc))
  173. new /obj/effect/temp_visual/dir_setting/ninja/shadow(T, L.dir)
  174. limit--
  175. if(limit<=0)
  176. break
  177. else
  178. new /obj/effect/temp_visual/dir_setting/ninja/shadow(mobloc, L.dir)
  179. var/T = get_step(L,direct)
  180. if(T)
  181. L.forceMove(T)
  182. L.setDir(direct)
  183. if(INCORPOREAL_MOVE_JAUNT) //Incorporeal move, but blocked by holy-watered tiles and salt piles.
  184. var/turf/open/floor/stepTurf = get_step(L, direct)
  185. if(stepTurf)
  186. for(var/obj/effect/decal/cleanable/food/salt/S in stepTurf)
  187. to_chat(L, "<span class='warning'>[S] bars your passage!</span>")
  188. if(isrevenant(L))
  189. var/mob/living/simple_animal/revenant/R = L
  190. R.reveal(20)
  191. R.stun(20)
  192. return
  193. if(stepTurf.flags_1 & NOJAUNT_1)
  194. to_chat(L, "<span class='warning'>Some strange aura is blocking the way.</span>")
  195. return
  196. if (locate(/obj/effect/blessing, stepTurf))
  197. to_chat(L, "<span class='warning'>Holy energies block your path!</span>")
  198. return
  199.  
  200. L.forceMove(stepTurf)
  201. L.setDir(direct)
  202. return TRUE
  203.  
  204.  
  205. ///Process_Spacemove
  206. ///Called by /client/Move()
  207. ///For moving in space
  208. ///return TRUE for movement 0 for none
  209. /mob/Process_Spacemove(movement_dir = 0)
  210. if(spacewalk || ..())
  211. return TRUE
  212. var/atom/movable/backup = get_spacemove_backup()
  213. if(backup)
  214. if(istype(backup) && movement_dir && !backup.anchored)
  215. if(backup.newtonian_move(turn(movement_dir, 180))) //You're pushing off something movable, so it moves
  216. to_chat(src, "<span class='info'>You push off of [backup] to propel yourself.</span>")
  217. return TRUE
  218. return FALSE
  219.  
  220. /mob/get_spacemove_backup()
  221. for(var/A in orange(1, get_turf(src)))
  222. if(isarea(A))
  223. continue
  224. else if(isturf(A))
  225. var/turf/turf = A
  226. if(isspaceturf(turf))
  227. continue
  228. if(!turf.density && !mob_negates_gravity())
  229. continue
  230. return A
  231. else
  232. var/atom/movable/AM = A
  233. if(AM == buckled)
  234. continue
  235. if(ismob(AM))
  236. var/mob/M = AM
  237. if(M.buckled)
  238. continue
  239. if(!AM.CanPass(src) || AM.density)
  240. if(AM.anchored)
  241. return AM
  242. if(pulling == AM)
  243. continue
  244. . = AM
  245.  
  246. /mob/proc/mob_has_gravity()
  247. return has_gravity()
  248.  
  249. /mob/proc/mob_negates_gravity()
  250. return FALSE
  251.  
  252.  
  253. /mob/proc/slip(knockdown, paralyze, forcedrop, w_amount, obj/O, lube)
  254. return
  255.  
  256. /mob/proc/update_gravity()
  257. return
  258.  
  259. //bodypart selection - Cyberboss
  260. //8 toggles through head - eyes - mouth
  261. //4: r-arm 5: chest 6: l-arm
  262. //1: r-leg 2: groin 3: l-leg
  263.  
  264. /client/proc/check_has_body_select()
  265. return mob && mob.hud_used && mob.hud_used.zone_select && istype(mob.hud_used.zone_select, /obj/screen/zone_sel)
  266.  
  267. /client/verb/body_toggle_head()
  268. set name = "body-toggle-head"
  269. set hidden = 1
  270.  
  271. if(!check_has_body_select())
  272. return
  273.  
  274. var/next_in_line
  275. switch(mob.zone_selected)
  276. if(BODY_ZONE_HEAD)
  277. next_in_line = BODY_ZONE_PRECISE_EYES
  278. if(BODY_ZONE_PRECISE_EYES)
  279. next_in_line = BODY_ZONE_PRECISE_MOUTH
  280. else
  281. next_in_line = BODY_ZONE_HEAD
  282.  
  283. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  284. selector.set_selected_zone(next_in_line, mob)
  285.  
  286. /client/verb/body_r_arm()
  287. set name = "body-r-arm"
  288. set hidden = 1
  289.  
  290. if(!check_has_body_select())
  291. return
  292.  
  293. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  294. selector.set_selected_zone(BODY_ZONE_R_ARM, mob)
  295.  
  296. /client/verb/body_chest()
  297. set name = "body-chest"
  298. set hidden = 1
  299.  
  300. if(!check_has_body_select())
  301. return
  302.  
  303. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  304. selector.set_selected_zone(BODY_ZONE_CHEST, mob)
  305.  
  306. /client/verb/body_l_arm()
  307. set name = "body-l-arm"
  308. set hidden = 1
  309.  
  310. if(!check_has_body_select())
  311. return
  312.  
  313. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  314. selector.set_selected_zone(BODY_ZONE_L_ARM, mob)
  315.  
  316. /client/verb/body_r_leg()
  317. set name = "body-r-leg"
  318. set hidden = 1
  319.  
  320. if(!check_has_body_select())
  321. return
  322.  
  323. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  324. selector.set_selected_zone(BODY_ZONE_R_LEG, mob)
  325.  
  326. /client/verb/body_groin()
  327. set name = "body-groin"
  328. set hidden = 1
  329.  
  330. if(!check_has_body_select())
  331. return
  332.  
  333. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  334. selector.set_selected_zone(BODY_ZONE_PRECISE_GROIN, mob)
  335.  
  336. /client/verb/body_l_leg()
  337. set name = "body-l-leg"
  338. set hidden = 1
  339.  
  340. if(!check_has_body_select())
  341. return
  342.  
  343. var/obj/screen/zone_sel/selector = mob.hud_used.zone_select
  344. selector.set_selected_zone(BODY_ZONE_L_LEG, mob)
  345.  
  346. /client/verb/toggle_walk_run()
  347. set name = "toggle-walk-run"
  348. set hidden = TRUE
  349. set instant = TRUE
  350. if(mob)
  351. mob.toggle_move_intent(usr)
  352.  
  353. /mob/proc/toggle_move_intent(mob/user)
  354. if(m_intent == MOVE_INTENT_RUN)
  355. m_intent = MOVE_INTENT_WALK
  356. else
  357. m_intent = MOVE_INTENT_RUN
  358. if(hud_used && hud_used.static_inventory)
  359. for(var/obj/screen/mov_intent/selector in hud_used.static_inventory)
  360. selector.update_icon(src)
  361.  
  362. /mob/verb/up()
  363. set name = "Move Upwards"
  364. set category = "IC"
  365.  
  366. if(zMove(UP, TRUE))
  367. to_chat(src, "<span class='notice'>You move upwards.</span>")
  368.  
  369. /mob/verb/down()
  370. set name = "Move Down"
  371. set category = "IC"
  372.  
  373. if(zMove(DOWN, TRUE))
  374. to_chat(src, "<span class='notice'>You move down.</span>")
  375.  
  376. /mob/proc/zMove(dir, feedback = FALSE)
  377. if(dir != UP && dir != DOWN)
  378. return FALSE
  379. var/turf/target = get_step_multiz(src, dir)
  380. if(!target)
  381. if(feedback)
  382. to_chat(src, "<span class='warning'>There's nothing in that direction!</span>")
  383. return FALSE
  384. if(!canZMove(dir, target))
  385. if(feedback)
  386. to_chat(src, "<span class='warning'>You couldn't move there!</span>")
  387. return FALSE
  388. forceMove(target)
  389. return TRUE
  390.  
  391. /mob/proc/canZMove(direction, turf/target)
  392. return FALSE
  393.  
  394. #define MAX_SW_LUMS 0.2
  395. #define ALLOW_PULL_THROUGH_WALLS 0
  396.  
  397. /proc/Can_ShadowWalk(var/mob/mob)
  398. if(mob.shadow_walk)
  399. return TRUE
  400. if(ishuman(mob))
  401. var/mob/living/carbon/human/H = mob
  402. if(istype(H.dna.species, /datum/species/shadow/ling))
  403. return TRUE
  404. return FALSE
  405.  
  406. /client/proc/Process_ShadowWalk(direct)
  407. var/turf/target = get_step(mob, direct)
  408. var/turf/mobloc = get_turf(mob)
  409.  
  410. var/atom/movable/A
  411. var/doPull = FALSE
  412. if (istype(mob.pulling))
  413. doPull = TRUE
  414. if (mob.pulling.anchored)
  415. mob.stop_pulling()
  416. doPull = FALSE
  417. if(isliving(mob.pulling))
  418. var/mob/living/L = mob.pulling
  419. if(L.buckled && L.buckled.buckle_prevents_pull) //if they're buckled to something that disallows pulling, prevent it
  420. mob.stop_pulling()
  421. doPull = FALSE
  422. if((mobloc.density || target.density) && !ALLOW_PULL_THROUGH_WALLS) //this will disallow the target to be pulled if the shadowwalker is on or going into a solid tile.
  423. doPull = FALSE
  424. if(istype(mob.pulling, /mob/living))
  425. var/mob/living/M = mob.pulling
  426. M.Knockdown(60)
  427. to_chat(M, "<span class='danger'>You fall down as you slam against the surface!</span>")
  428. if (doPull)
  429. var/turf/pullloc = get_turf(mob.pulling)
  430. if(is_shadowwalkable(mobloc) || is_shadowwalkable(target) || is_shadowwalkable(pullloc))
  431. mob.pulling.dir = get_dir(mob.pulling, mob)
  432. A = mob.pulling
  433. mob.pulling.forceMove(mob.loc)
  434.  
  435. if(is_shadowwalkable(target))
  436. mob.forceMove(target)
  437. mob.dir = direct
  438. if (doPull)
  439. mob.start_pulling(A, TRUE) //this was the only way I could figure out how to do this
  440. return TRUE
  441.  
  442. return FALSE
  443.  
  444. /mob/living/carbon/Move(atom/newloc, direct)
  445. . = ..(newloc, direct)
  446. if(lying && !pulledby && !buckled && (stat == SOFT_CRIT || get_num_legs() == 0) && !inertia_moving)
  447. if(stat == SOFT_CRIT)
  448. visible_message("<span class='danger'>[src] painfully crawls forward!</span>", "<span class='userdanger'>You crawl forward at the expense of some of your strength.</span>")
  449. apply_damage(1, OXY)
  450. playsound(src, pick('hippiestation/sound/effects/bodyscrape-01.ogg', 'hippiestation/sound/effects/bodyscrape-02.ogg'), 20, 1, -4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement