Merge pull request #8155 from FalseIncarnate/windows

Windows Update
This commit is contained in:
tigercat2000
2017-11-10 22:00:19 -08:00
committed by GitHub
5 changed files with 162 additions and 112 deletions
+4 -4
View File
@@ -44,7 +44,7 @@
icon_state = "plasmawindow"
shardtype = /obj/item/weapon/shard/plasma
glasstype = /obj/item/stack/sheet/plasmaglass
health = 120
health = 240
/obj/structure/window/full/plasmabasic/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature > T0C + 32000)
@@ -59,7 +59,7 @@
shardtype = /obj/item/weapon/shard/plasma
glasstype = /obj/item/stack/sheet/plasmaglass
reinf = 1
health = 160
health = 320
/obj/structure/window/full/plasmareinforced/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
return
@@ -69,7 +69,7 @@
desc = "It looks rather strong. Might take a few good hits to shatter it."
icon_state = "rwindow"
basestate = "rwindow"
health = 40
health = 80
reinf = 1
/obj/structure/window/full/reinforced/tinted
@@ -84,7 +84,7 @@
desc = "It looks rather strong and frosted over. Looks like it might take a few less hits then a normal reinforced window."
icon_state = "fwindow"
basestate = "fwindow"
health = 30
health = 60
/obj/structure/window/full/shuttle
name = "shuttle window"
+72 -55
View File
@@ -159,65 +159,82 @@
//window placing begin
else if(istype(W,/obj/item/stack/sheet/rglass) || istype(W,/obj/item/stack/sheet/glass) || istype(W,/obj/item/stack/sheet/plasmaglass) || istype(W,/obj/item/stack/sheet/plasmarglass))
if(!broken)
var/obj/item/stack/ST = W
if (ST.get_amount() < 1)
to_chat(user, "<span class='warning'>You need at least one sheet of glass for that!</span>")
return
var/dir_to_set = NORTH
if(!anchored)
to_chat(user, "<span class='warning'>[src] needs to be fastened to the floor first!</span>")
return
if(loc == user.loc)
dir_to_set = user.dir
else
if((x == user.x) || (y == user.y)) //Only supposed to work for cardinal directions.
if(x == user.x)
if(y > user.y)
dir_to_set = SOUTH
else
dir_to_set = NORTH
else if(y == user.y)
if(x > user.x)
dir_to_set = WEST
else
dir_to_set = EAST
else
to_chat(user, "<span class='notice'>You can't reach.</span>")
return //Only works for cardinal direcitons, diagonals aren't supposed to work like this.
for(var/obj/structure/window/WINDOW in loc)
if(WINDOW.dir == dir_to_set)
to_chat(user, "<span class='notice'>There is already a window facing this way there.</span>")
return
to_chat(user, "<span class='notice'>You start placing the window...</span>")
if(do_after(user, 20 * W.toolspeed, target = src))
if(!loc || !anchored) //Grille destroyed or unanchored while waiting
return
for(var/obj/structure/window/WINDOW in loc)
if(WINDOW.dir == dir_to_set)//checking this for a 2nd time to check if a window was made while we were waiting.
to_chat(user, "<span class='notice'>There is already a window facing this way there.</span>")
return
var/obj/structure/window/WD
if(istype(W,/obj/item/stack/sheet/rglass))
WD = new/obj/structure/window/reinforced(loc) //reinforced window
else if(istype(W,/obj/item/stack/sheet/glass))
WD = new/obj/structure/window/basic(loc) //normal window
else if(istype(W,/obj/item/stack/sheet/plasmaglass))
WD = new/obj/structure/window/plasmabasic(loc) //basic plasma window
else
WD = new/obj/structure/window/plasmareinforced(loc) //reinforced plasma window
WD.setDir(dir_to_set)
WD.ini_dir = dir_to_set
WD.anchored = 0
WD.state = 0
ST.use(1)
to_chat(user, "<span class='notice'>You place the [WD] on [src].</span>")
WD.update_icon()
return
build_window(W, user)
return
//window placing end
else if(istype(W, /obj/item/weapon/shard) || !shock(user, 70))
return attacked_by(W, user)
/obj/structure/grille/proc/build_window(obj/item/stack/sheet/S, mob/user)
if(!istype(S) || !user)
return
if(broken)
to_chat(user, "<span class='warning'>You must repair or replace [src] first!</span>")
return
if(S.get_amount() < 1)
to_chat(user, "<span class='warning'>You need at least one sheet of glass for that!</span>")
return
if(!anchored)
to_chat(user, "<span class='warning'>[src] needs to be fastened to the floor first!</span>")
return
if(!getRelativeDirection(src, user) && (user.loc != loc)) //essentially a cardinal direction adjacent or sharing same loc check
to_chat(user, "<span class='warning'>You can't reach.</span>")
return
if(/obj/structure/window/full in loc) //check for a full window already present (blocks the whole tile)
to_chat(user, "<span class='warning'>There is already a full window there.</span>")
return
var/selection = alert(user, "What type of window would you like to place?", "Window Construction", "One Direction", "Full", "Cancel")
if(selection == "Cancel")
return
if(selection == "Full")
if(S.get_amount() < 2)
to_chat(user, "<span class='warning'>You need at least two sheets of glass for that!</span>")
return
if(do_after(user, 20, target = src)) //glass doesn't have a toolspeed, so no multiplier
if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists!
return
if(S.get_amount() < 2) //make sure we still have enough for this!
return
if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location
return
var/obj/structure/window/W = new S.full_window(get_turf(src))
S.use(2)
W.anchored = 0
W.state = 0
to_chat(user, "<span class='notice'>You place [W] on [src].</span>")
W.update_icon()
return
if(selection == "One Direction")
var/dir_selection = input("Which direction will this window face?", "Direction") as null|anything in list("north", "east", "south", "west")
if(!dir_selection)
return
var/temp_dir = text2dir(dir_selection)
for(var/obj/structure/window/W in loc)
if(istype(W, /obj/structure/window/full)) //double checking in case a full window was created while selecting direction
to_chat(user, "<span class='warning'>There is already a full window there.</span>")
return
if(W.dir == temp_dir) //to avoid building a window on top of an existing window
to_chat(user, "<span class='warning'>There is already a window facing this direction there.</span>")
return
if(do_after(user, 20, target = src))
if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists!
return
if(S.get_amount() < 1) //make sure we still have enough fir this!
to_chat(user, "<span class='warning'>You need at least one sheet of glass for that!</span>")
return
if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location
return
var/obj/structure/window/W = new S.created_window(get_turf(src))
S.use(1)
W.setDir(temp_dir)
W.ini_dir = temp_dir
W.anchored = 0
W.state = 0
to_chat(user, "<span class='notice'>You place [W] on [src].</span>")
W.update_icon()
return
/obj/structure/grille/proc/attacked_by(obj/item/I, mob/living/user)
user.changeNext_move(CLICK_CD_MELEE)
user.do_attack_animation(src)
+76 -45
View File
@@ -180,7 +180,8 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f
/obj/structure/window/attackby(obj/item/I as obj, mob/living/user as mob, params)
if(!istype(I)) return//I really wish I did not need this
if(!istype(I))
return//I really wish I did not need this
if(istype(I, /obj/item/weapon/grab) && get_dist(src,user)<2)
var/obj/item/weapon/grab/G = I
if(istype(G.affecting,/mob/living))
@@ -209,67 +210,97 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f
M.apply_damage(30)
hit(75)
return
if(I.flags & NOBLUDGEON)
return
if(I.flags & NOBLUDGEON) return
if(handle_decon(I, user, is_fulltile()))
return
if(istype(I, /obj/item/weapon/screwdriver))
if(reinf && state >= 1)
state = 3 - state
playsound(loc, I.usesound, 75, 1)
to_chat(user, (state == 1 ? "<span class='notice'>You have unfastened the window from the frame.</span>" : "<span class='notice'>You have fastened the window to the frame.</span>"))
else if(reinf && state == 0)
if(I.damtype == BRUTE || I.damtype == BURN)
user.changeNext_move(CLICK_CD_MELEE)
hit(I.force)
if(health <= 7)
anchored = 0
update_nearby_icons()
step(src, get_dir(user, src))
else
playsound(loc, 'sound/effects/Glasshit.ogg', 75, 1)
..()
/obj/structure/window/proc/handle_decon(obj/item/weapon/W, mob/user, var/takes_time = FALSE)
//screwdriver
if(isscrewdriver(W))
playsound(loc, W.usesound, 75, 1)
if(reinf)
if(state == 0)
if(takes_time)
to_chat(user, "<span class='notice'>You begin to [anchored ? "unfasten the frame from" : "fasten the frame to"] the floor.</span>")
if(!do_after(user, 20 * W.toolspeed, target = src))
return 1
anchored = !anchored
to_chat(user, "<span class='notice'>You have [anchored? "fastened the frame to" : "unfastened the frame from"] the floor.</span>")
if(state >= 1)
if(takes_time)
to_chat(user, "<span class='notice'>You begin to [(state == 1) ? "fasten the window to" : "unfasten the window from"] the frame.</span>")
if(!do_after(user, 20 * W.toolspeed, target = src))
return 1
state = 3 - state
to_chat(user, "<span class='notice'>You have [(state == 1) ? "unfastened the window from" : "fastened the window to"] the frame.</span>")
else
if(takes_time)
to_chat(user, "<span class='notice'>You begin to [anchored ? "unfasten the frame from" : "fasten the frame to"] the floor.</span>")
if(!do_after(user, 20 * W.toolspeed, target = src))
return 1
anchored = !anchored
update_nearby_icons()
playsound(loc, I.usesound, 75, 1)
to_chat(user, (anchored ? "<span class='notice'>You have fastened the frame to the floor.</span>" : "<span class='notice'>You have unfastened the frame from the floor.</span>"))
else if(!reinf)
anchored = !anchored
update_nearby_icons()
playsound(loc, I.usesound, 75, 1)
to_chat(user, (anchored ? "<span class='notice'>You have fastened the window to the floor.</span>" : "<span class='notice'>You have unfastened the window.</span>"))
else if(istype(I, /obj/item/weapon/crowbar) && reinf && state <= 1)
to_chat(user, "<span class='notice'>You have [anchored ? "fastened the window to" : "unfastened the window from"] the floor.</span>")
return 1
//crowbar
if(iscrowbar(W))
if(!reinf || state > 1)
return 0
playsound(loc, W.usesound, 75, 1)
if(takes_time)
to_chat(user, "<span class='notice'>You begin to pry the window [state ? "out of" : "in to"] the frame.</span>")
if(!do_after(user, 20 * W.toolspeed, target = src))
return 1
state = 1 - state
playsound(loc, I.usesound, 75, 1)
to_chat(user, (state ? "<span class='notice'>You have pried the window into the frame.</span>" : "<span class='notice'>You have pried the window out of the frame.</span>"))
else if(istype(I, /obj/item/weapon/wrench) && !anchored && health > 7) //Disassemble deconstructed window into parts
playsound(src.loc, I.usesound, 50, 1)
for(var/i=0;i<sheets;i++)
var/obj/item/stack/sheet/glass/NG = new glasstype(src.loc)
for(var/obj/item/stack/sheet/glass/G in src.loc) //Stack em up
if(G==NG)
to_chat(user, "<span class='notice'>You have pried the window [state ? "into" : "out of"] the frame.</span>")
return 1
//wrench
if(iswrench(W))
if(anchored)
return 0
playsound(loc, W.usesound, 50, 1)
if(takes_time)
to_chat(user, "<span class='notice'>You begin to disassemble [src]...</span>")
if(!do_after(user, 20 * W.toolspeed, target = src))
return 1
for(var/i=0; i<sheets; i++)
var/obj/item/stack/sheet/NS = new glasstype(get_turf(src)) //glass types don't share a base tye of /glass, so this didn't work for plasma glass
for(var/obj/item/stack/sheet/S in loc) //Stack em up
if(S == NS)
continue
if(G.amount>=G.max_amount)
if(S.amount >= S.max_amount)
continue
G.attackby(NG, user, params)
S.attackby(NS, user)
if(reinf)
var/obj/item/stack/rods/NR = new (src.loc)
for(var/obj/item/stack/rods/R in src.loc)
if(R==NR)
var/obj/item/stack/rods/NR = new (get_turf(src))
for(var/obj/item/stack/rods/R in loc)
if(R == NR)
continue
if(R.amount>=R.max_amount)
if(R.amount >= R.max_amount)
continue
R.attackby(NR, user, params)
R.attackby(NR, user)
to_chat(user, "<span class='notice'>You have disassembled the window.</span>")
to_chat(user, "<span class='notice'>You have disassembled [src].</span>")
disassembled = 1
density = 0
air_update_turf(1)
update_nearby_icons()
qdel(src)
else
if(I.damtype == BRUTE || I.damtype == BURN)
user.changeNext_move(CLICK_CD_MELEE)
hit(I.force)
if(health <= 7)
anchored = 0
update_nearby_icons()
step(src, get_dir(user, src))
else
playsound(loc, 'sound/effects/Glasshit.ogg', 75, 1)
..()
return
return 1
/obj/structure/window/mech_melee_attack(obj/mecha/M)
if(..())