Page 1 of 1

HF sword code

PostPosted: Sat Aug 29, 2015 3:28 pm
by Zeke Sturm
Got bored, wrote some code for Metal Gear Rising-esque High Frequency swords (A kriegsmesser in this case), and a sample custom sword. No sprites as of yet, and I probably won't be getting those done as I can't boot dreammaker without crashing my entire computer because this craptop really doesn't like trying to load every last object on the map at once apparently. It's largely just mix-matched energy sword and physical sword coding to allow for an unconcealable sword that can be turned on to deal more damage. Was gonna test this version first then try to implement an energy-charge system to actually give the whole "on/off" state some meaning but given I can't actually test this at all... this is probably the furthest it'll get.

Code: Select all
/obj/item/weapon/melee/energy/hfkrieg
   name = "HF Kriegsmesser"
   desc = "A long, curved, single bladed High Frequency blade based off the medieval German Kriegsmesser. The blade vibrates at an enormously high frequency when activated, and cuts more efficiently than a standard blade as a result."
   icon_state = "hfkrieg_off"
   item_state = "hfkrieg_off"
   flags = FPRINT | TABLEPASS | CONDUCT
   slot_flags = SLOT_BELT | SLOT_BACK
   force = 30
   throwforce = 10
   w_class = 3
   attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")

   suicide_act(mob/user)
      viewers(user) << "\red <b>[user] is stabbing \himself in the chest with the [src.name]! It looks like \he's trying to commit suicide.</b>"
      return(BRUTELOSS)

/obj/item/weapon/melee/energy/hfkrieg/IsShield()
      return 1

/obj/item/weapon/melee/energy/hfkrieg/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
   playsound(loc, 'sound/weapons/bladeslice.ogg', 50, 1, -1)
   return ..()
   
/obj/item/weapon/melee/energy/hfkrieg/attack_self(mob/living/user as mob)
   if ((CLUMSY in user.mutations) && prob(50))
      user << "\red You accidentally cut yourself with [src]."
      user.take_organ_damage(5,5)
   active = !active
   if (active)
      force = 50
      icon_state = "hfkrieg_on"
      w_class = 4
      playsound(user, 'sound/weapons/saberon.ogg', 50, 1)
      user << "\blue [src] is now active."

   else
      force = 30
      icon_state = "hfkrieg_off"
      w_class = 3
      playsound(user, 'sound/weapons/saberoff.ogg', 50, 1)
      user << "\blue [src] can now be sheathed."

   if(istype(user,/mob/living/carbon/human))
      var/mob/living/carbon/human/H = user
      H.update_inv_l_hand()
      H.update_inv_r_hand()

   add_fingerprint(user)
   return
   
/obj/item/weapon/melee/energy/hfkrieg/kusanagi
   name = "Kusanagi"
   desc = "A long, curved, single bladed High Frequency blade based off the medieval German Kriegsmesser. The blade vibrates at an enormously high frequency when activated, and cuts more efficiently than a standard blade as a result. This unique prototype was the final variant before the production model, and carries a ZA insignia on the base of the acid green blade."
   icon_state = "kusanagi_off"
   item_state = "kusanagi_off"
   
/obj/item/weapon/melee/energy/hfkrieg/kusanagi/attack_self(mob/living/user as mob)
   if ((CLUMSY in user.mutations) && prob(50))
      user << "\red You accidentally cut yourself with [src]."
      user.take_organ_damage(5,5)
   active = !active
   if (active)
      force = 50
      icon_state = "kusanagi_on"
      w_class = 4
      playsound(user, 'sound/weapons/saberon.ogg', 50, 1)
      user << "\blue [src] is now active."

   else
      force = 30
      icon_state = "kusanagi_off"
      w_class = 3
      playsound(user, 'sound/weapons/saberoff.ogg', 50, 1)
      user << "\blue [src] can now be sheathed."

   if(istype(user,/mob/living/carbon/human))
      var/mob/living/carbon/human/H = user
      H.update_inv_l_hand()
      H.update_inv_r_hand()

   add_fingerprint(user)
   return