mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 11:05:03 +01:00
Convert wizard contract to TGUI (#15083)
* Convert Wizard Apprentice contract to TGUI * Addresses concerns * Formatting fix and redundant comment removal * Update code and remove unused variable * Rebuild TGUI
This commit is contained in:
committed by
GitHub
parent
cfde082a10
commit
72dff99c99
@@ -8,107 +8,99 @@
|
||||
throw_speed = 1
|
||||
throw_range = 5
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
var/used = 0
|
||||
var/used = FALSE
|
||||
|
||||
/obj/item/contract/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.inventory_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "WizardApprenticeContract", name, 400, 600, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/item/contract/attack_self(mob/user as mob)
|
||||
user.set_machine(src)
|
||||
var/dat
|
||||
if(used)
|
||||
dat = "<B>You have already summoned your apprentice.</B><BR>"
|
||||
else
|
||||
dat = "<B>Contract of Apprenticeship:</B><BR>"
|
||||
dat += "<I>Using this contract, you may summon an apprentice to aid you on your mission.</I><BR>"
|
||||
dat += "<I>If you are unable to establish contact with your apprentice, you can feed the contract back to the spellbook to refund your points.</I><BR>"
|
||||
dat += "<B>Which school of magic is your apprentice studying?:</B><BR>"
|
||||
dat += "<A href='byond://?src=[UID()];school=destruction'>Destruction</A><BR>"
|
||||
dat += "<I>Your apprentice is skilled in offensive magic. They know Magic Missile and Fireball.</I><BR>"
|
||||
dat += "<A href='byond://?src=[UID()];school=bluespace'>Bluespace Manipulation</A><BR>"
|
||||
dat += "<I>Your apprentice is able to defy physics, melting through solid objects and travelling great distances in the blink of an eye. They know Teleport and Ethereal Jaunt.</I><BR>"
|
||||
dat += "<A href='byond://?src=[UID()];school=healing'>Healing</A><BR>"
|
||||
dat += "<I>Your apprentice is training to cast spells that will aid your survival. They know Forcewall and Charge and come with a Staff of Healing.</I><BR>"
|
||||
dat += "<A href='byond://?src=[UID()];school=robeless'>Robeless</A><BR>"
|
||||
dat += "<I>Your apprentice is training to cast spells without their robes. They know Knock and Mindswap.</I><BR>"
|
||||
user << browse(dat, "window=radio")
|
||||
onclose(user, "radio")
|
||||
return
|
||||
/obj/item/contract/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["used"] = used
|
||||
return data
|
||||
|
||||
/obj/item/contract/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
/obj/item/contract/Topic(href, href_list)
|
||||
..()
|
||||
var/mob/living/carbon/human/H = usr
|
||||
|
||||
if(H.stat || H.restrained())
|
||||
if(used)
|
||||
return
|
||||
if(!istype(H, /mob/living/carbon/human))
|
||||
return 1
|
||||
|
||||
if(loc == H || (in_range(src, H) && istype(loc, /turf)))
|
||||
H.set_machine(src)
|
||||
if(href_list["school"])
|
||||
if(used)
|
||||
to_chat(H, "You already used this contract!")
|
||||
return
|
||||
used = 1
|
||||
var/image/source = image('icons/obj/cardboard_cutout.dmi', "cutout_wizard")
|
||||
var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as the wizard apprentice of [H.real_name]?", ROLE_WIZARD, TRUE, source = source)
|
||||
if(candidates.len)
|
||||
var/mob/C = pick(candidates)
|
||||
new /obj/effect/particle_effect/smoke(H.loc)
|
||||
var/mob/living/carbon/human/M = new/mob/living/carbon/human(H.loc)
|
||||
M.key = C.key
|
||||
to_chat(M, "<B>You are [H.real_name]'s apprentice! You are bound by magic contract to follow [H.p_their()] orders and help [H.p_them()] in accomplishing their goals.")
|
||||
switch(href_list["school"])
|
||||
if("destruction")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/projectile/magic_missile(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/click/fireball(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned powerful, destructive spells. You are able to cast magic missile and fireball.")
|
||||
if("bluespace")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/area_teleport/teleport(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/ethereal_jaunt(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned reality bending mobility spells. You are able to cast teleport and ethereal jaunt.")
|
||||
if("healing")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/charge(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/forcewall(null))
|
||||
M.equip_to_slot_or_del(new /obj/item/gun/magic/staff/healing(M), slot_r_hand)
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned livesaving survival spells. You are able to cast charge and forcewall.")
|
||||
if("robeless")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/knock(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/click/mind_transfer(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned stealthy, robeless spells. You are able to cast knock and mindswap.")
|
||||
used = TRUE
|
||||
|
||||
M.equip_to_slot_or_del(new /obj/item/radio/headset(M), slot_l_ear)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/under/color/lightpurple(M), slot_w_uniform)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/shoes/sandal(M), slot_shoes)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/suit/wizrobe(M), slot_wear_suit)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/head/wizard(M), slot_head)
|
||||
M.equip_to_slot_or_del(new /obj/item/storage/backpack(M), slot_back)
|
||||
M.equip_to_slot_or_del(new /obj/item/storage/box(M), slot_in_backpack)
|
||||
M.equip_to_slot_or_del(new /obj/item/teleportation_scroll/apprentice(M), slot_r_store)
|
||||
var/wizard_name_first = pick(GLOB.wizard_first)
|
||||
var/wizard_name_second = pick(GLOB.wizard_second)
|
||||
var/randomname = "[wizard_name_first] [wizard_name_second]"
|
||||
var/newname = sanitize(copytext(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN))
|
||||
var/image/source = image('icons/obj/cardboard_cutout.dmi', "cutout_wizard")
|
||||
var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as the wizard apprentice of [H.real_name]?", ROLE_WIZARD, TRUE, source = source)
|
||||
|
||||
if(!newname)
|
||||
newname = randomname
|
||||
M.mind.name = newname
|
||||
M.real_name = newname
|
||||
M.name = newname
|
||||
var/datum/objective/protect/new_objective = new /datum/objective/protect
|
||||
new_objective.owner = M:mind
|
||||
new_objective:target = H:mind
|
||||
new_objective.explanation_text = "Protect [H.real_name], the wizard."
|
||||
M.mind.objectives += new_objective
|
||||
SSticker.mode.apprentices += M.mind
|
||||
M.mind.special_role = SPECIAL_ROLE_WIZARD_APPRENTICE
|
||||
SSticker.mode.update_wiz_icons_added(M.mind)
|
||||
M.faction = list("wizard")
|
||||
else
|
||||
used = 0
|
||||
to_chat(H, "Unable to reach your apprentice! You can either attack the spellbook with the contract to refund your points, or wait and try again later.")
|
||||
return
|
||||
if(length(candidates))
|
||||
var/mob/C = pick(candidates)
|
||||
new /obj/effect/particle_effect/smoke(H.loc)
|
||||
var/mob/living/carbon/human/M = new/mob/living/carbon/human(H.loc)
|
||||
M.key = C.key
|
||||
to_chat(M, "<B>You are the [H.real_name]'s apprentice! You are bound by magic contract to follow [H.p_their()] orders and help [H.p_them()] in accomplishing their goals.")
|
||||
switch(action)
|
||||
if("destruction")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/projectile/magic_missile(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/click/fireball(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned powerful, destructive spells. You are able to cast magic missile and fireball.")
|
||||
if("bluespace")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/area_teleport/teleport(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/ethereal_jaunt(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned reality bending mobility spells. You are able to cast teleport and ethereal jaunt.")
|
||||
if("healing")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/charge(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/forcewall(null))
|
||||
M.equip_to_slot_or_del(new /obj/item/gun/magic/staff/healing(M), slot_r_hand)
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned livesaving survival spells. You are able to cast charge and forcewall.")
|
||||
if("robeless")
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/knock(null))
|
||||
M.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/click/mind_transfer(null))
|
||||
to_chat(M, "<B>Your service has not gone unrewarded, however. Studying under [H.real_name], you have learned stealthy, robeless spells. You are able to cast knock and mindswap.")
|
||||
|
||||
M.equip_to_slot_or_del(new /obj/item/radio/headset(M), slot_l_ear)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/under/color/lightpurple(M), slot_w_uniform)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/shoes/sandal(M), slot_shoes)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/suit/wizrobe(M), slot_wear_suit)
|
||||
M.equip_to_slot_or_del(new /obj/item/clothing/head/wizard(M), slot_head)
|
||||
M.equip_to_slot_or_del(new /obj/item/storage/backpack(M), slot_back)
|
||||
M.equip_to_slot_or_del(new /obj/item/storage/box(M), slot_in_backpack)
|
||||
M.equip_to_slot_or_del(new /obj/item/teleportation_scroll/apprentice(M), slot_r_store)
|
||||
var/wizard_name_first = pick(GLOB.wizard_first)
|
||||
var/wizard_name_second = pick(GLOB.wizard_second)
|
||||
var/randomname = "[wizard_name_first] [wizard_name_second]"
|
||||
var/newname = sanitize(copytext(input(M, "You are the wizard's apprentice. Would you like to change your name to something else?", "Name change", randomname) as null|text,1,MAX_NAME_LEN))
|
||||
|
||||
if(!newname)
|
||||
newname = randomname
|
||||
M.mind.name = newname
|
||||
M.real_name = newname
|
||||
M.name = newname
|
||||
var/datum/objective/protect/new_objective = new /datum/objective/protect
|
||||
new_objective.owner = M.mind
|
||||
new_objective.target = H.mind
|
||||
new_objective.explanation_text = "Protect [H.real_name], the wizard."
|
||||
M.mind.objectives += new_objective
|
||||
SSticker.mode.apprentices += M.mind
|
||||
M.mind.special_role = SPECIAL_ROLE_WIZARD_APPRENTICE
|
||||
SSticker.mode.update_wiz_icons_added(M.mind)
|
||||
M.faction = list("wizard")
|
||||
SStgui.close_uis(src)
|
||||
else
|
||||
used = FALSE
|
||||
to_chat(H, "<span class='warning'>Unable to reach your apprentice! You can either attack the spellbook with the contract to refund your points, or wait and try again later.</span>")
|
||||
|
||||
/obj/item/contract/attack_self(mob/user as mob)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(used)
|
||||
to_chat(user, "<span class='warning'> You've already summoned an apprentice or you are in process of summoning one. </span>")
|
||||
return
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
///////////////////////////Veil Render//////////////////////
|
||||
|
||||
@@ -341,7 +333,7 @@ GLOBAL_LIST_EMPTY(multiverse)
|
||||
|
||||
var/image/source = image('icons/obj/cardboard_cutout.dmi', "cutout_wizard")
|
||||
var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as the wizard apprentice of [user.real_name]?", ROLE_WIZARD, TRUE, 10 SECONDS, source = source)
|
||||
if(candidates.len)
|
||||
if(length(candidates))
|
||||
var/mob/C = pick(candidates)
|
||||
spawn_copy(C.client, get_turf(user.loc), user)
|
||||
to_chat(user, "<span class='warning'><B>The sword flashes, and you find yourself face to face with...you!</B></span>")
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, Box, LabeledList, Section } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
export const WizardApprenticeContract = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
used,
|
||||
} = data;
|
||||
return (
|
||||
<Window resizable>
|
||||
<Window.Content scrollable>
|
||||
<Section title="Contract of Apprenticeship">
|
||||
Using this contract, you may summon an apprentice to aid you on your mission.
|
||||
<p>If you are unable to establish contact with your apprentice, you can feed the contract back to the spellbook to refund your points.</p>
|
||||
{used ? <Box bold color="red">You've already summoned an apprentice or you are in process of summoning one.</Box> : ""}
|
||||
</Section>
|
||||
<Section title="Which school of magic is your apprentice studying?">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Destruction">
|
||||
Your apprentice is skilled in offensive magic. They know Magic Missile and Fireball.<br />
|
||||
<Button
|
||||
content="Select"
|
||||
disabled={used}
|
||||
onClick={() => act('destruction')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Divider />
|
||||
<LabeledList.Item label="Bluespace Manipulation">
|
||||
Your apprentice is able to defy physics, melting through solid objects and travelling great distances in the blink of an eye. They know Teleport and Ethereal Jaunt.<br />
|
||||
<Button
|
||||
content="Select"
|
||||
disabled={used}
|
||||
onClick={() => act('bluespace')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Divider />
|
||||
<LabeledList.Item label="Healing">
|
||||
Your apprentice is training to cast spells that will aid your survival. They know Forcewall and Charge and come with a Staff of Healing.<br />
|
||||
<Button
|
||||
content="Select"
|
||||
disabled={used}
|
||||
onClick={() => act('healing')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Divider />
|
||||
<LabeledList.Item label="Robeless">
|
||||
Your apprentice is training to cast spells without their robes. They know Knock and Mindswap.<br />
|
||||
<Button
|
||||
content="Select"
|
||||
disabled={used}
|
||||
onClick={() => act('robeless')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Divider />
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user