mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-27 14:08:44 +01:00
Stasis Cage Exporting (#19612)
* sellable stasis cage * Sellable mobs * crate code cleanup * export fix * clamp * sold mobs should vanish
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/datum/element/sellable
|
||||
var/sale_info = "This can be sold on the cargo shuttle if packed in a crate."
|
||||
var/needs_crate = TRUE
|
||||
var/datum/techweb/research_default_techweb = null
|
||||
var/department = DEPARTMENT_CARGO // Which kind of points does selling this give, by default it gives cargo supply points
|
||||
|
||||
/datum/element/sellable/Attach(datum/target)
|
||||
. = ..()
|
||||
@@ -45,7 +47,15 @@
|
||||
"value" = calculate_sell_value(source),
|
||||
"quantity" = calculate_sell_quantity(source)
|
||||
)
|
||||
EC.value += EC.contents[EC.contents.len]["value"]
|
||||
|
||||
var/point_value = EC.contents[EC.contents.len]["value"]
|
||||
switch(department)
|
||||
if(DEPARTMENT_CARGO)
|
||||
EC.value += point_value
|
||||
if(DEPARTMENT_RESEARCH)
|
||||
if(!research_default_techweb) // Lets do this when we sell a research giving item, instead of fighting subsystem init order
|
||||
research_default_techweb = locate(/datum/techweb/science) in SSresearch.techwebs
|
||||
research_default_techweb.add_point_list(list(TECHWEB_POINT_TYPE_GENERIC = point_value))
|
||||
return TRUE
|
||||
|
||||
/datum/element/sellable/proc/on_examine(datum/source, mob/user, list/examine_texts)
|
||||
@@ -398,3 +408,54 @@
|
||||
amount /= 20
|
||||
|
||||
return FLOOR(amount,5)
|
||||
|
||||
|
||||
// Selling xenomobs for science!!
|
||||
/datum/element/sellable/stasis_cage
|
||||
sale_info = "This can be export on the cargo shuttle. Central command will reward the station with research points if the creature within has scientific value."
|
||||
needs_crate = FALSE
|
||||
department = DEPARTMENT_RESEARCH
|
||||
|
||||
/datum/element/sellable/stasis_cage/sell_error(obj/source)
|
||||
var/obj/structure/stasis_cage/cage = source
|
||||
if(!cage.contained)
|
||||
return "Error: [cage] was empty."
|
||||
// Check if this creature can even be sold at all
|
||||
if(!istype(cage.contained, /mob/living/simple_mob))
|
||||
return "Error: This creature has no scientific value."
|
||||
if(cage.contained.client) // Lets not allow player possessed creatures to be sold
|
||||
return "Error: This creature has an undesirable mutation and has no scientific value."
|
||||
var/mob/living/simple_mob/our_mob = cage.contained
|
||||
if(our_mob.stat == DEAD)
|
||||
return "Error: The creature must be alive to study. It has no scientific value."
|
||||
if(!our_mob.export_research_value || !our_mob.export_research_diminished_max)
|
||||
return "Error: This creature has no scientific value."
|
||||
// We know it HAD value, see if it has any value remaining
|
||||
var/check_val = calculate_sell_value(source)
|
||||
if(!check_val)
|
||||
return "Error: This creature no longer has any scientific value."
|
||||
// Increase sold count, now that we've reached successful export
|
||||
var/mob_key = "[cage.contained.type]"
|
||||
if(!(mob_key in SSsupply.exported_research_mobs))
|
||||
SSsupply.exported_research_mobs[mob_key] = 0
|
||||
SSsupply.exported_research_mobs[mob_key] += 1
|
||||
return null
|
||||
|
||||
/datum/element/sellable/stasis_cage/calculate_sell_value(obj/source)
|
||||
var/obj/structure/stasis_cage/cage = source
|
||||
if(!cage.contained)
|
||||
return 0
|
||||
if(!istype(cage.contained, /mob/living/simple_mob))
|
||||
return 0
|
||||
var/mob/living/simple_mob/our_mob = cage.contained
|
||||
if(our_mob.stat == DEAD)
|
||||
return 0
|
||||
if(!our_mob.export_research_value || !our_mob.export_research_diminished_max)
|
||||
return 0
|
||||
// Calculate diminishing returns from number of mobs that have already been sold of this type
|
||||
var/mob_key = "[cage.contained.type]"
|
||||
var/sold_mobs = 0
|
||||
if(mob_key in SSsupply.exported_research_mobs)
|
||||
sold_mobs = SSsupply.exported_research_mobs[mob_key]
|
||||
var/research_val = our_mob.export_research_value // Each mob sold will linearly scale the value of research points recieved, until it hits 25% of it's value.
|
||||
return max(1, FLOOR(lerp(research_val, research_val * 0.25, CLAMP(sold_mobs / our_mob.export_research_diminished_max, 0, 1)), 1))
|
||||
|
||||
Reference in New Issue
Block a user