diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index 0d3baa00bd8..29ecd736372 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -325,4 +325,43 @@ proc/isInSight(var/atom/A, var/atom/B) if(O.started_as_observer) // Exclude people who started as observers continue active_players++ - return active_players \ No newline at end of file + return active_players + + +/datum/projectile_data + var/src_x + var/src_y + var/time + var/distance + var/power_x + var/power_y + var/dest_x + var/dest_y + +/datum/projectile_data/New(var/src_x, var/src_y, var/time, var/distance, \ + var/power_x, var/power_y, var/dest_x, var/dest_y) + src.src_x = src_x + src.src_y = src_y + src.time = time + src.distance = distance + src.power_x = power_x + src.power_y = power_y + src.dest_x = dest_x + src.dest_y = dest_y + +/proc/projectile_trajectory(var/src_x, var/src_y, var/rotation, var/angle, var/power) + + // returns the destination (Vx,y) that a projectile shot at [src_x], [src_y], with an angle of [angle], + // rotated at [rotation] and with the power of [power] + // Thanks to VistaPOWA for this function + + var/power_x = power * cos(angle) + var/power_y = power * sin(angle) + var/time = 2* power_y / 10 //10 = g + + var/distance = time * power_x + + var/dest_x = src_x + distance*sin(rotation); + var/dest_y = src_y + distance*cos(rotation); + + return new /datum/projectile_data(src_x, src_y, time, distance, power_x, power_y, dest_x, dest_y) \ No newline at end of file diff --git a/code/__HELPERS/maths.dm b/code/__HELPERS/maths.dm index 4150b78286a..54aaf0d3483 100644 --- a/code/__HELPERS/maths.dm +++ b/code/__HELPERS/maths.dm @@ -106,6 +106,12 @@ var/const/Sqrt2 = 1.41421356 // Pi / 180 return degrees * 0.0174532925 +// Will filter out extra rotations and negative rotations +// E.g: 540 becomes 180. -180 becomes 180. +// Thanks to Flexicode for the formula. +/proc/SimplifyDegrees(degrees) + return ((degrees % 360 + 22.5) + 360) % 365 + // min is inclusive, max is exclusive /proc/Wrap(val, min, max) var/d = max - min diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 7e3b58c1980..b62d1947db6 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -189,10 +189,7 @@ proc/tg_list2text(list/list, glue=",") //Converts an angle (degrees) into an ss13 direction /proc/angle2dir(var/degree) - // Will filter out extra rotations and negative rotations - // E.g: 540 becomes 180. -180 becomes 180. - // Thanks to Flexicode for the formula. - degree = ((degree % 360 + 22.5) + 360) % 365 + degree = SimplifyDegrees(degree) if(degree < 45) return NORTH if(degree < 90) return NORTHEAST diff --git a/code/datums/mixed.dm b/code/datums/mixed.dm index c815d34cbe9..616c4eee99a 100644 --- a/code/datums/mixed.dm +++ b/code/datums/mixed.dm @@ -16,4 +16,4 @@ /datum/debug - var/list/debuglist + var/list/debuglist \ No newline at end of file diff --git a/code/modules/telesci/telesci_computer.dm b/code/modules/telesci/telesci_computer.dm index 8d0c92cf12c..9700b1c51fd 100644 --- a/code/modules/telesci/telesci_computer.dm +++ b/code/modules/telesci/telesci_computer.dm @@ -8,17 +8,24 @@ // VARIABLES // var/teles_left // How many teleports left until it becomes uncalibrated - var/x_off // X offset - var/y_off // Y offset - var/x_co // X coordinate - var/y_co // Y coordinate - var/z_co // Z coordinate + var/datum/projectile_data/last_tele_data = null + var/z_co = 1 + var/rotation_off + var/power_off + + var/rotation + var/angle + var/power = 25 + + // Based on the power used + var/teleport_cooldown = 0 + var/list/power_options = list(50, 200, 500) // /obj/machinery/computer/telescience/New() ..() teles_left = rand(8,12) - x_off = rand(-10,10) - y_off = rand(-10,10) + rotation_off = rand(-10,10) + power_off = rand(-10,10) initialize() /obj/machinery/computer/telescience/initialize() @@ -51,14 +58,37 @@ /obj/machinery/computer/telescience/interact(mob/user) var/t = "