Files
vgstation13/code/modules/mob/living/carbon/alien/humanoid/queen.dm
sieve32@gmail.com 7bf6788082 -OPTIMIZATION TIME
-Almost every instance of 'for(mob in world)' has been killed. Because GODDAMN was it being run a bunch. Instead, a series of global lists have been made, and they are all handled auto-magically through New()'s, Del()'s, Login()'s, death()'s, etc...

Lists are as follows:
-mob_list : Contains all atom/mobs by ref
-player_list : Like mob_list, but only contains mobs with clients attached
-admin_list : Like player_list, but holds all mobs with clients attached and admin status
-living_mob_list : Contains all mobs that ARE alive, regardless of client status
-dead_mob_list : Contains all mobs that are dead, which comes down to corpses and ghosts
-cable_list : A list containing every obj/structure/cable in existence
Note: There is an object (/obj/item/debuglist) that you can use to check the contents of each of the lists except for cables (Since getting a message saying "a cable," x9001 isn't very helpful)

These lists have been tested as much as I could on my own, and have been mostly implemented. There are still places where they could be used, but for now it's important that the core is working. If this all checks out I would really like to implement it into the MC as well, simply so it doesn't check call Life() on every mob by checking for all the ones in world every damn tick.

Just testing locally I was able to notice improvements with certain aspects, like admin verbs being MUCH more responsive (They checked for every mob in the world every time they were clicked), many sources of needless lag were cut out (Like Adminwho and Who checking every single mob when clicked), and due to the cable_list powernet rebuilding is MUCH more efficient, because instead of checking for every cable in the world every time a powernet was broken (read: A cable was deleted), it runs though the pre-made list, and even with a singulo tearing all the way across the station, the powernet load was VERY small compared to pretty much everything else.

If you want to know how any of this works, check global_lists.dm, there I have it rigorously commented, and it should provide an understanding of what's going on.

Mob related in worlds before this commit: 1262
After: 4
I'm helping


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4179 316c924e-a436-60f5-8080-3fe189b3f50e
2012-07-26 03:04:05 +00:00

91 lines
2.6 KiB
Plaintext

/mob/living/carbon/alien/humanoid/queen/New()
var/datum/reagents/R = new/datum/reagents(100)
reagents = R
R.my_atom = src
//there should only be one queen
for(var/mob/living/carbon/alien/humanoid/queen/Q in living_mob_list)
if(Q == src) continue
if(Q.stat == DEAD) continue
if(Q.client)
name = "alien princess ([rand(1, 999)])" //if this is too cutesy feel free to change it/remove it.
break
real_name = src.name
verbs.Add(/mob/living/carbon/alien/humanoid/proc/corrosive_acid,/mob/living/carbon/alien/humanoid/proc/neurotoxin,/mob/living/carbon/alien/humanoid/proc/resin)
verbs -= /mob/living/carbon/alien/verb/ventcrawl
living_mob_list += src
/mob/living/carbon/alien/humanoid/queen
updatehealth()
if (src.nodamage)
src.health = 250
src.stat = 0
else
//oxyloss is only used for suicide
//toxloss isn't used for aliens, its actually used as alien powers!!
src.health = 250 - src.getOxyLoss() - src.getFireLoss() - src.getBruteLoss()
handle_regular_hud_updates()
..() //-Yvarov
if (src.healths)
if (src.stat != 2)
switch(health)
if(250 to INFINITY)
src.healths.icon_state = "health0"
if(175 to 250)
src.healths.icon_state = "health1"
if(100 to 175)
src.healths.icon_state = "health2"
if(50 to 100)
src.healths.icon_state = "health3"
if(0 to 50)
src.healths.icon_state = "health4"
else
src.healths.icon_state = "health5"
else
src.healths.icon_state = "health6"
handle_environment()
//If there are alien weeds on the ground then heal if needed or give some toxins
if(locate(/obj/effect/alien/weeds) in loc)
if(health >= 250)
adjustToxLoss(20)
else
adjustBruteLoss(-5)
adjustFireLoss(-5)
//Queen verbs
/mob/living/carbon/alien/humanoid/queen/verb/lay_egg()
set name = "Lay Egg (200)"
set desc = "Lay an egg to produce huggers to impregnate prey with."
set category = "Alien"
if(locate(/obj/effect/alien/egg) in get_turf(src))
src << "There's already an egg here."
return
if(powerc(50,1))//Can't plant eggs on spess tiles. That's silly.
adjustToxLoss(-200)
for(var/mob/O in viewers(src, null))
O.show_message(text("\green <B>[src] has laid an egg!</B>"), 1)
new /obj/effect/alien/egg(loc)
return
/mob/living/carbon/alien/humanoid/queen/updatehealth()
if(nodamage)
health = 250
stat = CONSCIOUS
else
//oxyloss is only used for suicide
//toxloss isn't used for aliens, its actually used as alien powers!!
health = 250 - getOxyLoss() - getFireLoss() - getBruteLoss() - getCloneLoss()