Merge pull request #3348 from ComicIronic/MechContRedo

Construction datum changes.
This commit is contained in:
d3athrow
2015-03-11 16:44:14 -05:00
7 changed files with 1291 additions and 1828 deletions

View File

@@ -499,6 +499,7 @@
#include "code\game\mecha\mech_bay.dm"
#include "code\game\mecha\mech_fabricator.dm"
#include "code\game\mecha\mecha.dm"
#include "code\game\mecha\mecha_construction_chassis.dm"
#include "code\game\mecha\mecha_construction_paths.dm"
#include "code\game\mecha\mecha_control_console.dm"
#include "code\game\mecha\mecha_designs.dm"

View File

@@ -15,210 +15,189 @@
bound_width = 64
bound_height = 64
construct = new /datum/construction/reversible2/pod(src)
construct = new /datum/construction/reversible/pod(src)
dir = EAST
/obj/structure/spacepod_frame/attackby(obj/item/W as obj, mob/user as mob)
if(!construct || !construct.action(W, user))
..()
return
return ..()
return 1
/obj/structure/spacepod_frame/attack_hand()
return
/////////////////////////////////
// CONSTRUCTION STEPS
/////////////////////////////////
/datum/construction/reversible2/pod
/datum/construction/reversible/pod
result = /obj/spacepod/civilian
base_icon="pod"
//taskpath = /datum/job_objective/make_pod
steps = list(
// 1. Initial state
// 12. Bolted-down armor
list(
"desc" = "An empty pod frame.",
state_next = list(
"key" = /obj/item/stack/cable_coil,
"vis_msg" = "{USER} wires the {HOLDER}.",
"self_msg" = "You wire the {HOLDER}."
)
),
// 2. Crudely Wired
list(
"desc" = "A crudely-wired pod frame.",
state_prev = list(
"key" = /obj/item/weapon/wirecutters,
"vis_msg" = "{USER} cuts out the {HOLDER}'s wiring.",
"self_msg" = "You remove the {HOLDER}'s wiring."
Co_DESC = "A space pod with unsecured armor.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} unsecure{s} {HOLDER}'s armor."
),
state_next = list(
"key" = /obj/item/weapon/screwdriver,
"vis_msg" = "{USER} adjusts the wiring.",
"self_msg" = "You adjust the {HOLDER}'s wiring."
)
),
// 3. Cleanly wired
list(
"desc" = "A wired pod frame.",
state_prev = list(
"key" = /obj/item/weapon/screwdriver,
"vis_msg" = "{USER} unclips {HOLDER}'s wiring harnesses.",
"self_msg" = "You unclip {HOLDER}'s wiring harnesses."
),
state_next = list(
"key" = /obj/item/weapon/circuitboard/mecha/pod,
"vis_msg" = "{USER} inserts the mainboard into the {HOLDER}.",
"self_msg" = "You insert the mainboard into the {HOLDER}.",
"delete" = 1
)
),
// 4. Circuit added
list(
"desc" = "A wired pod frame with a loose mainboard.",
state_prev = list(
"key" = /obj/item/weapon/crowbar,
"vis_msg" = "{USER} pries out the mainboard.",
"self_msg" = "You pry out the mainboard.",
"spawn" = /obj/item/weapon/circuitboard/mecha/pod,
"amount" = 1
),
state_next = list(
"key" = /obj/item/weapon/screwdriver,
"vis_msg" = "{USER} secures the mainboard.",
"self_msg" = "You secure the mainboard."
)
),
// 5. Circuit secured
list(
"desc" = "A wired pod frame with a secured mainboard.",
state_prev = list(
"key" = /obj/item/weapon/screwdriver,
"vis_msg" = "{USER} unsecures the mainboard.",
"self_msg" = "You unscrew the mainboard from the {HOLDER}."
),
state_next = list(
"key" = /obj/item/pod_parts/core,
"vis_msg" = "{USER} inserts the core into the {HOLDER}.",
"self_msg" = "You carefully insert the core into the {HOLDER}.",
"delete" = 1
)
),
// 6. Core inserted
list(
"desc" = "A naked space pod with a loose core.",
state_prev = list(
"key" = /obj/item/weapon/crowbar,
"vis_msg" = "{USER} delicately removes the core from the {HOLDER} with a crowbar.",
"self_msg" = "You delicately remove the core from the {HOLDER} with a crowbar.",
"spawn" = /obj/item/pod_parts/core,
"amount" = 1
),
state_next = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} secures the core's bolts.",
"self_msg" = "You secure the core's bolts."
)
),
// 7. Core secured
list(
"desc" = "A naked space pod with an exposed core. How lewd.",
state_prev = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} unsecures the {HOLDER}'s core.",
"self_msg" = "You unsecure the {HOLDER}'s core."
),
state_next = list(
"key" = /obj/item/stack/sheet/metal,
"amount" = 5,
"vis_msg" = "{USER} frabricates a pressure bulkhead for the {HOLDER}.",
"self_msg" = "You frabricate a pressure bulkhead for the {HOLDER}."
)
),
// 8. Bulkhead added
list(
"desc" = "A space pod with loose bulkhead panelling exposed.",
state_prev = list(
"key" = /obj/item/weapon/crowbar,
"vis_msg" = "{USER} pops the {HOLDER}'s bulkhead panelling loose.",
"self_msg" = "You pop the {HOLDER}'s bulkhead panelling loose.",
"spawn" = /obj/item/stack/sheet/metal,
"amount" = 5,
),
state_next = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} secures the {HOLDER}'s bulkhead panelling.",
"self_msg" = "You secure the {HOLDER}'s bulkhead panelling."
)
),
// 9. Bulkhead secured with bolts
list(
"desc" = "A space pod with unwelded bulkhead panelling exposed.",
state_prev = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} unbolts the {HOLDER}'s bulkhead panelling.",
"self_msg" = "You unbolt the {HOLDER}'s bulkhead panelling."
),
state_next = list(
"key" = /obj/item/weapon/weldingtool,
"vis_msg" = "{USER} seals the {HOLDER}'s bulkhead panelling with a weld.",
"self_msg" = "You seal the {HOLDER}'s bulkhead panelling with a weld."
)
),
// 10. Welded bulkhead
list(
"desc" = "A space pod with sealed bulkhead panelling exposed.",
state_prev = list(
"key" = /obj/item/weapon/weldingtool,
"vis_msg" = "{USER} cuts the {HOLDER}'s bulkhead panelling loose.",
"self_msg" = "You cut the {HOLDER}'s bulkhead panelling loose."
),
state_next = list(
"key" = /obj/item/pod_parts/armor,
"vis_msg" = "{USER} installs the {HOLDER}'s armor plating.",
"self_msg" = "You install the {HOLDER}'s armor plating.",
"delete" = 1
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/weldingtool,
Co_VIS_MSG = "{USER} weld{s} {HOLDER}'s armor."
)
),
// 11. Loose armor
list(
"desc" = "A space pod with unsecured armor.",
state_prev = list(
"key" = /obj/item/weapon/crowbar,
"vis_msg" = "{USER} pries off {HOLDER}'s armor.",
"self_msg" = "You pry off {HOLDER}'s armor.",
"spawn" = /obj/item/pod_parts/armor,
"amount" = 1
Co_DESC = "A space pod with unsecured armor.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/crowbar,
Co_VIS_MSG = "{USER} prie{s} off {HOLDER}'s armor."
),
state_next = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} bolts down the {HOLDER}'s armor.",
"self_msg" = "You bolt down the {HOLDER}'s armor."
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} bolt{s} down {HOLDER}'s armor."
)
),
// 12. Bolted-down armor
// 10. Welded bulkhead
list(
"desc" = "A space pod with unsecured armor.",
state_prev = list(
"key" = /obj/item/weapon/wrench,
"vis_msg" = "{USER} unsecures the {HOLDER}'s armor.",
"self_msg" = "You unsecure the {HOLDER}'s armor."
Co_DESC = "A space pod with sealed bulkhead panelling exposed.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/weldingtool,
Co_VIS_MSG = "{USER} cut{s} {HOLDER}'s bulkhead panelling loose.",
Co_AMOUNT = 3
),
state_next = list(
"key" = /obj/item/weapon/weldingtool,
"vis_msg" = "{USER} welds the {HOLDER}'s armor.",
"self_msg" = "You weld the {HOLDER}'s armor."
Co_NEXTSTEP = list(
Co_KEY = /obj/item/pod_parts/armor,
Co_VIS_MSG = "{USER} install{s} {HOLDER}'s armor plating.",
Co_AMOUNT = 1,
Co_KEEP
)
),
// 9. Bulkhead secured with bolts
list(
Co_DESC = "A space pod with unwelded bulkhead panelling exposed.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} unbolt{s} {HOLDER}'s bulkhead panelling.",
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/weldingtool,
Co_VIS_MSG = "{USER} seal{s} {HOLDER}'s bulkhead panelling with a weld.",
Co_AMOUNT = 3
)
),
// 8. Bulkhead added
list(
Co_DESC = "A space pod with loose bulkhead panelling exposed.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/crowbar,
Co_VIS_MSG = "{USER} pop{s} {HOLDER}'s bulkhead panelling loose.",
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} secure{s} {HOLDER}'s bulkhead panelling."
)
),
// 7. Core secured
list(
Co_DESC = "A naked space pod with an exposed core. How lewd.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} unsecure{s} {HOLDER}'s core."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/stack/sheet/metal,
Co_AMOUNT = 5,
Co_VIS_MSG = "{USER} fabricate{s} a pressure bulkhead for {HOLDER}.",
)
),
// 6. Core inserted
list(
Co_DESC = "A naked space pod with a loose core.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/crowbar,
Co_VIS_MSG = "{USER} delicately remove{s} the core from {HOLDER} with a crowbar."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/wrench,
Co_VIS_MSG = "{USER} secure{s} the core's bolts."
)
),
// 5. Circuit secured
list(
Co_DESC = "A wired pod frame with a secured mainboard.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/screwdriver,
Co_VIS_MSG = "{USER} unsecure{s} the mainboard."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/pod_parts/core,
Co_VIS_MSG = "{USER} insert{s} the core into {HOLDER}.",
Co_AMOUNT = 1,
Co_KEEP
)
),
// 4. Circuit added
list(
Co_DESC = "A wired pod frame with a loose mainboard.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/crowbar,
Co_VIS_MSG = "{USER} prie{s} out the mainboard."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/screwdriver,
Co_VIS_MSG = "{USER} secure{s} the mainboard."
)
),
// 3. Cleanly wired
list(
Co_DESC = "A wired pod frame.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/screwdriver,
Co_VIS_MSG = "{USER} unclip{s} {HOLDER}'s wiring harnesses."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/circuitboard/mecha/pod,
Co_VIS_MSG = "{USER} insert{s} the mainboard into {HOLDER}.",
Co_AMOUNT = 1,
Co_KEEP
)
),
// 2. Crudely Wired
list(
Co_DESC = "A crudely-wired pod frame.",
Co_BACKSTEP = list(
Co_KEY = /obj/item/weapon/wirecutters,
Co_VIS_MSG = "{USER} cut{s} out {HOLDER}'s wiring."
),
Co_NEXTSTEP = list(
Co_KEY = /obj/item/weapon/screwdriver,
Co_VIS_MSG = "{USER} adjust{s} the wiring."
)
),
// 1. Initial state
list(
Co_DESC = "An empty pod frame.",
Co_NEXTSTEP = list(
Co_KEY = /obj/item/stack/cable_coil,
Co_VIS_MSG = "{USER} wire{s} {HOLDER}.",
Co_AMOUNT = 10
)
)
// EOF
)
spawn_result(mob/user as mob)
..()
feedback_inc("spacepod_created",1)
return
/datum/construction/reversible/pod/spawn_result(mob/user as mob)
..()
feedback_inc("spacepod_created",1)
return
/datum/construction/reversible/pod/custom_action(index, diff, atom/used_atom, mob/user)
if(!..())
return 0
holder.icon_state = "pod_[steps.len - index + 1 - diff]"
return 1
/datum/construction/reversible/pod/action(atom/used_atom,mob/user)
return check_step(used_atom,user)

View File

@@ -1,251 +1,391 @@
#define FORWARD -1
#define BACKWARD 1
#define Co_KEY "key"
#define Co_VIS_MSG "vis_msg"
#define Co_START_MSG "start_msg"
#define Co_AMOUNT "amount"
#define Co_MAX_AMOUNT "max_amount"
#define Co_DELAY "delay"
#define Co_KEEP "keep" //if permanence is set to 0, we can still store specific step items by including this in the step
#define Co_TAKE "take" //if we want to actually have a stack or weldingtool in construction, rather than weld or add a stack, we can use this override
#define Co_DESC "desc"
#define Co_NEXTSTEP "nextstep"
#define Co_BACKSTEP "backstep"
/datum/construction
var/list/steps
var/atom/holder
var/result
var/list/steps_desc
var/taskpath = null // Path of job objective completed.
var/assembling = 0 //if we're in a step, we won't be allowed to do another step
var/permanence = 0
var/list/used_atoms = list() //contains the stuff we add. Can be used in multiple-choice construction
New(atom)
..()
holder = atom
if(!holder) //don't want this without a holder
spawn
del src
/datum/construction/New(atom)
..()
holder = atom
if(!holder) //don't want this without a holder
spawn
del src
set_desc(steps.len)
add_max_amounts()
return
/datum/construction/proc/next_step(mob/user as mob)
steps.len--
if(!steps.len)
spawn_result(user)
else
set_desc(steps.len)
return
return
proc/next_step(mob/user as mob)
steps.len--
if(!steps.len)
spawn_result(user)
else
set_desc(steps.len)
return
/datum/construction/proc/action(atom/used_atom,mob/user as mob)
return
proc/action(atom/used_atom,mob/user as mob)
return
/datum/construction/proc/check_step(atom/used_atom,mob/user as mob) //check last step only
var/valid_step = is_right_key(user,used_atom)
if(valid_step)
assembling = 1
if(custom_action(valid_step, used_atom, user))
next_step(user)
assembling = 0
return 1
assembling = 0
return 0
proc/check_step(atom/used_atom,mob/user as mob) //check last step only
var/valid_step = is_right_key(user,used_atom)
if(valid_step)
if(custom_action(valid_step, used_atom, user))
next_step(user)
/datum/construction/proc/is_right_key(mob/user as mob, atom/used_atom) // returns current step num if used_atom is of the right type.
if(assembling) return 0
var/list/L = steps[steps.len]
if((istype(L[Co_KEY], /list) && is_type_in_list(used_atom, L[Co_KEY])) || istype(used_atom, L[Co_KEY]))
//if our keys are in a list, we want to check them all
//otherwise, sanity permits setting it as a single type and checking that
if(!try_consume(user, used_atom, L))
return 0
return steps.len
return 0
/datum/construction/proc/custom_action(step, used_atom, user)
if(istype(used_atom, /obj/item/weapon/weldingtool))
playsound(holder, 'sound/items/Welder2.ogg', 50, 1)
else if(istype(used_atom, /obj/item/weapon/wrench))
playsound(holder, 'sound/items/Ratchet.ogg', 50, 1)
else if(istype(used_atom, /obj/item/weapon/screwdriver))
playsound(holder, 'sound/items/Screwdriver.ogg', 50, 1)
else if(istype(used_atom, /obj/item/weapon/wirecutters))
playsound(holder, 'sound/items/Wirecutter.ogg', 50, 1)
construct_message(step, user)
return 1
/datum/construction/proc/fixText(text,user,self=0)
if(self)
text = replacetext(text, "{s}", "")
text = replacetext(text, "{USER}", "You")
else
text = replacetext(text, "{s}", "s")
text = replacetext(text,"{USER}","[user]")
text = replacetext(text,"{HOLDER}","[holder]")
return text
/datum/construction/proc/construct_message(step, mob/user)
user.visible_message(fixText(step[Co_VIS_MSG],user), fixText(step[Co_VIS_MSG],user,1))
/datum/construction/proc/start_construct_message(step, mob/user, atom/movable/used_atom)
user.visible_message(fixText(step[Co_START_MSG],user), fixText(step[Co_START_MSG],user,1))
/datum/construction/proc/check_all_steps(atom/used_atom,mob/user as mob) //check all steps, remove matching one.
for(var/i=1;i<=steps.len;i++)
var/list/L = steps[i];
if((islist(L[Co_KEY]) && is_type_in_list(used_atom, L[Co_KEY])) ||istype(used_atom, L[Co_KEY]))
if(custom_action(i, used_atom, user))
steps[i]=null;//stupid byond list from list removal...
listclearnulls(steps);
if(!steps.len)
spawn_result(user)
return 1
return 0
return 0
proc/is_right_key(mob/user as mob, atom/used_atom) // returns current step num if used_atom is of the right type.
var/list/L = steps[steps.len]
if(istype(used_atom, L["key"]))
//if(L["consume"] && !try_consume(used_atom,L["consume"]))
// return 0
return steps.len
return 0
proc/custom_action(step, used_atom, user)
if(istype(used_atom, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/W = used_atom
if (W.remove_fuel(0, user))
playsound(holder, 'sound/items/Welder2.ogg', 50, 1)
else
return 0
else if(istype(used_atom, /obj/item/weapon/wrench))
playsound(holder, 'sound/items/Ratchet.ogg', 50, 1)
/datum/construction/proc/spawn_result(mob/user as mob)
if(result)
testing("[user] finished a [result]!")
else if(istype(used_atom, /obj/item/weapon/screwdriver))
playsound(holder, 'sound/items/Screwdriver.ogg', 50, 1)
new result(get_turf(holder))
spawn()
del holder
return
else if(istype(used_atom, /obj/item/weapon/wirecutters))
playsound(holder, 'sound/items/Wirecutter.ogg', 50, 1)
/datum/construction/proc/set_desc(index as num)
var/list/step = steps[index]
holder.desc = step[Co_DESC]
return
else if(istype(used_atom, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C = used_atom
if(C.amount<4)
user << ("There's not enough cable to finish the task.")
return 0
else
C.use(4)
playsound(holder, 'sound/items/Deconstruct.ogg', 50, 1)
else if(istype(used_atom, /obj/item/stack))
var/obj/item/stack/S = used_atom
if(S.amount < 5)
user << ("There's not enough material in this stack.")
return 0
else
S.use(5)
/datum/construction/proc/try_consume(mob/user as mob, atom/movable/used_atom, given_step)
if(!(Co_AMOUNT in given_step) && !(Co_DELAY in given_step))
return 1
proc/check_all_steps(atom/used_atom,mob/user as mob) //check all steps, remove matching one.
for(var/i=1;i<=steps.len;i++)
var/list/L = steps[i];
if(istype(used_atom, L["key"]))
if(custom_action(i, used_atom, user))
steps[i]=null;//stupid byond list from list removal...
listclearnulls(steps);
if(!steps.len)
spawn_result(user)
return 1
return 0
var/delay = 0
if(Co_DELAY in given_step)
delay = given_step[Co_DELAY]
if(delay > 0)
start_construct_message(given_step, user, used_atom)
if(!do_after(user, delay, needhand = 1))
return 0
proc/spawn_result(mob/user as mob)
if(result)
testing("[user] finished a [result]!")
var/amount = 0
if(Co_AMOUNT in given_step)
amount = given_step[Co_AMOUNT]
if(amount>0)
// STACKS
if(istype(used_atom,/obj/item/stack) && !(Co_TAKE in given_step))
var/obj/item/stack/stack=used_atom
if(stack.amount < amount)
user << "<span class='notice'>You start adding [stack] to \the [holder]. It still needs [amount - stack.amount] [stack.singular_name].</span>"
given_step[Co_AMOUNT] -= stack.amount
stack.use(stack.amount)
return 0
stack.use(amount)
// WELDER
else if(istype(used_atom,/obj/item/weapon/weldingtool) && !(Co_TAKE in given_step))
var/obj/item/weapon/weldingtool/welder=used_atom
if(!welder.isOn())
user << "\blue You tap the [src] with your unlit welder. [pick("Ding","Dong")]."
return 0
if(!welder.remove_fuel(amount,user))
user << "\red You don't have enough fuel!"
return 0
//generic things
else
var/atom_name = used_atom.name
if(permanence || (Co_KEEP in given_step))
user.drop_item(holder)
used_atom.loc = holder
used_atoms.Add(list("[steps.Find(given_step)]" = used_atom))
else
qdel(used_atom)
given_step[Co_AMOUNT]--
if(given_step[Co_AMOUNT] > 0)
user << "<span class='notice'>You add \a [atom_name] to \the [holder]. It still needs [amount -1 ] [atom_name]\s.</span>"
return 0
given_step[Co_AMOUNT] = given_step[Co_MAX_AMOUNT]
return 1
new result(get_turf(holder))
spawn()
del holder
return
proc/set_desc(index as num)
var/list/step = steps[index]
holder.desc = step["desc"]
return
proc/try_consume(mob/user as mob, atom/used_atom, amount)
if(amount>0)
// STACKS
if(istype(used_atom,/obj/item/stack))
var/obj/item/stack/stack=used_atom
if(stack.amount < amount)
user << "\red You don't have enough [stack]! You need at least [amount]."
return 0
stack.use(amount)
// CABLES
if(istype(used_atom,/obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/coil=used_atom
if(coil.amount < amount)
user << "\red You don't have enough cable! You need at least [amount] coils."
return 0
coil.use(amount)
// WELDER
if(istype(used_atom,/obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/welder=used_atom
if(!welder.isOn())
user << "\blue You tap the [src] with your unlit welder. [pick("Ding","Dong")]."
return 0
if(!welder.remove_fuel(amount,user))
user << "\red You don't have enough fuel!"
return 0
return 1
/datum/construction/proc/add_max_amounts()
for(var/list/this_step in steps)
if((Co_AMOUNT in this_step))
this_step.Add(list(Co_MAX_AMOUNT = this_step[Co_AMOUNT])) //puts in something we can refer to when we reset the step
/datum/construction/reversible
var/index
New(atom)
..()
index = steps.len
return
/datum/construction/reversible/New(atom)
..()
index = steps.len
return
proc/update_index(diff as num, mob/user as mob)
index+=diff
if(index==0)
spawn_result(user)
else
set_desc(index)
return
/datum/construction/reversible/proc/update_index(diff as num, mob/user as mob)
index+=diff
if(index==0)
spawn_result(user)
else
set_desc(index)
return
is_right_key(mob/user as mob,atom/used_atom) // returns index step
var/list/L = steps[index]
if(istype(used_atom, L["key"]))
//if(L["consume"] && !try_consume(used_atom,L["consume"]))
// return 0
return FORWARD //to the first step -> forward
else if(L["backkey"] && istype(used_atom, L["backkey"]))
//if(L["consume"] && !try_consume(used_atom,L["consume"]))
// return 0
return BACKWARD //to the last step -> backwards
return 0
check_step(atom/used_atom,mob/user as mob)
var/diff = is_right_key(user,used_atom)
if(diff)
if(custom_action(index, diff, used_atom, user))
update_index(diff,user)
return 1
return 0
custom_action(index, diff, used_atom, user)
if(!..(index,used_atom,user))
/datum/construction/reversible/is_right_key(mob/user as mob,atom/used_atom) // returns index step
if(assembling) return 0
assembling = 1
var/list/step_next = get_forward_step(index)
var/list/step_back = get_backward_step(index)
if(step_next && (islist(step_next[Co_KEY]) && is_type_in_list(used_atom, step_next[Co_KEY])) || istype(used_atom, step_next[Co_KEY]))
//if our keys are in a list, we want to check them all
//otherwise, sanity permits setting it as a single type and checking that
if(!try_consume(user, used_atom, step_next, index, FORWARD))
assembling = 0
return 0
return 1
return FORWARD //to the first step -> forward
if(step_back && (islist(step_back[Co_KEY]) && is_type_in_list(used_atom, step_back[Co_KEY])) || istype(used_atom, step_back[Co_KEY]))
if(!try_consume(user, used_atom, step_back, index, BACKWARD))
assembling = 0
return 0
return BACKWARD //to the last step -> backwards
assembling = 0
return 0
#define state_next "next"
#define state_prev "prev"
/datum/construction/reversible/check_step(atom/used_atom,mob/user as mob)
var/diff = is_right_key(user,used_atom)
if(diff)
assembling = 1
if(custom_action(index, diff, used_atom, user))
update_index(diff,user)
assembling = 0
return 1
assembling = 0
return 0
/datum/construction/reversible2
var/index
var/base_icon = "durand"
/datum/construction/reversible/custom_action(index, diff, used_atom, user)
. = ..(index,used_atom,user)
New(atom)
..()
index = 1
if(.)
construct_message(steps[index], user, diff, 1)
/datum/construction/reversible/construct_message(step, mob/user, diff, override)
if(!override)
return
var/message_step
if(diff == FORWARD && (Co_NEXTSTEP in step))
message_step = step[Co_NEXTSTEP]
else if (Co_BACKSTEP in step)
message_step = step[Co_BACKSTEP]
if(message_step)
user.visible_message(fixText(message_step[Co_VIS_MSG],user), fixText(message_step[Co_VIS_MSG],user,1))
proc/update_index(diff as num, mob/user as mob)
index-=diff
if(index==steps.len+1)
spawn_result(user)
/datum/construction/reversible/start_construct_message(step, mob/user, atom/movable/used_atom)
user.visible_message(fixText(step[Co_START_MSG],user), fixText(step[Co_START_MSG],user,1))
/datum/construction/reversible/add_max_amounts()
for(var/i = 1; i <= steps.len; i++)
var/list/dir_step = get_forward_step(i)
if((Co_AMOUNT in dir_step))
dir_step.Add(list(Co_MAX_AMOUNT = dir_step[Co_AMOUNT])) //puts in something we can refer to when we reset the step
dir_step = get_backward_step(i)
if((Co_AMOUNT in dir_step))
dir_step.Add(list(Co_MAX_AMOUNT = dir_step[Co_AMOUNT]))
//NOT IN PLACE: message segments like verbs can be written as {UN|forwardmessage|backwardmessage}. This formats that in selection
/datum/construction/reversible/fixText(message, mob/user, self = 0)
return ..(message, user, self)
/*
while("{UN|" in text)
var/start_bracket = findtext(text, "{")
var/this_verb = copytext(text, start_bracket, findtext(text, "}", start_bracket + 1))
world << this_verb
var/marker = findtext(this_verb, "|")
var/final_verb = ""
if(diff == FORWARD)
final_verb = copytext(this_verb, marker + 1, findtext(this_verb, "|", marker + 1))
else
final_verb = copytext(this_verb, findtext(this_verb, "|", marker + 1), findtext(text, "}", start_bracket + 1))
world << final_verb
replacetext(text, this_verb, final_verb)
*/
/datum/construction/reversible/try_consume(mob/user as mob, atom/movable/used_atom, given_step, index, diff)
//if we've made some progress on a step, we want to drop it
var/current_step = (diff == BACKWARD ? get_forward_step(index) : get_backward_step(index))
if(current_step && (Co_AMOUNT in current_step) && (Co_MAX_AMOUNT in current_step) && (current_step[Co_AMOUNT] < current_step[Co_MAX_AMOUNT]))
var/obj/item/stack/S
if(used_atoms["[index][diff == FORWARD ? "+" : "-"]"])
for(var/atom/movable/A in used_atoms["[index][diff == FORWARD ? "+" : "-"]"])
A.loc = holder.loc
used_atoms.Remove("[index][diff == FORWARD ? "+" : "-"]")
else
set_desc(index)
return
var/working_type = (islist(current_step[Co_KEY]) ? pick(current_step[Co_KEY]) : current_step[Co_KEY])
S = new working_type(holder.loc)
if(istype(S) && !(Co_KEEP in current_step))
S.amount = current_step[Co_MAX_AMOUNT] - current_step[Co_AMOUNT]
S.update_icon()
else
for(var/i = 2; i <= current_step[Co_MAX_AMOUNT] - current_step[Co_AMOUNT]; i++)
new working_type(holder.loc)
current_step[Co_AMOUNT] = current_step[Co_MAX_AMOUNT]
proc/update_icon()
holder.icon_state="[base_icon]_[index]"
is_right_key(mob/user as mob,atom/used_atom) // returns index step
var/list/state = steps[index]
if(state_next in state)
var/list/step = state[state_next]
if(istype(used_atom, step["key"]))
//if(L["consume"] && !try_consume(used_atom,L["consume"]))
// return 0
return FORWARD //to the first step -> forward
else if(state_prev in state)
var/list/step = state[state_prev]
if(istype(used_atom, step["key"]))
//if(L["consume"] && !try_consume(used_atom,L["consume"]))
// return 0
return BACKWARD //to the first step -> forward
return 0
check_step(atom/used_atom,mob/user as mob)
var/diff = is_right_key(user,used_atom)
if(diff)
if(custom_action(index, diff, used_atom, user))
update_index(diff,user)
update_icon()
return 1
return 0
proc/fixText(text,user)
text = replacetext(text,"{USER}","[user]")
text = replacetext(text,"{HOLDER}","[holder]")
return text
custom_action(index, diff, used_atom, var/mob/user)
if(!..(index,used_atom,user))
var/delay = 0
if(Co_DELAY in given_step)
delay = given_step[Co_DELAY]
if(delay > 0)
start_construct_message(given_step, user, used_atom)
if(!do_after(user, delay, needhand = 1))
return 0
var/list/step = steps[index]
var/list/state = step[diff==FORWARD ? state_next : state_prev]
user.visible_message(fixText(state["vis_msg"],user),fixText(state["self_msg"],user))
var/amount = 0
if(Co_AMOUNT in given_step)
amount = given_step[Co_AMOUNT]
if(amount > 0)
// STACKS
if(istype(used_atom,/obj/item/stack) && !(Co_TAKE in given_step))
var/obj/item/stack/stack=used_atom
if(stack.amount < amount)
user << "<span class='notice'>You start adding [stack] to \the [holder]. It still needs [amount - stack.amount] [stack.singular_name].</span>"
given_step[Co_AMOUNT] -= stack.amount
stack.use(stack.amount)
return 0
stack.use(amount)
// WELDER
else if(istype(used_atom,/obj/item/weapon/weldingtool) && !(Co_TAKE in given_step))
var/obj/item/weapon/weldingtool/welder=used_atom
if(!welder.isOn())
user << "<span class='notice'>You tap the [holder] with your unlit welder. [pick("Ding","Dong")].</span>"
return 0
if(!welder.remove_fuel(amount,user))
user << "<span class='rose'>You don't have enough fuel!</span>"
return 0
//generic things
else
var/atom_name = used_atom.name
if(permanence || (Co_KEEP in given_step))
user.drop_item(holder)
used_atom.loc = holder
if(!("[index][diff == FORWARD ? "+" : "-"]" in used_atoms))
used_atoms.Add(list("[index][diff == FORWARD ? "+" : "-"]" = list()))
used_atoms["[index][diff == FORWARD ? "+" : "-"]"] += used_atom
else
qdel(used_atom)
given_step[Co_AMOUNT]--
if(given_step[Co_AMOUNT] > 0)
user << "<span class='notice'>You add \a [atom_name] to \the [holder]. It still needs [amount -1 ] [atom_name]\s.</span>"
return 0
given_step[Co_AMOUNT] = given_step[Co_MAX_AMOUNT]
if("delete" in state)
qdel(used_atom)
else if("spawn" in state)
var/spawntype=state["spawn"]
var/atom/A = new spawntype(holder.loc)
if("amount" in state)
if(istype(A,/obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/C=A
C.amount=state["amount"]
if(istype(A,/obj/item/stack))
var/obj/item/stack/S=A
S.amount=state["amount"]
else
var/list/spawn_step
var/new_index = (diff == FORWARD ? index - 1 : index + 1)
if(diff == FORWARD)
spawn_step = get_backward_step(new_index)
else if(diff == BACKWARD)
spawn_step = get_forward_step(new_index)
var/list/atom/movable/to_drop = list()
return 1
action(used_atom,user)
return check_step(used_atom,user)
if(("[new_index][diff == FORWARD ? "-" : "+"]" in used_atoms) && used_atoms["[new_index][diff == FORWARD ? "-" : "+"]"])
to_drop = used_atoms["[new_index][diff == FORWARD ? "-" : "+"]"]
used_atoms.Remove("[new_index][diff == FORWARD ? "-" : "+"]")
else if(Co_AMOUNT in spawn_step)
var/to_create = (islist(spawn_step[Co_KEY]) ? pick(spawn_step[Co_KEY]) : spawn_step[Co_KEY])
var/test = new to_create
if(istype(test, /obj/item/weapon/weldingtool) && !(Co_TAKE in spawn_step))
qdel(test)
else if(istype(test, /obj/item/stack) && !(Co_TAKE in spawn_step))
var/obj/item/stack/S = test
S.amount = spawn_step[Co_AMOUNT]
to_drop.Add(S)
else
to_drop.Add(test)
for(var/i = 1; i <= spawn_step[Co_AMOUNT] - 1; i++)
to_drop.Add(new to_create)
for(var/atom/movable/this_drop in to_drop)
this_drop.loc = holder.loc
return 1
/datum/construction/reversible/proc/get_forward_step(index)
if(index < 0 || index > steps.len)
return
var/list/S = steps[index]
if(Co_NEXTSTEP in S)
return S[Co_NEXTSTEP]
/datum/construction/reversible/proc/get_backward_step(index)
if(index < 0 || index > steps.len)
return
var/list/S = steps[index]
if(Co_BACKSTEP in S)
return S[Co_BACKSTEP]

View File

@@ -0,0 +1,154 @@
/datum/construction/mecha_chassis
/datum/construction/mecha_chassis/custom_action(step, atom/used_atom, mob/user)
user.visible_message("[user] has connected [used_atom] to [holder].", "You connect [used_atom] to [holder]")
holder.overlays += used_atom.icon_state+"+o"
del used_atom
return 1
/datum/construction/mecha_chassis/action(atom/used_atom,mob/user as mob)
return check_all_steps(used_atom,user)
// RIPLEY //
/datum/construction/mecha_chassis/ripley
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/ripley_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/ripley_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/ripley_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/ripley_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/ripley_right_leg)//5
)
/datum/construction/mecha_chassis/ripley/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/ripley(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "ripley0"
const_holder.density = 1
const_holder.overlays.len = 0
spawn()
del src
return
// FIREFIGHTER //
/datum/construction/mecha_chassis/firefighter
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/ripley_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/ripley_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/ripley_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/ripley_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/ripley_right_leg),//5
list(Co_KEY=/obj/item/clothing/suit/fire)//6
)
/datum/construction/mecha_chassis/firefighter/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/firefighter(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "firefighter0"
const_holder.density = 1
spawn()
del src
return
// GYGAX //
/datum/construction/mecha_chassis/gygax
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/gygax_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/gygax_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/gygax_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/gygax_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/gygax_right_leg),//5
list(Co_KEY=/obj/item/mecha_parts/part/gygax_head)
)
/datum/construction/mecha_chassis/gygax/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/combat/gygax(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "gygax0"
const_holder.density = 1
spawn()
del src
return
// DURAND //
/datum/construction/mecha_chassis/durand
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/durand_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/durand_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/durand_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/durand_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/durand_right_leg),//5
list(Co_KEY=/obj/item/mecha_parts/part/durand_head)
)
/datum/construction/mecha_chassis/durand/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/combat/durand(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "durand0"
const_holder.density = 1
spawn()
del src
return
// ODYSSEUS //
/datum/construction/mecha_chassis/odysseus
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/odysseus_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/odysseus_head),//2
list(Co_KEY=/obj/item/mecha_parts/part/odysseus_left_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/odysseus_right_arm),//4
list(Co_KEY=/obj/item/mecha_parts/part/odysseus_left_leg),//5
list(Co_KEY=/obj/item/mecha_parts/part/odysseus_right_leg)//6
)
/datum/construction/mecha_chassis/odysseus/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/odysseus(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "odysseus0"
const_holder.density = 1
spawn()
del src
return
// PHAZON //
/datum/construction/mecha_chassis/phazon
result = "/obj/mecha/combat/phazon"
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/phazon_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/phazon_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/phazon_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/phazon_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/phazon_right_leg),//5
list(Co_KEY=/obj/item/mecha_parts/part/phazon_head)
)
/datum/construction/mecha_chassis/phazon/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/phazon(const_holder)
const_holder.icon = 'icons/mecha/mech_construction.dmi'
const_holder.icon_state = "phazon0"
const_holder.density = 1
spawn()
del src
return
////////////HONK////////////////
/datum/construction/mecha_chassis/honker
steps = list(list(Co_KEY=/obj/item/mecha_parts/part/honker_torso),//1
list(Co_KEY=/obj/item/mecha_parts/part/honker_left_arm),//2
list(Co_KEY=/obj/item/mecha_parts/part/honker_right_arm),//3
list(Co_KEY=/obj/item/mecha_parts/part/honker_left_leg),//4
list(Co_KEY=/obj/item/mecha_parts/part/honker_right_leg),//5
list(Co_KEY=/obj/item/mecha_parts/part/honker_head)
)
/datum/construction/mecha_chassis/honker/spawn_result(mob/user as mob)
var/obj/item/mecha_parts/chassis/const_holder = holder
const_holder.construct = new /datum/construction/reversible/mecha/honker(const_holder)
const_holder.density = 1
spawn()
del src
return

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@
New()
..()
construct = new /datum/construction/mecha/ripley_chassis(src)
construct = new /datum/construction/mecha_chassis/ripley(src)
/obj/item/mecha_parts/part/ripley_torso
name="Ripley Torso"
@@ -73,7 +73,7 @@
New()
..()
construct = new /datum/construction/mecha/gygax_chassis(src)
construct = new /datum/construction/mecha_chassis/gygax(src)
/obj/item/mecha_parts/part/gygax_torso
name="Gygax Torso"
@@ -122,7 +122,7 @@
New()
..()
construct = new /datum/construction/mecha/durand_chassis(src)
construct = new /datum/construction/mecha_chassis/durand(src)
/obj/item/mecha_parts/part/durand_torso
name="Durand Torso"
@@ -168,7 +168,7 @@
New()
..()
construct = new /datum/construction/mecha/firefighter_chassis(src)
construct = new /datum/construction/mecha_chassis/firefighter(src)
/*
/obj/item/mecha_parts/part/firefighter_torso
name="Ripley-on-Fire Torso"
@@ -198,7 +198,7 @@
New()
..()
construct = new /datum/construction/mecha/honker_chassis(src)
construct = new /datum/construction/mecha_chassis/honker(src)
/obj/item/mecha_parts/part/honker_torso
name="H.O.N.K Torso"
@@ -233,7 +233,7 @@
New()
..()
construct = new /datum/construction/mecha/phazon_chassis(src)
construct = new /datum/construction/mecha_chassis/phazon(src)
/obj/item/mecha_parts/part/phazon_torso
name="Phazon Torso"
@@ -278,7 +278,7 @@
New()
..()
construct = new /datum/construction/mecha/odysseus_chassis(src)
construct = new /datum/construction/mecha_chassis/odysseus(src)
/obj/item/mecha_parts/part/odysseus_head
name="Odysseus Head"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB