forked from shiptest-ss13/Shiptest
-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1045 from Discozavisim/bruh
смешная овермапочка
- Loading branch information
Showing
24 changed files
with
1,144 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,86 @@ | ||
TIMER_SUBSYSTEM_DEF(overmap_movement) | ||
name = "Overmap Movement" | ||
priority = FIRE_PRIORITY_OVERMAP_MOVEMENT | ||
|
||
// [CELADON-ADD] - OVERMAP COLLISION - Это вагабонд насрал | ||
|
||
/proc/get_relative_motion(var/A, var/B) | ||
var/mins = -1 | ||
if(A > 0 && B > 0) | ||
return B-A | ||
if(A < 0 && B > 0) | ||
return B*mins + A | ||
if(A > 0 && B < 0) | ||
return A*mins + B | ||
if(A < 0 && B < 0) | ||
return -(B*mins - A*mins) | ||
if(A == 0 && B != 0) | ||
return B | ||
if(A != 0 && B == 0) | ||
return -A | ||
else | ||
return 0 | ||
|
||
/proc/calculate_cpa(datum/overmap/ship/controlled/A, datum/overmap/ship/controlled/B, info = FALSE) | ||
var/cpa = -1 | ||
var/tcpa = -1 | ||
|
||
var/bearing = get_angle_raw(A.token.x, A.token.y, A.token.pixel_w, A.token.pixel_z, B.token.x, B.token.y, B.token.pixel_w, B.token.pixel_z) | ||
var/relative_motion_angle = get_angle_raw(B.speed_x * 60 SECONDS, B.speed_y * 60 SECONDS, 0, 0, -A.speed_x * 60 SECONDS, -A.speed_y * 60 SECONDS, 0, 0) | ||
if(max(closer_angle_difference(SIMPLIFY_DEGREES(bearing+180), relative_motion_angle), -closer_angle_difference(SIMPLIFY_DEGREES(bearing+180), relative_motion_angle)) >= 90) | ||
return list("cpa" = "--", "tcpa" = "--", "brg" = round(SIMPLIFY_DEGREES(bearing-A.bow_heading))) | ||
var/hypotenosis = get_pixel_distance(A.token, B.token) | ||
var/alpha = max(SIMPLIFY_DEGREES(relative_motion_angle-SIMPLIFY_DEGREES(bearing+180)), -SIMPLIFY_DEGREES(relative_motion_angle-SIMPLIFY_DEGREES(bearing+180))) | ||
cpa = sin(alpha)*hypotenosis //Smoothing the distance for sure | ||
cpa = max(cpa, -cpa) | ||
|
||
var/relative_motion_x = get_relative_motion(A.speed_x, B.speed_x) | ||
var/relative_motion_y = get_relative_motion(A.speed_y, B.speed_y) | ||
|
||
var/distance_in_x = (A.token.x*32+A.token.pixel_w)-(B.token.x*32+B.token.pixel_w) | ||
var/distance_in_y = (A.token.y*32+A.token.pixel_z)-(B.token.y*32+B.token.pixel_z) | ||
|
||
var/tcpa_by_x = -1 | ||
var/tcpa_by_y = -1 | ||
if(relative_motion_x != 0) | ||
tcpa_by_x = (distance_in_x/32)/relative_motion_x | ||
if(relative_motion_y != 0) | ||
tcpa_by_y = (distance_in_y/32)/relative_motion_y | ||
|
||
if(tcpa_by_x != -1 && tcpa_by_y != -1) | ||
tcpa = (max(tcpa_by_x, -tcpa_by_x)+max(tcpa_by_y, -tcpa_by_y))/2 | ||
else | ||
tcpa = max(tcpa_by_x, tcpa_by_y) | ||
|
||
if(!info) | ||
if(cpa != -1 && tcpa != -1) | ||
if(tcpa/SSovermap_stuff.wait <= 5 && cpa <= 8) | ||
var/arpdequeue_pointer = 0 | ||
while (arpdequeue_pointer++ < A.helms.len) | ||
var/obj/machinery/computer/helm/a = A.helms[arpdequeue_pointer] | ||
a.say("Proximity alarm! Possible collision situation.") | ||
playsound(a, 'sound/machines/engine_alert1.ogg', 50, FALSE) | ||
if(get_pixel_distance(A.token, B.token) <= 4 && cpa != -1 && (A.get_speed() != 0 || B.get_speed() != 0)) | ||
var/arpdequeue_pointer = 0 | ||
while (arpdequeue_pointer++ < A.helms.len) | ||
var/obj/machinery/computer/helm/a = A.helms[arpdequeue_pointer] | ||
a.say("Collision impact with vessel \"[B.name]\".") | ||
playsound(a, 'sound/machines/engine_alert2.ogg', 50, FALSE) | ||
var/opposite_x = sin(SIMPLIFY_DEGREES(bearing+180))*(B.shuttle_port.turf_count/A.shuttle_port.turf_count)*max(0.002, max(B.speed_x, -B.speed_x)) | ||
var/opposite_y = cos(SIMPLIFY_DEGREES(bearing+180))*(B.shuttle_port.turf_count/A.shuttle_port.turf_count)*max(0.002, max(B.speed_y, -B.speed_y)) | ||
if(!(A.datum_flags & DF_ISPROCESSING)) | ||
A.adjust_speed(-A.speed_x/2 + opposite_x, -A.speed_y/2 + opposite_y) | ||
else | ||
A.vector_to_add = list("x" = -A.speed_x/2 + opposite_x, "y" = -A.speed_y/2 + opposite_y) | ||
|
||
if(!(B.datum_flags & DF_ISPROCESSING)) | ||
B.adjust_speed(-B.speed_x/2 + opposite_x, -B.speed_y/2 + opposite_y) | ||
else | ||
B.vector_to_add = list("x" = -B.speed_x/2 + -opposite_x, "y" = -B.speed_y/2 + -opposite_y) | ||
|
||
spawn_meteors_alt(round(A.get_speed()+B.get_speed())+1, list(/obj/effect/meteor/invisible), A.shuttle_port.get_virtual_level(), angle2dir_cardinal(SIMPLIFY_DEGREES((bearing+90+A.bow_heading)))) | ||
spawn_meteors_alt(round(A.get_speed()+B.get_speed())+1, list(/obj/effect/meteor/invisible), B.shuttle_port.get_virtual_level(), angle2dir_cardinal(SIMPLIFY_DEGREES((bearing+270+B.bow_heading)))) | ||
|
||
return list("cpa" = round(cpa), "tcpa" = round(tcpa/10), "brg" = round(SIMPLIFY_DEGREES(bearing-A.bow_heading))) | ||
|
||
// [/CELADON-ADD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// [CELADON-ADD] - OVERMAP PHYSICS - Это вагабонд насрал | ||
|
||
SUBSYSTEM_DEF(overmap_stuff) | ||
name = "Overmap Stuff" | ||
wait = 10 | ||
init_order = INIT_ORDER_OVERMAP | ||
flags = SS_KEEP_TIMING|SS_NO_TICK_CHECK | ||
runlevels = RUNLEVEL_SETUP | RUNLEVEL_GAME | ||
|
||
var/list/controlled_ships | ||
|
||
/datum/controller/subsystem/overmap_stuff/get_metrics() | ||
. = ..() | ||
var/list/cust = list() | ||
cust["controlled_ships"] = length(controlled_ships) | ||
.["custom"] = cust | ||
|
||
/datum/controller/subsystem/overmap_stuff/fire() | ||
controlled_ships = SSovermap.controlled_ships | ||
for(var/datum/overmap/ship/i in controlled_ships) | ||
if(QDELING(i) || i.docked_to) | ||
i.speed_x = 0 | ||
i.speed_y = 0 | ||
if(!i.docked_to) | ||
i.check_proximity() | ||
i.x_pixels_moved += i.speed_x*(30 SECONDS) | ||
i.y_pixels_moved += i.speed_y*(30 SECONDS) | ||
|
||
if(i.x != i.position_to_move["x"] || i.y != i.position_to_move["y"]) | ||
i.not_tick_move(i.position_to_move["x"]-i.x, i.position_to_move["y"]-i.y) | ||
i.token.update_screen() | ||
var/list/smooth_anim = list("x" = round(i.x_pixels_moved), "y" = round(i.y_pixels_moved)) | ||
|
||
if(i.x_pixels_moved >= 16) | ||
i.x_pixels_moved = i.x_pixels_moved-32 | ||
i.position_to_move["x"] = i.x+1 | ||
if(i.x_pixels_moved <= -16) | ||
i.x_pixels_moved = i.x_pixels_moved+32 | ||
i.position_to_move["x"] = i.x-1 | ||
if(i.y_pixels_moved >= 16) | ||
i.y_pixels_moved = i.y_pixels_moved-32 | ||
i.position_to_move["y"] = i.y+1 | ||
if(i.y_pixels_moved <= -16) | ||
i.y_pixels_moved = i.y_pixels_moved+32 | ||
i.position_to_move["y"] = i.y-1 | ||
|
||
if(i.token) | ||
i.token.pixel_w = i.last_anim["x"] | ||
i.token.pixel_z = i.last_anim["y"] | ||
|
||
animate(i.token, pixel_w = smooth_anim["x"], pixel_z = smooth_anim["y"], wait, 1) | ||
if(i.token.ship_image) | ||
if(i.token.ship_image.loc != i.token.loc) | ||
i.token.ship_image.forceMove(i.token.loc) | ||
i.token.ship_image.pixel_w = i.last_anim["x"] | ||
i.token.ship_image.pixel_z = i.last_anim["y"] | ||
animate(i.token.ship_image, pixel_w = smooth_anim["x"], pixel_z = smooth_anim["y"], wait, 1) | ||
if(i.token.move_vec) | ||
if(i.token.move_vec.loc != i.token.loc) | ||
i.token.move_vec.forceMove(i.token.loc) | ||
i.token.move_vec.pixel_w = i.last_anim["x"] | ||
i.token.move_vec.pixel_z = i.last_anim["y"] | ||
animate(i.token.move_vec, pixel_w = smooth_anim["x"], pixel_z = smooth_anim["y"], wait, 1) | ||
|
||
if(i.speed_x != 0 || i.speed_y != 0) | ||
if(i.skiptickfortrail < 4) | ||
i.skiptickfortrail = i.skiptickfortrail+1 | ||
else | ||
i.skiptickfortrail = 0 | ||
i.update_trails() | ||
else | ||
i.hide_trails() | ||
|
||
i.last_anim["x"] = round(i.x_pixels_moved) | ||
i.last_anim["y"] = round(i.y_pixels_moved) | ||
|
||
SUBSYSTEM_DEF(overmap_rotation_velocity) | ||
name = "Overmap Rotation Velocity" | ||
wait = 4 //Пиздец немного но сойдёт | ||
init_order = INIT_ORDER_OVERMAP | ||
flags = SS_KEEP_TIMING|SS_NO_TICK_CHECK | ||
runlevels = RUNLEVEL_SETUP | RUNLEVEL_GAME | ||
|
||
var/list/controlled_ships | ||
|
||
/datum/controller/subsystem/overmap_rotation_velocity/get_metrics() | ||
. = ..() | ||
var/list/cust = list() | ||
cust["controlled_ships"] = length(controlled_ships) | ||
.["custom"] = cust | ||
|
||
/datum/controller/subsystem/overmap_rotation_velocity/fire() | ||
controlled_ships = SSovermap.controlled_ships | ||
for(var/datum/overmap/ship/i in controlled_ships) | ||
if(!i.docked_to) | ||
if(i.token) | ||
if(i.token.ship_image) | ||
i.token.ship_image.alpha = 255 | ||
if(i.token.move_vec) | ||
i.token.move_vec.alpha = 255 | ||
if(i.rotating == 1) | ||
i.bow_heading = SIMPLIFY_DEGREES(i.bow_heading+i.rotation_velocity) | ||
i.rotation_velocity = min(90, i.rotation_velocity+1) | ||
if(i.rotating == -1) | ||
i.bow_heading = SIMPLIFY_DEGREES(i.bow_heading+i.rotation_velocity) | ||
i.rotation_velocity = max(-90, i.rotation_velocity-1) | ||
|
||
var/matrix/N = matrix() | ||
N.Turn(i.bow_heading) | ||
if(i.token.ship_image) | ||
i.token.ship_image.transform = N | ||
else | ||
if(i.token) | ||
if(i.token.ship_image) | ||
i.token.ship_image.alpha = 0 | ||
if(i.token.move_vec) | ||
i.token.move_vec.alpha = 0 | ||
|
||
// [/CELADON-ADD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.