Files
Aurora.3/code/game/objects/random/random.dm
courierbravo ea56fbffc3 Randoms Part 1 and also Corn - Random object sprites and corn tank changes. (#19975)
Added new sprites for random objects for everything in random/clothing,
/food, /loot, /medical, and /misc.
Also got distracted and changed how the corn oil/cooking oil tank looks
and how much reagent it holds. Now looks like the rest of the reagent
tanks and holds the same amount of liquid, 1000u.
2024-10-05 01:02:16 +00:00

57 lines
1.5 KiB
Plaintext

/obj/random
name = "random object"
desc = "This item type is used to spawn random objects at round-start"
icon = 'icons/obj/random.dmi'
icon_state = "need-sprite"
var/spawn_nothing_percentage = 0 // this variable determines the likelyhood that this random object will not spawn anything
var/list/spawnlist
var/list/problist
var/has_postspawn
// creates a new object and deletes itself
/obj/random/Initialize()
. = ..()
if (!prob(spawn_nothing_percentage))
var/obj/spawned_item = spawn_item()
if(spawned_item)
spawned_item.pixel_x = pixel_x
spawned_item.pixel_y = pixel_y
if(has_postspawn)
post_spawn(spawned_item)
return INITIALIZE_HINT_QDEL
// this function should return a specific item to spawn
/obj/random/proc/item_to_spawn()
return 0
/obj/random/proc/post_spawn(obj/thing)
LOG_DEBUG("random_obj: [DEBUG_REF(src)] registered itself as having post_spawn, but did not override post_spawn()!")
// creates the random item
/obj/random/proc/spawn_item()
if (spawnlist)
var/itemtype = pick(spawnlist)
. = new itemtype(loc)
else if (problist)
var/itemtype = pickweight(problist)
. = new itemtype(loc)
else
var/itemtype = item_to_spawn()
. = new itemtype(loc)
if (!.)
LOG_DEBUG("random_obj: [DEBUG_REF(src)] returned null item!")
/obj/random/single
name = "randomly spawned object"
desc = "This item type is used to randomly spawn a given object at round-start"
icon_state = "x3"
var/spawn_object = null
/obj/random/single/item_to_spawn()
return ispath(spawn_object) ? spawn_object : text2path(spawn_object)