Stunbaton Cells

Upgrades the stunbaton code to have cells.
This commit is contained in:
skull132
2014-12-17 00:42:03 +02:00
parent ddfeba5b3d
commit 05decbebcd
9 changed files with 139 additions and 210 deletions
+4 -4
View File
@@ -30,7 +30,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
for(var/D in ItemList)
var/list/O = text2list(D, ":")
if(O.len>0)
valid_items += O[1]
valid_items += O[1]
@@ -147,7 +147,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
randomItems.Add("/obj/item/weapon/melee/energy/sword") //Energy Sword
randomItems.Add("/obj/item/clothing/mask/gas/voice") //Voice Changer
randomItems.Add("/obj/item/device/chameleon") //Chameleon Projector
randomItems.Add("/obj/item/weapon/melee/baton/stunrod") //Stunrod
randomItems.Add("/obj/item/weapon/melee/baton/stunrod/loaded") //Stunrod
if(uses > 2)
randomItems.Add("/obj/item/weapon/storage/box/emps") //EMP Grenades
@@ -198,7 +198,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
uses -= 6
if("/obj/item/weapon/gun/energy/crossbow" , "/obj/item/device/powersink" , "/obj/item/weapon/storage/box/walkingcane")
uses -= 5
if("/obj/item/weapon/melee/energy/sword" , "/obj/item/clothing/mask/gas/voice" , "/obj/item/device/chameleon" , "/obj/item/weapon/melee/baton/stunrod")
if("/obj/item/weapon/melee/energy/sword" , "/obj/item/clothing/mask/gas/voice" , "/obj/item/device/chameleon" , "/obj/item/weapon/melee/baton/stunrod/loaded")
uses -= 4
if("/obj/item/weapon/storage/box/emps" , "/obj/item/weapon/pen/paralysis" , "/obj/item/weapon/cartridge/syndicate" , "/obj/item/clothing/under/chameleon" , \
"/obj/item/weapon/card/emag" , "/obj/item/weapon/storage/box/syndie_kit/space" , "/obj/item/device/encryptionkey/binary" , \
@@ -276,7 +276,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
feedback_add_details("traitor_uplink_items_bought","GM")
if("/obj/item/weapon/storage/box/syndie_kit/masks")
feedback_add_details("traitor_uplink_items_bought","MM")
if("/obj/item/weapon/melee/baton/stunrod")
if("/obj/item/weapon/melee/baton/stunrod/loaded")
feedback_add_details("traitor_uplink_items_bought","SR")
+110 -170
View File
@@ -1,56 +1,105 @@
/obj/item/weapon/melee/baton
name = "stun baton"
name = "stunbaton"
desc = "A stun baton for incapacitating people with."
icon_state = "stunbaton"
item_state = "baton"
flags = FPRINT | TABLEPASS
slot_flags = SLOT_BELT
force = 10
force = 15
sharp = 0
edge = 0
throwforce = 7
w_class = 3
var/charges = 10
var/status = 0
var/mob/foundmob = "" //Used in throwing proc.
origin_tech = "combat=2"
attack_verb = list("beaten")
var/status = 0 //whether the thing is on or not
var/obj/item/weapon/cell/bcell = null
var/hitcost = 1000 //oh god why do power cells carry so much charge? We probably need to make a distinction between "industrial" sized power cells for APCs and power cells for everything else.
var/mob/foundmob = "" //Throwing! And proc.
suicide_act(mob/user)
viewers(user) << "\red <b>[user] is putting the live [src.name] in \his mouth! It looks like \he's trying to commit suicide.</b>"
return (FIRELOSS)
/obj/item/weapon/melee/baton/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is putting the live [name] in \his mouth! It looks like \he's trying to commit suicide.</span>")
return (FIRELOSS)
/obj/item/weapon/melee/baton/New()
..()
update_icon()
return
/obj/item/weapon/melee/baton/loaded/New() //this one starts with a cell pre-installed.
..()
bcell = new/obj/item/weapon/cell/high(src)
update_icon()
return
/obj/item/weapon/melee/baton/proc/deductcharge(var/chrgdeductamt)
if(bcell)
if(bcell.use(chrgdeductamt))
return 1
else
status = 0
update_icon()
return 0
/obj/item/weapon/melee/baton/update_icon()
if(status)
icon_state = "stunbaton_active"
icon_state = "[initial(name)]_active"
else if(!bcell)
icon_state = "[initial(name)]_nocell"
else
icon_state = "stunbaton"
icon_state = "[initial(name)]"
/obj/item/weapon/melee/baton/attack_self(mob/user as mob)
if(status && (CLUMSY in user.mutations) && prob(50))
user << "\red You grab the [src] on the wrong side."
user.Weaken(30)
charges--
if(charges < 1)
/obj/item/weapon/melee/baton/examine()
set src in view(1)
..()
if(bcell)
usr <<"<span class='notice'>The baton is [round(bcell.percent())]% charged.</span>"
if(!bcell)
usr <<"<span class='warning'>The baton does not have a power source installed.</span>"
/obj/item/weapon/melee/baton/attackby(obj/item/weapon/W, mob/user)
if(istype(W, /obj/item/weapon/cell))
if(!bcell)
user.drop_item()
W.loc = src
bcell = W
user << "<span class='notice'>You install a cell in [src].</span>"
update_icon()
else
user << "<span class='notice'>[src] already has a cell.</span>"
else if(istype(W, /obj/item/weapon/screwdriver))
if(bcell)
bcell.updateicon()
bcell.loc = get_turf(src.loc)
bcell = null
user << "<span class='notice'>You remove the cell from the [src].</span>"
status = 0
update_icon()
return
if(charges > 0)
return
..()
return
/obj/item/weapon/melee/baton/attack_self(mob/user)
if(bcell && bcell.charge > hitcost)
status = !status
user << "<span class='notice'>\The [src] is now [status ? "on" : "off"].</span>"
playsound(src.loc, "sparks", 75, 1, -1)
user << "<span class='notice'>[src] is now [status ? "on" : "off"].</span>"
playsound(loc, "sparks", 75, 1, -1)
update_icon()
else
status = 0
user << "<span class='warning'>\The [src] is out of charge.</span>"
if(!bcell)
user << "<span class='warning'>[src] does not have a power source!</span>"
else
user << "<span class='warning'>[src] is out of charge.</span>"
add_fingerprint(user)
/obj/item/weapon/melee/baton/attack(mob/M as mob, mob/user as mob)
/obj/item/weapon/melee/baton/attack(mob/M, mob/user)
if(status && (CLUMSY in user.mutations) && prob(50))
user << "<span class='danger'>You accidentally hit yourself with the [src]!</span>"
user.Weaken(30)
charges--
if(charges < 1)
status = 0
update_icon()
deductcharge(hitcost)
return
var/mob/living/carbon/human/H = M
@@ -61,15 +110,15 @@
if(user.a_intent == "hurt")
if(!..()) return
//H.apply_effect(5, WEAKEN, 0)
H.visible_message("<span class='danger'>[M] has been beaten with the [src] by [user]!</span>")
M.visible_message("<span class='danger'>[M] has been beaten with the [src] by [user]!</span>")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Beat [H.name] ([H.ckey]) with [src.name]</font>"
H.attack_log += "\[[time_stamp()]\]<font color='orange'> Beaten by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[user.name] ([user.ckey]) beat [H.name] ([H.ckey]) with [src.name] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Beat [M.name] ([M.ckey]) with [src.name]</font>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'> Beaten by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[user.name] ([user.ckey]) beat [M.name] ([M.ckey]) with [src.name] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
playsound(src.loc, "swing_hit", 50, 1, -1)
playsound(loc, "swing_hit", 50, 1, -1)
else if(!status)
H.visible_message("<span class='warning'>[M] has been prodded with the [src] by [user]. Luckily it was off.</span>")
M.visible_message("<span class='warning'>[M] has been prodded with the [src] by [user]. Luckily it was off.</span>")
return
if(status)
@@ -77,21 +126,21 @@
H.apply_effect(10, WEAKEN, 0)
H.apply_effect(10, STUTTER, 0)
user.lastattacked = M
H.lastattacker = user
M.lastattacker = user
if(isrobot(src.loc))
var/mob/living/silicon/robot/R = src.loc
if(R && R.cell)
R.cell.use(50)
else
charges--
H.visible_message("<span class='danger'>[M] has been stunned with the [src] by [user]!</span>")
deductcharge(hitcost)
M.visible_message("<span class='danger'>[M] has been stunned with the [src] by [user]!</span>")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Stunned [H.name] ([H.ckey]) with [src.name]</font>"
H.attack_log += "\[[time_stamp()]\]<font color='orange'> Stunned by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[key_name(user)] stunned [key_name(H)] with [src.name] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[H.x];Y=[H.y];Z=[H.z]'>JMP</a>")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Stunned [M.name] ([M.ckey]) with [src.name]</font>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'> Stunned by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[key_name(user)] stunned [key_name(M)] with [src.name] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[M.x];Y=[M.y];Z=[M.z]'>JMP</a>")
playsound(src.loc, 'sound/weapons/Egloves.ogg', 50, 1, -1)
if(charges < 1)
if(bcell && bcell.charge < hitcost)
status = 0
update_icon()
@@ -106,7 +155,7 @@
H.apply_effect(10, STUN, 0)
H.apply_effect(10, WEAKEN, 0)
H.apply_effect(10, STUTTER, 0)
charges--
deductcharge(hitcost)
for(var/mob/M in player_list) if(M.key == src.fingerprintslast)
foundmob = M
@@ -118,15 +167,20 @@
msg_admin_attack("Flying [src.name], last touched by ([src.fingerprintslast]) stunned [key_name(H)] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[H.x];Y=[H.y];Z=[H.z]'>JMP</a>" )
/obj/item/weapon/melee/baton/emp_act(severity)
switch(severity)
if(1)
charges = 0
if(2)
charges = max(0, charges - 5)
if(charges < 1)
status = 0
update_icon()
if(bcell)
bcell.emp_act(severity) //let's not duplicate code everywhere if we don't have to please.
..()
//secborg stun baton module
/obj/item/weapon/melee/baton/robot/attack_self(mob/user)
//try to find our power cell
var/mob/living/silicon/robot/R = loc
if (istype(R))
bcell = R.cell
return ..()
/obj/item/weapon/melee/baton/robot/attackby(obj/item/weapon/W, mob/user)
return
/*
*
@@ -137,133 +191,19 @@
*/
/obj/item/weapon/melee/baton/stunrod
name = "stun rod"
name = "stunrod"
desc = "A more-than-lethal weapon used to deal with high threat situations."
icon_state = "stunrod"
item_state = "stunrod"
flags = FPRINT | TABLEPASS
slot_flags = SLOT_BELT
force = 12
force = 15
throwforce = 8
w_class = 3
origin_tech = "combat=4,illegal=2"
suicide_act(mob/user)
viewers(user) << "\red <b>[user] is putting the live [src.name] in \his mouth! It looks like \he's trying to commit suicide.</b>"
return (FIRELOSS)
/obj/item/weapon/melee/baton/stunrod/update_icon()
if(status)
icon_state = "stunrod_active"
item_state = "stunrod_active"
else
icon_state = "stunrod"
item_state = "stunrod"
/obj/item/weapon/melee/baton/stunrod/attack_self(mob/user as mob)
if(status && (CLUMSY in user.mutations) && prob(50))
user << "\red You grab the [src] on the wrong side and burn yourself."
user.Weaken(40)
charges--
if(charges < 1)
status = 0
update_icon()
return
if(charges > 0)
status = !status
user << "<span class='notice'>\The [src] is now [status ? "on" : "off"].</span>"
playsound(src.loc, "sparks", 75, 1, -1)
update_icon()
else
status = 0
user << "<span class='warning'>\The [src] is out of charge.</span>"
add_fingerprint(user)
/obj/item/weapon/melee/baton/stunrod/attack(mob/M as mob, mob/user as mob)
if(status && (CLUMSY in user.mutations) && prob(50))
user << "<span class='danger'>You accidentally hit yourself with the [src]!</span>"
user.Weaken(20)
// user.apply_damage(10,BURN)
charges--
if(charges < 1)
status = 0
update_icon()
return
var/mob/living/carbon/human/H = M
if(isrobot(M))
..()
return
if(user.a_intent == "hurt")
if(!..()) return
H.apply_effect(5, WEAKEN, 0)
H.apply_damage(15, BURN)
H.visible_message("<span class='danger'>[M] has been beaten with the [src] by [user]!</span>")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Beat [H.name] ([H.ckey]) with [src.name]</font>"
H.attack_log += "\[[time_stamp()]\]<font color='orange'> Beaten by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[user.name] ([user.ckey]) beat [H.name] ([H.ckey]) with [src.name] (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
playsound(src.loc, "swing_hit", 50, 1, -1)
else if(!status)
H.visible_message("<span class='warning'>[M] has been prodded with the [src] by [user]. Luckily it was off.</span>")
return
if(status)
H.apply_effect(5, STUN, 0)
H.apply_effect(5, WEAKEN, 0)
H.apply_effect(5, STUTTER, 0)
H.apply_damage(15, BURN)
user.lastattacked = M
H.lastattacker = user
if(isrobot(src.loc))
var/mob/living/silicon/robot/R = src.loc
if(R && R.cell)
R.cell.use(75)
else
charges--
H.visible_message("<span class='danger'>[M] has been stunned with the [src] by [user]!</span>")
user.attack_log += "\[[time_stamp()]\]<font color='red'> Stunned [H.name] ([H.ckey]) with [src.name]</font>"
H.attack_log += "\[[time_stamp()]\]<font color='orange'> Stunned by [user.name] ([user.ckey]) with [src.name]</font>"
msg_admin_attack("[key_name(user)] stunned [key_name(H)] with [src.name] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[H.x];Y=[H.y];Z=[H.z]'>JMP</a>")
playsound(src.loc, 'sound/weapons/Egloves.ogg', 50, 1, -1)
if(charges < 1)
status = 0
update_icon()
add_fingerprint(user)
/obj/item/weapon/melee/baton/stunrod/throw_impact(atom/hit_atom)
. = ..()
if (prob(50))
if(istype(hit_atom, /mob/living))
var/mob/living/carbon/human/H = hit_atom
if(status)
H.apply_effect(5, STUN, 0)
H.apply_effect(5, WEAKEN, 0)
H.apply_effect(5, STUTTER, 0)
H.apply_damage(15, BURN)
charges--
for(var/mob/M in player_list) if(M.key == src.fingerprintslast)
foundmob = M
break
H.visible_message("<span class='danger'>[src], thrown by [foundmob.name], strikes [H] and stuns them!</span>")
H.attack_log += "\[[time_stamp()]\]<font color='orange'> Stunned by thrown [src.name] last touched by ([src.fingerprintslast])</font>"
msg_admin_attack("Flying [src.name], last touched by ([src.fingerprintslast]) stunned [key_name(H)] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[H.x];Y=[H.y];Z=[H.z]'>JMP</a>" )
/obj/item/weapon/melee/baton/stunrod/emp_act(severity)
switch(severity)
if(1)
charges = 0
if(2)
charges = max(0, charges - 5)
if(charges < 1)
status = 0
update_icon()
/obj/item/weapon/melee/baton/stunrod/loaded/New() //this one starts with a cell pre-installed.
..()
bcell = new/obj/item/weapon/cell/high(src)
update_icon()
return