Files
Aurora.3/code/game/objects/items/weapons/implants/implanter.dm
Zulker Nayeen Nahiyan 6e550d7308 Cleanup helper files maths.dm, time.dm, type2type.dm, add macros for bit-manipulation
`maths.dm`:
	Rewrite `Gcd(x)` to remove recursive behaviour.
	Remove `RaiseToPower(x)` and its usage from `event_manager.dm`.
	Rename `Lerp()` to `Interpolate()`.
	Add `Square(x)`, which squares a number.
	Rearrange most of the functions in the file. (trigonometric functions together, etc.)

`type2type.dm`:
	Rewrite `num2hex()` and optimise `hex2num()` for superior clarity and a 100% speed improvement.
	Correct indenting, spaces, make switches more concise.

`time.dm`:
	Remove old, slanderous commented-out function `/proc/time_stamp()`

`lists.dm`:
	Add the macros, `BITTEST(bitfield,index)`, `BITSET(...)`, `BITRESET(...)`
	  and `BITFLIP(...)` for bit-manipulation and use them where 20+ files
	  do it manually, for arguments of reader clarity and standardness.
2015-01-09 21:55:11 +06:00

132 lines
3.7 KiB
Plaintext

/obj/item/weapon/implanter
name = "implanter"
icon = 'icons/obj/items.dmi'
icon_state = "implanter0"
item_state = "syringe_0"
throw_speed = 1
throw_range = 5
w_class = 2.0
var/obj/item/weapon/implant/imp = null
/obj/item/weapon/implanter/proc/update()
/obj/item/weapon/implanter/update()
if (src.imp)
src.icon_state = "implanter1"
else
src.icon_state = "implanter0"
return
/obj/item/weapon/implanter/attack(mob/M as mob, mob/user as mob)
if (!istype(M, /mob/living/carbon))
return
if (user && src.imp)
for (var/mob/O in viewers(M, null))
O.show_message("\red [user] is attemping to implant [M].", 1)
var/turf/T1 = get_turf(M)
if (T1 && ((M == user) || do_after(user, 50)))
if(user && M && (get_turf(M) == T1) && src && src.imp)
for (var/mob/O in viewers(M, null))
O.show_message("\red [M] has been implanted by [user].", 1)
M.attack_log += text("\[[time_stamp()]\] <font color='orange'> Implanted with [src.name] ([src.imp.name]) by [user.name] ([user.ckey])</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Used the [src.name] ([src.imp.name]) to implant [M.name] ([M.ckey])</font>")
msg_admin_attack("[user.name] ([user.ckey]) implanted [M.name] ([M.ckey]) with [src.name] (INTENT: [uppertext(user.a_intent)]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
user.show_message("\red You implanted the implant into [M].")
if(src.imp.implanted(M))
src.imp.loc = M
src.imp.imp_in = M
src.imp.implanted = 1
if (ishuman(M))
var/mob/living/carbon/human/H = M
var/datum/organ/external/affected = H.get_organ(user.zone_sel.selecting)
affected.implants += src.imp
imp.part = affected
BITSET(H.hud_updateflag, IMPLOYAL_HUD)
src.imp = null
update()
return
/obj/item/weapon/implanter/loyalty
name = "implanter-loyalty"
/obj/item/weapon/implanter/loyalty/New()
src.imp = new /obj/item/weapon/implant/loyalty( src )
..()
update()
return
/obj/item/weapon/implanter/explosive
name = "implanter (E)"
/obj/item/weapon/implanter/explosive/New()
src.imp = new /obj/item/weapon/implant/explosive( src )
..()
update()
return
/obj/item/weapon/implanter/adrenalin
name = "implanter-adrenalin"
/obj/item/weapon/implanter/adrenalin/New()
src.imp = new /obj/item/weapon/implant/adrenalin(src)
..()
update()
return
/obj/item/weapon/implanter/compressed
name = "implanter (C)"
icon_state = "cimplanter1"
/obj/item/weapon/implanter/compressed/New()
imp = new /obj/item/weapon/implant/compressed( src )
..()
update()
return
/obj/item/weapon/implanter/compressed/update()
if (imp)
var/obj/item/weapon/implant/compressed/c = imp
if(!c.scanned)
icon_state = "cimplanter1"
else
icon_state = "cimplanter2"
else
icon_state = "cimplanter0"
return
/obj/item/weapon/implanter/compressed/attack(mob/M as mob, mob/user as mob)
var/obj/item/weapon/implant/compressed/c = imp
if (!c) return
if (c.scanned == null)
user << "Please scan an object with the implanter first."
return
..()
/obj/item/weapon/implanter/compressed/afterattack(atom/A, mob/user as mob, proximity)
if(!proximity)
return
if(istype(A,/obj/item) && imp)
var/obj/item/weapon/implant/compressed/c = imp
if (c.scanned)
user << "\red Something is already scanned inside the implant!"
return
c.scanned = A
if(istype(A.loc,/mob/living/carbon/human))
var/mob/living/carbon/human/H = A.loc
H.u_equip(A)
else if(istype(A.loc,/obj/item/weapon/storage))
var/obj/item/weapon/storage/S = A.loc
S.remove_from_storage(A)
A.loc.contents.Remove(A)
update()