Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 1aebe88

Browse files
skill issue
1 parent 892d598 commit 1aebe88

File tree

8 files changed

+52
-20
lines changed

8 files changed

+52
-20
lines changed

code/datums/mind.dm

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
SKILL_FITNESS = 0,
6969
)
7070

71+
/// One-time experience gains that have already been acquired
72+
var/list/unique_exp = list()
73+
7174
/// Free skill points to allocate
7275
var/skill_points = 0
7376

@@ -804,12 +807,15 @@
804807
return FALSE
805808
return (mind.skills[skill] >= amount)
806809

807-
/// Adds progress towards increasing skill level. Returns TRUE if it improved the skill.
808-
/mob/proc/add_exp(skill, amount)
810+
/// Adds progress towards increasing skill level. Returns TRUE if it added progress. Adding a source prevents gaining exp from that source again.
811+
/mob/proc/add_exp(skill, amount, source)
809812
if(!mind)
810813
return FALSE
811-
if(mind.skill_points > 0)
814+
if(!amount)
815+
return FALSE
816+
if(source && (source in mind.unique_exp))
812817
return FALSE
818+
mind.unique_exp.Add(source)
813819
var/exp_required = EXPERIENCE_PER_LEVEL * (2**mind.skills[skill]) // exp required scales exponentially
814820
if(mind.exp_progress[skill] + amount >= exp_required)
815821
var/levels_gained = round(log(2, 1 + (mind.exp_progress[skill] + amount) / exp_required)) // in case you gained so much you go up more than one level
@@ -818,11 +824,17 @@
818824
hud_used.skill_menu.allocated_points -= min(levels_gained, levels_allocated)
819825
hud_used.skill_menu.allocated_skills[skill] -= min(levels_gained, levels_allocated)
820826
mind.exp_progress[skill] += amount - exp_required * (2**(levels_gained - 1))
827+
mind.skill_points = max(mind.skill_points - levels_gained, 0) // remove an equal amount of unallocated skill points to prevent exploits
821828
adjust_skill(skill, levels_gained)
822829
to_chat(src, span_boldnotice("Your [skill] skill is now level [get_skill(skill)]!"))
823-
return TRUE
824830
mind.exp_progress[skill] += amount
825-
return FALSE
831+
return TRUE
832+
833+
/// Returns whether experience has been gained from a given source
834+
/mob/proc/has_exp(source)
835+
if(!mind)
836+
return FALSE
837+
return (source in mind.unique_exp) ? TRUE : FALSE
826838

827839
/// Adds skill points to be allocated at will.
828840
/mob/proc/add_skill_points(amount)

code/datums/wires/_wires.dm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@
184184
return TRUE
185185
return FALSE
186186

187-
/datum/wires/proc/cut(wire)
187+
/datum/wires/proc/cut(wire, mob/user)
188188
if(is_cut(wire))
189189
cut_wires -= wire
190190
on_cut(wire, mend = TRUE)
191191
else
192192
cut_wires += wire
193193
on_cut(wire, mend = FALSE)
194+
if(user)
195+
user.add_exp(SKILL_TECHNICAL, 50, "[wire]_[type]")
194196

195197
/datum/wires/proc/cut_color(color)
196198
cut(get_wire(color))
@@ -202,10 +204,12 @@
202204
for(var/wire in wires)
203205
cut(wire)
204206

205-
/datum/wires/proc/pulse(wire, user)
207+
/datum/wires/proc/pulse(wire, mob/user)
206208
if(is_cut(wire))
207209
return
208210
on_pulse(wire, user)
211+
if(user)
212+
user.add_exp(SKILL_TECHNICAL, 50, "[wire]_[type]")
209213

210214
/datum/wires/proc/pulse_color(color, mob/living/user)
211215
pulse(get_wire(color), user)

code/game/objects/items/storage/bags.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
if(usr.incapacitated())
285285
return
286286
for(var/obj/item/O in contents)
287-
seedify(O, 1)
287+
seedify(O, 1, null, usr)
288288

289289
// -----------------------------
290290
// Stack Snatcher

code/modules/hydroponics/gene_modder.dm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@
255255
/obj/machinery/plantgenes/Topic(href, list/href_list)
256256
if(..())
257257
return
258-
usr.set_machine(src)
258+
259+
var/mob/user = usr
260+
user.set_machine(src)
259261

260262
if(href_list["eject_seed"] && !operation)
261263
if (seed)
@@ -338,6 +340,9 @@
338340
gene.value = max(gene.value, min_wrate)
339341
else if(istype(G, /datum/plant_gene/core/weed_chance))
340342
gene.value = max(gene.value, min_wchance)
343+
if(G.extract_value && user.add_exp(SKILL_SCIENCE, G.extract_value, G.type))
344+
user.playsound_local(get_turf(src), 'sound/machines/ping.ogg', 25, TRUE)
345+
balloon_alert(user, "new trait catalogued: [lowertext(G.name)]")
341346
disk.update_appearance()
342347
qdel(seed)
343348
seed = null

code/modules/hydroponics/plant_genes.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/datum/plant_gene
22
var/name
3+
/// Skill gain from extracting this gene. Can only be gained once.
4+
var/extract_value = 0
35

46
/datum/plant_gene/proc/get_name() // Used for manipulator display and gene disk name.
57
return name
@@ -138,6 +140,7 @@
138140
var/rate = 0.05
139141
var/examine_line = ""
140142
var/trait_id // must be set and equal for any two traits of the same type
143+
extract_value = 150
141144

142145
/datum/plant_gene/trait/Copy()
143146
var/datum/plant_gene/trait/G = ..()
@@ -433,6 +436,7 @@
433436

434437
/datum/plant_gene/trait/fire_resistance // Lavaland
435438
name = "Fire Resistance"
439+
extract_value = 500
436440

437441
/datum/plant_gene/trait/fire_resistance/apply_vars(obj/item/seeds/S)
438442
if(!(S.resistance_flags & FIRE_PROOF))
@@ -454,3 +458,4 @@
454458

455459
/datum/plant_gene/trait/plant_type/alien_properties
456460
name ="?????"
461+
extract_value = 500

code/modules/hydroponics/seed_extractor.dm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
else
2323
t_max = rand(1,4)
2424

25-
var/seedloc = O.loc
25+
var/atom/seedloc = O.loc
2626
if(extractor)
2727
seedloc = extractor.loc
2828

@@ -37,7 +37,6 @@
3737
t_prod.forceMove(seedloc)
3838
t_amount++
3939
qdel(O)
40-
return seeds
4140

4241
else if(istype(O, /obj/item/grown))
4342
var/obj/item/grown/F = O
@@ -46,13 +45,18 @@
4645
return
4746
while(t_amount < t_max)
4847
var/obj/item/seeds/t_prod = F.seed.Copy()
48+
seeds.Add(t_prod)
4949
t_prod.forceMove(seedloc)
5050
t_amount++
5151
qdel(O)
52-
return 1
5352

54-
return 0
53+
if(user && seeds.len)
54+
var/obj/item/seeds/seed = seeds[1] // all seeds are duplicates, pick the first one in the list
55+
if(user.add_exp(SKILL_SCIENCE, seed.rarity * 10, seed.type))
56+
user.playsound_local(get_turf(seedloc), 'sound/machines/ping.ogg', 25, TRUE)
57+
seedloc.balloon_alert(user, "rare plant catalogued: [initial(seed.product.name)]")
5558

59+
return (seeds.len ? seeds : FALSE)
5660

5761
/obj/machinery/seed_extractor
5862
name = "seed extractor"

code/modules/hydroponics/seeds.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
resistance_flags = FLAMMABLE
1010
var/plantname = "Plants" // Name of plant when planted.
1111
var/plantdesc // Description of plant when planted
12-
var/product // A type path. The thing that is created when the plant is harvested.
12+
var/atom/product // A type path. The thing that is created when the plant is harvested.
1313
var/species = "" // Used to update icons. Should match the name in the sprites unless all icon_* are overridden.
1414

1515
var/growing_icon = 'icons/obj/hydroponics/growing.dmi' //the file that stores the sprites of the growing plant from this seed.

code/modules/research/machinery/plortmachine.dm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@
4040
return
4141

4242
if(istype(W, /obj/item/slime_extract))
43-
refine_plort(W)
44-
qdel(W)
43+
refine_plort(W, user)
4544
return
46-
47-
/obj/machinery/plortrefinery/proc/refine_plort(obj/item/slime_extract/W)
48-
point_gain = W.plort_value * research_point_multiplier
49-
linked_techweb.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, point_gain)
5045

46+
/obj/machinery/plortrefinery/proc/refine_plort(obj/item/slime_extract/extract, mob/user)
47+
point_gain = extract.plort_value * research_point_multiplier
48+
linked_techweb.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, point_gain)
49+
if(user.add_exp(SKILL_SCIENCE, extract.plort_value * 5, extract.type))
50+
user.playsound_local(get_turf(src), 'sound/machines/ping.ogg', 25, TRUE)
51+
balloon_alert(user, "new sample processed: [extract.effectmod]")
52+
qdel(extract)
5153

5254
/obj/machinery/plortrefinery/Initialize(mapload)
5355
. = ..()

0 commit comments

Comments
 (0)