April sync (#360)

* Maps and things no code/icons

* helpers defines globalvars

* Onclick world.dm orphaned_procs

* subsystems

Round vote and shuttle autocall done here too

* datums

* Game folder

* Admin - chatter modules

* clothing - mining

* modular computers - zambies

* client

* mob level 1

* mob stage 2 + simple_animal

* silicons n brains

* mob stage 3 + Alien/Monkey

* human mobs

* icons updated

* some sounds

* emitter y u no commit

* update tgstation.dme

* compile fixes

* travis fixes

Also removes Fast digest mode, because reasons.

* tweaks for travis Mentors are broke again

Also fixes Sizeray guns

* oxygen loss fix for vore code.

* removes unused code

* some code updates

* bulk fixes

* further fixes

* outside things

* whoops.

* Maint bar ported

* GLOBs.
This commit is contained in:
Poojawa
2017-04-13 23:37:00 -05:00
committed by GitHub
parent cdc32c98fa
commit 7e9b96a00f
1322 changed files with 174827 additions and 23888 deletions
+96 -97
View File
@@ -1,39 +1,31 @@
var/datum/controller/subsystem/npcpool/SSnpc
#define PROCESSING_NPCS 0
#define PROCESSING_DELEGATES 1
#define PROCESSING_ASSISTANTS 2
/datum/controller/subsystem/npcpool
SUBSYSTEM_DEF(npcpool)
name = "NPC Pool"
init_order = 17
flags = SS_POST_FIRE_TIMING|SS_NO_INIT|SS_NO_TICK_CHECK
priority = 25
flags = SS_POST_FIRE_TIMING|SS_NO_INIT|SS_BACKGROUND
priority = 20
var/list/canBeUsed = list()
var/list/canBeUsed_non = list()
var/list/needsDelegate = list()
var/list/needsAssistant = list()
var/list/needsHelp_non = list()
var/list/botPool_l = list() //list of all npcs using the pool
var/list/botPool_l_non = list() //list of all non SNPC mobs using the pool
/datum/controller/subsystem/npcpool/proc/insertBot(toInsert)
if(istype(toInsert,/mob/living/carbon/human/interactive))
botPool_l |= toInsert
/datum/controller/subsystem/npcpool/New()
NEW_SS_GLOBAL(SSnpc)
var/list/processing = list()
var/list/currentrun = list()
var/stage
/datum/controller/subsystem/npcpool/stat_entry()
..("T:[botPool_l.len + botPool_l_non.len]|D:[needsDelegate.len]|A:[needsAssistant.len + needsHelp_non.len]|U:[canBeUsed.len + canBeUsed_non.len]")
..("NPCS:[processing.len]|D:[needsDelegate.len]|A:[needsAssistant.len]|U:[canBeUsed.len]")
/datum/controller/subsystem/npcpool/proc/stop_processing(mob/living/carbon/human/interactive/I)
processing -= I
currentrun -= I
needsDelegate -= I
canBeUsed -= I
needsAssistant -= I
/datum/controller/subsystem/npcpool/proc/cleanNull()
//cleanup nulled bots
listclearnulls(botPool_l)
listclearnulls(needsDelegate)
listclearnulls(canBeUsed)
listclearnulls(needsAssistant)
/datum/controller/subsystem/npcpool/fire()
/datum/controller/subsystem/npcpool/fire(resumed = FALSE)
//bot delegation and coordination systems
//General checklist/Tasks for delegating a task or coordinating it (for SNPCs)
// 1. Bot proximity to task target: if too far, delegate, if close, coordinate
@@ -41,87 +33,94 @@ var/datum/controller/subsystem/npcpool/SSnpc
// 3. Process delegation: if a bot (or bots) has been delegated, assign them to the task.
// 4. Process coordination: if a bot(or bots) has been asked to coordinate, assign them to help.
// 5. Do all assignments: goes through the delegated/coordianted bots and assigns the right variables/tasks to them.
var/npcCount = 1
cleanNull()
if (!resumed)
src.currentrun = processing.Copy()
stage = PROCESSING_NPCS
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
var/list/canBeUsed = src.canBeUsed
//SNPC handling
for(var/mob/living/carbon/human/interactive/check in botPool_l)
if(!check)
botPool_l.Cut(npcCount,npcCount+1)
continue
var/checkInRange = view(MAX_RANGE_FIND,check)
if(!(locate(check.TARGET) in checkInRange))
needsDelegate |= check
if(stage == PROCESSING_NPCS)
while(currentrun.len)
var/mob/living/carbon/human/interactive/thing = currentrun[currentrun.len]
--currentrun.len
else if(check.IsDeadOrIncap(FALSE))
needsDelegate |= check
thing.InteractiveProcess()
else if(check.doing & FIGHTING)
needsAssistant |= check
var/checkInRange = view(MAX_RANGE_FIND,thing)
if(thing.IsDeadOrIncap(FALSE) || !(locate(thing.TARGET) in checkInRange))
needsDelegate += thing
else if(thing.doing & FIGHTING)
needsAssistant += thing
else
canBeUsed += thing
else
canBeUsed |= check
npcCount++
if (MC_TICK_CHECK)
return
stage = PROCESSING_DELEGATES
currentrun = needsDelegate //localcache
src.currentrun = currentrun
if(needsDelegate.len)
if(stage == PROCESSING_DELEGATES)
while(currentrun.len && canBeUsed.len)
var/mob/living/carbon/human/interactive/check = currentrun[currentrun.len]
var/mob/living/carbon/human/interactive/candidate = canBeUsed[canBeUsed.len]
--currentrun.len
needsDelegate -= pick(needsDelegate) // cheapo way to make sure stuff doesn't pingpong around in the pool forever. delegation runs seperately to each loop so it will work much smoother
var/helpProb = 0
var/list/chfac = check.faction
var/list/canfac = candidate.faction
var/facCount = LAZYLEN(chfac) * LAZYLEN(canfac)
npcCount = 1 //reset the count
for(var/mob/living/carbon/human/interactive/check in needsDelegate)
if(!check)
needsDelegate.Cut(npcCount,npcCount+1)
continue
if(canBeUsed.len)
var/mob/living/carbon/human/interactive/candidate = pick(canBeUsed)
var/facCount = 0
var/helpProb = 0
for(var/C in check.faction)
for(var/D in candidate.faction)
if(D == C)
helpProb = min(100,helpProb + 25)
facCount++
if(facCount == 1 && helpProb > 0)
helpProb = 100
if(prob(helpProb))
if(candidate.takeDelegate(check))
needsDelegate -= check
canBeUsed -= candidate
candidate.eye_color = "red"
candidate.update_icons()
npcCount++
for(var/C in chfac)
if(C in canfac)
helpProb = min(100,helpProb + 25)
if(helpProb >= 100)
break
if(needsAssistant.len)
if(facCount == 1 && helpProb)
helpProb = 100
needsAssistant -= pick(needsAssistant)
if(prob(helpProb) && candidate.takeDelegate(check))
--canBeUsed.len
candidate.eye_color = "red"
candidate.update_icons()
npcCount = 1 //reset the count
for(var/mob/living/carbon/human/interactive/check in needsAssistant)
if(!check)
needsAssistant.Cut(npcCount,npcCount+1)
continue
if(canBeUsed.len)
var/mob/living/carbon/human/interactive/candidate = pick(canBeUsed)
var/facCount = 0
var/helpProb = 0
for(var/C in check.faction)
for(var/D in candidate.faction)
if(D == C)
helpProb = min(100,helpProb + 25)
facCount++
if(facCount == 1 && helpProb > 0)
helpProb = 100
if(prob(helpProb))
if(candidate.takeDelegate(check,FALSE))
needsAssistant -= check
canBeUsed -= candidate
candidate.eye_color = "yellow"
candidate.update_icons()
npcCount++
if(MC_TICK_CHECK)
return
stage = PROCESSING_ASSISTANTS
currentrun = needsAssistant //localcache
src.currentrun = currentrun
//no need for the stage check
while(currentrun.len && canBeUsed.len)
var/mob/living/carbon/human/interactive/check = currentrun[currentrun.len]
var/mob/living/carbon/human/interactive/candidate = canBeUsed[canBeUsed.len]
--currentrun.len
var/helpProb = 0
var/list/chfac = check.faction
var/list/canfac = candidate.faction
var/facCount = LAZYLEN(chfac) * LAZYLEN(canfac)
for(var/C in chfac)
if(C in canfac)
helpProb = min(100,helpProb + 25)
if(helpProb >= 100)
break
if(facCount == 1 && helpProb)
helpProb = 100
if(prob(helpProb) && candidate.takeDelegate(check,FALSE))
--canBeUsed.len
candidate.eye_color = "yellow"
candidate.update_icons()
if(!currentrun.len || MC_TICK_CHECK) //don't change SS state if it isn't necessary
return
/datum/controller/subsystem/npcpool/Recover()
if (istype(SSnpc.botPool_l))
botPool_l = SSnpc.botPool_l
if (istype(SSnpc.botPool_l_non))
botPool_l_non = SSnpc.botPool_l_non
processing = SSnpcpool.processing