Files
Aurora.3/code/modules/events/brand_intelligence.dm
skull132 0fc67f2cb9 Remove a whole bunch of in world loops and rework machinery global lists (#3053)
Removes a whole bunch of in world loops.
Reworks SSmachinery to hold two lists: all_machines and processing_machines. all_machines contains all machines 5ever. All of them. Literally. Forever. And ever. processing_machines only contains machines that process with the SSmachinery controller.

I checked most types at runtime on the live server to see whether they're in processing_machines or in all_machines, and did debug to ensure that most machinery ends up and stays in all_machines.

Includes a basic UT to make sure all mapped in machinery types remain within the all_machines list post-init.
2017-07-16 20:32:33 +03:00

56 lines
2.1 KiB
Plaintext

/datum/event/brand_intelligence
announceWhen = 21
endWhen = 1000 //Ends when all vending machines are subverted anyway.
var/list/obj/machinery/vending/vendingMachines = list()
var/list/obj/machinery/vending/infectedVendingMachines = list()
var/obj/machinery/vending/originMachine
/datum/event/brand_intelligence/announce()
command_announcement.Announce("Rampant brand intelligence has been detected aboard [station_name()], please stand-by.", "Machine Learning Alert", new_sound = 'sound/AI/brandintelligence.ogg')
/datum/event/brand_intelligence/start()
for(var/obj/machinery/vending/V in SSmachinery.processing_machines)
if(isNotStationLevel(V.z)) continue
vendingMachines.Add(V)
if(!vendingMachines.len)
kill()
return
originMachine = pick(vendingMachines)
vendingMachines.Remove(originMachine)
originMachine.shut_up = 0
originMachine.shoot_inventory = 1
/datum/event/brand_intelligence/tick()
if(!vendingMachines.len || !originMachine || originMachine.shut_up) //if every machine is infected, or if the original vending machine is missing or has it's voice switch flipped
end()
kill()
return
if(IsMultiple(activeFor, 5))
if(prob(15))
var/obj/machinery/vending/infectedMachine = pick(vendingMachines)
vendingMachines.Remove(infectedMachine)
infectedVendingMachines.Add(infectedMachine)
infectedMachine.shut_up = 0
infectedMachine.shoot_inventory = 1
if(IsMultiple(activeFor, 12))
originMachine.speak(pick("Try our aggressive new marketing strategies!", \
"You should buy products to feed your lifestyle obsession!", \
"Consume!", \
"Your money can buy happiness!", \
"Engage direct marketing!", \
"Advertising is legalized lying! But don't let that put you off our great deals!", \
"You don't want to buy anything? Yeah, well I didn't want to buy your mom either."))
/datum/event/brand_intelligence/end()
for(var/obj/machinery/vending/infectedMachine in infectedVendingMachines)
infectedMachine.shut_up = 1
infectedMachine.shoot_inventory = 0