Files
Polaris/code/defines/obj/toy.dm
elly1989@rocketmail.com 8961bd96d0 WARNING: This has been thoroughly tested and I'm happy that it's -stable- (it shouldn't runtime). However, it might have a few niggly bugs caused by specific items using no-standard or weird code. Most bugs will be stuff like it not updating overlays and such and can be fixed simply by dropping the item. That being said, if you're not comfortable with this, I'd suggest waiting to update past this revision.
update_clothing() has been broken up into it's key parts. A full explanation can be found in code/modules/mob/living/carbon/human/update_icons.dm
the tl;dr of it is that overlay updates are no longer called by the gameticker. Instead they are called by procs such as u_equip db_cick etc. This means faster updates (although admittedly, more of them can be called per tick). This however is offset by the fact that specific overlays can be updated now, vastly improving its efficiency. This will especially help when there are large numbers of dead mobs.

Fixed the throw code for TKgrab so it can be toggled.

Cloaking for aliens/humans/ninjas was changed. It's very crude at the moment and for that I apologise. But it works and is very efficient.It also stops cloaked individuals becomming invincible due to people being unable to hit them (even when they know exactly where  they are)

Fixed a bunch of bugs with damage-overlays. They  were updating FAR FAR to frequently. They were also horribly inefficient. They should now be virtually seamless when updating and only use cached icons, so they aren't affected by lag as badly. This may help with explosions lag a little.

There's still a tonne of stuff I need to refine with this. I'll be refining it down into some helper procs to reduce on code duplication and such

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3811 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-13 19:03:25 +00:00

516 lines
14 KiB
Plaintext

/obj/item/toy
throwforce = 0
throw_speed = 4
throw_range = 20
force = 0
/////////Toy Mechs/////////
/obj/item/toy/prize
icon = 'toy.dmi'
icon_state = "ripleytoy"
/obj/item/toy/prize/ripley
name = "toy ripley"
desc = "Mini-Mecha action figure! Collect them all! 1/11"
/obj/item/toy/prize/fireripley
name = "toy firefighting ripley"
desc = "Mini-Mecha action figure! Collect them all! 2/11"
icon_state = "fireripleytoy"
/obj/item/toy/prize/deathripley
name = "toy deathsquad ripley"
desc = "Mini-Mecha action figure! Collect them all! 3/11"
icon_state = "deathripleytoy"
/obj/item/toy/prize/gygax
name = "toy gygax"
desc = "Mini-Mecha action figure! Collect them all! 4/11"
icon_state = "gygaxtoy"
/obj/item/toy/prize/durand
name = "toy gygax"
desc = "Mini-Mecha action figure! Collect them all! 5/11"
icon_state = "durandprize"
/obj/item/toy/prize/honk
name = "toy H.O.N.K."
desc = "Mini-Mecha action figure! Collect them all! 6/11"
icon_state = "honkprize"
/obj/item/toy/prize/marauder
name = "toy marauder"
desc = "Mini-Mecha action figure! Collect them all! 7/11"
icon_state = "marauderprize"
/obj/item/toy/prize/seraph
name = "toy seraph"
desc = "Mini-Mecha action figure! Collect them all! 8/11"
icon_state = "seraphprize"
/obj/item/toy/prize/mauler
name = "toy mauler"
desc = "Mini-Mecha action figure! Collect them all! 9/11"
icon_state = "maulerprize"
/obj/item/toy/prize/odysseus
name = "toy odysseus"
desc = "Mini-Mecha action figure! Collect them all! 10/11"
icon_state = "odysseusprize"
/obj/item/toy/prize/phazon
name = "toy phazon"
desc = "Mini-Mecha action figure! Collect them all! 11/11"
icon_state = "phazonprize"
/obj/item/toy/syndicateballoon
name = "syndicate balloon"
desc = "There is a tag on the back that reads \"FUK NT!11!\"."
throwforce = 0
throw_speed = 4
throw_range = 20
force = 0
icon = 'weapons.dmi'
icon_state = "syndballoon"
item_state = "syndballoon"
w_class = 4.0
/obj/item/toy/blink
name = "electronic blink toy game"
desc = "Blink. Blink. Blink. Ages 8 and up."
icon = 'radio.dmi'
icon_state = "beacon"
item_state = "signaler"
/obj/item/toy/spinningtoy
name = "Gravitational Singularity"
desc = "\"Singulo\" brand spinning toy."
icon = 'singularity.dmi'
icon_state = "singularity_s1"
/obj/item/toy/ammo/gun
name = "ammo-caps"
desc = "There are 7 caps left! Make sure to recyle the box in an autolathe when it gets empty."
icon = 'ammo.dmi'
icon_state = "357-7"
flags = FPRINT | TABLEPASS| CONDUCT
w_class = 1.0
g_amt = 10
m_amt = 10
var/amount_left = 7.0
update_icon()
src.icon_state = text("357-[]", src.amount_left)
src.desc = text("There are [] caps\s left! Make sure to recycle the box in an autolathe when it gets empty.", src.amount_left)
return
/obj/item/toy/ammo/crossbow
name = "foam dart"
desc = "Its nerf or nothing! Ages 8 and up."
icon = 'toy.dmi'
icon_state = "foamdart"
flags = FPRINT | TABLEPASS
w_class = 1.0
/obj/effect/foam_dart_dummy
name = ""
desc = ""
icon = 'toy.dmi'
icon_state = "null"
anchored = 1
density = 0
/obj/item/toy/gun
name = "cap gun"
desc = "There are 0 caps left. Looks almost like the real thing! Ages 8 and up. Please recycle in an autolathe when you're out of caps!"
icon = 'gun.dmi'
icon_state = "revolver"
item_state = "gun"
flags = FPRINT | TABLEPASS | CONDUCT | USEDELAY
slot_flags = SLOT_BELT
w_class = 3.0
g_amt = 10
m_amt = 10
var/bullets = 7.0
examine()
set src in usr
src.desc = text("There are [] caps\s left. Looks almost like the real thing! Ages 8 and up.", src.bullets)
..()
return
attackby(obj/item/toy/ammo/gun/A as obj, mob/user as mob)
if (istype(A, /obj/item/toy/ammo/gun))
if (src.bullets >= 7)
user << "\blue It's already fully loaded!"
return 1
if (A.amount_left <= 0)
user << "\red There is no more caps!"
return 1
if (A.amount_left < (7 - src.bullets))
src.bullets += A.amount_left
user << text("\red You reload [] caps\s!", A.amount_left)
A.amount_left = 0
else
user << text("\red You reload [] caps\s!", 7 - src.bullets)
A.amount_left -= 7 - src.bullets
src.bullets = 7
A.update_icon()
return 1
return
afterattack(atom/target as mob|obj|turf|area, mob/user as mob, flag)
if (flag)
return
if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey")
usr << "\red You don't have the dexterity to do this!"
return
src.add_fingerprint(user)
if (src.bullets < 1)
user.show_message("\red *click* *click*", 2)
return
playsound(user, 'Gunshot.ogg', 100, 1)
src.bullets--
for(var/mob/O in viewers(user, null))
O.show_message(text("\red <B>[] fires a cap gun at []!</B>", user, target), 1, "\red You hear a gunshot", 2)
/obj/item/toy/sword
name = "toy sword"
desc = "A cheap, plastic replica of an energy sword. Realistic sounds! Ages 8 and up."
icon = 'weapons.dmi'
icon_state = "sword0"
item_state = "sword0"
var/active = 0.0
w_class = 2.0
flags = FPRINT | TABLEPASS | NOSHIELD
attack_self(mob/user as mob)
src.active = !( src.active )
if (src.active)
user << "\blue You extend the plastic blade with a quick flick of your wrist."
playsound(user, 'saberon.ogg', 50, 1)
src.icon_state = "swordblue"
src.item_state = "swordblue"
src.w_class = 4
else
user << "\blue You push the plastic blade back down into the handle."
playsound(user, 'saberoff.ogg', 50, 1)
src.icon_state = "sword0"
src.item_state = "sword0"
src.w_class = 2
src.add_fingerprint(user)
return
/obj/item/toy/crossbow
name = "foam dart crossbow"
desc = "A weapon favored by many overactive children. Ages 8 and up."
icon = 'gun.dmi'
icon_state = "crossbow"
item_state = "crossbow"
flags = FPRINT | TABLEPASS | USEDELAY
w_class = 2.0
var/bullets = 5
examine()
set src in view(2)
..()
if (bullets)
usr << "\blue It is loaded with [bullets] foam darts!"
attackby(obj/item/I as obj, mob/user as mob)
if(istype(I, /obj/item/toy/ammo/crossbow))
if(bullets <= 4)
user.drop_item()
del(I)
bullets++
user << "\blue You load the foam dart into the crossbow."
else
usr << "\red It's already fully loaded."
afterattack(atom/target as mob|obj|turf|area, mob/user as mob, flag)
if(!isturf(target.loc) || target == user) return
if(flag) return
if (locate (/obj/structure/table, src.loc))
return
else if (bullets)
var/turf/trg = get_turf(target)
var/obj/effect/foam_dart_dummy/D = new/obj/effect/foam_dart_dummy(get_turf(src))
bullets--
D.icon_state = "foamdart"
D.name = "foam dart"
playsound(user.loc, 'syringeproj.ogg', 50, 1)
for(var/i=0, i<6, i++)
if (D)
if(D.loc == trg) break
step_towards(D,trg)
for(var/mob/living/M in D.loc)
if(!istype(M,/mob/living)) continue
if(M == user) continue
for(var/mob/O in viewers(world.view, D))
O.show_message(text("\red [] was hit by the foam dart!", M), 1)
new /obj/item/toy/ammo/crossbow(M.loc)
del(D)
return
for(var/atom/A in D.loc)
if(A == user) continue
if(A.density)
new /obj/item/toy/ammo/crossbow(A.loc)
del(D)
sleep(1)
spawn(10)
if(D)
new /obj/item/toy/ammo/crossbow(D.loc)
del(D)
return
else if (bullets == 0)
user.Weaken(5)
for(var/mob/O in viewers(world.view, user))
O.show_message(text("\red [] realized they were out of ammo and starting scrounging for some!", user), 1)
attack(mob/M as mob, mob/user as mob)
src.add_fingerprint(user)
// ******* Check
if (src.bullets > 0 && M.lying)
for(var/mob/O in viewers(M, null))
if(O.client)
O.show_message(text("\red <B>[] casually lines up a shot with []'s head and pulls the trigger!</B>", user, M), 1, "\red You hear the sound of foam against skull", 2)
O.show_message(text("\red [] was hit in the head by the foam dart!", M), 1)
playsound(user.loc, 'syringeproj.ogg', 50, 1)
new /obj/item/toy/ammo/crossbow(M.loc)
src.bullets--
else if (M.lying && src.bullets == 0)
for(var/mob/O in viewers(M, null))
if (O.client) O.show_message(text("\red <B>[] casually lines up a shot with []'s head, pulls the trigger, then realizes they are out of ammo and drops to the floor in search of some!</B>", user, M), 1, "\red You hear someone fall", 2)
user.Weaken(5)
return
/obj/item/weapon/storage/crayonbox
name = "box of crayons"
desc = "A box of crayons for all your rune drawing needs."
icon = 'crayons.dmi'
icon_state = "crayonbox"
w_class = 2.0
storage_slots = 6
can_hold = list(
"/obj/item/toy/crayon"
)
/obj/item/toy/crayon
name = "crayon"
desc = "A colourful crayon. Looks tasty. Mmmm..."
icon = 'crayons.dmi'
icon_state = "crayonred"
w_class = 1.0
var/colour = "#FF0000" //RGB
var/shadeColour = "#220000" //RGB
var/uses = 30 //0 for unlimited uses
var/instant = 0
var/colourName = "red" //for updateIcon purposes
/obj/item/toy/snappop
name = "snap pop"
desc = "Wow!"
icon = 'toy.dmi'
icon_state = "snappop"
throw_impact(atom/hit_atom)
..()
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
new /obj/effect/decal/ash(src.loc)
src.visible_message("\red The [src.name] explodes!","\red You hear a snap!")
playsound(src, 'snap.ogg', 50, 1)
del(src)
/obj/item/toy/snappop/HasEntered(H as mob|obj)
if((ishuman(H))) //i guess carp and shit shouldn't set them off
var/mob/living/carbon/M = H
if(M.m_intent == "run")
M << "\red You step on the snap pop!"
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 0, src)
s.start()
new /obj/effect/decal/ash(src.loc)
src.visible_message("\red The [src.name] explodes!","\red You hear a snap!")
playsound(src, 'snap.ogg', 50, 1)
del(src)
/obj/item/toy/snappopbox
name = "snap pop box"
desc = "Eight wrappers of fun! Ages 8 and up. Not suitable for children."
icon = 'toy.dmi'
icon_state = "spbox"
var/amount = 8
attack_hand(mob/user as mob, unused, flag)
add_fingerprint(user)
if(user.r_hand == src || user.l_hand == src)
if(amount)
var/obj/item/toy/snappop/M = new /obj/item/toy/snappop(src)
if (user.hand)
user.l_hand = M
user.update_inv_l_hand()
else
user.r_hand = M
user.update_inv_r_hand()
M.loc = user
M.layer = 20
user << "You take a snap pop out of the box."
amount--
else
user << "There are no snap pops left in the box."
else
..()
return
attack_paw(mob/user as mob)
return attack_hand(user)
/obj/item/toy/waterflower
name = "Water Flower"
desc = "A seemingly innocent sunflower...with a twist."
icon = 'harvest.dmi'
icon_state = "sunflower"
item_state = "sunflower"
var/empty = 0
flags = USEDELAY
/obj/item/toy/waterflower/New()
var/datum/reagents/R = new/datum/reagents(10)
reagents = R
R.my_atom = src
R.add_reagent("water", 10)
/obj/item/toy/waterflower/attack(mob/living/carbon/human/M as mob, mob/user as mob)
return
/obj/item/toy/waterflower/afterattack(atom/A as mob|obj, mob/user as mob)
if (istype(A, /obj/item/weapon/storage/backpack ))
return
else if (locate (/obj/structure/table, src.loc))
return
else if (istype(A, /obj/structure/reagent_dispensers/watertank) && get_dist(src,A) <= 1)
A.reagents.trans_to(src, 10)
user << "\blue You refill your flower!"
return
else if (src.reagents.total_volume < 1)
src.empty = 1
user << "\blue Your flower has run dry!"
return
else
src.empty = 0
var/obj/effect/decal/D = new/obj/effect/decal/(get_turf(src))
D.name = "water"
D.icon = 'chemical.dmi'
D.icon_state = "chempuff"
D.create_reagents(5)
src.reagents.trans_to(D, 1)
playsound(src.loc, 'spray3.ogg', 50, 1, -6)
spawn(0)
for(var/i=0, i<1, i++)
step_towards(D,A)
D.reagents.reaction(get_turf(D))
for(var/atom/T in get_turf(D))
D.reagents.reaction(T)
if(ismob(T) && T:client)
T:client << "\red [user] has sprayed you with water!"
sleep(4)
del(D)
return
/obj/item/toy/waterflower/examine()
set src in usr
usr << text("\icon[] [] units of water left!", src, src.reagents.total_volume)
..()
return
/obj/item/toy/balloon
name = "water balloon"
desc = "A translucent balloon. There's nothing in it."
icon = 'toy.dmi'
icon_state = "waterballoon-e"
item_state = "balloon-empty"
/obj/item/toy/balloon/New()
var/datum/reagents/R = new/datum/reagents(10)
reagents = R
R.my_atom = src
/obj/item/toy/balloon/attack(mob/living/carbon/human/M as mob, mob/user as mob)
return
/obj/item/toy/balloon/afterattack(atom/A as mob|obj, mob/user as mob)
if (istype(A, /obj/structure/reagent_dispensers/watertank) && get_dist(src,A) <= 1)
A.reagents.trans_to(src, 10)
user << "\blue You fill the balloon with the contents of [A]."
src.desc = "A translucent balloon with some form of liquid sloshing around in it."
src.update_icon()
return
/obj/item/toy/balloon/attackby(obj/O as obj, mob/user as mob)
if(istype(O, /obj/item/weapon/reagent_containers/glass))
if(O.reagents)
if(O.reagents.total_volume < 1)
user << "The [O] is empty."
else if(O.reagents.total_volume >= 1)
if(O.reagents.has_reagent("pacid", 1))
user << "The acid chews through the balloon!"
O.reagents.reaction(user)
del(src)
else
src.desc = "A translucent balloon with some form of liquid sloshing around in it."
user << "\blue You fill the balloon with the contents of [O]."
O.reagents.trans_to(src, 10)
src.update_icon()
return
/obj/item/toy/balloon/throw_impact(atom/hit_atom)
if(src.reagents.total_volume >= 1)
src.visible_message("\red The [src] bursts!","You hear a pop and a splash.")
src.reagents.reaction(get_turf(hit_atom))
for(var/atom/A in get_turf(hit_atom))
src.reagents.reaction(A)
src.icon_state = "burst"
spawn(5)
if(src)
del(src)
return
/obj/item/toy/balloon/update_icon()
if(src.reagents.total_volume >= 1)
icon_state = "waterballoon"
item_state = "balloon"
else
icon_state = "waterballoon-e"
item_state = "balloon-empty"