Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 6160f0b

Browse files
committed
Merge branch 'PortsPsionics' of https://github.com/cowbot92/Yogstation into PortsPsionics
2 parents 53679d0 + c36d08d commit 6160f0b

File tree

12 files changed

+299
-190
lines changed

12 files changed

+299
-190
lines changed

code/__DEFINES/psi.dm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616
#define PSI_IMPLANT_LOG "Log Incident"
1717
#define PSI_IMPLANT_DISABLED "Disabled"
1818

19-
#define COMSIG_PSI_SELECTION "select action"
2019
#define COMSIG_PSI_INVOKE "invoke selected"

code/_onclick/hud/action_button.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
if(usr.next_click > world.time)
6060
return
6161
usr.next_click = world.time + 1
62-
// var/trigger_flags
63-
// if(LAZYACCESS(modifiers, RIGHT_CLICK)) FUCK COMBAT MODE!!!!
64-
// trigger_flags |= TRIGGER_SECONDARY_ACTION
65-
linked_action.Trigger()
62+
var/trigger_flags
63+
if(LAZYACCESS(modifiers, RIGHT_CLICK))
64+
trigger_flags |= TRIGGER_SECONDARY_ACTION
65+
linked_action.Trigger(trigger_flags)
6666
SEND_SOUND(usr, get_sfx(SFX_TERMINAL_TYPE))
6767
transform = turn(matrix() * 0.9, pick(-8, 8))
6868
alpha = 200

code/_onclick/other_mobs.dm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050

5151
A.attack_hand(src, modifiers)
5252

53-
/mob/living/carbon/human/attack_empty_hand()
54-
if(psi)
55-
SEND_SIGNAL(src, COMSIG_PSI_SELECTION)
56-
5753
/mob/living/carbon/human/RangedAttack(atom/A, params)
5854
if(psi)
5955
SEND_SIGNAL(src, COMSIG_PSI_INVOKE, A, FALSE, params)

code/modules/psionics/complexus/complexus.dm

Lines changed: 157 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,31 @@
6363
var/image/_aura_image // Client image
6464
var/obj/effect/overlay/aura/image_holder //holder so we don't have to apply the image directly to the mob, making it's clickbox massive
6565

66+
67+
///weakref to button to access the complexus interface
68+
var/datum/weakref/info_button_ref
69+
6670
/datum/psi_complexus/New(mob/M)
6771
owner = M
6872
image_holder = new(src)
6973
owner.vis_contents += image_holder
7074
START_PROCESSING(SSpsi, src)
71-
RegisterSignal(owner, COMSIG_PSI_SELECTION, PROC_REF(select_power))
7275
RegisterSignal(owner, COMSIG_PSI_INVOKE, PROC_REF(invoke_power))
7376
thinker = owner.mind
7477
if(thinker && istype(thinker))
7578
RegisterSignal(thinker, COMSIG_MIND_TRANSFERRED, PROC_REF(mind_swap))
7679

80+
var/datum/action/complexus_info/info_button = new(src)
81+
info_button_ref = WEAKREF(info_button)
82+
7783
/datum/psi_complexus/proc/mind_swap(datum/mind/brain, mob/living/oldbody)
7884
if(!brain || !istype(brain) || !brain.current)
7985
return
80-
UnregisterSignal(owner, COMSIG_PSI_SELECTION)
8186
UnregisterSignal(owner, COMSIG_PSI_INVOKE)
8287
owner.vis_contents -= image_holder
8388
owner.psi = null
8489
owner = brain.current
8590
owner.vis_contents += image_holder
86-
RegisterSignal(owner, COMSIG_PSI_SELECTION, PROC_REF(select_power))
8791
RegisterSignal(owner, COMSIG_PSI_INVOKE, PROC_REF(invoke_power))
8892
owner.psi = src
8993
update(TRUE, TRUE)
@@ -94,7 +98,6 @@
9498
if(thinker && istype(thinker))
9599
UnregisterSignal(thinker, COMSIG_MIND_TRANSFERRED)
96100
if(owner)
97-
UnregisterSignal(owner, COMSIG_PSI_SELECTION)
98101
UnregisterSignal(owner, COMSIG_PSI_INVOKE)
99102
cancel()
100103
if(owner.client)
@@ -105,29 +108,163 @@
105108
QDEL_NULL(ui)
106109
owner.psi = null
107110
owner = null
108-
QDEL_NULL(image_holder)
111+
112+
if(image_holder)
113+
QDEL_NULL(image_holder)
114+
115+
if(info_button_ref)
116+
QDEL_NULL(info_button_ref)
109117

110118
if(manifested_items)
111119
for(var/thing in manifested_items)
112120
qdel(thing)
113121
manifested_items.Cut()
114122
. = ..()
115123

116-
/datum/psi_complexus/proc/select_power(mob/user)
117-
if(suppressed)
124+
////////////////////////////////////////////////////////////////////////////////////
125+
//----------------------------Ability selection stuff-----------------------------//
126+
////////////////////////////////////////////////////////////////////////////////////
127+
/datum/psi_complexus/ui_interact(mob/user, datum/tgui/ui)
128+
ui = SStgui.try_update_ui(user, src, ui)
129+
if(!ui)
130+
ui = new(user, src, "PsionicComplexus", "Psi Complexus")
131+
ui.open()
132+
133+
/datum/psi_complexus/ui_data(mob/user)
134+
var/list/data = list()
135+
var/use_rating
136+
var/effective_rating = rating
137+
if(effective_rating > 1 && suppressed)
138+
effective_rating = max(0, rating-2)
139+
var/rating_descriptor
140+
if(!use_rating)
141+
switch(effective_rating)
142+
if(1)
143+
use_rating = "[effective_rating]-Epsilon"
144+
rating_descriptor = "This indicates the presence of minor latent psi potential with little or no operant capabilities."
145+
if(2)
146+
use_rating = "[effective_rating]-Delta"
147+
rating_descriptor = "This indicates the presence of minor psi capabilities of the Operant rank or higher."
148+
if(3)
149+
use_rating = "[effective_rating]-Gamma"
150+
rating_descriptor = "This indicates the presence of psi capabilities of the Master rank or higher."
151+
if(4)
152+
use_rating = "[effective_rating]-Beta"
153+
rating_descriptor = "This indicates the presence of significant psi capabilities of the Grandmaster rank or higher."
154+
if(5)
155+
use_rating = "[effective_rating]-Alpha"
156+
rating_descriptor = "This indicates the presence of major psi capabilities of the Paramount rank or higher."
157+
else
158+
use_rating = "[effective_rating]-Lambda"
159+
rating_descriptor = "This indicates the presence of trace latent psi capabilities."
160+
161+
if(selected_power && istype(selected_power))
162+
data["selected_power"] = initial(selected_power.name)
163+
data["use_rating"] = use_rating
164+
data["rating_descriptor"] = rating_descriptor
165+
data["faculties"] = list()
166+
for(var/faculty_id in ranks)
167+
var/list/check_powers = get_powers_by_faculty(faculty_id)
168+
if(LAZYLEN(check_powers))
169+
var/list/details = list()
170+
var/datum/psionic_faculty/faculty = SSpsi.get_faculty(faculty_id)
171+
details["name"] += faculty.name
172+
details["rank"] += ranks[faculty_id]
173+
for(var/datum/psionic_power/power in check_powers)
174+
var/list/power_data = list()
175+
power_data["name"] = power.name
176+
power_data["description"] = power.use_description
177+
power_data["path"] = power.type
178+
details["powers"] += list(power_data)
179+
data["faculties"] += list(details)
180+
return data
181+
182+
/datum/psi_complexus/ui_act(action, params)
183+
if(..())
184+
return
185+
switch(action)
186+
if("select")
187+
var/ability = text2path(params["ability"])
188+
var/datum/psionic_power/finder = locate(ability) in learned_powers
189+
if(!finder || !istype(finder))
190+
return
191+
selected_power = finder
192+
owner.balloon_alert(owner, "Selected [selected_power.name]")
193+
if("deselect")
194+
selected_power = null
195+
owner.balloon_alert(owner, "Deselected power")
196+
update_button_icon()
197+
198+
/datum/psi_complexus/ui_state()
199+
return GLOB.always_state
200+
201+
/datum/psi_complexus/ui_assets(mob/user)
202+
return list(
203+
get_asset_datum(/datum/asset/spritesheet/sheetmaterials)
204+
)
205+
206+
/datum/asset/spritesheet/psi_icons
207+
name = "psi_icons"
208+
209+
/datum/asset/spritesheet/psi_icons/create_spritesheets()
210+
InsertAll("", 'icons/obj/psychic_powers.dmi')
211+
212+
/**
213+
* Update the button icon
214+
*/
215+
/datum/psi_complexus/proc/update_button_icon()
216+
var/datum/action/complexus_info/info_button = info_button_ref?.resolve()
217+
if(info_button)
218+
if(selected_power)
219+
info_button.desc = "Selected power: [selected_power.name]"
220+
info_button.button_icon = selected_power.icon
221+
info_button.button_icon_state = selected_power.icon_state
222+
else
223+
info_button.desc = initial(info_button.desc)
224+
info_button.button_icon = initial(info_button.button_icon)
225+
info_button.button_icon_state = initial(info_button.button_icon_state)
226+
info_button.build_all_button_icons()
227+
228+
/**
229+
* The ability in question
230+
*/
231+
/datum/action/complexus_info
232+
name = "Open psi complexus"
233+
desc = "No currently selected power."
234+
button_icon = 'icons/obj/telescience.dmi'
235+
button_icon_state = "psionic_null_skull"
236+
show_to_observers = FALSE
237+
238+
/datum/action/complexus_info/Trigger(trigger_flags)
239+
. = ..()
240+
if(!.)
118241
return
119-
rebuild_power_cache()
120-
if(!LAZYLEN(learned_powers))
242+
if(trigger_flags & TRIGGER_SECONDARY_ACTION)
243+
var/datum/psi_complexus/host = target
244+
if(istype(host))
245+
if(!host.selected_power)
246+
return
247+
host.selected_power = null
248+
owner.balloon_alert(owner, "Deselected power")
249+
host.update_button_icon()
250+
return
251+
252+
target.ui_interact(owner)
253+
254+
/datum/action/complexus_info/IsAvailable(feedback = FALSE)
255+
if(!target)
256+
stack_trace("[type] was used without a target psi complexus datum!")
257+
return FALSE
258+
. = ..()
259+
if(!.)
121260
return
122-
var/list/choice_list = LAZYCOPY(learned_powers)
123-
for(var/datum/psionic_power/I as anything in choice_list)
124-
choice_list[I] = image(I.icon, null, I.icon_state)
125-
var/selection = show_radial_menu(user, user, choice_list, null, 40, tooltips = TRUE, autopick_single_option = FALSE)
126-
selected_power = selection
127-
if(selection) //wipe the selected power unless something was actually chosen
128-
selected_power.on_select(user)
129-
user.balloon_alert(user, "Selected [selected_power.name]")
261+
if(!owner.mind)
262+
return FALSE
263+
return TRUE
130264

265+
////////////////////////////////////////////////////////////////////////////////////
266+
//------------------------------Invoke the power----------------------------------//
267+
////////////////////////////////////////////////////////////////////////////////////
131268
/datum/psi_complexus/proc/invoke_power(mob/user, atom/target, proximity, parameters)
132269
if(suppressed)
133270
return
@@ -137,6 +274,9 @@
137274
if(.)
138275
selected_power.handle_post_power(user, target)
139276

277+
////////////////////////////////////////////////////////////////////////////////////
278+
//------------------------------Aura image stuff----------------------------------//
279+
////////////////////////////////////////////////////////////////////////////////////
140280
/datum/psi_complexus/proc/get_aura_image()
141281
if(_aura_image && !istype(_aura_image))
142282
var/atom/A = _aura_image

code/modules/psionics/complexus/complexus_process.dm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
highest_faculty = faculty
2525
highest_rank = check_rank
2626

27+
28+
var/datum/action/complexus_info/info_button = info_button_ref?.resolve()
29+
if(info_button && istype(info_button))
30+
if(highest_rank >= PSI_RANK_OPERANT)
31+
info_button.Grant(owner)
32+
else
33+
info_button.Remove(owner)
34+
35+
2736
UNSETEMPTY(latencies)
2837
var/rank_count = max(1, LAZYLEN(ranks))
2938
rebuild_power_cache = TRUE

code/modules/psionics/faculties/_power.dm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,3 @@
5858
log_attack("[user] Used psipower ([name]) on [target]")
5959
if(use_sound)
6060
playsound(user.loc, use_sound, 75)
61-
62-
/datum/psionic_power/proc/on_select(mob/living/user)
63-
return TRUE

code/modules/psionics/faculties/coercion.dm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
cooldown = 5 SECONDS
2525
min_rank = PSI_RANK_OPERANT
2626
icon_state = "coe_commune"
27-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click on a creature on to psionically send them a message."
27+
use_description = "Click on a creature on to psionically send them a message."
2828

2929
/datum/psionic_power/coercion/commune/invoke(mob/living/user, mob/living/target, proximity, parameters)
3030
if(!istype(target) || user == target)
@@ -68,7 +68,7 @@
6868
cooldown = 5 SECONDS
6969
min_rank = PSI_RANK_OPERANT
7070
icon_state = "coe_assay"
71-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click on a target in order to perform a deep coercive-redactive probe of their psionic potential."
71+
use_description = "Click on a target in order to perform a deep coercive-redactive probe of their psionic potential."
7272

7373
/datum/psionic_power/coercion/assay/invoke(mob/living/user, mob/living/target, proximity, parameters)
7474
if(!istype(target) || user == target)
@@ -160,7 +160,7 @@
160160
cooldown = 2 SECONDS
161161
min_rank = PSI_RANK_OPERANT
162162
icon_state = "coe_agony"
163-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, attack someone while in combat mode to deal minor stamina damage. Higher psi levels augment the damage done."
163+
use_description = "Attack someone while in combat mode to deal minor stamina damage. Higher psi levels augment the damage done."
164164

165165
/datum/psionic_power/coercion/agony/invoke(mob/living/user, mob/living/target, proximity, parameters)
166166
if(!istype(target) || !proximity || user == target || !user.combat_mode)
@@ -180,7 +180,7 @@
180180
cooldown = 10 SECONDS
181181
min_rank = PSI_RANK_MASTER
182182
icon_state = "coe_spasm"
183-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then target a creature to use a ranged attack that may rip the weapons away from the target."
183+
use_description = "Target a creature to use a ranged attack that may rip the weapons away from the target."
184184

185185
/datum/psionic_power/coercion/spasm/invoke(mob/living/user, mob/living/carbon/human/target, proximity, parameters)
186186
if(!istype(target) || user == target || !user.combat_mode)
@@ -204,7 +204,7 @@
204204
cooldown = 8 SECONDS
205205
min_rank = PSI_RANK_MASTER
206206
icon_state = "coe_focus"
207-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click on someone in order to cure ailments of the mind."
207+
use_description = "Click on someone in order to cure ailments of the mind."
208208

209209
/datum/psionic_power/coercion/focus/invoke(mob/living/user, mob/living/target, proximity, parameters)
210210
if(!istype(target) || !proximity || user == target)
@@ -243,7 +243,7 @@
243243
cooldown = 25 SECONDS //It should take a WHILE to be able to use this again.
244244
min_rank = PSI_RANK_MASTER
245245
icon_state = "coe_mindread"
246-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click on someone in melee range to attempt to read a surface level thought."
246+
use_description = "Click on someone in melee range to attempt to read a surface level thought."
247247

248248
/datum/psionic_power/coercion/mindread/invoke(mob/living/user, mob/living/target, proximity, parameters)
249249
if(!istype(target) || target == user || !proximity)
@@ -280,7 +280,7 @@
280280
cooldown = 10 SECONDS
281281
min_rank = PSI_RANK_GRANDMASTER
282282
icon_state = "coe_blindstrike"
283-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click anywhere to use a radial attack that blinds, deafens and disorients everyone near you."
283+
use_description = "Click anywhere to use a radial attack that blinds, deafens and disorients everyone near you."
284284

285285
/datum/psionic_power/coercion/blindstrike/invoke(mob/living/user, mob/living/target, proximity, parameters)
286286
. = ..()
@@ -304,7 +304,7 @@
304304
cooldown = 100 SECONDS
305305
min_rank = PSI_RANK_PARAMOUNT
306306
icon_state = "coe_disarm"
307-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then click your target with combat mode to Psionically rip their arms off."
307+
use_description = "Click your target with combat mode to Psionically rip their arms off."
308308

309309
/datum/psionic_power/coercion/dis_arm/invoke(mob/living/user, mob/living/target, proximity, parameters)
310310
if(!user.combat_mode || user == target)

code/modules/psionics/faculties/energistics.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
cooldown = 7.5 SECONDS
1414
min_rank = PSI_RANK_OPERANT
1515
icon_state = "ene_ele"
16-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, in an empty, then Enter combat mode to use a melee attack that electrocutes a victim, or charge an energy cell."
16+
use_description = "Enter combat mode to use a melee attack that electrocutes a victim, or charge an energy cell."
1717

1818
/datum/psionic_power/energistics/electrocute/invoke(mob/living/user, mob/living/target, proximity, parameters)
1919
if(!user.combat_mode || !istype(target) || !proximity)
@@ -40,7 +40,7 @@
4040
cooldown = 1 SECONDS
4141
min_rank = PSI_RANK_OPERANT
4242
icon_state = "ene_spark"
43-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then target a non-living thing in melee range with combat mode on to cause some sparks to appear. This can light fires."
43+
use_description = "Target a non-living thing in melee range with combat mode on to cause some sparks to appear. This can light fires."
4444

4545
/datum/psionic_power/energistics/spark/invoke(mob/living/user, mob/living/target, proximity, parameters)
4646
if(!user.combat_mode || isnull(target) || istype(target) || !proximity)
@@ -65,7 +65,7 @@
6565
cooldown = 2 SECONDS
6666
min_rank = PSI_RANK_MASTER
6767
icon_state = "ene_zorch"
68-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then use this ranged laser attack with combat mode on. Your mastery of Energistics will determine how powerful the laser is. Be wary of overuse, and try not to fry your own brain."
68+
use_description = "Use this ranged laser attack with combat mode on. Your mastery of Energistics will determine how powerful the laser is. Be wary of overuse, and try not to fry your own brain."
6969

7070
/datum/psionic_power/energistics/zorch/invoke(mob/living/user, mob/living/target, proximity, parameters)
7171
if(!user.combat_mode)
@@ -114,7 +114,7 @@
114114
cooldown = 10 SECONDS
115115
min_rank = PSI_RANK_GRANDMASTER
116116
icon_state = "ene_disrupt"
117-
use_description = "Activate the power with the 'use' key (initially bound to Z) in an empty hand, then attack a target while in combat mode to cause a localized electromagnetic pulse."
117+
use_description = "Attack a target while in combat mode to cause a localized electromagnetic pulse."
118118

119119
/datum/psionic_power/energistics/disrupt/invoke(mob/living/user, mob/living/target, proximity, parameters)
120120
if(!user.combat_mode || !istype(target) || !proximity)

0 commit comments

Comments
 (0)