Skip to content

Commit

Permalink
allinone (#13512)
Browse files Browse the repository at this point in the history
  • Loading branch information
KIBORG04 committed Sep 24, 2024
1 parent 67b3e56 commit fb36112
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 100 deletions.
159 changes: 68 additions & 91 deletions code/game/gamemodes/modes_gameplays/cult/structures/tech_table.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#define ASPECT_CATEGORY "Аспекты"
#define UNIQ_CATEGORY "Уникальные технологии"

/obj/structure/cult/tech_table
name = "scientific altar"
desc = "A bloodstained altar dedicated to Nar-Sie."
Expand All @@ -6,20 +9,19 @@
light_power = 2
light_range = 3

// /datum/aspect = image
// Maybe be wrapped too in /datum/building_agent
var/static/list/aspect_images = list()
// /datum/building_agent = image
var/static/list/uniq_images = list()
// string = image
// string = image()
var/static/list/tech_images = list()
// string = /datum/religion_tech
var/static/list/tech_by_id = list()
// string = image()
var/static/list/category_images = list()

var/researching = FALSE
var/research_time = 15 MINUTES
var/end_research_time

var/current_research = "Ничего"
var/datum/building_agent/tech/choosed_tech
var/datum/religion_tech/chosen_tech
var/tech_timer

var/list/pylon_around
Expand All @@ -30,9 +32,9 @@
pylon_around = null
if(tech_timer)
deltimer(tech_timer)
if(choosed_tech)
choosed_tech.researching = FALSE
choosed_tech = null
if(chosen_tech)
chosen_tech.researching = FALSE
chosen_tech = null
return ..()

/obj/structure/cult/tech_table/examine(mob/user, distance)
Expand Down Expand Up @@ -70,106 +72,78 @@
to_chat(user, "<span class='warning'>По решению Возвышенного последователям запрещено самим исследовать!</span>")
return

if(!aspect_images.len)
gen_aspect_images()
if(uniq_images.len < religion.available_techs.len)
if(tech_images.len < religion.available_techs.len)
gen_tech_images(user)
if(!category_images.len)
gen_category_images()

var/choice = show_radial_menu(user, src, category_images, tooltips = TRUE, require_near = TRUE)

switch(choice)
if("Аспекты")
choose_aspect(user)
if("Уникальные технологии")
choose_uniq_tech(user)

/obj/structure/cult/tech_table/proc/choose_uniq_tech(mob/user)
for(var/datum/building_agent/B in uniq_images)
B.name = "[initial(B.name)] [B.get_costs()]"

choosed_tech = show_radial_menu(user, src, uniq_images, tooltips = TRUE, require_near = TRUE)
if(!choosed_tech || choosed_tech.researching)
var/list/tech = list()
var/list/user_tech_images = list()
for(var/tech_id in tech_by_id)
var/datum/religion_tech/RT = tech_by_id[tech_id]
if(istype(RT, /datum/religion_tech/upgrade_aspect))
var/datum/religion_tech/upgrade_aspect/aspect = RT
aspect.calculate_costs(religion)

var/tech_with_cost = "[RT.info.name] [RT.info.get_costs()]"
if(choice == ASPECT_CATEGORY && istype(RT, /datum/religion_tech/upgrade_aspect))
tech[tech_with_cost] = tech_id
user_tech_images[tech_with_cost] = tech_images[tech_id]
else if(choice == UNIQ_CATEGORY && istype(RT, /datum/religion_tech/cult))
tech[tech_with_cost] = tech_id
user_tech_images[tech_with_cost] = tech_images[tech_id]
choose_tech(user, tech, user_tech_images)

// list/techs is (tech_name_with_cost = tech_id)
// list/user_techs_images is (tech_name_with_cost = tech_images)
/obj/structure/cult/tech_table/proc/choose_tech(mob/user, list/techs, list/user_techs_images)
var/tech_name_with_cost = show_radial_menu(user, src, user_techs_images, tooltips = TRUE, require_near = TRUE)
chosen_tech = tech_by_id[techs[tech_name_with_cost]]
if(!chosen_tech)
return
if(!religion.check_costs(choosed_tech.favor_cost, choosed_tech.piety_cost, user))
if(chosen_tech.researching)
to_chat(user, "<span class='warning'>Уже изучается.</span>")
return
if(!religion.check_costs(chosen_tech.info.favor_cost, chosen_tech.info.piety_cost, user))
return

religion.adjust_favor(-choosed_tech.favor_cost)
religion.adjust_piety(-choosed_tech.piety_cost)

to_chat(user, "<span class='notice'>Вы начали изучение [initial(choosed_tech.name)].</span>")

current_research = initial(choosed_tech.name)
choosed_tech.researching = TRUE
start_activity(CALLBACK(src, PROC_REF(research_tech), choosed_tech))

/obj/structure/cult/tech_table/proc/research_tech(datum/building_agent/tech/choosed_tech)
religion.add_tech(choosed_tech.building_type)

uniq_images -= choosed_tech
religion.available_techs -= choosed_tech
qdel(uniq_images[choosed_tech])

end_activity()

/obj/structure/cult/tech_table/proc/choose_aspect(mob/user)
// Generates a name with the power of an aspect and upgrade cost
for(var/datum/aspect/A in aspect_images)
var/datum/aspect/in_religion = religion.aspects[initial(A.name)]
A.name = "[initial(A.name)], сила: [in_religion ? in_religion.power : "0"], piety: [get_upgrade_cost(in_religion)]"
religion.adjust_favor(-chosen_tech.info.favor_cost)
religion.adjust_piety(-chosen_tech.info.piety_cost)

var/datum/aspect/choosed_aspect = show_radial_menu(user, src, aspect_images, tooltips = TRUE, require_near = TRUE)
if(!choosed_aspect)
return
var/datum/aspect/in_religion = religion.aspects[initial(choosed_aspect.name)]
if(!religion.check_costs(null, get_upgrade_cost(in_religion), user))
return
to_chat(user, "<span class='notice'>Вы начали изучение [chosen_tech.info.name].</span>")

religion.adjust_piety(-get_upgrade_cost(in_religion))
current_research = initial(chosen_tech.info.name)
chosen_tech.researching = TRUE
start_activity(CALLBACK(src, PROC_REF(research_tech), chosen_tech))

to_chat(user, "<span class='notice'>Вы начали [in_religion ? "улучшение" : "изучение"] [initial(choosed_aspect.name)].</span>")
current_research = "[in_religion ? "улучшение" : "изучение"] [initial(choosed_aspect.name)]"
start_activity(CALLBACK(src, PROC_REF(upgrade_aspect), choosed_aspect))
/obj/structure/cult/tech_table/proc/research_tech(datum/religion_tech/researched)
religion.add_tech(researched)

/obj/structure/cult/tech_table/proc/upgrade_aspect(datum/aspect/aspect_to_upgrade)
if(initial(aspect_to_upgrade.name) in religion)
var/datum/aspect/A = religion.aspects[initial(aspect_to_upgrade.name)]
A.power += 1
else
religion.add_aspects(list(aspect_to_upgrade.type = 1))
tech_by_id -= researched.id
religion.available_techs -= researched
qdel(tech_images[researched.id])
tech_images -= researched.id

end_activity()

/obj/structure/cult/tech_table/proc/get_upgrade_cost(datum/aspect/in_religion)
if(!in_religion)
var/all_aspects = 0
for(var/aspect_name in cult_religion.aspects)
all_aspects++
var/cost = max(100, 50 + 25 * all_aspects) //We don't count 6 initial aspects and scale for static 150, +50 piety for each new aspect
return cost
return in_religion.power * 50

/obj/structure/cult/tech_table/proc/gen_category_images()
category_images = list(
"Аспекты" = aspect_images[pick(aspect_images)],
"Уникальные технологии" = uniq_images[pick(uniq_images)],
)
for(var/name in tech_images)
var/is_aspect_tech = istype(tech_by_id[name], /datum/religion_tech/upgrade_aspect)
if(!category_images[ASPECT_CATEGORY] && is_aspect_tech)
category_images[ASPECT_CATEGORY] = tech_images[name]
else if(!category_images[UNIQ_CATEGORY] && !is_aspect_tech)
category_images[UNIQ_CATEGORY] = tech_images[name]
if(category_images[UNIQ_CATEGORY] && category_images[ASPECT_CATEGORY])
break

/obj/structure/cult/tech_table/proc/gen_tech_images(mob/user)
uniq_images = list()
for(var/datum/building_agent/tech/BA in religion.available_techs)
uniq_images[BA] = image(icon = BA.icon, icon_state = BA.icon_state)

/obj/structure/cult/tech_table/proc/gen_aspect_images()
var/list/aspects = subtypesof(/datum/aspect)
aspect_images = list()
for(var/type in aspects)
var/datum/aspect/A = new type
if(!A.name)
qdel(A)
continue
aspect_images[A] = image(icon = A.icon, icon_state = A.icon_state)
tech_images = list()
tech_by_id = list()
for(var/datum/religion_tech/T in religion.available_techs)
tech_images[T.id] = image(icon = T.info.icon, icon_state = T.info.icon_state)
tech_by_id[T.id] = T

/obj/structure/cult/tech_table/proc/start_activity(datum/callback/end_activity)
LAZYINITLIST(pylon_around)
Expand All @@ -195,3 +169,6 @@

current_research = "Ничего"
can_unwrench = TRUE

#undef ASPECT_CATEGORY
#undef UNIQ_CATEGORY
9 changes: 7 additions & 2 deletions code/modules/religion/building_agent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Maybe rename
/datum/building_agent
var/name
var/atom/building_type
var/datum/building_type
var/favor_cost = 0
var/deconstruct_favor_cost = 0
var/piety_cost = 0
Expand Down Expand Up @@ -139,9 +139,14 @@
/datum/building_agent/tech
var/icon
var/icon_state
var/researching = FALSE

/datum/building_agent/tech/aspect
// base costs
favor_cost = 0
piety_cost = 100

/datum/building_agent/tech/cult

/datum/building_agent/tech/cult/memorize_rune
name = "Запомнить Руну"
icon = 'icons/obj/rune.dmi'
Expand Down
12 changes: 7 additions & 5 deletions code/modules/religion/religion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
// Type of initial runes agent for which available_runes will be generated
var/rune_agent_type
// All tech that religion can research
var/list/datum/building_agent/available_techs = list()
var/list/datum/religion_tech/available_techs = list()
// Type of initial tech agent for which available_runes will be generated
var/tech_agent_type

Expand Down Expand Up @@ -611,6 +611,9 @@
/datum/religion/proc/gen_agent_lists()
init_subtypes(build_agent_type, available_buildings)
init_subtypes(rune_agent_type, available_runes)
get_tech_agent_lists()

/datum/religion/proc/get_tech_agent_lists()
init_subtypes(tech_agent_type, available_techs)

/datum/religion/proc/on_holy_reagent_created(datum/reagent/R)
Expand Down Expand Up @@ -663,10 +666,9 @@
link = FOLLOW_LINK(M, source)
to_chat(M, "<font size='[font_size]'><span class='[style_text]'>[link][format_name][message]</span></font>")

/datum/religion/proc/add_tech(tech_type)
var/datum/religion_tech/T = new tech_type
T.on_add(src)
all_techs[T.id] = T
/datum/religion/proc/add_tech(datum/religion_tech/tech)
tech.on_add(src)
all_techs[tech.id] = tech

/datum/religion/proc/get_tech(tech_id)
return all_techs[tech_id]
Expand Down
21 changes: 20 additions & 1 deletion code/modules/religion/religion_types/cult.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
area_type = /area/custom/cult
build_agent_type = /datum/building_agent/structure/cult
rune_agent_type = /datum/building_agent/rune/cult
tech_agent_type = /datum/building_agent/tech/cult
tech_agent_type = /datum/religion_tech/cult
wall_types = list(/turf/simulated/wall/cult, /turf/simulated/wall/cult/runed, /turf/simulated/wall/cult/runed/anim)
floor_types = list(/turf/simulated/floor/engine/cult, /turf/simulated/floor/engine/cult/lava)
door_types = list(/obj/structure/mineral_door/cult)
Expand Down Expand Up @@ -113,6 +113,25 @@
/datum/religion/cult/setup_religions()
global.cult_religion = src

/datum/religion/cult/get_tech_agent_lists()
..()
var/list/aspect_types = subtypesof(/datum/aspect)
for(var/type in aspect_types)
var/datum/aspect/A = new type
if(!A.name)
qdel(A)
continue
var/datum/religion_tech/upgrade_aspect/tech = new
tech.id = A.name
tech.aspect_type = type
tech.info = new /datum/building_agent/tech/aspect
tech.info.name = A.name
tech.info.icon = A.icon
tech.info.icon_state = A.icon_state
tech.calculate_costs(src)
available_techs += tech
qdel(A)

/datum/religion/cult/process()
adjust_favor(passive_favor_gain)
if(next_anomaly < world.time)
Expand Down
40 changes: 39 additions & 1 deletion code/modules/religion/tech.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// A small /datum for applying some technology to religion
/datum/religion_tech
var/id
var/researching = FALSE
var/datum/building_agent/tech/info

/datum/religion_tech/New()
if(info)
info = new info

/datum/religion_tech/proc/on_add(datum/religion/R)
return

/datum/religion_tech/cult
/datum/religion_tech/cult/memorizing_rune
id = RTECH_MEMORIZE_RUNE
info = /datum/building_agent/tech/cult/memorize_rune

/datum/religion_tech/cult/memorizing_rune/proc/give_spell(datum/religion/R, mob/M, holy_role)
var/obj/effect/proc_holder/spell/no_target/memorize_rune/MR = M.GetSpell(/obj/effect/proc_holder/spell/no_target/memorize_rune)
Expand All @@ -32,22 +38,54 @@

/datum/religion_tech/cult/reusable_runes
id = RTECH_REUSABLE_RUNE
info = /datum/building_agent/tech/cult/reusable_runes

/datum/religion_tech/cult/build_everywhere
id = RTECH_BUILD_EVERYWHERE
info = /datum/building_agent/tech/cult/build_everywhere

/datum/religion_tech/cult/more_runes
id = RTECH_MORE_RUNES
info = /datum/building_agent/tech/cult/more_runes

/datum/religion_tech/cult/more_runes/on_add(datum/religion/cult/R)
R.max_runes_on_mob += 5

/datum/religion_tech/cult/mirror_shield
id = RTECH_MIRROR_SHIELD
info = /datum/building_agent/tech/cult/mirror_shield

/datum/religion_tech/cult/improved_pylons
id = RTECH_IMPROVED_PYLONS
info = /datum/building_agent/tech/cult/improved_pylons

/datum/religion_tech/cult/improved_pylons/on_add(datum/religion/cult/R)
for(var/obj/structure/cult/pylon/P as anything in global.pylons)
P.init_healing()

/datum/religion_tech/upgrade_aspect
var/datum/aspect/aspect_type

/datum/religion_tech/upgrade_aspect/on_add(datum/religion/R)
if(aspect_type::name in R.aspects)
var/datum/aspect/A = R.aspects[aspect_type::name]
A.power += 1
else
R.add_aspects(list(aspect_type = 1))

var/datum/religion_tech/upgrade_aspect/tech = new
tech.id = id + "+"
tech.aspect_type = aspect_type
tech.info = new /datum/building_agent/tech/aspect
tech.info.name = info.name
tech.info.icon = info.icon
tech.info.icon_state = info.icon_state
tech.calculate_costs(R)
R.available_techs += tech

/datum/religion_tech/upgrade_aspect/proc/calculate_costs(datum/religion/R)
if(aspect_type::name in R.aspects)
var/datum/aspect/A = R.aspects[aspect_type::name]
info.piety_cost = A.power * 50
else
info.piety_cost = max(100, 50 + 25 * R.aspects.len) //We don't count 6 initial aspects and scale for static 150, +50 piety for each new aspect

0 comments on commit fb36112

Please sign in to comment.