Skip to content

Commit

Permalink
Merge branch 'module_cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-ed committed Jul 2, 2024
2 parents 5ee47ed + 03dcdb8 commit 9db80cc
Show file tree
Hide file tree
Showing 88 changed files with 877 additions and 1,199 deletions.
28 changes: 14 additions & 14 deletions code/__DEFINES/~RUtgmc_defines/xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

//List of weed images
GLOBAL_LIST_INIT(weed_images_list, list(
WEED = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = WEED),
STICKY_WEED = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = STICKY_WEED),
RESTING_WEED = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = RESTING_WEED),
AUTOMATIC_WEEDING = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = AUTOMATIC_WEEDING)
WEED = image('icons/Xeno/actions.dmi', icon_state = WEED),
STICKY_WEED = image('icons/Xeno/actions.dmi', icon_state = STICKY_WEED),
RESTING_WEED = image('icons/Xeno/actions.dmi', icon_state = RESTING_WEED),
AUTOMATIC_WEEDING = image('icons/Xeno/actions.dmi', icon_state = AUTOMATIC_WEEDING)
))

//List of pheromone images
GLOBAL_LIST_INIT(pheromone_images_list, list(
AURA_XENO_RECOVERY = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = AURA_XENO_RECOVERY),
AURA_XENO_WARDING = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = AURA_XENO_WARDING),
AURA_XENO_FRENZY = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = AURA_XENO_FRENZY),
AURA_XENO_RECOVERY = image('icons/Xeno/actions.dmi', icon_state = AURA_XENO_RECOVERY),
AURA_XENO_WARDING = image('icons/Xeno/actions.dmi', icon_state = AURA_XENO_WARDING),
AURA_XENO_FRENZY = image('icons/Xeno/actions.dmi', icon_state = AURA_XENO_FRENZY),
))

//List of plant images
Expand All @@ -40,17 +40,17 @@ GLOBAL_LIST_INIT(plant_images_list, list(

//List of resin structure images
GLOBAL_LIST_INIT(resin_images_list, list(
RESIN_WALL = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = RESIN_WALL),
STICKY_RESIN = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = STICKY_RESIN),
RESIN_DOOR = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = RESIN_DOOR),
ALIEN_NEST = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = ALIEN_NEST)
RESIN_WALL = image('icons/Xeno/actions.dmi', icon_state = RESIN_WALL),
STICKY_RESIN = image('icons/Xeno/actions.dmi', icon_state = STICKY_RESIN),
RESIN_DOOR = image('icons/Xeno/actions.dmi', icon_state = RESIN_DOOR),
ALIEN_NEST = image('icons/Xeno/actions.dmi', icon_state = ALIEN_NEST)
))
/* RU TGMC EDIT
//List of puppeteer pheromone images
GLOBAL_LIST_INIT(puppeteer_phero_images_list, list(
AURA_XENO_BLESSFURY = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = "Fury"),
AURA_XENO_BLESSWARDING = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = "Warding"),
AURA_XENO_BLESSFRENZY = image('modular_RUtgmc/icons/Xeno/actions.dmi', icon_state = "Frenzy"),
AURA_XENO_BLESSFURY = image('icons/Xeno/actions.dmi', icon_state = "Fury"),
AURA_XENO_BLESSWARDING = image('icons/Xeno/actions.dmi', icon_state = "Warding"),
AURA_XENO_BLESSFRENZY = image('icons/Xeno/actions.dmi', icon_state = "Frenzy"),
))
RU TGMC EDIT*/
GLOBAL_LIST_INIT(panther_toxin_type_list, list(
Expand Down
109 changes: 109 additions & 0 deletions code/__HELPERS/matrices.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ round(cos_inv_third+sqrt3_sin, 0.001), round(cos_inv_third-sqrt3_sin, 0.001), ro
return output




//Returns a matrix multiplication of A with B
/proc/color_matrix_multiply(list/A, list/B)
if(!istype(A) || !istype(B))
Expand All @@ -207,3 +209,110 @@ round(cos_inv_third+sqrt3_sin, 0.001), round(cos_inv_third-sqrt3_sin, 0.001), ro
for(x in 1 to 4)
output[offset+x] = round(A[offset+1]*B[x] + A[offset+2]*B[x+4] + A[offset+3]*B[x+8] + A[offset+4]*B[x+12]+(y==5?B[x+16]:0), 0.001)
return output

//word of warning: using a matrix like this as a color value will simplify it back to a string after being set
/proc/color_hex2color_matrix(string)
var/length = length(string)
if((length != 7 && length != 9) || length != length_char(string))
return color_matrix_identity()
var/r = hex2num(copytext(string, 2, 4))/255
var/g = hex2num(copytext(string, 4, 6))/255
var/b = hex2num(copytext(string, 6, 8))/255
var/a = 1
if(length == 9)
a = hex2num(copytext(string, 8, 10))/255
if(!isnum(r) || !isnum(g) || !isnum(b) || !isnum(a))
return color_matrix_identity()
return list(r, 0, 0, 0, 0, g, 0, 0, 0, 0, b, 0, 0, 0, 0, a, 0, 0, 0, 0)


///Converts a hex color string to a color matrix.
/proc/color_matrix_from_string(string)
if(!string || !istext(string))
return color_matrix_identity()

var/string_r = hex2num(copytext(string, 2, 4)) / 255
var/string_g = hex2num(copytext(string, 4, 6)) / 255
var/string_b = hex2num(copytext(string, 6, 8)) / 255

return list(string_r, 0, 0, 0, 0, string_g, 0, 0, 0, 0, string_b, 0, 0, 0, 0, 1, 0, 0, 0, 0)


/*Changing/updating a mob's client color matrices. These render over the map window and affect most things the player sees, except things like inventory,
text popups, HUD, and some fullscreens. Code based on atom filter code, since these have similar issues with application order - for ex. if you have
a desaturation and a recolor matrix, you'll get very different results if you desaturate before recoloring, or recolor before desaturating.
See matrices.dm for the matrix procs.
If you want to recolor a specific atom, you should probably do it as a color matrix filter instead since that code already exists.
Apparently color matrices are not the same sort of matrix used by matrix datums and can't be worked with using normal matrix procs.*/

///Adds a color matrix and updates the client. Priority is the order the matrices are applied, lowest first. Will replace an existing matrix of the same name, if one exists.
/mob/proc/add_client_color_matrix(name, priority, list/params, time, easing)
LAZYINITLIST(client_color_matrices)

//Package the matrices in another list that stores priority.
client_color_matrices[name] = list("priority" = priority, "color_matrix" = params.Copy())

update_client_color_matrices(time, easing)

/**Combines all color matrices and applies them to the client.
Also used on login to give a client its new body's color matrices.
Responsible for sorting the matrices.
Transition is animated but instant by default.**/
/mob/proc/update_client_color_matrices(time = 0 SECONDS, easing = LINEAR_EASING)
if(!client)
return

if(!length(client_color_matrices))
animate(client, color = null, time = time, easing = easing)
UNSETEMPTY(client_color_matrices)
SEND_SIGNAL(src, COMSIG_MOB_RECALCULATE_CLIENT_COLOR)
return

//Sort the matrix packages by priority.
client_color_matrices = sortTim(client_color_matrices, GLOBAL_PROC_REF(cmp_filter_data_priority), TRUE)

var/list/final_matrix

for(var/package in client_color_matrices)
var/list/current_matrix = client_color_matrices[package]["color_matrix"]
if(!final_matrix)
final_matrix = current_matrix
else
final_matrix = color_matrix_multiply(final_matrix, current_matrix)

animate(client, color = final_matrix, time = time, easing = easing)
SEND_SIGNAL(src, COMSIG_MOB_RECALCULATE_CLIENT_COLOR)

///Changes a matrix package's priority and updates client.
/mob/proc/change_client_color_matrix_priority(name, new_priority, time, easing)
if(!client_color_matrices || !client_color_matrices[name])
return

client_color_matrices[name]["priority"] = new_priority

update_client_color_matrices(time, easing)

///Returns the matrix of that name, if it exists.
/mob/proc/get_client_color_matrix(name)
return client_color_matrices[name]["color_matrix"]

///Can take either a single name or a list of several. Attempts to remove target matrix packages and update client.
/mob/proc/remove_client_color_matrix(name_or_names, time, easing)
if(!client_color_matrices)
return

var/found = FALSE
var/list/names = islist(name_or_names) ? name_or_names : list(name_or_names)

for(var/name in names)
if(client_color_matrices[name])
client_color_matrices -= name
found = TRUE

if(found)
update_client_color_matrices(time, easing)

///Removes all matrices and updates client.
/mob/proc/clear_client_color_matrices(time, easing)
client_color_matrices = null
update_client_color_matrices(time, easing)
33 changes: 33 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
#define strip_improper(input_text) replacetext(replacetext(input_text, "\proper", ""), "\improper", "")

GLOBAL_LIST_INIT(ru_key_to_en_key, list("й" = "q", "ц" = "w", "у" = "e", "к" = "r", "е" = "t", "н" = "y", "г" = "u", "ш" = "i", "щ" = "o", "з" = "p", "х" = "\[", "ъ" = "]",
"ф" = "a", "ы" = "s", "в" = "d", "а" = "f", "п" = "g", "р" = "h", "о" = "j", "л" = "k", "д" = "l", "ж" = ";", "э" = "'",
"я" = "z", "ч" = "x", "с" = "c", "м" = "v", "и" = "b", "т" = "n", "ь" = "m", "б" = ",", "ю" = "."))

GLOBAL_LIST_INIT(en_key_to_ru_key, list(
"q" = "й", "w" = "ц", "e" = "у", "r" = "к", "t" = "е", "y" = "н",
"u" = "г", "i" = "ш", "o" = "щ", "p" = "з",
"a" = "ф", "s" = "ы", "d" = "в", "f" = "а", "g" = "п", "h" = "р",
"j" = "о", "k" = "л", "l" = "д", ";" = "ж", "'" = "э", "z" = "я",
"x" = "ч", "c" = "с", "v" = "м", "b" = "и", "n" = "т", "m" = "ь",
"," = "б", "." = "ю",
))

/proc/convert_ru_key_to_en_key(var/_key)
var/new_key = lowertext(_key)
new_key = GLOB.ru_key_to_en_key[new_key]
if(!new_key)
return _key
return uppertext(new_key)

/proc/convert_ru_string_to_en_string(text)
. = ""
for(var/i in 1 to length_char(text))
. += convert_ru_key_to_en_key(copytext_char(text, i, i+1))

/proc/sanitize_en_key_to_ru_key(char)
var/new_char = GLOB.en_key_to_ru_key[lowertext(char)]
return (new_char != null) ? new_char : char

/proc/sanitize_en_string_to_ru_string(text)
. = ""
for(var/i in 1 to length_char(text))
. += sanitize_en_key_to_ru_key(copytext_char(text, i, i+1))


/proc/format_table_name(table)
Expand Down
138 changes: 138 additions & 0 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1307,3 +1307,141 @@ GLOBAL_LIST_INIT(survivor_outfits, typecacheof(/datum/outfit/job/survivor))
return FALSE
line_count ++
return TRUE



/proc/get_true_location(atom/loc)
var/atom/subLoc = loc
while(subLoc.z == 0)
if (istype(subLoc.loc, /atom))
subLoc = subLoc.loc
else
return subLoc
return subLoc

#define get_true_turf(loc) get_turf(get_true_location(loc))

GLOBAL_LIST_EMPTY(loose_yautja_gear)
GLOBAL_LIST_EMPTY(tracked_yautja_gear) // list of pred gear with a tracking element attached

GLOBAL_LIST_EMPTY(mainship_yautja_teleports)
GLOBAL_LIST_EMPTY(mainship_yautja_desc)
GLOBAL_LIST_EMPTY(yautja_teleports)
GLOBAL_LIST_EMPTY(yautja_teleport_descs)

GLOBAL_LIST_INIT_TYPED(all_yautja_capes, /obj/item/clothing/yautja_cape, setup_yautja_capes())

/proc/setup_yautja_capes()
var/list/cape_list = list()
for(var/obj/item/clothing/yautja_cape/cape_type as anything in typesof(/obj/item/clothing/yautja_cape))
cape_list[initial(cape_type.name)] = cape_type
return cape_list

GLOBAL_VAR_INIT(roles_whitelist, load_role_whitelist())

/proc/load_role_whitelist(filename = "config/role_whitelist.txt")
var/L[] = file2list(filename)
var/P[]
var/W[] = new //We want a temporary whitelist list, in case we need to reload.

var/i
var/r
var/ckey
var/role
for(i in L)
if(!i)
continue
i = trim(i)

if(!length(i))
continue

else if(copytext(i, 1, 2) == "#")
continue

P = splittext(i, "+")

if(!P.len)
continue

ckey = ckey(P[1]) //Converting their key to canonical form. ckey() does this by stripping all spaces, underscores and converting to lower case.

role = NONE
r = 1
while(++r <= P.len)
switch(ckey(P[r]))
if("yautja")
role |= WHITELIST_YAUTJA
if("yautjalegacy")
role |= WHITELIST_YAUTJA_LEGACY
if("yautjacouncil")
role |= WHITELIST_YAUTJA_COUNCIL
if("yautjacouncillegacy")
role |= WHITELIST_YAUTJA_COUNCIL_LEGACY
if("yautjaleader")
role |= WHITELIST_YAUTJA_LEADER

W[ckey] = role

return W

//yautja ship AI announcement
/proc/yautja_announcement(message, title = "You receive a message from your ship AI...", sound_to_play = sound('sound/misc/notice1.ogg'))
var/list/targets = GLOB.human_mob_list + GLOB.dead_mob_list
for(var/mob/M in targets)
if(!isobserver(M)) //observers see everything
var/mob/living/carbon/human/H = M
if(!isyautja(H) || H.stat != CONSCIOUS)
continue

to_chat(M, html = "<span class='big bold'>[title]</span><BR><BR>[span_alert(message)]")
SEND_SOUND(M, sound_to_play)

/// Will attempt to find what's holding this item if it's being contained by something, ie if it's in a satchel held by a human, this'll return the human
/proc/recursive_holder_check(obj/item/held_item, recursion_limit = 3)
if(recursion_limit <= 0)
return held_item
if(!held_item.loc || isturf(held_item.loc))
return held_item
recursion_limit--
return recursive_holder_check(held_item.loc, recursion_limit)

// returns turf relative to A for a given clockwise angle at set range
// result is bounded to map size
/proc/get_angle_target_turf(atom/A, angle, range)
if(!istype(A))
return null
var/x = A.x
var/y = A.y

x += range * sin(angle)
y += range * cos(angle)

//Restricts to map boundaries while keeping the final angle the same
var/dx = A.x - x
var/dy = A.y - y
var/ratio

if(dy == 0) //prevents divide-by-zero errors
ratio = INFINITY
else
ratio = dx / dy

if(x < 1)
y += (1 - x) / ratio
x = 1
else if (x > world.maxx)
y += (world.maxx - x) / ratio
x = world.maxx
if(y < 1)
x += (1 - y) * ratio
y = 1
else if (y > world.maxy)
x += (world.maxy - y) * ratio
y = world.maxy


x = round(x,1)
y = round(y,1)

return locate(x,y,A.z)
Loading

0 comments on commit 9db80cc

Please sign in to comment.