Merge pull request #1534 from Citadel-Station-13/SelectiveMirrorSync

Selective mirror sync
This commit is contained in:
LetterJay
2017-06-14 06:41:01 -05:00
committed by GitHub
104 changed files with 2272 additions and 1039 deletions
+32 -31
View File
@@ -4,13 +4,13 @@
desc = "A basic energy-based gun."
icon = 'icons/obj/guns/energy.dmi'
var/obj/item/weapon/stock_parts/cell/power_supply //What type of power cell this uses
var/obj/item/weapon/stock_parts/cell/cell //What type of power cell this uses
var/cell_type = /obj/item/weapon/stock_parts/cell
var/modifystate = 0
var/list/ammo_type = list(/obj/item/ammo_casing/energy)
var/select = 1 //The state of the select fire switch. Determines from the ammo_type list what kind of shot is fired next.
var/can_charge = 1 //Can it be charged in a recharger?
var/automatic_charge_overlays = TRUE //Do we handle overlays with base update_icon()?
var/automatic_charge_overlays = TRUE //Do we handle overlays with base update_icon()?
var/charge_sections = 4
ammo_x_offset = 2
var/shaded_charge = 0 //if this gun uses a stateful charge bar for more detail
@@ -20,19 +20,22 @@
var/use_cyborg_cell = 0 //whether the gun's cell drains the cyborg user's cell to recharge
/obj/item/weapon/gun/energy/emp_act(severity)
power_supply.use(round(power_supply.charge / severity))
cell.use(round(cell.charge / severity))
chambered = null //we empty the chamber
recharge_newshot() //and try to charge a new shot
update_icon()
/obj/item/weapon/gun/energy/get_cell()
return cell
/obj/item/weapon/gun/energy/Initialize()
. = ..()
/obj/item/weapon/gun/energy/Initialize()
. = ..()
if(cell_type)
power_supply = new cell_type(src)
cell = new cell_type(src)
else
power_supply = new(src)
power_supply.give(power_supply.maxcharge)
cell = new(src)
cell.give(cell.maxcharge)
update_ammo_types()
recharge_newshot(1)
if(selfcharge)
@@ -50,9 +53,7 @@
fire_delay = shot.delay
/obj/item/weapon/gun/energy/Destroy()
if(power_supply)
qdel(power_supply)
power_supply = null
QDEL_NULL(cell)
STOP_PROCESSING(SSobj, src)
return ..()
@@ -62,9 +63,9 @@
if(charge_tick < charge_delay)
return
charge_tick = 0
if(!power_supply)
if(!cell)
return
power_supply.give(100)
cell.give(100)
if(!chambered) //if empty chamber we try to charge a new shot
recharge_newshot(1)
update_icon()
@@ -76,10 +77,10 @@
/obj/item/weapon/gun/energy/can_shoot()
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
return power_supply.charge >= shot.e_cost
return cell.charge >= shot.e_cost
/obj/item/weapon/gun/energy/recharge_newshot(no_cyborg_drain)
if (!ammo_type || !power_supply)
if (!ammo_type || !cell)
return
if(use_cyborg_cell && !no_cyborg_drain)
if(iscyborg(loc))
@@ -87,10 +88,10 @@
if(R.cell)
var/obj/item/ammo_casing/energy/shot = ammo_type[select] //Necessary to find cost of shot
if(R.cell.use(shot.e_cost)) //Take power from the borg...
power_supply.give(shot.e_cost) //... to recharge the shot
cell.give(shot.e_cost) //... to recharge the shot
if(!chambered)
var/obj/item/ammo_casing/energy/AC = ammo_type[select]
if(power_supply.charge >= AC.e_cost) //if there's enough power in the power_supply cell...
if(cell.charge >= AC.e_cost) //if there's enough power in the cell cell...
chambered = AC //...prepare a new shot based on the current ammo type selected
if(!chambered.BB)
chambered.newshot()
@@ -98,7 +99,7 @@
/obj/item/weapon/gun/energy/process_chamber()
if(chambered && !chambered.BB) //if BB is null, i.e the shot has been fired...
var/obj/item/ammo_casing/energy/shot = chambered
power_supply.use(shot.e_cost)//... drain the power_supply cell
cell.use(shot.e_cost)//... drain the cell cell
chambered = null //either way, released the prepared shot
recharge_newshot() //try to charge a new shot
@@ -117,10 +118,10 @@
return
/obj/item/weapon/gun/energy/update_icon()
..()
if(!automatic_charge_overlays)
return
var/ratio = Ceiling((power_supply.charge / power_supply.maxcharge) * charge_sections)
..()
if(!automatic_charge_overlays)
return
var/ratio = Ceiling((cell.charge / cell.maxcharge) * charge_sections)
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
var/iconState = "[icon_state]_charge"
var/itemState = null
@@ -131,16 +132,16 @@
iconState += "_[shot.select_name]"
if(itemState)
itemState += "[shot.select_name]"
if(power_supply.charge < shot.e_cost)
if(cell.charge < shot.e_cost)
add_overlay("[icon_state]_empty")
else
if(!shaded_charge)
var/mutable_appearance/charge_overlay = mutable_appearance(icon, iconState)
var/mutable_appearance/charge_overlay = mutable_appearance(icon, iconState)
for(var/i = ratio, i >= 1, i--)
charge_overlay.pixel_x = ammo_x_offset * (i - 1)
add_overlay(charge_overlay)
charge_overlay.pixel_x = ammo_x_offset * (i - 1)
add_overlay(charge_overlay)
else
add_overlay("[icon_state]_charge[ratio]")
add_overlay("[icon_state]_charge[ratio]")
if(itemState)
itemState += "[ratio]"
item_state = itemState
@@ -156,7 +157,7 @@
user.visible_message("<span class='suicide'>[user] melts [user.p_their()] face off with [src]!</span>")
playsound(loc, fire_sound, 50, 1, -1)
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
power_supply.use(shot.e_cost)
cell.use(shot.e_cost)
update_icon()
return(FIRELOSS)
else
@@ -191,17 +192,17 @@
user.visible_message("<span class='danger'>[user] tries to light their [A.name] with [src], but it doesn't do anything. Dumbass.</span>")
playsound(user, E.fire_sound, 50, 1)
playsound(user, BB.hitsound, 50, 1)
power_supply.use(E.e_cost)
cell.use(E.e_cost)
. = ""
else if(BB.damage_type != BURN)
user.visible_message("<span class='danger'>[user] tries to light their [A.name] with [src], but only succeeds in utterly destroying it. Dumbass.</span>")
playsound(user, E.fire_sound, 50, 1)
playsound(user, BB.hitsound, 50, 1)
power_supply.use(E.e_cost)
cell.use(E.e_cost)
qdel(A)
. = ""
else
playsound(user, E.fire_sound, 50, 1)
playsound(user, BB.hitsound, 50, 1)
power_supply.use(E.e_cost)
cell.use(E.e_cost)
. = "<span class='danger'>[user] casually lights their [A.name] with [src]. Damn.</span>"
@@ -98,7 +98,7 @@
empty()
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/empty()
power_supply.use(500)
cell.use(500)
update_icon()
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/attempt_reload(recharge_time)
@@ -125,7 +125,7 @@
return
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/reload()
power_supply.give(500)
cell.give(500)
recharge_newshot(1)
if(!suppressed)
playsound(src.loc, 'sound/weapons/kenetic_reload.ogg', 60, 1)
@@ -163,6 +163,7 @@
range = 3
log_override = TRUE
var/pressure_decrease_active = FALSE
var/pressure_decrease = 0.25
var/obj/item/weapon/gun/energy/kinetic_accelerator/kinetic_gun
@@ -179,6 +180,7 @@
if(pressure > 50)
name = "weakened [name]"
damage = damage * pressure_decrease
pressure_decrease_active = TRUE
. = ..()
/obj/item/projectile/kinetic/on_range()
@@ -194,7 +196,10 @@
if(!target_turf)
target_turf = get_turf(src)
if(kinetic_gun) //hopefully whoever shot this was not very, very unfortunate.
for(var/obj/item/borg/upgrade/modkit/M in kinetic_gun.get_modkits())
var/list/mods = kinetic_gun.get_modkits()
for(var/obj/item/borg/upgrade/modkit/M in mods)
M.projectile_strike_predamage(src, target_turf, target, kinetic_gun)
for(var/obj/item/borg/upgrade/modkit/M in mods)
M.projectile_strike(src, target_turf, target, kinetic_gun)
if(ismineralturf(target_turf))
var/turf/closed/mineral/M = target_turf
@@ -210,6 +215,7 @@
icon = 'icons/obj/objects.dmi'
icon_state = "modkit"
origin_tech = "programming=2;materials=2;magnets=4"
w_class = WEIGHT_CLASS_SMALL
require_module = 1
module_type = /obj/item/weapon/robot_module/miner
var/denied_type = null
@@ -264,6 +270,10 @@
/obj/item/borg/upgrade/modkit/proc/modify_projectile(obj/item/projectile/kinetic/K)
//use this one for effects you want to trigger before mods that do damage
/obj/item/borg/upgrade/modkit/proc/projectile_strike_predamage(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
//and this one for things that don't need to trigger before other damage-dealing mods
/obj/item/borg/upgrade/modkit/proc/projectile_strike(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
//Range
@@ -370,7 +380,7 @@
modifier = -14 //Makes the cooldown 3 seconds(with no cooldown mods) if you miss. Don't miss.
cost = 50
/obj/item/borg/upgrade/modkit/cooldown/repeater/projectile_strike(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
/obj/item/borg/upgrade/modkit/cooldown/repeater/projectile_strike_predamage(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
var/valid_repeat = FALSE
if(isliving(target))
var/mob/living/L = target
@@ -380,7 +390,7 @@
valid_repeat = TRUE
if(valid_repeat)
KA.overheat = FALSE
KA.attempt_reload(KA.overheat_time * 0.25) //If you hit, the cooldown drops to 0.75 seconds.
KA.attempt_reload(KA.overheat_time * 0.25) //If you hit, the cooldown drops to 0.75 seconds.
/obj/item/borg/upgrade/modkit/lifesteal
name = "lifesteal crystal"
@@ -390,7 +400,7 @@
cost = 20
var/static/list/damage_heal_order = list(BRUTE, BURN, OXY)
/obj/item/borg/upgrade/modkit/lifesteal/projectile_strike(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
/obj/item/borg/upgrade/modkit/lifesteal/projectile_strike_predamage(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
if(isliving(target) && isliving(K.firer))
var/mob/living/L = target
if(L.stat == DEAD)
@@ -414,6 +424,43 @@
return
new /obj/effect/temp_visual/resonance(target_turf, K.firer, null, 30)
/obj/item/borg/upgrade/modkit/bounty
name = "death syphon"
desc = "Killing or assisting in killing a creature permenantly increases your damage against that type of creature."
denied_type = /obj/item/borg/upgrade/modkit/bounty
modifier = 1.25
cost = 30
var/maximum_bounty = 25
var/list/bounties_reaped = list()
/obj/item/borg/upgrade/modkit/bounty/projectile_strike(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
if(isliving(target))
var/mob/living/L = target
var/list/existing_marks = L.has_status_effect_list(STATUS_EFFECT_SYPHONMARK)
for(var/i in existing_marks)
var/datum/status_effect/syphon_mark/SM = i
if(SM.reward_target == src) //we want to allow multiple people with bounty modkits to use them, but we need to replace our own marks so we don't multi-reward
SM.reward_target = null
qdel(SM)
var/datum/status_effect/syphon_mark/SM = L.apply_status_effect(STATUS_EFFECT_SYPHONMARK)
SM.reward_target = src
if(bounties_reaped[L.type])
var/kill_modifier = 1
if(K.pressure_decrease_active)
kill_modifier *= K.pressure_decrease
var/armor = L.run_armor_check(K.def_zone, K.flag, "", "", K.armour_penetration)
L.apply_damage(bounties_reaped[L.type]*kill_modifier, K.damage_type, K.def_zone, armor)
/obj/item/borg/upgrade/modkit/bounty/proc/get_kill(mob/living/L)
var/bonus_mod = 1
if(ismegafauna(L)) //megafauna reward
bonus_mod = 4
if(!bounties_reaped[L.type])
bounties_reaped[L.type] = min(modifier * bonus_mod, maximum_bounty)
else
bounties_reaped[L.type] = min(bounties_reaped[L.type] + (modifier * bonus_mod), maximum_bounty)
//Indoors
/obj/item/borg/upgrade/modkit/indoors
name = "decrease pressure penalty"
@@ -39,7 +39,7 @@
/obj/item/weapon/gun/energy/decloner/update_icon()
..()
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
if(power_supply.charge > shot.e_cost)
if(cell.charge > shot.e_cost)
add_overlay("decloner_spin")
/obj/item/weapon/gun/energy/floragun
@@ -137,19 +137,19 @@
/obj/item/weapon/gun/energy/plasmacutter/examine(mob/user)
..()
if(power_supply)
to_chat(user, "<span class='notice'>[src] is [round(power_supply.percent())]% charged.</span>")
if(cell)
to_chat(user, "<span class='notice'>[src] is [round(cell.percent())]% charged.</span>")
/obj/item/weapon/gun/energy/plasmacutter/attackby(obj/item/A, mob/user)
if(istype(A, /obj/item/stack/sheet/mineral/plasma))
var/obj/item/stack/sheet/S = A
S.use(1)
power_supply.give(1000)
cell.give(1000)
recharge_newshot(1)
to_chat(user, "<span class='notice'>You insert [A] in [src], recharging it.</span>")
else if(istype(A, /obj/item/weapon/ore/plasma))
qdel(A)
power_supply.give(500)
cell.give(500)
recharge_newshot(1)
to_chat(user, "<span class='notice'>You insert [A] in [src], recharging it.</span>")
else
+48 -38
View File
@@ -78,7 +78,7 @@
return "chest"
/obj/item/projectile/proc/prehit(atom/target)
return
return TRUE
/obj/item/projectile/proc/on_hit(atom/target, blocked = 0)
var/turf/target_loca = get_turf(target)
@@ -142,7 +142,7 @@
if(firer && !ricochets)
if(A == firer || (A == firer.loc && istype(A, /obj/mecha))) //cannot shoot yourself or your mech
loc = A.loc
return 0
return FALSE
var/distance = get_dist(get_turf(A), starting) // Get the distance between the turf shot from and the mob we hit and use that for the calculations.
def_zone = ran_zone(def_zone, max(100-(7*distance), 5)) //Lower accurancy/longer range tradeoff. 7 is a balanced number to use.
@@ -155,13 +155,14 @@
var/turf/target_turf = get_turf(A)
prehit(A)
if(!prehit(A))
return FALSE
var/permutation = A.bullet_act(src, def_zone) // searches for return value, could be deleted after run so check A isn't null
if(permutation == -1 || forcedodge)// the bullet passes through a dense object!
loc = target_turf
if(A)
permutated.Add(A)
return 0
return FALSE
else
if(A && A.density && !ismob(A) && !(A.flags & ON_BORDER)) //if we hit a dense non-border obj or dense turf then we also hit one of the mobs on that tile.
var/list/mobs_list = list()
@@ -169,9 +170,11 @@
mobs_list += L
if(mobs_list.len)
var/mob/living/picked_mob = pick(mobs_list)
prehit(picked_mob)
if(!prehit(picked_mob))
return FALSE
picked_mob.bullet_act(src, def_zone)
qdel(src)
return TRUE
/obj/item/projectile/proc/check_ricochet()
if(prob(ricochet_chance))
@@ -277,46 +280,53 @@
Range()
sleep(config.run_speed * 0.9)
/obj/item/projectile/proc/preparePixelProjectile(atom/target, var/turf/targloc, mob/living/user, params, spread)
var/turf/curloc = get_turf(user)
src.loc = get_turf(user)
src.starting = get_turf(user)
src.current = curloc
src.yo = targloc.y - curloc.y
src.xo = targloc.x - curloc.x
forceMove(get_turf(user))
starting = get_turf(user)
current = curloc
yo = targloc.y - curloc.y
xo = targloc.x - curloc.x
if(params)
var/list/mouse_control = params2list(params)
if(mouse_control["icon-x"])
src.p_x = text2num(mouse_control["icon-x"])
if(mouse_control["icon-y"])
src.p_y = text2num(mouse_control["icon-y"])
if(mouse_control["screen-loc"])
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",")
var/list/calculated = calculate_projectile_angle_and_pixel_offsets(user, params)
Angle = calculated[1]
p_x = calculated[2]
p_y = calculated[3]
//Split X+Pixel_X up into list(X, Pixel_X)
var/list/screen_loc_X = splittext(screen_loc_params[1],":")
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
var/list/screen_loc_Y = splittext(screen_loc_params[2],":")
// to_chat(world, "X: [screen_loc_X[1]] PixelX: [screen_loc_X[2]] / Y: [screen_loc_Y[1]] PixelY: [screen_loc_Y[2]]")
var/x = text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32
var/y = text2num(screen_loc_Y[1]) * 32 + text2num(screen_loc_Y[2]) - 32
//Calculate the "resolution" of screen based on client's view and world's icon size. This will work if the user can view more tiles than average.
var/screenview = (user.client.view * 2 + 1) * world.icon_size //Refer to http://www.byond.com/docs/ref/info.html#/client/var/view for mad maths
var/ox = round(screenview/2) //"origin" x
var/oy = round(screenview/2) //"origin" y
// to_chat(world, "Pixel position: [x] [y]")
var/angle = Atan2(y - oy, x - ox)
// to_chat(world, "Angle: [angle]")
src.Angle = angle
if(spread)
src.Angle += spread
/proc/calculate_projectile_angle_and_pixel_offsets(mob/user, params)
var/list/mouse_control = params2list(params)
var/p_x = 0
var/p_y = 0
var/angle = 0
if(mouse_control["icon-x"])
p_x = text2num(mouse_control["icon-x"])
if(mouse_control["icon-y"])
p_y = text2num(mouse_control["icon-y"])
if(mouse_control["screen-loc"])
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",")
//Split X+Pixel_X up into list(X, Pixel_X)
var/list/screen_loc_X = splittext(screen_loc_params[1],":")
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
var/list/screen_loc_Y = splittext(screen_loc_params[2],":")
// to_chat(world, "X: [screen_loc_X[1]] PixelX: [screen_loc_X[2]] / Y: [screen_loc_Y[1]] PixelY: [screen_loc_Y[2]]")
var/x = text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32
var/y = text2num(screen_loc_Y[1]) * 32 + text2num(screen_loc_Y[2]) - 32
//Calculate the "resolution" of screen based on client's view and world's icon size. This will work if the user can view more tiles than average.
var/screenview = (user.client.view * 2 + 1) * world.icon_size //Refer to http://www.byond.com/docs/ref/info.html#/client/var/view for mad maths
var/ox = round(screenview/2) - user.client.pixel_x //"origin" x
var/oy = round(screenview/2) - user.client.pixel_y //"origin" y
// to_chat(world, "Pixel position: [x] [y]")
angle = Atan2(y - oy, x - ox)
// to_chat(world, "Angle: [angle]")
return list(angle, p_x, p_y)
/obj/item/projectile/Crossed(atom/movable/AM) //A mob moving on a tile with a projectile is hit by it.
..()