Merge pull request #12121 from Ghommie/Ghommie-cit723
Generic skills support for items, level based skill type. Wiring skill.
This commit is contained in:
@@ -48,8 +48,7 @@
|
||||
if(2)
|
||||
// State 2
|
||||
if(istype(W, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(C.use(2))
|
||||
if(W.use_tool(src, user, 0, 2))
|
||||
to_chat(user, "<span class='notice'>You add wires to the assembly.</span>")
|
||||
state = 3
|
||||
else
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
if(istype(P, /obj/item/stack/cable_coil))
|
||||
if(!P.tool_start_check(user, amount=5))
|
||||
return
|
||||
|
||||
to_chat(user, "<span class='notice'>You start to add cables to the frame...</span>")
|
||||
if(P.use_tool(src, user, 20, volume=50, amount=5))
|
||||
to_chat(user, "<span class='notice'>You add cables to the frame.</span>")
|
||||
|
||||
@@ -400,12 +400,11 @@
|
||||
"<span class='notice'>You begin adding wires to [src]...</span>")
|
||||
playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, 1)
|
||||
if(do_after(user, 60, target = src))
|
||||
if(constructionStep != CONSTRUCTION_GUTTED || B.get_amount() < 5 || !B)
|
||||
if(constructionStep != CONSTRUCTION_GUTTED || !B.use_tool(src, user, 0, 5))
|
||||
return
|
||||
user.visible_message("<span class='notice'>[user] adds wires to [src].</span>", \
|
||||
"<span class='notice'>You wire [src].</span>")
|
||||
playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, 1)
|
||||
B.use(5)
|
||||
constructionStep = CONSTRUCTION_WIRES_EXPOSED
|
||||
update_icon()
|
||||
return
|
||||
|
||||
@@ -205,11 +205,9 @@
|
||||
return
|
||||
if(1)
|
||||
if(istype(W, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/coil = W
|
||||
if(coil.get_amount() < 5)
|
||||
if(!W.use_tool(src, user, 0, 5))
|
||||
to_chat(user, "<span class='warning'>You need more cable for this!</span>")
|
||||
else
|
||||
coil.use(5)
|
||||
buildstage = 2
|
||||
to_chat(user, "<span class='notice'>You wire \the [src].</span>")
|
||||
update_icon()
|
||||
|
||||
@@ -160,10 +160,7 @@
|
||||
to_chat(user, "<span class='warning'>You need one length of cable to repair [src]!</span>")
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You begin to replace the wires...</span>")
|
||||
if(do_after(user, 30, target = src))
|
||||
if(coil.get_amount() < 1)
|
||||
return
|
||||
coil.use(1)
|
||||
if(W.use_tool(src, user, 30, 1))
|
||||
obj_integrity = max_integrity
|
||||
stat &= ~BROKEN
|
||||
to_chat(user, "<span class='notice'>You repair \the [src].</span>")
|
||||
|
||||
@@ -220,8 +220,7 @@
|
||||
return
|
||||
else if(istype(W, /obj/item/stack/cable_coil))
|
||||
if(state == 3 && (internal_damage & MECHA_INT_SHORT_CIRCUIT))
|
||||
var/obj/item/stack/cable_coil/CC = W
|
||||
if(CC.use(2))
|
||||
if(W.use_tool(src, user, 0, 2))
|
||||
clearInternalDamage(MECHA_INT_SHORT_CIRCUIT)
|
||||
to_chat(user, "<span class='notice'>You replace the fused wires.</span>")
|
||||
else
|
||||
|
||||
@@ -132,6 +132,12 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
|
||||
var/list/grind_results //A reagent list containing the reagents this item produces when ground up in a grinder - this can be an empty list to allow for reagent transferring only
|
||||
var/list/juice_results //A reagent list containing blah blah... but when JUICED in a grinder!
|
||||
|
||||
///Skills vars
|
||||
//list of skill PATHS exercised when using this item. An associated bitfield can be set to indicate additional ways the skill is used by this specific item.
|
||||
var/list/datum/skill/used_skills
|
||||
var/skill_difficulty = THRESHOLD_COMPETENT //how difficult it's to use this item in general.
|
||||
var/skill_gain = DEF_SKILL_GAIN //base skill value gain from using this item.
|
||||
|
||||
/obj/item/Initialize()
|
||||
|
||||
if (attack_verb)
|
||||
@@ -783,7 +789,7 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
|
||||
|
||||
// Called when a mob tries to use the item as a tool.
|
||||
// Handles most checks.
|
||||
/obj/item/proc/use_tool(atom/target, mob/living/user, delay, amount=0, volume=0, datum/callback/extra_checks)
|
||||
/obj/item/proc/use_tool(atom/target, mob/living/user, delay, amount=0, volume=0, datum/callback/extra_checks, skill_gain_mult = 1, max_level = INFINITY)
|
||||
// No delay means there is no start message, and no reason to call tool_start_check before use_tool.
|
||||
// Run the start check here so we wouldn't have to call it manually.
|
||||
if(!delay && !tool_start_check(user, amount))
|
||||
@@ -795,6 +801,9 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
|
||||
play_tool_sound(target, volume)
|
||||
|
||||
if(delay)
|
||||
if(user.mind && used_skills)
|
||||
delay = user.mind.skill_holder.item_action_skills_mod(src, delay, skill_difficulty, SKILL_USE_TOOL, NONE, FALSE)
|
||||
|
||||
// Create a callback with checks that would be called every tick by do_after.
|
||||
var/datum/callback/tool_check = CALLBACK(src, .proc/tool_check_callback, user, amount, extra_checks)
|
||||
|
||||
@@ -819,6 +828,12 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
|
||||
if(delay >= MIN_TOOL_SOUND_DELAY)
|
||||
play_tool_sound(target, volume)
|
||||
|
||||
if(user.mind && used_skills && skill_gain_mult)
|
||||
for(var/skill in used_skills)
|
||||
if(!(used_skills[skill] & SKILL_TRAINING_TOOL))
|
||||
continue
|
||||
user.mind.skill_holder.auto_gain_experience(skill, skill_gain*skill_gain_mult, GET_STANDARD_LVL(max_level))
|
||||
|
||||
return TRUE
|
||||
|
||||
// Called before use_tool if there is a delay, or by use_tool if there isn't.
|
||||
|
||||
@@ -97,8 +97,7 @@
|
||||
to_chat(user, "<span class='notice'>You add [A] to the [initial(name)] assembly.</span>")
|
||||
|
||||
else if(stage == EMPTY && istype(I, /obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/C = I
|
||||
if (C.use(1))
|
||||
if (I.use_tool(src, user, 0, 1, max_level = JOB_SKILL_BASIC))
|
||||
det_time = 50 // In case the cable_coil was removed and readded.
|
||||
stage_change(WIRED)
|
||||
to_chat(user, "<span class='notice'>You rig the [initial(name)] assembly.</span>")
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
else
|
||||
target.LAssailant = WEAKREF(user)
|
||||
cooldown_check = world.time + cooldown
|
||||
user.adjustStaminaLossBuffered(getweight())//CIT CHANGE - makes swinging batons cost stamina
|
||||
user.adjustStaminaLossBuffered(getweight(user, STAM_COST_BATON_MOB_MULT))
|
||||
else
|
||||
var/wait_desc = get_wait_description()
|
||||
if(wait_desc)
|
||||
|
||||
@@ -69,7 +69,7 @@ GLOBAL_LIST_INIT(glass_recipes, list ( \
|
||||
if (get_amount() < 1 || CC.get_amount() < 5)
|
||||
to_chat(user, "<span class='warning>You need five lengths of coil and one sheet of glass to make wired glass!</span>")
|
||||
return
|
||||
CC.use(5)
|
||||
CC.use_tool(src, user, 0, 5, max_level = JOB_SKILL_BASIC)
|
||||
use(1)
|
||||
to_chat(user, "<span class='notice'>You attach wire to the [name].</span>")
|
||||
var/obj/item/stack/light_w/new_tile = new(user.loc)
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
if(status)
|
||||
if(baton_stun(M, user, disarming))
|
||||
user.do_attack_animation(M)
|
||||
user.adjustStaminaLossBuffered(getweight()) //CIT CHANGE - makes stunbatonning others cost stamina
|
||||
user.adjustStaminaLossBuffered(getweight(user, STAM_COST_BATON_MOB_MULT))
|
||||
else if(user.a_intent != INTENT_HARM) //they'll try to bash in the last proc.
|
||||
M.visible_message("<span class='warning'>[user] has prodded [M] with [src]. Luckily it was off.</span>", \
|
||||
"<span class='warning'>[user] has prodded you with [src]. Luckily it was off</span>")
|
||||
|
||||
@@ -241,11 +241,13 @@
|
||||
playsound(user, activation_sound, transform_volume, 1)
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
AddElement(/datum/element/sword_point)
|
||||
total_mass = total_mass_on
|
||||
else
|
||||
to_chat(user, "<span class='notice'>[deactivation_message]</span>")
|
||||
playsound(user, deactivation_sound, transform_volume, 1)
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
RemoveElement(/datum/element/sword_point)
|
||||
total_mass = initial(total_mass)
|
||||
|
||||
update_icon()
|
||||
add_fingerprint(user)
|
||||
@@ -287,9 +289,6 @@
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/toy/sword/getweight()
|
||||
return (active ? total_mass_on : total_mass) || w_class *1.25
|
||||
|
||||
/obj/item/toy/sword/cx
|
||||
name = "\improper DX Non-Euplastic LightSword"
|
||||
desc = "A deluxe toy replica of an energy sword. Realistic visuals and sounds! Ages 8 and up."
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
if(C.get_amount() >= 5)
|
||||
playsound(loc, 'sound/items/deconstruct.ogg', 50, 1)
|
||||
to_chat(user, "<span class='notice'>You start to add cables to the frame...</span>")
|
||||
if(do_after(user, 20, target = src) && state == SCREWED_CORE && C.use(5))
|
||||
if(do_after(user, 20, target = src) && state == SCREWED_CORE && C.use_tool(src, user, 0, 5))
|
||||
to_chat(user, "<span class='notice'>You add cables to the frame.</span>")
|
||||
state = CABLED_CORE
|
||||
update_icon()
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
panel_open = FALSE
|
||||
|
||||
else if(istype(I, /obj/item/stack/cable_coil) && panel_open)
|
||||
var/obj/item/stack/cable_coil/C = I
|
||||
if(obj_flags & EMAGGED) //Emagged, not broken by EMP
|
||||
to_chat(user, "<span class='warning'>Sign has been damaged beyond repair!</span>")
|
||||
return
|
||||
@@ -92,7 +91,7 @@
|
||||
to_chat(user, "<span class='warning'>This sign is functioning properly!</span>")
|
||||
return
|
||||
|
||||
if(C.use(2))
|
||||
if(I.use_tool(src, user, 0, 2))
|
||||
to_chat(user, "<span class='notice'>You replace the burnt wiring.</span>")
|
||||
broken = FALSE
|
||||
else
|
||||
|
||||
@@ -169,8 +169,7 @@
|
||||
if(do_after(user, 40, target = src))
|
||||
if(!src || !anchored || src.state != "01")
|
||||
return
|
||||
var/obj/item/stack/cable_coil/CC = W
|
||||
if(!CC.use(1))
|
||||
if(!W.use_tool(src, user, 0, 1))
|
||||
to_chat(user, "<span class='warning'>You need more cable to do this!</span>")
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You wire the windoor.</span>")
|
||||
|
||||
Reference in New Issue
Block a user