mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-15 12:43:13 +00:00
- Ports TSA Newmalf code. - Complete overhaul of Malfunction. New modular abilities, 12 of which are in game by default. - Adds AI hardware. AI may have only one piece and it gives unique boost in certain area (turrets strength, secondary power supply, etc.) - Adds hardware drivers - these abilities control AI's hardware such as the APU power supply or self destruct explosives. - Station overtake was changed to "hack all APCs" ability instead. When completed self-destruct is unlocked. Timer for station self destruct increased to 2 minutes. AI may activate/deactivate the self destruct at will. Please bear in mind this is only INITIAL COMMIT. More commits are to follow. Minimal player count is now set to 1 but will be 2 when finished.
70 lines
2.2 KiB
Plaintext
70 lines
2.2 KiB
Plaintext
/datum/malf_research
|
|
var/stored_cpu = 0 // Currently stored amount of CPU time.
|
|
var/last_tick = 0 // Last process() tick.
|
|
var/max_cpu = 0 // Maximal amount of CPU time stored.
|
|
var/cpu_increase_per_tick = 0 // Amount of CPU time generated by tick
|
|
var/list/available_abilities = null // List of available abilities that may be researched.
|
|
var/list/unlocked_abilities = null // List of already unlocked abilities.
|
|
var/mob/living/silicon/ai/owner = null // AI which owns this research datum.
|
|
var/datum/malf_research_ability/focus = null // Currently researched item
|
|
|
|
/datum/malf_research/New()
|
|
setup_abilities()
|
|
last_tick = world.time
|
|
|
|
|
|
// Proc: setup_abilities()
|
|
// Parameters: None
|
|
// Description: Sets up basic abilities for AI Malfunction gamemode.
|
|
/datum/malf_research/proc/setup_abilities()
|
|
available_abilities = list()
|
|
unlocked_abilities = list()
|
|
|
|
available_abilities += new/datum/malf_research_ability/networking/basic_hack()
|
|
available_abilities += new/datum/malf_research_ability/interdiction/recall_shuttle()
|
|
available_abilities += new/datum/malf_research_ability/manipulation/electrical_pulse()
|
|
|
|
|
|
// Proc: finish_research()
|
|
// Parameters: None
|
|
// Description: Finishes currently focused research.
|
|
/datum/malf_research/proc/finish_research()
|
|
if(!focus)
|
|
return
|
|
owner << "<b>Research Completed</b>: [focus.name]"
|
|
owner.verbs.Add(focus.ability)
|
|
available_abilities -= focus
|
|
if(focus.next)
|
|
available_abilities += focus.next
|
|
unlocked_abilities += focus
|
|
focus = null
|
|
|
|
|
|
// Proc: process()
|
|
// Parameters: None
|
|
// Description: Processes CPU gain and research progress based on "realtime" calculation.
|
|
/datum/malf_research/proc/process(var/idle = 0)
|
|
if(idle) // No power or running on APU. Do nothing.
|
|
last_tick = world.time
|
|
return
|
|
var/time_diff = (world.time - last_tick)
|
|
last_tick = world.time
|
|
var/cpu_gained = time_diff * cpu_increase_per_tick
|
|
if(cpu_gained < 0)
|
|
return // This shouldn't happen, but just in case..
|
|
if(max_cpu > stored_cpu)
|
|
var/given = min((max_cpu - stored_cpu), cpu_gained)
|
|
stored_cpu += given
|
|
cpu_gained -= given
|
|
|
|
cpu_gained = max(0, cpu_gained)
|
|
if(focus && (cpu_gained > 0))
|
|
focus.process(cpu_gained)
|
|
if(focus.unlocked)
|
|
finish_research()
|
|
|
|
|
|
|
|
|
|
|