-
-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tesla Cannon #244
Tesla Cannon #244
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
// BEGIN_INTERNALS | ||
/* | ||
MAP_ICON_TYPE: 0 | ||
LAST_COMPILE_TIME: 1461346265 | ||
DIR: code code\defines code\defines\obj code\game code\game\machinery code\game\mecha code\game\mecha\equipment code\game\mecha\equipment\tools code\game\mecha\equipment\weapons code\game\objects code\game\objects\items code\game\objects\items\devices code\game\objects\items\weapons code\modules code\modules\mob code\modules\mob\living code\modules\mob\living\carbon code\modules\mob\living\carbon\human code\modules\paperwork code\modules\power code\modules\power\antimatter code\modules\projectiles code\modules\projectiles\guns code\modules\projectiles\guns\energy code\modules\research code\modules\research\designs tauceti tauceti\items tauceti\items\musical_instruments tauceti\items\weapons tauceti\items\weapons\guns | ||
AUTO_FILE_DIR: OFF | ||
MAP_ICON_TYPE: 0 | ||
LAST_COMPILE_VERSION: 510.1338 | ||
WINDOW: code\modules\research\designs.dm;code\game\mecha\equipment\tools\tools.dm;code\game\mecha\equipment\weapons\weapons.dm;code\game\mecha\equipment\mecha_equipment.dm;code\game\mecha\mecha.dm;code\modules\research\designs\mechfabricator_designs.dm;code\modules\mob\living\carbon\human\human.dm;code\modules\paperwork\clipboard.dm;code\modules\projectiles\guns\energy\tesla.dm | ||
FILE: code\modules\projectiles\guns\energy\tesla.dm | ||
*/ | ||
// END_INTERNALS |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/obj/item/weapon/gun/energy/tesla | ||
name = "Tesla Cannon" | ||
desc = "Cannon which uses electrical charge to damage multiple targets. Spin the generator handle to charge it up" | ||
icon = 'icons/obj/gun.dmi' | ||
icon_state = "tesla" | ||
w_class = 4.0 | ||
origin_tech = "combat = 5;materials = 5;powerstorage = 5;magnets = 5;engineering = 5" | ||
var/charge = 0 | ||
var/charging = 0 | ||
var/cooldown = 0 | ||
|
||
/obj/item/weapon/gun/energy/tesla/proc/charge(mob/living/user as mob) | ||
spawn(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Зачем спавн? |
||
if(do_after(user, 40)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не хватает третьего аргумента - цели. if(do_after(user, 40, target = src)) в данном случае. |
||
if(charging==1 && charge < 3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. операторы лучше разделять пробелами, а то они у тебя то с ними, то без |
||
switch(charge) | ||
if(0) icon_state="tesla_1" | ||
if(1) icon_state="tesla_2" | ||
if(2) icon_state="tesla_3" | ||
++charge | ||
playsound(loc, "sparks", 75, 1, -1) | ||
if(charging && charge < 3) | ||
charge(user) | ||
else | ||
charging=0 | ||
else | ||
charging=0 | ||
else | ||
user << "\red \italic Generator is too difficult to spin while moving! Charging aborted" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. user << "Generator is too difficult to spin while moving! Charging aborted." |
||
charging=0 | ||
|
||
|
||
|
||
/obj/item/weapon/gun/energy/tesla/attack_self(mob/living/user as mob) | ||
if(charging==1) | ||
charging=0 | ||
user << "\blue You stop charging Tesla Cannon..." | ||
cooldown = 1 | ||
spawn(50) cooldown = 0 | ||
return | ||
if(cooldown) return | ||
if(charge == 3) return | ||
user.visible_message("\red \italic [user] starts spinning generator on Tesla Cannon!") | ||
user << "\blue You start charging Tesla Cannon..." | ||
charging=1 | ||
charge(user) | ||
|
||
|
||
/obj/item/weapon/gun/energy/tesla/Fire(atom/pbtarget as mob|obj|turf, mob/living/user as mob|obj, message = 1, params, zone_override) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Коли оверрайдишь - т.е перезаписываешь прок не вызывая при этом родителя - смотри что делает основной прок у пушек - у тебя потеряны проверки на халков, лингов, абдукторов, клоуна и еще по мелочи. |
||
if(!charge) | ||
user << "\red Tesla Cannon is not charged!" | ||
return | ||
|
||
if(!istype(pbtarget,/mob/living)) | ||
user << "\red Tesla Cannon needs to be aimed directly at living target" | ||
return | ||
|
||
if(charging) | ||
user << "\red You can't shoot while charging!" | ||
return | ||
|
||
icon_state = "tesla100" | ||
spawn(1) user.Beam(pbtarget,icon_state="lightning",icon='icons/effects/effects.dmi',time=5) | ||
Bolt(user,pbtarget,user,charge) | ||
charge=0 | ||
if(user) | ||
if(user.hand) | ||
user.update_inv_l_hand() | ||
else | ||
user.update_inv_r_hand() | ||
feedback_add_details("gun_fired","[src.type]") | ||
|
||
/obj/item/weapon/gun/energy/tesla/proc/los_check(mob/A,mob/B) | ||
for(var/atom/turf in getline(A,B)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. turf суть часть atom'а, но atom это не только turf. Короче, лучше var/atom/A, потому что твой вариант вводит в заблуждение. |
||
if(turf.density && !istype(turf,/obj/structure/table)) | ||
return 0 | ||
return 1 | ||
|
||
/obj/item/weapon/gun/energy/tesla/proc/Bolt(mob/origin,mob/target,mob/user = usr,jumps) | ||
spawn(1) origin.Beam(target,icon_state="lightning[rand(1,12)]",icon='icons/effects/effects.dmi',time=5) | ||
var/mob/living/carbon/current = target | ||
current.electrocute_act(15*(jumps+1),"electric bolt",1.0,null,1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вообще, если посмотреть в прок electrocute_act() то второй аргумент по атому идет, хорошо что он лишь для текста используется и поэтому никаких нет к счастью рантаймов - это я про "electric bolt" что как бы стринг, а не атом. И тоже самое и ниже. |
||
playsound(get_turf(current), 'sound/machines/defib_zap.ogg', 50, 1, -1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вместо get_turf() можно просто current. |
||
var/list/possible_targets = new | ||
for(var/mob/living/M in range(2,target)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А почему range() а не view()? |
||
if(user == M || !los_check(current,M) || origin == M || current == M) | ||
continue | ||
possible_targets += M | ||
if(!possible_targets.len) | ||
return | ||
var/mob/living/next = pick(possible_targets) | ||
if(next && jumps > 0) | ||
Bolt(current,next,user,--jumps) | ||
--jumps | ||
|
||
/obj/item/weapon/gun/energy/tesla/emp_act(severity) | ||
if(src && src.charge) | ||
if(istype(loc, /mob/living/carbon)) | ||
var/mob/living/carbon/M = loc | ||
M.electrocute_act(5*(4-severity)*charge,"Tesla Cannon") | ||
charge=0 | ||
icon_state = "tesla100" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mob, as mob|obj|turf и вообще as что-то там - это все лишнее и не нужно.