-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Watermelon914
authored and
Watermelon914
committed
Apr 15, 2021
1 parent
56c2b1a
commit 69cddb2
Showing
14 changed files
with
303 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#define LOOT_NONE 0 | ||
#define LOOT_COMMON 1 | ||
#define LOOT_RARE 2 | ||
#define LOOT_VERY_RARE 3 | ||
#define LOOT_LEGENDARY 4 | ||
|
||
#define RARITY_COUNT 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Works on the basis that legendary rolls first, then very rare and so on. | ||
|
||
/datum/config_entry/number/loot_common_chance | ||
config_entry_value = 100 | ||
|
||
/datum/config_entry/number/loot_rare_chance | ||
config_entry_value = 33 | ||
|
||
/datum/config_entry/number/loot_very_rare_chance | ||
config_entry_value = 10 | ||
|
||
/datum/config_entry/number/loot_legendary_chance | ||
config_entry_value = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
SUBSYSTEM_DEF(loot) | ||
name = "Loot" | ||
init_order = SS_INIT_LOOT | ||
|
||
flags = SS_NO_FIRE | ||
|
||
var/list/drop_chances[RARITY_COUNT] | ||
|
||
/datum/controller/subsystem/loot/Initialize() | ||
. = ..() | ||
reload_drop_chances() | ||
|
||
/datum/controller/subsystem/loot/proc/reload_drop_chances() | ||
drop_chances[LOOT_COMMON] = CONFIG_GET(number/loot_common_chance) | ||
drop_chances[LOOT_RARE] = CONFIG_GET(number/loot_rare_chance) | ||
drop_chances[LOOT_VERY_RARE] = CONFIG_GET(number/loot_very_rare_chance) | ||
drop_chances[LOOT_LEGENDARY] = CONFIG_GET(number/loot_legendary_chance) | ||
|
||
/datum/controller/subsystem/loot/proc/generate_loot(var/datum/loot_table/loot) | ||
RETURN_TYPE(/datum/loot_entry) | ||
|
||
if(!loot.table) | ||
return | ||
|
||
var/chosen_rarity = LOOT_NONE | ||
for(var/index in 1 to length(loot.rarities)) | ||
var/rarity = loot.rarities[index] | ||
var/probability = drop_chances[rarity] | ||
if(prob(probability)) | ||
chosen_rarity = rarity | ||
break | ||
|
||
if(chosen_rarity == LOOT_NONE) | ||
return | ||
|
||
if(!loot.table[chosen_rarity]) | ||
return | ||
|
||
return pick(loot.table[chosen_rarity]) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
GLOBAL_DATUM_INIT(loot_weapons, /datum/loot_table/weapons, new()) | ||
|
||
/obj/structure/closet/crate/loot/weapons | ||
name = "weapons crate" | ||
|
||
/obj/structure/closet/crate/loot/weapons/Initialize() | ||
. = ..() | ||
possible_items = GLOB.loot_weapons | ||
|
||
/datum/loot_table/weapons/New() | ||
. = ..() | ||
for(var/i in subtypesof(/datum/loot_entry/weapon)) | ||
var/datum/loot_entry/weapon/W = i | ||
if(initial(W.abstract_type) == i) | ||
continue | ||
|
||
if(!(initial(W.rarity) in rarities)) | ||
stack_trace("Invalid rarity value from [W]. Rarity not found in rarities variable.") | ||
continue | ||
|
||
table[initial(W.rarity)] += new W() | ||
|
||
/datum/loot_entry/weapon | ||
name = "weapon item" | ||
var/item_to_spawn | ||
|
||
/datum/loot_entry/weapon/spawn_item(var/atom/spawn_location) | ||
if(!item_to_spawn) | ||
return | ||
return new item_to_spawn(spawn_location) | ||
|
||
/* | ||
SHOTGUN WEAPONS | ||
Ordered from Legendary items to Common items | ||
*/ | ||
|
||
/datum/loot_entry/weapon/marsoc_shotgun | ||
name = "MARSOC Shotgun" | ||
item_to_spawn = /obj/item/weapon/gun/shotgun/combat/marsoc | ||
rarity = LOOT_LEGENDARY | ||
|
||
/datum/loot_entry/weapon/combat_shotgun | ||
name = "MK221 Tactical Shotgun" | ||
item_to_spawn = /obj/item/weapon/gun/shotgun/combat | ||
rarity = LOOT_VERY_RARE | ||
|
||
/datum/loot_entry/weapon/sawnoff_shotgun | ||
name = "Sawn-off Shotgun" | ||
item_to_spawn = /obj/item/weapon/gun/shotgun/double/sawn | ||
rarity = LOOT_RARE | ||
|
||
/datum/loot_entry/weapon/double_barrel | ||
name = "Double-barrel Shotgun" | ||
item_to_spawn = /obj/item/weapon/gun/shotgun/double | ||
rarity = LOOT_COMMON | ||
|
||
/datum/loot_entry/weapon/hg_shotgun | ||
name = "HG 37-12 Pump Shotgun" | ||
item_to_spawn = /obj/item/weapon/gun/shotgun/pump/cmb | ||
rarity = LOOT_COMMON | ||
|
||
/* | ||
GENERAL WEAPONS | ||
Ordered from Legendary items to Common items | ||
*/ | ||
|
||
/datum/loot_entry/weapon/m40_sd | ||
name = "M40-SD pulse rifle" | ||
item_to_spawn = /obj/item/weapon/gun/rifle/m41a/elite/m40_sd | ||
rarity = LOOT_VERY_RARE | ||
|
||
/datum/loot_entry/weapon/m41a_elite | ||
name = "M41A/2 pulse rifle" | ||
item_to_spawn = /obj/item/weapon/gun/rifle/m41a/elite | ||
rarity = LOOT_VERY_RARE | ||
|
||
/datum/loot_entry/weapon/m39_elite | ||
name = "M39B/2 submachinegun" | ||
item_to_spawn = /obj/item/weapon/gun/smg/m39/elite | ||
rarity = LOOT_RARE | ||
|
||
/datum/loot_entry/weapon/fp9000 | ||
name = "FP9000 submachinegun" | ||
item_to_spawn = /obj/item/weapon/gun/smg/fp9000 | ||
rarity = LOOT_RARE | ||
|
||
/datum/loot_entry/weapon/m46c | ||
name = "M46C pulse rifle" | ||
item_to_spawn = /obj/item/weapon/gun/rifle/m46c | ||
rarity = LOOT_RARE | ||
|
||
/datum/loot_entry/weapon/m4ra | ||
name = "M4RA battle rifle" | ||
item_to_spawn = /obj/item/weapon/gun/rifle/m4ra | ||
rarity = LOOT_COMMON | ||
|
||
/datum/loot_entry/weapon/mateba | ||
name = "Mateba autorevolver" | ||
item_to_spawn = /obj/item/weapon/gun/revolver/mateba | ||
rarity = LOOT_COMMON | ||
|
||
/* | ||
SPECIAL WEAPONS | ||
Ordered from Legendary items to Common items | ||
*/ | ||
|
||
/datum/loot_entry/weapon/minigun | ||
name = "Minigun" | ||
item_to_spawn = /obj/item/weapon/gun/minigun | ||
rarity = LOOT_LEGENDARY | ||
|
||
/datum/loot_entry/weapon/rpg | ||
name = "M5 RPG" | ||
item_to_spawn = /obj/item/weapon/gun/launcher/rocket | ||
rarity = LOOT_LEGENDARY | ||
|
||
/datum/loot_entry/weapon/m60 | ||
name = "M60 Machinegun" | ||
item_to_spawn = /obj/item/weapon/gun/m60 | ||
rarity = LOOT_VERY_RARE | ||
|
||
/datum/loot_entry/weapon/grenade_launcher | ||
name = "Grenade Launcher" | ||
item_to_spawn = /obj/item/weapon/gun/launcher/grenade/m92 | ||
rarity = LOOT_RARE | ||
|
||
#define TESTING | ||
#ifdef TESTING | ||
/client/verb/do_loot_table_test(var/amount as num) | ||
set name = "Do Weapon Loot Table Test" | ||
set category = "Debug" | ||
|
||
var/legendary = 0 | ||
var/very_rare = 0 | ||
var/rare = 0 | ||
var/common = 0 | ||
for(var/i in 1 to amount) | ||
var/datum/loot_entry/L = SSloot.generate_loot(GLOB.loot_weapons) | ||
switch(L.rarity) | ||
if(LOOT_COMMON) | ||
common++ | ||
if(LOOT_RARE) | ||
rare++ | ||
if(LOOT_VERY_RARE) | ||
very_rare++ | ||
if(LOOT_LEGENDARY) | ||
legendary++ | ||
|
||
to_chat(usr, "Got [legendary] legendaries, [very_rare] very rares, [rare] rares, [common] commons.") | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/obj/structure/closet/crate/loot | ||
name = "debug loot crate" | ||
icon_state = "secure_locked_weapons" | ||
icon_opened = "secure_open_weapons" | ||
icon_closed = "secure_locked_weapons" | ||
wrenchable = FALSE | ||
anchored = TRUE | ||
|
||
/// Loot table used to determine what a box can give depending on what the dice roll comes out on. | ||
var/datum/loot_table/possible_items | ||
|
||
// Can't close loot crates, they stay open once open. | ||
/obj/structure/closet/crate/loot/can_close() | ||
return FALSE | ||
|
||
/obj/structure/closet/crate/loot/open() | ||
if(!possible_items) | ||
return | ||
|
||
. = ..() | ||
if(!.) | ||
return | ||
|
||
var/datum/loot_entry/item = SSloot.generate_loot(possible_items) | ||
if(!item) | ||
return | ||
|
||
item.spawn_item(get_turf(src)) | ||
|
||
/obj/structure/closet/crate/loot/Destroy() | ||
possible_items = null | ||
return ..() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/datum/loot_table | ||
/// The list of rarities that this loot table includes. Used for probability calculations. | ||
/// The order in which the probabilities are checked depend on the order of the rarities. | ||
var/list/rarities = list( | ||
LOOT_LEGENDARY, | ||
LOOT_VERY_RARE, | ||
LOOT_RARE, | ||
LOOT_COMMON | ||
) | ||
var/list/datum/loot_entry/table | ||
|
||
/datum/loot_table/New() | ||
. = ..() | ||
var/highest_value = 0 | ||
for(var/i in rarities) | ||
if(i > highest_value) | ||
highest_value = i | ||
|
||
table = new(highest_value) | ||
for(var/i in rarities) | ||
table[i] = list() | ||
|
||
/datum/loot_entry | ||
var/name | ||
var/abstract_type = /datum/loot_entry | ||
var/rarity = LOOT_COMMON | ||
|
||
/// Returns the item to spawn, whilst also spawning at the desired spawn location. Can return null. | ||
/datum/loot_entry/proc/spawn_item(var/atom/spawn_location) | ||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.