RFD animations for building stuff (#8769)

This commit is contained in:
Wowzewow (Wezzy)
2020-06-03 10:51:28 +02:00
committed by GitHub
parent 4b791e0804
commit d252656e4b
6 changed files with 144 additions and 52 deletions
+57 -50
View File
@@ -23,18 +23,23 @@
drop_sound = 'sound/items/drop/gun.ogg'
pickup_sound = 'sound/items/pickup/gun.ogg'
var/stored_matter = 30 // Starts off full.
var/working = 0
var/working = FALSE
var/mode = 1
var/number_of_modes = 1
var/list/modes
var/crafting = FALSE
var/build_cost = 0
var/build_type
var/build_turf
var/build_delay
/obj/item/rfd/Initialize()
. = ..()
update_icon()
/obj/item/rfd/attack()
return 0
return FALSE
/obj/item/rfd/proc/can_use(var/mob/user,var/turf/T)
return (user.Adjacent(T) && user.get_active_hand() == src && !user.stat && !user.restrained())
@@ -59,7 +64,6 @@
if((stored_matter + 10) > 30)
to_chat(user, "<span class='notice'>The RFD can't hold any more matter-units.</span>")
return
//TODO: Possible better animation
user.drop_from_inventory(W,src)
qdel(W)
stored_matter += 10
@@ -96,10 +100,10 @@
/obj/item/rfd/proc/useResource(var/amount, var/mob/user)
if(stored_matter < amount)
return 0
return FALSE
stored_matter -= amount
update_icon()
return 1
return TRUE
/obj/item/rfd/update_icon() //For the fancy "ammo" counter
overlays.Cut()
@@ -150,43 +154,38 @@ RFD Construction-Class
mode = 3
else
mode = 1
to_chat(user, SPAN_NOTICE("You switch the selection dial to <i>\"[current_mode]\"</i>."))
playsound(src.loc, 'sound/effects/pop.ogg', 50, 0)
if(prob(20))
spark(get_turf(src), 3, alldirs)
if(current_mode)
to_chat(user, SPAN_NOTICE("You switch the selection dial to <i>\"[current_mode]\"</i>."))
playsound(src.loc, 'sound/effects/pop.ogg', 50, 0)
if(prob(20))
spark(get_turf(src), 3, alldirs)
/obj/item/rfd/construction/afterattack(atom/A, mob/user, proximity)
if(!proximity)
return
if(disabled && !isrobot(user))
return 0
return FALSE
if(istype(get_area(A),/area/shuttle)||istype(get_area(A),/turf/space/transit))
return 0
return FALSE
var/turf/t = get_turf(A)
if (isNotStationLevel(t.z))
return 0
return FALSE
return alter_turf(A, user, (mode == 3))
/obj/item/rfd/construction/proc/alter_turf(var/turf/T,var/mob/user,var/deconstruct)
var/build_cost = 0
var/build_type
var/build_turf
var/build_delay
var/build_other
if(working == 1)
return 0
if(working)
return FALSE
if(mode == 3 && istype(T,/obj/machinery/door/airlock))
build_cost = 10
build_delay = 50
build_type = "airlock"
else if(mode == 2 && !deconstruct && istype(T,/turf/simulated/floor))
build_cost = 10
build_delay = 50
build_cost = 3
build_delay = 20
build_type = "airlock"
build_other = /obj/machinery/door/airlock
build_turf = /obj/machinery/door/airlock
else if(!deconstruct && (istype(T,/turf/space) || istype(T,T.baseturf)))
build_cost = 1
build_type = "floor"
@@ -203,39 +202,48 @@ RFD Construction-Class
build_type = deconstruct ? "floor" : "wall"
build_turf = deconstruct ? T.baseturf : /turf/simulated/wall
else
return 0
return FALSE
if(!build_type)
working = 0
return 0
working = FALSE
return FALSE
if(!useResource(build_cost, user))
if(mode == 3 && !T.density && !istype(T,/turf/simulated/floor))
to_chat(user, "<span class='warning'>\The [build_type] must be closed before you can deconstruct it.</span>")
return FALSE
if(stored_matter < build_cost)
to_chat(user, SPAN_WARNING("The \'Low Ammo\' light on the device blinks yellow."))
flick("[icon_state]-empty", src)
return 0
return FALSE
playsound(get_turf(src), 'sound/machines/hydraulic_long.ogg', 50, 1)
playsound(get_turf(src), 'sound/machines/hydraulic_short.ogg', 50, 1)
working = 1
working = TRUE
user.visible_message(SPAN_NOTICE("[user] holds \the [src] towards \the [T]."), SPAN_NOTICE("You start [deconstruct ? "deconstructing" : "constructing"] \a [build_type]..."))
var/obj/effect/constructing_effect/rfd_effect = new(get_turf(T), src.build_delay, src.mode)
if(build_delay && !do_after(user, build_delay))
working = 0
return 0
if((build_delay && !do_after(user, build_delay)) || (!useResource(build_cost, user)))
working = FALSE
rfd_effect.end_animation()
return FALSE
working = 0
working = FALSE
if(build_delay && !can_use(user,T))
return 0
return FALSE
if(build_turf)
T.ChangeTurf(build_turf)
else if(build_other)
new build_other(T)
else
qdel(T)
rfd_effect.end_animation()
playsound(get_turf(src), 'sound/effects/magnetclamp.ogg', 50, 1)
return 1
build_cost = null
build_delay = null
build_type = null
build_turf = null // So it resets and any fuckery is avoided
return TRUE
/obj/item/rfd/construction/borg
canRwall = 1
@@ -247,11 +255,11 @@ RFD Construction-Class
var/cost = amount*30
if(R.cell.charge >= cost)
R.cell.use(cost)
return 1
return 0
return TRUE
return FALSE
/obj/item/rfd/construction/borg/infinite/useResource()
return 1
return TRUE
/obj/item/rfd/construction/borg/attackby()
return
@@ -266,13 +274,13 @@ RFD Construction-Class
if(module.holder && module.holder.cell)
if(module.holder.cell.charge >= cost)
module.holder.cell.use(cost)
return 1
return TRUE
else if(istype(user, /mob/living/heavy_vehicle))
var/obj/item/cell/c = user.get_cell()
if(c && c.charge >= cost)
c.use(cost)
return 1
return 0
return TRUE
return FALSE
/obj/item/rfd/construction/mounted/attackby()
return
@@ -462,8 +470,8 @@ RFD Piping-Class
var/selected_mode = STANDARD_PIPE
var/pipe_examine = "Pipe" // used in the examine proc to see what you're putting down at a glance
var/selected_pipe = 0 // default is standard pipe, used for the new pipe creation
var/build_cost = 1 // this RFD only uses 1 unit of power per pipe, but can be modified if need be in future
var/build_delay = 10
build_cost = 1 // this RFD only uses 1 unit of power per pipe, but can be modified if need be in future
build_delay = 10
// The numbers below refer to the numberized designator for each pipe, which is used in obj/item/pipe's new
// Take a look at code\game\machinery\pipe\construction.dm line 69 for more information. - Geeves
@@ -522,7 +530,7 @@ RFD Piping-Class
if(working)
return FALSE
if(!useResource(build_cost, user))
if(stored_matter < build_cost)
to_chat(user, SPAN_WARNING("The \'Low Ammo\' light on the device blinks yellow."))
flick("[icon_state]-empty", src)
return FALSE
@@ -530,13 +538,12 @@ RFD Piping-Class
playsound(get_turf(src), 'sound/machines/click.ogg', 50, TRUE)
working = TRUE
to_chat(user, SPAN_NOTICE("You start laying down your pipe..."))
user.visible_message(SPAN_NOTICE("[user] holds \the [src] towards \the [T]."), SPAN_NOTICE("You start laying down your pipe..."))
if(build_delay && !do_after(user, build_delay))
if((build_delay && !do_after(user, build_delay)) || (!useResource(build_cost, user)))
working = FALSE
return FALSE
working = FALSE
if(build_delay && !can_use(user, T))
return FALSE