/
githubmirror
/
vgstation13
Обзор
Документация
Войти
/
githubmirror
/
vgstation13
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
Bleeding-Edge
code/modules/maps/spawners/pick_spawner.dm
132 строки
6 KB
SECBATON GRIFFON
Reticulite (#37357)
06 май 2026, 17:56
Не верифицирован
06 май 2026, 17:56
309ea7f
Код
Авторство
О чём код?
// // PICK_SPAWNERS // // These work the same as regular map spawners, except that you place many of them and only ONE will be picked to spawn. // They have a required category field (which is a string). By default, only one successful spawn is allowed per category. // // Example: You want to spawn 1 pair of insulated gloves in a room, but you want to randomize in which tile they will spawn. // For this purpose, you would create a pickspawner that spawns 1 pair of insulated gloves, and give it a new, unique category like "yellowgloves_myroomname". // You then place that same pickspawner 5 times in 5 different tiles. When the game loads, the gloves will randomly spawn in 1 out of those 5 possible locations. // If you want to add a second pair of insulated gloves in a DIFFERENT room, you need a new pickspawner with a fresh category, like "yellowgloves_myotherroom". // // Technically, you can have multiple subtypes of pickspawner with different functionality but the same category. // For example, you can make a "maint bear" pickspawner, a "space carp" pickspawner, and a "morgue spider" pickspawner, and give them all the same category. // In that case, even though they do very different things and are in different places, only 1 will spawn regardless. // This is OK, just make sure that's what you actually want to do (and make sure all pickspawners sharing an category have the same number for var/spawners_to_pick) /obj/abstract/map/spawner/pick_spawner var/category = "" //required var/spawners_to_pick = 1 //how many spawners to spawn per our category. if adding multiply types of spawner to an category, ensure this number is consistent between all of them var/weight = 100 //set this higher to prioritize a certain spawner over others in the same category /obj/abstract/map/spawner/pick_spawner/New() //deliberately not calling parent, because our parent would perform_spawn() us ASSERT(category) if(!map_pickspawners[category]) map_pickspawners[category] = list() map_pickspawners[category] += src /obj/abstract/map/spawner/pick_spawner/kill_spawner() if(category && map_pickspawners[category]) map_pickspawners[category] -= src ..() //This is called in /datum/subsystem/map/Initialize(). /proc/spawn_map_pickspawners() for(var/category in map_pickspawners) var/amount_to_spawn var/possible_spawners = list() //Formatted for pickweight() for(var/obj/abstract/map/spawner/pick_spawner/candidate in map_pickspawners[category]) if(!amount_to_spawn) //We are just taking the value for the first spawner we find since we assume it's consistent between all spawners in the category amount_to_spawn = candidate.spawners_to_pick possible_spawners[candidate] = candidate.weight for(amount_to_spawn, amount_to_spawn, amount_to_spawn--) var/obj/abstract/map/spawner/pick_spawner/winner = pickweight(possible_spawners) winner.perform_spawn() //It automatically removes itself from the list when spawning. for(var/obj/abstract/map/spawner/pick_spawner/loser in map_pickspawners[category]) loser.kill_spawner() //They automatically remove themselves from the list here. //************************************************************** // Subtypes //////////////////////////////////////////////////// //************************************************************** /obj/abstract/map/spawner/pick_spawner/yellowgloves category = "yellowgloves_maint" name = "insulated gloves pickspawner" icon_state = "glubb_rand" to_spawn = list( /obj/item/clothing/gloves/yellow ) /obj/abstract/map/spawner/pick_spawner/yellowgloves/tcomms_storage category = "yellowgloves_tcommsstorage" name = "glubb pickspawner (tcomms_storage)" /obj/abstract/map/spawner/pick_spawner/yellowgloves/cyborgcharger category = "yellowgloves_cyborgcharger" name = "glubb pickspawner (cyborgcharger)" /obj/abstract/map/spawner/pick_spawner/yellowgloves/technicalstorage category = "yellowgloves_technicalstorage" name = "glubb pickspawner (technicalstorage)" /obj/abstract/map/spawner/pick_spawner/mecha_wreckage category = "mecha_graveyard_wreckage" name = "Mecha Graveyard Wreckage Spawner" spawners_to_pick = 14 icon_state = "robot_any" to_spawn = list( /obj/effect/decal/mecha_wreckage/ripley, /obj/effect/decal/mecha_wreckage/ripley, /obj/effect/decal/mecha_wreckage/ripley, /obj/effect/decal/mecha_wreckage/ripley, /obj/effect/decal/mecha_wreckage/clarke, /obj/effect/decal/mecha_wreckage/clarke, /obj/effect/decal/mecha_wreckage/clarke, /obj/effect/decal/mecha_wreckage/clarke, /obj/effect/decal/mecha_wreckage/odysseus, /obj/effect/decal/mecha_wreckage/odysseus, /obj/effect/decal/mecha_wreckage/marauder, /obj/effect/decal/mecha_wreckage/marauder, /obj/effect/decal/mecha_wreckage/gygax, /obj/effect/decal/mecha_wreckage/gygax, /obj/effect/decal/mecha_wreckage/durand, /obj/effect/decal/mecha_wreckage/durand, /obj/effect/decal/mecha_wreckage/honker, /obj/effect/decal/mecha_wreckage/honker, /obj/effect/decal/mecha_wreckage/roswell, ) /obj/abstract/map/spawner/pick_spawner/mecha_wreckage_good category = "mecha_graveyard_wreckage_good" name = "Mecha Graveyard Good Wreckage Spawner" icon_state = "engi_materials" to_spawn = list( /obj/effect/decal/mecha_wreckage/graveyard_ripley, /obj/effect/decal/mecha_wreckage/graveyard_ripley, /obj/effect/decal/mecha_wreckage/graveyard_clarke, /obj/effect/decal/mecha_wreckage/graveyard_clarke, /obj/effect/decal/mecha_wreckage/roswell/graveyard, ) /obj/abstract/map/spawner/pick_spawner/mecha_wreckage_equip category = "mecha_graveyard_wreckage_good" name = "Mecha Graveyard Good Wreckage Spawner" spawners_to_pick = 2 icon_state = "space_tools" to_spawn = list( /obj/item/mecha_parts/mecha_equipment/passive/runningboard, /obj/item/mecha_parts/mecha_equipment/passive/rack, /obj/item/mecha_parts/mecha_equipment/tool/jail, /obj/item/mecha_parts/mecha_equipment/jetpack, /obj/item/mecha_parts/mecha_equipment/tool/scythe, /obj/item/mecha_parts/mecha_equipment/tool/extinguisher, /obj/item/mecha_parts/mecha_equipment/tool/red, /obj/item/mecha_parts/mecha_equipment/wormhole_generator, /obj/item/mecha_parts/mecha_equipment/gravcatapult, /obj/item/mecha_parts/mecha_equipment/repair_droid, /obj/item/mecha_parts/mecha_equipment/tesla_energy_relay, )