Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/NebulaSS13/Nebula into u…
Browse files Browse the repository at this point in the history
…pdate/devmerge-2022-05-09
  • Loading branch information
noelle-lavenza committed May 28, 2022
2 parents 95ba2f1 + 17c18bb commit f9b31c0
Show file tree
Hide file tree
Showing 55 changed files with 395 additions and 288 deletions.
2 changes: 1 addition & 1 deletion code/__defines/items_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
#define FIRE_MAX_STACKS 25
#define FIRE_MAX_FIRESUIT_STACKS 20 // If the number of stacks goes above this firesuits won't protect you anymore. If not, you can walk around while on fire like a badass.

#define THROWFORCE_GIBS 10 // Throw speed for gibbed or dismembered organs.
#define THROWFORCE_GIBS 3 // Throw speed for gibbed or dismembered organs.
#define THROWFORCE_SPEED_DIVISOR 12 // The throwing speed value at which the throwforce multiplier is exactly 1.
#define THROWNOBJ_KNOCKBACK_SPEED 15 // The minumum speed of a w_class 2 thrown object that will cause living mobs it hits to be knocked back. Heavier objects can cause knockback at lower speeds.
#define THROWNOBJ_KNOCKBACK_DIVISOR 2 // Affects how much speed the mob is knocked back with.
Expand Down
8 changes: 8 additions & 0 deletions code/__defines/unit_tests.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#define UT_NORMAL 1 // Standard one atmosphere 20celsius
#define UT_VACUUM 2 // Vacume on simulated turfs
#define UT_NORMAL_COLD 3 // Cold but standard atmosphere.

#define FAILURE 0
#define SUCCESS 1
#define SKIP 2
21 changes: 12 additions & 9 deletions code/_helpers/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,15 @@ proc/dd_sortedObjectList(list/incoming)

var/global/list/json_cache = list()
/proc/cached_json_decode(var/json_to_decode)
if(!json_to_decode || !length(json_to_decode))
return list()
try
if(isnull(global.json_cache[json_to_decode]))
global.json_cache[json_to_decode] = json_decode(json_to_decode)
. = global.json_cache[json_to_decode]
catch(var/exception/e)
log_error("Exception during JSON decoding ([json_to_decode]): [e]")
return list()
if(length(json_to_decode))
try
if(isnull(global.json_cache[json_to_decode]))
global.json_cache[json_to_decode] = json_decode(json_to_decode)
var/list/decoded = global.json_cache[json_to_decode]
if(islist(decoded)) // To prevent cache mutation.
return deepCopyList(decoded)
else if(decoded)
return decoded
catch(var/exception/e)
log_error("Exception during JSON decoding ([json_to_decode]): [e]")
return list()
14 changes: 0 additions & 14 deletions code/_helpers/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,10 @@
if(turfs.len)
return pick(turfs)

/proc/screen_loc2turf(text, turf/origin)
if(!origin)
return null
var/tZ = splittext(text, ",")
var/tX = splittext(tZ[1], "-")
var/tY = text2num(tX[2])
tX = splittext(tZ[2], "-")
tX = text2num(tX[2])
tZ = origin.z
tX = max(1, min(origin.x + 7 - tX, world.maxx))
tY = max(1, min(origin.y + 7 - tY, world.maxy))
return locate(tX, tY, tZ)

/*
Predicate helpers
*/


/proc/is_holy_turf(var/turf/T)
return T && T.holy

Expand Down
31 changes: 19 additions & 12 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,18 @@
var/global/list/click_catchers
/proc/get_click_catchers()
if(!global.click_catchers)
global.click_catchers = create_click_catcher()
global.click_catchers = list()
var/ox = -(round(config.max_client_view_x*0.5))
for(var/i = 0 to config.max_client_view_x)
var/oy = -(round(config.max_client_view_y*0.5))
var/tx = ox + i
for(var/j = 0 to config.max_client_view_y)
var/ty = oy + j
var/obj/screen/click_catcher/CC = new
CC.screen_loc = "CENTER[tx < 0 ? tx : "+[tx]"],CENTER[ty < 0 ? ty : "+[ty]"]"
CC.x_offset = tx
CC.y_offset = ty
global.click_catchers += CC
return global.click_catchers

/obj/screen/click_catcher
Expand All @@ -378,26 +389,22 @@ var/global/list/click_catchers
plane = CLICKCATCHER_PLANE
mouse_opacity = 2
screen_loc = "CENTER-7,CENTER-7"
var/x_offset = 0
var/y_offset = 0

/obj/screen/click_catcher/Destroy()
SHOULD_CALL_PARENT(FALSE)
return QDEL_HINT_LETMELIVE

/proc/create_click_catcher()
. = list()
for(var/i = 0, i<15, i++)
for(var/j = 0, j<15, j++)
var/obj/screen/click_catcher/CC = new()
CC.screen_loc = "TOP-[i],RIGHT-[j]"
. += CC

/obj/screen/click_catcher/Click(location, control, params)
var/list/modifiers = params2list(params)
if(modifiers["middle"] && istype(usr, /mob/living/carbon))
var/mob/living/carbon/C = usr
C.swap_hand()
else
var/turf/T = screen_loc2turf(screen_loc, get_turf(usr))
if(T)
T.Click(location, control, params)
var/turf/origin = get_turf(usr)
if(isturf(origin))
var/turf/clicked = locate(origin.x + x_offset, origin.y + y_offset, origin.z)
if(clicked)
clicked.Click(location, control, params)
. = 1
3 changes: 1 addition & 2 deletions code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@
#define ui_iarrowleft "BOTTOM-1,RIGHT-4"
#define ui_iarrowright "BOTTOM-1,RIGHT-2"

#define ui_spell_master "RIGHT-1:16,TOP-1:16"
#define ui_genetic_master "RIGHT-1:16,TOP-3:16"
#define ui_ability_master "RIGHT-2:16,TOP-1:16"

// AI
#define ui_ai_core "LEFT:6,BOTTOM:5"
Expand Down
59 changes: 33 additions & 26 deletions code/_onclick/hud/ability_screen_objects.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/obj/screen/movable/ability_master
/obj/screen/ability_master
name = "Abilities"
icon = 'icons/mob/screen_spells.dmi'
icon_state = "grey_spell_ready"
var/list/obj/screen/ability/ability_objects = list()
var/list/obj/screen/ability/spell_objects = list()
var/showing = 0 // If we're 'open' or not.

var/const/abilities_per_row = 7
var/open_state = "master_open" // What the button looks like when it's 'open', showing the other buttons.
var/closed_state = "master_closed" // Button when it's 'closed', hiding everything else.

screen_loc = ui_spell_master // TODO: Rename
screen_loc = ui_ability_master

var/mob/my_mob = null // The mob that possesses this hud object.

/obj/screen/movable/ability_master/Initialize(mapload, owner)
/obj/screen/ability_master/Initialize(mapload, owner)
. = ..()
if(owner)
my_mob = owner
Expand All @@ -22,7 +23,7 @@
. = INITIALIZE_HINT_QDEL
CRASH("ERROR: ability_master's Initialize() was not given an owner argument. This is a bug.")

/obj/screen/movable/ability_master/Destroy()
/obj/screen/ability_master/Destroy()
. = ..()
remove_all_abilities() //Get rid of the ability objects.
ability_objects.Cut()
Expand All @@ -32,18 +33,18 @@
my_mob.client.screen -= src
my_mob = null

/obj/screen/movable/ability_master/handle_mouse_drop(var/atom/over, var/mob/user)
/obj/screen/ability_master/handle_mouse_drop(var/atom/over, var/mob/user)
if(showing)
return FALSE
. = ..()

/obj/screen/movable/ability_master/Click()
/obj/screen/ability_master/Click()
if(!ability_objects.len) // If we're empty for some reason.
return

toggle_open()

/obj/screen/movable/ability_master/proc/toggle_open(var/forced_state = 0)
/obj/screen/ability_master/proc/toggle_open(var/forced_state = 0)
if(showing && (forced_state != 2)) // We are closing the ability master, hide the abilities.
for(var/obj/screen/ability/O in ability_objects)
if(my_mob && my_mob.client)
Expand All @@ -60,9 +61,15 @@
overlays.Add(open_state)
update_icon()

/obj/screen/movable/ability_master/proc/open_ability_master()
/obj/screen/ability_master/proc/open_ability_master()
for(var/i = 1 to length(ability_objects))
var/obj/screen/ability/A = ability_objects[i]
var/row = round(i/abilities_per_row)
A.screen_loc = "RIGHT-[(i-(row*abilities_per_row))+2]:16,TOP-[row+1]:16"
if(my_mob && my_mob.client)
my_mob.client.screen += A

/obj/screen/movable/ability_master/proc/update_abilities(forced = 0, mob/user)
/obj/screen/ability_master/proc/update_abilities(forced = 0, mob/user)
update_icon()
if(user && user.client)
if(!(src in user.client.screen))
Expand All @@ -73,13 +80,13 @@
ability.maptext = "[i]" // Slot number
i++

/obj/screen/movable/ability_master/on_update_icon()
/obj/screen/ability_master/on_update_icon()
if(ability_objects.len)
set_invisibility(0)
else
set_invisibility(101)

/obj/screen/movable/ability_master/proc/add_ability(var/name_given)
/obj/screen/ability_master/proc/add_ability(var/name_given)
if(!name) return
var/obj/screen/ability/new_button = new /obj/screen/ability
new_button.ability_master = src
Expand All @@ -90,7 +97,7 @@
if(my_mob.client)
toggle_open(2) //forces the icons to refresh on screen

/obj/screen/movable/ability_master/proc/remove_ability(var/obj/screen/ability/ability)
/obj/screen/ability_master/proc/remove_ability(var/obj/screen/ability/ability)
if(!ability)
return
ability_objects.Remove(ability)
Expand All @@ -105,36 +112,36 @@
// else
// qdel(src)

/obj/screen/movable/ability_master/proc/remove_all_abilities()
/obj/screen/ability_master/proc/remove_all_abilities()
for(var/obj/screen/ability/A in ability_objects)
remove_ability(A)

/obj/screen/movable/ability_master/proc/get_ability_by_name(name_to_search)
/obj/screen/ability_master/proc/get_ability_by_name(name_to_search)
for(var/obj/screen/ability/A in ability_objects)
if(A.name == name_to_search)
return A
return null

/obj/screen/movable/ability_master/proc/get_ability_by_proc_ref(proc_ref)
/obj/screen/ability_master/proc/get_ability_by_proc_ref(proc_ref)
for(var/obj/screen/ability/verb_based/V in ability_objects)
if(V.verb_to_call == proc_ref)
return V
return null

/obj/screen/movable/ability_master/proc/get_ability_by_instance(var/obj/instance/)
/obj/screen/ability_master/proc/get_ability_by_instance(var/obj/instance/)
for(var/obj/screen/ability/obj_based/O in ability_objects)
if(O.object == instance)
return O
return null

/obj/screen/movable/ability_master/proc/get_ability_by_spell(var/spell/s)
/obj/screen/ability_master/proc/get_ability_by_spell(var/spell/s)
for(var/screen in spell_objects)
var/obj/screen/ability/spell/S = screen
if(S.spell == s)
return S
return null

/obj/screen/movable/ability_master/proc/synch_spells_to_mind(var/datum/mind/M)
/obj/screen/ability_master/proc/synch_spells_to_mind(var/datum/mind/M)
if(!M)
return
LAZYINITLIST(M.learned_spells)
Expand All @@ -144,7 +151,7 @@

/mob/Initialize()
. = ..()
ability_master = new /obj/screen/movable/ability_master(null,src)
ability_master = new /obj/screen/ability_master(null,src)

///////////ACTUAL ABILITIES////////////
//This is what you click to do things//
Expand All @@ -155,7 +162,7 @@
maptext_x = 3
var/background_base_state = "grey"
var/ability_icon_state = null
var/obj/screen/movable/ability_master/ability_master
var/obj/screen/ability_master/ability_master

/obj/screen/ability/Destroy()
if(ability_master)
Expand Down Expand Up @@ -217,7 +224,7 @@
if(object_used && verb_to_call)
call(object_used,verb_to_call)(arguments_to_use)

/obj/screen/movable/ability_master/proc/add_verb_ability(var/object_given, var/verb_given, var/name_given, var/ability_icon_given, var/arguments)
/obj/screen/ability_master/proc/add_verb_ability(var/object_given, var/verb_given, var/name_given, var/ability_icon_given, var/arguments)
if(!object_given)
message_admins("ERROR: add_verb_ability() was not given an object in its arguments.")
if(!verb_given)
Expand All @@ -241,7 +248,7 @@
icon_state = "ling_spell_base"
background_base_state = "ling"

/obj/screen/movable/ability_master/proc/add_ling_ability(var/object_given, var/verb_given, var/name_given, var/ability_icon_given, var/arguments)
/obj/screen/ability_master/proc/add_ling_ability(var/object_given, var/verb_given, var/name_given, var/ability_icon_given, var/arguments)
if(!object_given)
message_admins("ERROR: add_ling_ability() was not given an object in its arguments.")
if(!verb_given)
Expand Down Expand Up @@ -277,7 +284,7 @@
icon_state = "wiz_spell_base"
background_base_state = "wiz"

/obj/screen/movable/ability_master/proc/add_technomancer_ability(var/obj/object_given, var/ability_icon_given)
/obj/screen/ability_master/proc/add_technomancer_ability(var/obj/object_given, var/ability_icon_given)
if(!object_given)
message_admins("ERROR: add_technomancer_ability() was not given an object in its arguments.")
if(get_ability_by_instance(object_given))
Expand All @@ -304,7 +311,7 @@
spell = null
return ..()

/obj/screen/movable/ability_master/proc/add_spell(var/spell/spell)
/obj/screen/ability_master/proc/add_spell(var/spell/spell)
if(!spell) return

if(spell.spell_flags & NO_BUTTON) //no button to add if we don't get one
Expand All @@ -331,7 +338,7 @@
if(my_mob.client)
toggle_open(2) //forces the icons to refresh on screen

/obj/screen/movable/ability_master/proc/update_spells(var/forced = 0)
/obj/screen/ability_master/proc/update_spells(var/forced = 0)
for(var/obj/screen/ability/spell/spell in spell_objects)
spell.update_charge(forced)

Expand Down Expand Up @@ -380,7 +387,7 @@
/obj/screen/ability/spell/activate()
spell.perform(usr)

/obj/screen/movable/ability_master/proc/silence_spells(var/amount)
/obj/screen/ability_master/proc/silence_spells(var/amount)
for(var/obj/screen/ability/spell/spell in spell_objects)
spell.spell.silenced = amount
spell.spell.process()
Expand Down
Loading

0 comments on commit f9b31c0

Please sign in to comment.