Merge pull request #24418 from Xhuis/tome_refactor

Speeds up tome code
This commit is contained in:
Joan Lung
2017-02-25 23:28:20 -05:00
committed by GitHub
2 changed files with 16 additions and 18 deletions
+15 -18
View File
@@ -13,6 +13,14 @@ This file contains the arcane tome files.
throw_range = 5
w_class = WEIGHT_CLASS_SMALL
/obj/item/weapon/tome/New()
..()
if(!LAZYLEN(rune_types))
rune_types = list()
for(var/i_can_do_loops_now_thanks_remie in non_revealed_runes)
var/obj/effect/rune/R = i_can_do_loops_now_thanks_remie
rune_types[initial(R.cultist_name)] = R //Uses the cultist name for displaying purposes
/obj/item/weapon/tome/examine(mob/user)
..()
if(iscultist(user) || isobserver(user))
@@ -167,33 +175,22 @@ This file contains the arcane tome files.
var/chosen_keyword
var/obj/effect/rune/rune_to_scribe
var/entered_rune_name
var/list/possible_runes = list()
var/list/shields = list()
var/area/A = get_area(src)
if(!check_rune_turf(Turf, user))
return
for(var/T in subtypesof(/obj/effect/rune) - /obj/effect/rune/malformed)
var/obj/effect/rune/R = T
if(initial(R.cultist_name))
possible_runes.Add(initial(R.cultist_name)) //This is to allow the menu to let cultists select runes by name rather than by object path. I don't know a better way to do this
if(!possible_runes.len)
return
entered_rune_name = input(user, "Choose a rite to scribe.", "Sigils of Power") as null|anything in possible_runes
entered_rune_name = input(user, "Choose a rite to scribe.", "Sigils of Power") as null|anything in rune_types
if(!src || QDELETED(src) || !Adjacent(user) || user.incapacitated() || !check_rune_turf(Turf, user))
return
for(var/T in typesof(/obj/effect/rune))
var/obj/effect/rune/R = T
if(initial(R.cultist_name) == entered_rune_name)
rune_to_scribe = R
if(initial(R.req_keyword))
var/the_keyword = stripped_input(usr, "Please enter a keyword for the rune.", "Enter Keyword", "")
if(!the_keyword)
return
chosen_keyword = the_keyword
break
rune_to_scribe = rune_types[entered_rune_name]
if(!rune_to_scribe)
return
if(initial(rune_to_scribe.req_keyword))
chosen_keyword = stripped_input(user, "Enter a keyword for the new rune.", "Words of Power")
if(!chosen_keyword)
scribe_rune(user) //Go back a menu!
return
Turf = get_turf(user) //we may have moved. adjust as needed...
A = get_area(src)
if(!src || QDELETED(src) || !Adjacent(user) || user.incapacitated() || !check_rune_turf(Turf, user))
+1
View File
@@ -1,5 +1,6 @@
/var/list/sacrificed = list() //a mixed list of minds and mobs
var/list/non_revealed_runes = (subtypesof(/obj/effect/rune) - /obj/effect/rune/malformed)
var/global/list/rune_types //Every rune that can be drawn by tomes
/*