mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
Merge pull request #1737 from Giacom/tele_sci_change
Telescience now uses projectile trajectories to calculate the tile to teleport to! [MAP]
This commit is contained in:
+39
-1
@@ -329,4 +329,42 @@ 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
|
||||
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)
|
||||
|
||||
@@ -106,6 +106,14 @@ 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.
|
||||
/proc/SimplifyDegrees(degrees)
|
||||
degrees = degrees % 360
|
||||
if(degrees < 0)
|
||||
degrees += 360
|
||||
return degrees
|
||||
|
||||
// min is inclusive, max is exclusive
|
||||
/proc/Wrap(val, min, max)
|
||||
var/d = max - min
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
|
||||
/datum/debug
|
||||
var/list/debuglist
|
||||
var/list/debuglist
|
||||
@@ -84,6 +84,23 @@
|
||||
</html>
|
||||
"}
|
||||
|
||||
/obj/item/weapon/book/manual/telescience
|
||||
name = "Teleportation Science - Bluespace for dummies!"
|
||||
icon_state = "book7"
|
||||
author = "University of Bluespace"
|
||||
title = "Teleportation Science - Bluespace for dummies!"
|
||||
|
||||
dat = {"
|
||||
<html><head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<iframe width='100%' height='97%' src="http://wiki.nanotrasen.com/index.php?title=Telescience&printable=yes&remove_links=1" frameborder="0" id="main_frame"></iframe>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
"}
|
||||
|
||||
/obj/item/weapon/book/manual/engineering_hacking
|
||||
name = "Hacking"
|
||||
icon_state ="bookHacking"
|
||||
|
||||
@@ -57,15 +57,11 @@ var/list/GPS_list = list()
|
||||
..()
|
||||
if(href_list["tag"] )
|
||||
var/a = input("Please enter desired tag.", name, gpstag) as text
|
||||
a = copytext(sanitize(a), 1, 20)
|
||||
a = uppertext(copytext(sanitize(a), 1, 5))
|
||||
if(src.loc == usr)
|
||||
if(length(a) != 4)
|
||||
usr << "<span class = 'caution'> The tag must be four letters long!</span>"
|
||||
return
|
||||
else
|
||||
gpstag = a
|
||||
name = "global positioning system ([gpstag])"
|
||||
attack_self(usr)
|
||||
gpstag = a
|
||||
name = "global positioning system ([gpstag])"
|
||||
attack_self(usr)
|
||||
|
||||
/obj/item/device/gps/science
|
||||
icon_state = "gps-s"
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/obj/machinery/computer/telescience
|
||||
name = "telepad control console"
|
||||
name = "\improper Telepad Control Console"
|
||||
desc = "Used to teleport objects to and from the telescience telepad."
|
||||
icon_state = "teleport"
|
||||
var/sending = 1
|
||||
var/obj/machinery/telepad/telepad = null
|
||||
var/temp_msg = "Telescience control console initialized."
|
||||
var/temp_msg = "Telescience control console initialized.<BR>Welcome."
|
||||
|
||||
// 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/power_off
|
||||
|
||||
var/rotation = 0
|
||||
var/angle = 45
|
||||
var/power
|
||||
|
||||
// Based on the power used
|
||||
var/teleport_cooldown = 0
|
||||
var/list/power_options = list(5, 10, 25, 50, 100) //
|
||||
var/teleporting = 0
|
||||
|
||||
/obj/machinery/computer/telescience/New()
|
||||
..()
|
||||
teles_left = rand(8,12)
|
||||
x_off = rand(-10,10)
|
||||
y_off = rand(-10,10)
|
||||
recalibrate()
|
||||
power = power_options[1]
|
||||
initialize()
|
||||
|
||||
/obj/machinery/computer/telescience/initialize()
|
||||
@@ -50,16 +56,39 @@
|
||||
|
||||
/obj/machinery/computer/telescience/interact(mob/user)
|
||||
|
||||
var/t = "<div class='statusDisplay'>[temp_msg]</div>"
|
||||
t += "<A href='?src=\ref[src];setx=1'>Set X</A>"
|
||||
t += "<A href='?src=\ref[src];sety=1'>Set Y</A>"
|
||||
t += "<A href='?src=\ref[src];setz=1'>Set Z</A>"
|
||||
t += "<BR><BR>Current set coordinates:"
|
||||
t += "([x_co ? x_co : "null"], [y_co ? y_co : "null"], [z_co ? z_co : "null"])"
|
||||
t += "<BR><BR><A href='?src=\ref[src];send=1'>Send</A>"
|
||||
var/t = "<div class='statusDisplay'>[temp_msg]</div><BR>"
|
||||
t += "<A href='?src=\ref[src];setrotation=1'>Set Bearing</A>"
|
||||
t += "<div class='statusDisplay'>[rotation]°</div>"
|
||||
t += "<A href='?src=\ref[src];setangle=1'>Set Elevation</A>"
|
||||
t += "<div class='statusDisplay'>[angle]°</div>"
|
||||
t += "<span class='linkOn'>Set Power</span>"
|
||||
t += "<div class='statusDisplay'>"
|
||||
|
||||
for(var/pwr in power_options)
|
||||
if(power == pwr)
|
||||
t += "<span class='linkOn'>[pwr]</span>"
|
||||
continue
|
||||
t += "<A href='?src=\ref[src];setpower=[pwr]'>[pwr]</A>"
|
||||
|
||||
t += "</div>"
|
||||
t += "<A href='?src=\ref[src];setz=1'>Set Sector</A>"
|
||||
t += "<div class='statusDisplay'>[z_co ? z_co : "NULL"]</div>"
|
||||
|
||||
t += "<BR><A href='?src=\ref[src];send=1'>Send</A>"
|
||||
t += " <A href='?src=\ref[src];receive=1'>Receive</A>"
|
||||
t += "<BR><BR><A href='?src=\ref[src];recal=1'>Recalibrate</A>"
|
||||
var/datum/browser/popup = new(user, "telesci", name)
|
||||
t += "<BR><A href='?src=\ref[src];recal=1'>Recalibrate</A>"
|
||||
|
||||
// Information about the last teleport
|
||||
t += "<BR><div class='statusDisplay'>"
|
||||
if(!last_tele_data)
|
||||
t += "No teleport data found."
|
||||
else
|
||||
t += "Source Location: ([last_tele_data.src_x], [last_tele_data.src_y])<BR>"
|
||||
t += "Distance: [last_tele_data.distance]m<BR>"
|
||||
t += "Time: [last_tele_data.time] secs<BR>"
|
||||
t += "</div>"
|
||||
|
||||
var/datum/browser/popup = new(user, "telesci", name, 300, 500)
|
||||
popup.set_content(t)
|
||||
popup.open()
|
||||
return
|
||||
@@ -79,78 +108,125 @@
|
||||
return
|
||||
|
||||
/obj/machinery/computer/telescience/proc/doteleport(mob/user)
|
||||
var/trueX = (x_co + x_off)
|
||||
var/trueY = (y_co + y_off)
|
||||
trueX = Clamp(trueX, 1, world.maxx)
|
||||
trueY = Clamp(trueY, 1, world.maxy)
|
||||
|
||||
if(teleport_cooldown > world.time)
|
||||
temp_msg = "Telepad is recharging power.<BR>Please wait [round((teleport_cooldown - world.time) / 10)] seconds."
|
||||
return
|
||||
|
||||
if(teleporting)
|
||||
temp_msg = "Telepad is in use.<BR>Please wait."
|
||||
return
|
||||
|
||||
if(telepad)
|
||||
|
||||
var/truePower = Clamp(power + power_off, 1, 1000)
|
||||
var/trueRotation = rotation
|
||||
|
||||
var/datum/projectile_data/proj_data = projectile_trajectory(telepad.x, telepad.y, trueRotation, angle, truePower)
|
||||
last_tele_data = proj_data
|
||||
|
||||
var/trueX = Clamp(round(proj_data.dest_x, 1), 1, world.maxx)
|
||||
var/trueY = Clamp(round(proj_data.dest_y, 1), 1, world.maxy)
|
||||
var/spawn_time = round(proj_data.time) * 10
|
||||
|
||||
var/turf/target = locate(trueX, trueY, z_co)
|
||||
var/area/A = get_area(target)
|
||||
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
||||
s.set_up(5, 1, telepad)
|
||||
s.start()
|
||||
flick("pad-beam", telepad)
|
||||
temp_msg = "Teleport successful."
|
||||
investigate_log("[key_name(usr)]/[user] has teleported with Telescience at [trueX],[trueY],[z_co], in [A.name].","telesci")
|
||||
var/sparks = get_turf(target)
|
||||
var/datum/effect/effect/system/spark_spread/y = new /datum/effect/effect/system/spark_spread
|
||||
y.set_up(5, 1, sparks)
|
||||
y.start()
|
||||
var/turf/source = target
|
||||
var/turf/dest = get_turf(telepad)
|
||||
if(sending)
|
||||
source = dest
|
||||
dest = target
|
||||
for(var/atom/movable/ROI in source)
|
||||
if(!ismob(ROI) && ROI.anchored) continue
|
||||
do_teleport(ROI, dest, 0)
|
||||
return
|
||||
return
|
||||
|
||||
if(spawn_time > 15) // 1.5 seconds
|
||||
playsound(telepad.loc, 'sound/weapons/flash.ogg', 25, 1)
|
||||
// Wait depending on the time the projectile took to get there
|
||||
teleporting = 1
|
||||
temp_msg = "Powering up bluespace crystals.<BR>Please wait."
|
||||
|
||||
|
||||
spawn(round(proj_data.time) * 10) // in seconds
|
||||
teleporting = 0
|
||||
teleport_cooldown = world.time + (power * 2)
|
||||
teles_left -= 1
|
||||
|
||||
// use a lot of power
|
||||
use_power(power * 10)
|
||||
|
||||
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
||||
|
||||
s.set_up(5, 1, telepad)
|
||||
s.start()
|
||||
temp_msg = "Teleport successful.<BR>"
|
||||
if(teles_left < 10)
|
||||
temp_msg += "<BR>Calibration required soon."
|
||||
else
|
||||
temp_msg += "Data printed below."
|
||||
investigate_log("[key_name(usr)]/[user] has teleported with Telescience at [trueX],[trueY],[z_co], in [A ? A.name : "null area"].","telesci")
|
||||
var/sparks = get_turf(target)
|
||||
var/datum/effect/effect/system/spark_spread/y = new /datum/effect/effect/system/spark_spread
|
||||
y.set_up(5, 1, sparks)
|
||||
y.start()
|
||||
var/turf/source = target
|
||||
var/turf/dest = get_turf(telepad)
|
||||
if(sending)
|
||||
source = dest
|
||||
dest = target
|
||||
flick("pad-beam", telepad)
|
||||
playsound(telepad.loc, 'sound/weapons/emitter2.ogg', 25, 1)
|
||||
for(var/atom/movable/ROI in source)
|
||||
if(!ismob(ROI) && ROI.anchored) continue
|
||||
do_teleport(ROI, dest, 0)
|
||||
updateDialog()
|
||||
|
||||
// TO DO: add projectile_trajectory to telesci
|
||||
|
||||
/obj/machinery/computer/telescience/proc/teleport(mob/user)
|
||||
if(x_co == null || y_co == null || z_co == null)
|
||||
temp_msg = "Error: set coordinates."
|
||||
if(rotation == null || angle == null || z_co == null)
|
||||
temp_msg = "ERROR!<BR>Set a angle, rotation and sector."
|
||||
return
|
||||
if(x_co < 1 || x_co > 255)
|
||||
if(rotation < 0 || rotation > 360)
|
||||
telefail()
|
||||
temp_msg = "Error: X is less than 1 or greater than 255."
|
||||
temp_msg = "ERROR!<BR>Bearing is less than 0 or greater than 360."
|
||||
return
|
||||
if(y_co < 1 || y_co > 255)
|
||||
if(angle < 1 || angle > 90)
|
||||
telefail()
|
||||
temp_msg = "Error: Y is less than 1 or greater than 255."
|
||||
temp_msg = "ERROR!<BR>Elevation is less than 1 or greater than 90."
|
||||
return
|
||||
if(z_co == 2 || z_co < 1 || z_co > 7)
|
||||
telefail()
|
||||
temp_msg = "Error: Z is less than 1, greater than 7, or equal to 2."
|
||||
temp_msg = "ERROR! Sector is less than 1, <BR>greater than 7, or equal to 2."
|
||||
return
|
||||
if(teles_left > 0)
|
||||
teles_left -= 1
|
||||
doteleport(user)
|
||||
else
|
||||
telefail()
|
||||
temp_msg = "ERROR!<BR>Calibration required."
|
||||
return
|
||||
return
|
||||
|
||||
/obj/machinery/computer/telescience/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
if(href_list["setx"])
|
||||
var/new_x = input("Please input desired X coordinate.", name, x_co) as num
|
||||
if(href_list["setrotation"])
|
||||
var/new_rot = input("Please input desired bearing in degrees.", name, rotation) as num
|
||||
if(..()) // Check after we input a value, as they could've moved after they entered something
|
||||
return
|
||||
x_co = Clamp(new_x, 1, 9999)
|
||||
rotation = Clamp(round(new_rot, 0.1), -9999, 9999)
|
||||
rotation = SimplifyDegrees(rotation)
|
||||
|
||||
if(href_list["sety"])
|
||||
var/new_y = input("Please input desired Y coordinate.", name, y_co) as num
|
||||
if(href_list["setangle"])
|
||||
var/new_angle = input("Please input desired elevation in degrees.", name, angle) as num
|
||||
if(..())
|
||||
return
|
||||
y_co = Clamp(new_y, 1, 9999)
|
||||
angle = Clamp(round(new_angle, 0.1), 1, 9999)
|
||||
|
||||
if(href_list["setpower"])
|
||||
var/pwr = href_list["setpower"]
|
||||
pwr = text2num(pwr)
|
||||
if(pwr != null && pwr in power_options)
|
||||
power = pwr
|
||||
|
||||
if(href_list["setz"])
|
||||
var/new_z = input("Please input desired Z coordinate.", name, z_co) as num
|
||||
var/new_z = input("Please input desired sector.", name, z_co) as num
|
||||
if(..())
|
||||
return
|
||||
z_co = Clamp(new_z, 1, 9999)
|
||||
z_co = Clamp(new_z, 1, 10)
|
||||
|
||||
if(href_list["send"])
|
||||
sending = 1
|
||||
@@ -161,10 +237,12 @@
|
||||
teleport(usr)
|
||||
|
||||
if(href_list["recal"])
|
||||
teles_left = rand(9,12)
|
||||
x_off = rand(-10,10)
|
||||
y_off = rand(-10,10)
|
||||
recalibrate()
|
||||
sparks()
|
||||
temp_msg = "Calibration successful."
|
||||
temp_msg = "NOTICE:<BR>Calibration successful."
|
||||
|
||||
updateDialog()
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/computer/telescience/proc/recalibrate()
|
||||
teles_left = rand(40, 50)
|
||||
power_off = rand(-10, 10)
|
||||
+7
-1
@@ -53,7 +53,13 @@ should be listed in the changelog upon commit tho. Thanks. -->
|
||||
<!-- You can simply add changelogs using AddToChangelog.exe -->
|
||||
|
||||
|
||||
<!-- DO NOT REMOVE OR MOVE THIS COMMENT! THIS MUST BE THE LAST NON-EMPTY LINE BEFORE THE LOGS #ADDTOCHANGELOGMARKER# -->␍␍␍
|
||||
<!-- DO NOT REMOVE OR MOVE THIS COMMENT! THIS MUST BE THE LAST NON-EMPTY LINE BEFORE THE LOGS #ADDTOCHANGELOGMARKER# -->␍␍<div class='commit sansserif'>
|
||||
<h2 class='date'>9 November 2013</h2>
|
||||
<h3 class='author'>Giacom, SuperSayu, Iamgoofball, VistaPOWA updated:</h3>
|
||||
<ul class='changes bgimages16'>
|
||||
<li class='rscadd'>Added Telescience! I would explain how it works but then it wouldn't be very sciencey! Have fun figuring it out. The room is near Xenobiology.</li>
|
||||
</ul>
|
||||
</div>␍
|
||||
|
||||
<div class='commit sansserif'>
|
||||
<h2 class='date'>6 November 2013</h2>
|
||||
|
||||
@@ -4736,7 +4736,7 @@
|
||||
"bNd" = (/obj/structure/closet,/turf/simulated/floor/plating,/area/maintenance/asmaint2)
|
||||
"bNe" = (/obj/structure/rack{dir = 1},/obj/item/clothing/suit/fire/firefighter,/obj/item/weapon/tank/oxygen,/obj/item/clothing/mask/gas,/obj/item/weapon/extinguisher,/obj/item/clothing/head/hardhat/red,/obj/item/clothing/glasses/meson,/turf/simulated/floor/plating,/area/maintenance/asmaint2)
|
||||
"bNf" = (/obj/item/device/radio/beacon,/turf/simulated/floor/engine,/area/toxins/telesci)
|
||||
"bNg" = (/obj/structure/table/reinforced,/obj/machinery/atmospherics/unary/vent_pump{dir = 1; on = 1},/obj/item/weapon/clipboard,/turf/simulated/floor{icon_state = "white"},/area/toxins/telesci)
|
||||
"bNg" = (/obj/structure/table/reinforced,/obj/machinery/atmospherics/unary/vent_pump{dir = 1; on = 1},/obj/item/weapon/clipboard,/obj/item/weapon/book/manual/telescience,/turf/simulated/floor{icon_state = "white"},/area/toxins/telesci)
|
||||
"bNh" = (/obj/structure/closet/emcloset,/turf/simulated/floor/plating,/area/maintenance/asmaint2)
|
||||
"bNi" = (/obj/structure/grille,/obj/structure/window/reinforced{dir = 4},/obj/structure/window/reinforced{dir = 8},/obj/machinery/door/poddoor/preopen{id = "telelab"; name = "test chamber blast door"},/turf/simulated/floor/plating,/area/toxins/telesci)
|
||||
"bNj" = (/obj/machinery/atmospherics/pipe/simple/scrubbers/hidden,/obj/structure/cable{d1 = 1; d2 = 2; icon_state = "1-2"},/turf/simulated/floor{icon_state = "white"},/area/toxins/telesci)
|
||||
|
||||
Reference in New Issue
Block a user