Skip to content

Commit

Permalink
Beam datum updates, assembly code refactor, adds the ability to place…
Browse files Browse the repository at this point in the history
… assemblies on tanks (#11046)

* Attempt 1

To do: Fix the infrared laser's source position not updating when placed on a table

make the infrared laser emissive

fix the error

* bug fix

* to do: fix signaller send button

* fixes

* fix

* PR links added, various misc fixes

* fixed signaller button

* aaaaa

* Finally done

* done

* thank you CI/CD for trusting in me once more

* testening
  • Loading branch information
XeonMations authored Sep 10, 2024
1 parent 99441d6 commit 5f85843
Show file tree
Hide file tree
Showing 29 changed files with 1,032 additions and 531 deletions.
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "code\__DEFINES\areas.dm"
#include "code\__DEFINES\armor.dm"
#include "code\__DEFINES\art.dm"
#include "code\__DEFINES\assemblies.dm"
#include "code\__DEFINES\assets.dm"
#include "code\__DEFINES\async.dm"
#include "code\__DEFINES\atmospherics.dm"
Expand Down
8 changes: 8 additions & 0 deletions code/__DEFINES/assemblies.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// When combined in a holder, blacklists duplicate assemblies
#define ASSEMBLY_NO_DUPLICATES (1<<0)

/// How loud do assemblies beep at
#define ASSEMBLY_BEEP_VOLUME 5

/// The max amount of assemblies attachable on an assembly holder
#define HOLDER_MAX_ASSEMBLIES 2
3 changes: 3 additions & 0 deletions code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#define COOLDOWN_CIRCUIT_PATHFIND_DIF "circuit_pathfind_different"
#define COOLDOWN_CIRCUIT_TARGET_INTERCEPT "circuit_target_intercept"

//Item cooldowns
#define COOLDOWN_SIGNALLER_SEND "cooldown_signaller_send"

//Mecha cooldowns
#define COOLDOWN_MECHA_MESSAGE "mecha_message"
#define COOLDOWN_MECHA_EQUIPMENT "mecha_equipment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@
/// Tell a deployable item to force its deployment (datum/source, atom/location)
#define COMSIG_DEPLOYABLE_FORCE_DEPLOY "force_deploy"
#define DEPLOYMENT_SUCCESS (1 << 0) //Indicates that something was successfully deployed

#define COMSIG_IGNITER_ACTIVATE "ignite_activate" //called when an igniter activates

/// Called before beam is redrawn
#define COMSIG_BEAM_BEFORE_DRAW "beam_before_draw"
#define BEAM_CANCEL_DRAW (1 << 0)

/// Sent to a beam when an atom enters any turf the beam covers: (obj/effect/ebeam/hit_beam, atom/movable/entered)
#define COMSIG_BEAM_ENTERED "beam_entered"

/// Sent to a beam when an atom exits any turf the beam covers: (obj/effect/ebeam/hit_beam, atom/movable/exited)
#define COMSIG_BEAM_EXITED "beam_exited"

/// Sent to a beam when any turf the beam covers changes: (list/datum/callback/post_change_callbacks)
#define COMSIG_BEAM_TURFS_CHANGED "beam_turfs_changed"
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_obj/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
///Called when a payment component changes value
#define COMSIG_OBJ_ATTEMPT_CHARGE_CHANGE "obj_attempt_simple_charge_change"

///from /obj/item/assembly/proc/pulsed(mob/pulser)
#define COMSIG_ASSEMBLY_PULSED "assembly_pulsed"
3 changes: 3 additions & 0 deletions code/__DEFINES/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#define INVESTIGATE_VERB_DROPPED "dropped"
#define INVESTIGATE_VERB_EQUIPPED "equipped"

// The maximum number of entries allowed in the signaler investigate log, keep this relatively small to prevent performance issues when an admin tries to query it
#define INVESTIGATE_SIGNALER_LOG_MAX_LENGTH 500

// Logging types for log_message()
#define LOG_ATTACK (1 << 0)
#define LOG_SAY (1 << 1)
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ GLOBAL_LIST_INIT(approved_status_pictures, list(
#define WIRE_PULSE_SPECIAL (1<<2)
#define WIRE_RADIO_RECEIVE (1<<3)
#define WIRE_RADIO_PULSE (1<<4)
#define ASSEMBLY_BEEP_VOLUME 5

// Camera defines
// ---------------------------------------------------
Expand Down
68 changes: 22 additions & 46 deletions code/__HELPERS/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
else if(dx < 0)
. += 360

/// Calculate the angle produced by a pair of x and y deltas
/proc/delta_to_angle(x, y)
if(!y)
return (x >= 0) ? 90 : 270
. = arctan(x/y)
if(y < 0)
. += 180
else if(x < 0)
. += 360

/// Angle between two arbitrary points and horizontal line same as [/proc/get_angle]
/proc/get_angle_raw(start_x, start_y, start_pixel_x, start_pixel_y, end_x, end_y, end_pixel_x, end_pixel_y)
var/dy = (32 * end_y + end_pixel_y) - (32 * start_y + start_pixel_y)
var/dx = (32 * end_x + end_pixel_x) - (32 * start_x + start_pixel_x)
if(!dy)
return (dx >= 0) ? 90 : 270
. = arctan(dx/dy)
if(dy < 0)
. += 180
else if(dx < 0)
. += 360

///for getting the angle when animating something's pixel_x and pixel_y
/proc/get_pixel_angle(y, x)
if(!y)
Expand Down Expand Up @@ -70,52 +92,6 @@
line += locate(current_x_step, current_y_step, starting_z)
return line

/**
* Get a list of turfs in a line from `starting_atom` to `ending_atom`.
*
* Uses the ultra-fast [Bresenham Line-Drawing Algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm).
*/
/proc/get_line(atom/starting_atom, atom/ending_atom)
var/current_x_step = starting_atom.x//start at x and y, then add 1 or -1 to these to get every turf from starting_atom to ending_atom
var/current_y_step = starting_atom.y
var/starting_z = starting_atom.z

var/list/line = list(get_turf(starting_atom))//get_turf(atom) is faster than locate(x, y, z)

var/x_distance = ending_atom.x - current_x_step //x distance
var/y_distance = ending_atom.y - current_y_step

var/abs_x_distance = abs(x_distance)//Absolute value of x distance
var/abs_y_distance = abs(y_distance)

var/x_distance_sign = SIGN(x_distance) //Sign of x distance (+ or -)
var/y_distance_sign = SIGN(y_distance)

var/x = abs_x_distance >> 1 //Counters for steps taken, setting to distance/2
var/y = abs_y_distance >> 1 //Bit-shifting makes me l33t. It also makes get_line() unnessecarrily fast.

if(abs_x_distance >= abs_y_distance) //x distance is greater than y
for(var/distance_counter in 0 to (abs_x_distance - 1))//It'll take abs_x_distance steps to get there
y += abs_y_distance

if(y >= abs_x_distance) //Every abs_y_distance steps, step once in y direction
y -= abs_x_distance
current_y_step += y_distance_sign

current_x_step += x_distance_sign //Step on in x direction
line += locate(current_x_step, current_y_step, starting_z)//Add the turf to the list
else
for(var/distance_counter in 0 to (abs_y_distance - 1))
x += abs_x_distance

if(x >= abs_y_distance)
x -= abs_y_distance
current_x_step += x_distance_sign

current_y_step += y_distance_sign
line += locate(current_x_step, current_y_step, starting_z)
return line

//chances are 1:value. anyprob(1) will always return true
/proc/anyprob(value)
return (rand(1,value)==value)
Expand Down
9 changes: 9 additions & 0 deletions code/_globalvars/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ GLOBAL_PROTECT(admin_log)
GLOBAL_LIST_EMPTY(lastsignalers) //! keeps last 100 signals here in format: "[src] used [REF(src)] @ location [src.loc]: [freq]/[code]"
GLOBAL_PROTECT(lastsignalers)

/// Used to add a text log to the signaler investigation log.
/// Do not add to the list directly; if the list is too large it can cause lag when an admin tries to view it.
/proc/add_to_signaler_investigate_log(text)
var/log_length = length(GLOB.lastsignalers)
if(log_length >= INVESTIGATE_SIGNALER_LOG_MAX_LENGTH)
GLOB.lastsignalers = GLOB.lastsignalers.Copy((INVESTIGATE_SIGNALER_LOG_MAX_LENGTH - log_length) + 2)
GLOB.lastsignalers += list(text)


GLOBAL_LIST_EMPTY(lawchanges) //! Stores who uploaded laws to which silicon-based lifeform, and what the law was
GLOBAL_PROTECT(lawchanges)

Expand Down
Loading

0 comments on commit 5f85843

Please sign in to comment.