mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-29 19:42:42 +00:00
Christ on a stick. SO MANY ERRORS. REEE. # Conflicts: # baystation12.dme # code/_helpers/lists.dm # code/_helpers/logging.dm # code/_helpers/text.dm # code/_onclick/click.dm # code/controllers/configuration.dm # code/controllers/master_controller.dm # code/datums/supplypacks.dm # code/game/antagonist/antagonist.dm # code/game/antagonist/antagonist_print.dm # code/game/antagonist/outsider/commando.dm # code/game/antagonist/outsider/ninja.dm # code/game/area/areas.dm # code/game/gamemodes/cult/cult_items.dm # code/game/gamemodes/game_mode.dm # code/game/jobs/access.dm # code/game/machinery/atmoalter/canister.dm # code/game/machinery/autolathe.dm # code/game/machinery/doors/airlock.dm # code/game/machinery/recharger.dm # code/game/machinery/suit_storage_unit.dm # code/game/mecha/mech_fabricator.dm # code/game/mecha/mecha.dm # code/game/objects/effects/spiders.dm # code/game/objects/items.dm # code/game/objects/items/devices/PDA/PDA.dm # code/game/objects/items/devices/flash.dm # code/game/objects/items/devices/lightreplacer.dm # code/game/objects/items/devices/paicard.dm # code/game/objects/items/devices/scanners.dm # code/game/objects/items/devices/suit_cooling.dm # code/game/objects/items/devices/uplink.dm # code/game/objects/items/robot/robot_upgrades.dm # code/game/objects/items/toys.dm # code/game/objects/items/weapons/cards_ids.dm # code/game/objects/items/weapons/handcuffs.dm # code/game/objects/items/weapons/manuals.dm # code/game/objects/items/weapons/material/kitchen.dm # code/game/objects/items/weapons/material/misc.dm # code/game/objects/items/weapons/material/swords.dm # code/game/objects/items/weapons/melee/energy.dm # code/game/objects/items/weapons/melee/misc.dm # code/game/objects/items/weapons/scrolls.dm # code/game/objects/items/weapons/storage/belt.dm # code/game/objects/items/weapons/stunbaton.dm # code/game/objects/items/weapons/tools.dm # code/game/objects/objs.dm # code/game/objects/structures/crates_lockers/closets.dm # code/game/objects/structures/crates_lockers/closets/secure/security.dm # code/game/objects/structures/janicart.dm # code/game/sound.dm # code/game/turfs/simulated.dm # code/game/verbs/ooc.dm # code/global.dm # code/modules/admin/verbs/debug.dm # code/modules/admin/verbs/modifyvariables.dm # code/modules/client/client procs.dm # code/modules/client/preferences.dm # code/modules/clothing/clothing.dm # code/modules/clothing/head/hardhat.dm # code/modules/clothing/head/helmet.dm # code/modules/clothing/head/jobs.dm # code/modules/clothing/head/misc_special.dm # code/modules/clothing/shoes/jobs.dm # code/modules/clothing/spacesuits/alien.dm # code/modules/clothing/spacesuits/captain.dm # code/modules/clothing/spacesuits/miscellaneous.dm # code/modules/clothing/spacesuits/rig/rig_pieces.dm # code/modules/clothing/spacesuits/rig/suits/alien.dm # code/modules/clothing/spacesuits/spacesuits.dm # code/modules/clothing/spacesuits/void/merc.dm # code/modules/clothing/spacesuits/void/void.dm # code/modules/clothing/suits/armor.dm # code/modules/clothing/suits/jobs.dm # code/modules/clothing/suits/storage.dm # code/modules/clothing/suits/utility.dm # code/modules/clothing/suits/wiz_robe.dm # code/modules/clothing/under/jobs/security.dm # code/modules/economy/Events.dm # code/modules/economy/Events_Mundane.dm # code/modules/economy/economy_misc.dm # code/modules/events/blob.dm # code/modules/events/event.dm # code/modules/events/event_container.dm # code/modules/events/event_manager.dm # code/modules/events/money_lotto.dm # code/modules/events/prison_break.dm # code/modules/events/spacevine.dm # code/modules/hydroponics/trays/tray.dm # code/modules/mob/dead/observer/observer.dm # code/modules/mob/emote.dm # code/modules/mob/holder.dm # code/modules/mob/language/station.dm # code/modules/mob/living/bot/cleanbot.dm # code/modules/mob/living/carbon/alien/diona/diona.dm # code/modules/mob/living/carbon/alien/diona/diona_attacks.dm # code/modules/mob/living/carbon/give.dm # code/modules/mob/living/carbon/human/emote.dm # code/modules/mob/living/carbon/human/human.dm # code/modules/mob/living/carbon/human/human_defense.dm # code/modules/mob/living/carbon/human/inventory.dm # code/modules/mob/living/carbon/human/life.dm # code/modules/mob/living/carbon/human/species/outsider/vox.dm # code/modules/mob/living/carbon/human/species/station/golem.dm # code/modules/mob/living/carbon/human/species/station/station.dm # code/modules/mob/living/carbon/human/update_icons.dm # code/modules/mob/living/carbon/metroid/metroid.dm # code/modules/mob/living/living.dm # code/modules/mob/living/living_defense.dm # code/modules/mob/living/living_defines.dm # code/modules/mob/living/silicon/ai/ai.dm # code/modules/mob/living/silicon/pai/admin.dm # code/modules/mob/living/silicon/pai/pai.dm # code/modules/mob/living/silicon/robot/drone/drone.dm # code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm # code/modules/mob/living/silicon/robot/emote.dm # code/modules/mob/living/silicon/robot/robot_items.dm # code/modules/mob/living/silicon/robot/robot_modules.dm # code/modules/mob/living/silicon/silicon.dm # code/modules/mob/living/simple_animal/bees.dm # code/modules/mob/living/simple_animal/friendly/cat.dm # code/modules/mob/living/simple_animal/friendly/corgi.dm # code/modules/mob/living/simple_animal/friendly/farm_animals.dm # code/modules/mob/living/simple_animal/friendly/mouse.dm # code/modules/mob/living/simple_animal/friendly/spiderbot.dm # code/modules/mob/living/simple_animal/hostile/hostile.dm # code/modules/mob/living/simple_animal/simple_animal.dm # code/modules/mob/logout.dm # code/modules/mob/mob.dm # code/modules/mob/mob_grab_specials.dm # code/modules/mob/mob_helpers.dm # code/modules/mob/new_player/sprite_accessories.dm # code/modules/organs/organ.dm # code/modules/organs/organ_alien.dm # code/modules/organs/organ_external.dm # code/modules/paperwork/faxmachine.dm # code/modules/projectiles/ammunition/boxes.dm # code/modules/projectiles/ammunition/bullets.dm # code/modules/projectiles/guns/energy/nuclear.dm # code/modules/projectiles/guns/energy/rifle.dm # code/modules/projectiles/guns/energy/special.dm # code/modules/projectiles/guns/projectile.dm # code/modules/projectiles/guns/projectile/automatic.dm # code/modules/projectiles/guns/projectile/pistol.dm # code/modules/projectiles/guns/projectile/revolver.dm # code/modules/projectiles/guns/projectile/shotgun.dm # code/modules/projectiles/projectile/bullets.dm # code/modules/projectiles/projectile/special.dm # code/modules/reagents/reagent_containers.dm # code/modules/reagents/reagent_containers/food/drinks.dm # code/modules/research/designs.dm # code/modules/research/destructive_analyzer.dm # code/modules/research/rdconsole.dm # code/modules/spells/artifacts.dm # code/modules/spells/spellbook.dm # code/modules/tables/tables.dm # code/world.dm # config/example/config.txt # icons/mob/items_lefthand.dmi # icons/mob/items_righthand.dmi # icons/obj/lighting.dmi
168 lines
5.6 KiB
Plaintext
168 lines
5.6 KiB
Plaintext
/datum/event_meta
|
|
var/name = ""
|
|
var/enabled = 1 // Whether or not the event is available for random selection at all
|
|
var/weight = 0 // The base weight of this event. A zero means it may never fire, but see get_weight()
|
|
var/min_weight = 0 // The minimum weight that this event will have. Only used if non-zero.
|
|
var/max_weight = 0 // The maximum weight that this event will have. Only use if non-zero.
|
|
var/severity = 0 // The current severity of this event
|
|
var/one_shot = 0 // If true, then the event will not be re-added to the list of available events
|
|
var/add_to_queue= 1 // If true, add back to the queue of events upon finishing.
|
|
var/list/role_weights = list()
|
|
var/list/excluded_gamemodes = list() // A list of gamemodes during which this event won't fire.
|
|
var/datum/event/event_type
|
|
|
|
/datum/event_meta/New(var/event_severity, var/event_name, var/datum/event/type, var/event_weight, var/list/job_weights, var/is_one_shot = 0, var/min_event_weight = 0, var/max_event_weight = 0, var/list/excluded_roundtypes)
|
|
name = event_name
|
|
severity = event_severity
|
|
event_type = type
|
|
one_shot = is_one_shot
|
|
weight = event_weight
|
|
min_weight = min_event_weight
|
|
max_weight = max_event_weight
|
|
src.add_to_queue = add_to_queue
|
|
if(job_weights)
|
|
role_weights = job_weights
|
|
if(excluded_roundtypes)
|
|
excluded_gamemodes = excluded_roundtypes
|
|
|
|
/datum/event_meta/proc/get_weight(var/list/active_with_role)
|
|
if(!enabled)
|
|
return 0
|
|
|
|
if(excluded_gamemodes.len && (ticker.mode in excluded_gamemodes))
|
|
// There's no way it'll be run this round anyways.
|
|
enabled = 0
|
|
return 0
|
|
|
|
var/job_weight = 0
|
|
for(var/role in role_weights)
|
|
if(role in active_with_role)
|
|
job_weight += active_with_role[role] * role_weights[role]
|
|
|
|
var/total_weight = weight + job_weight
|
|
|
|
// Only min/max the weight if the values are non-zero
|
|
if(min_weight && total_weight < min_weight) total_weight = min_weight
|
|
if(max_weight && total_weight > max_weight) total_weight = max_weight
|
|
|
|
return total_weight
|
|
|
|
/datum/event //NOTE: Times are measured in master controller ticks!
|
|
var/startWhen = 0 //When in the lifetime to call start().
|
|
var/announceWhen = 0 //When in the lifetime to call announce().
|
|
var/endWhen = 0 //When in the lifetime the event should end.
|
|
|
|
var/severity = 0 //Severity. Lower means less severe, higher means more severe. Does not have to be supported. Is set on New().
|
|
var/activeFor = 0 //How long the event has existed. You don't need to change this.
|
|
var/isRunning = 1 //If this event is currently running. You should not change this.
|
|
var/startedAt = 0 //When this event started.
|
|
var/endedAt = 0 //When this event ended.
|
|
var/datum/event_meta/event_meta = null
|
|
|
|
var/no_fake = 0
|
|
//If set to 1, this event will not be picked for false announcements
|
|
//This should really only be used for events that have no announcement
|
|
|
|
var/ic_name = null
|
|
//A lore-suitable name that maintains the mystery, used for faking events
|
|
|
|
var/dummy = 0
|
|
//If 1, this event is a dummy instance used for retrieving values, it should not run or add/remove itself from any lists
|
|
|
|
/datum/event/nothing
|
|
no_fake = 1
|
|
|
|
//Called first before processing.
|
|
//Allows you to setup your event, such as randomly
|
|
//setting the startWhen and or announceWhen variables.
|
|
//Only called once.
|
|
/datum/event/proc/setup()
|
|
return
|
|
|
|
//Called when the tick is equal to the startWhen variable.
|
|
//Allows you to start before announcing or vice versa.
|
|
//Only called once.
|
|
/datum/event/proc/start()
|
|
return
|
|
|
|
//Called when the tick is equal to the announceWhen variable.
|
|
//Allows you to announce before starting or vice versa.
|
|
//Only called once.
|
|
/datum/event/proc/announce()
|
|
return
|
|
|
|
//Called on or after the tick counter is equal to startWhen.
|
|
//You can include code related to your event or add your own
|
|
//time stamped events.
|
|
//Called more than once.
|
|
/datum/event/proc/tick()
|
|
return
|
|
|
|
//Called on or after the tick is equal or more than endWhen
|
|
//You can include code related to the event ending.
|
|
//Do not place spawn() in here, instead use tick() to check for
|
|
//the activeFor variable.
|
|
//For example: if(activeFor == myOwnVariable + 30) doStuff()
|
|
//Only called once.
|
|
/datum/event/proc/end()
|
|
return
|
|
|
|
//Returns the latest point of event processing.
|
|
/datum/event/proc/lastProcessAt()
|
|
return max(startWhen, max(announceWhen, endWhen))
|
|
|
|
//Do not override this proc, instead use the appropiate procs.
|
|
//This proc will handle the calls to the appropiate procs.
|
|
/datum/event/proc/process()
|
|
if(activeFor > startWhen && activeFor < endWhen)
|
|
tick()
|
|
|
|
if(activeFor == startWhen)
|
|
isRunning = 1
|
|
start()
|
|
|
|
if(activeFor == announceWhen)
|
|
announce()
|
|
|
|
if(activeFor == endWhen)
|
|
isRunning = 0
|
|
end()
|
|
|
|
// Everything is done, let's clean up.
|
|
if(activeFor >= lastProcessAt())
|
|
kill()
|
|
|
|
activeFor++
|
|
|
|
//Called when start(), announce() and end() has all been called.
|
|
/datum/event/proc/kill()
|
|
// If this event was forcefully killed run end() for individual cleanup
|
|
|
|
if(!dummy && isRunning)
|
|
end()
|
|
|
|
isRunning = 0
|
|
endedAt = world.time
|
|
|
|
if(!dummy)
|
|
event_manager.active_events -= src
|
|
event_manager.event_complete(src)
|
|
|
|
|
|
|
|
/datum/event/New(var/datum/event_meta/EM = null, var/is_dummy = 0)
|
|
dummy = is_dummy
|
|
event_meta = EM
|
|
severity = event_meta.severity
|
|
if(severity < EVENT_LEVEL_MUNDANE) severity = EVENT_LEVEL_MUNDANE
|
|
if(severity > EVENT_LEVEL_MAJOR) severity = EVENT_LEVEL_MAJOR
|
|
|
|
if (dummy)
|
|
return
|
|
// event needs to be responsible for this, as stuff like APLUs currently make their own events for curious reasons
|
|
event_manager.active_events += src
|
|
startedAt = world.time
|
|
|
|
setup()
|
|
..()
|