Skip to content

Commit

Permalink
Merge pull request #1045 from Discozavisim/bruh
Browse files Browse the repository at this point in the history
смешная овермапочка
  • Loading branch information
MysticalFaceLesS authored Oct 17, 2024
2 parents 723233e + be2bb88 commit 5c1de22
Show file tree
Hide file tree
Showing 24 changed files with 1,144 additions and 217 deletions.
83 changes: 83 additions & 0 deletions code/controllers/subsystem/overmap_move.dm
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]
119 changes: 119 additions & 0 deletions code/controllers/subsystem/overmap_stuff.dm
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]
32 changes: 31 additions & 1 deletion code/game/gamemodes/meteor/meteors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,27 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event
for(var/i = 0; i < number; i++)
spawn_meteor(meteortypes)

/proc/spawn_meteor(list/meteortypes, datum/virtual_level/vlevel, padding = MAP_EDGE_PAD)
// [CELADON-ADD] - OVERMAP COLLISION - Это вагабонд насрал

/proc/spawn_meteors_alt(number = 10, list/meteortypes, port, dirc)
for(var/i = 0; i < number; i++)
spawn_meteor(meteortypes, port, 0, dirc)

// [/CELADON-ADD]

// [CELADON-EDIT] - OVERMAP COLLISION - Это вагабонд насрал
// /proc/spawn_meteor(list/meteortypes, datum/virtual_level/vlevel, padding = MAP_EDGE_PAD)
/proc/spawn_meteor(list/meteortypes, datum/virtual_level/vlevel, padding = MAP_EDGE_PAD, direc = "none")
// [/CELADON-EDIT]
var/turf/pickedstart
var/turf/pickedgoal
var/max_i = 10//number of tries to spawn meteor.
while(!isspaceturf(pickedstart))
var/startSide = pick(GLOB.cardinals)
// [CELADON-ADD] - OVERMAP COLLISION - Это вагабонд насрал
if(direc != "none")
startSide = direc
// [/CELADON-ADD]
pickedstart = vlevel.get_side_turf(startSide, padding)
pickedgoal = vlevel.get_side_turf(REVERSE_DIR(startSide), padding)
max_i--
Expand Down Expand Up @@ -228,6 +243,21 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event
..()
explosion(src.loc, 1, 2, 3, 4, 0)

// [CELADON-ADD] - OVERMAP COLLISION - Это вагабонд насрал
//Invisible
/obj/effect/meteor/invisible
name = "G-Imact"
alpha = 0
hits = 6
heavy = 1
dropamt = 4
threat = 10

/obj/effect/meteor/invisible/meteor_effect()
..()
explosion(src.loc, 1, 2, 3, 4, 0)
// [/CELADON-ADD]

//Flaming meteor
/obj/effect/meteor/flaming
name = "flaming meteor"
Expand Down
35 changes: 35 additions & 0 deletions code/modules/overmap/_overmap_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,44 @@
/// The icon state the token will be set to on init.
var/token_icon_state = "object"

// [CELADON-ADD] - OVERMAP SENSORS - Это вагабонд насрал
var/sensor_range = 4
// [/CELADON-ADD]

/// The current docking ticket of this object, if any
var/datum/docking_ticket/current_docking_ticket

// [CELADON-ADD] - OVERMAP STUFF - Это вагабонд насрал
/obj/overmap
var/skip_alarm = 0

/proc/get_pixel_distance(atom/A, atom/B)
var/x_dist = 0
var/y_dist = 0

if(A.x < B.x)
x_dist = (B.x-A.x)*32-A.pixel_w+B.pixel_w
else if(A.x > B.x)
x_dist = (A.x-B.x)*32+A.pixel_w-B.pixel_w
else
if(A.pixel_w < B.pixel_w)
x_dist = B.pixel_w-A.pixel_w
else if(A.pixel_w > B.pixel_w)
x_dist = A.pixel_w-B.pixel_w

if(A.y < B.y)
y_dist = (B.y-A.y)*32-A.pixel_z+B.pixel_z
else if(A.y > B.y)
y_dist = (A.y-B.y)*32+A.pixel_z-B.pixel_z
else
if(A.pixel_z < B.pixel_z)
y_dist = B.pixel_z-A.pixel_z
else if(A.pixel_z > B.pixel_z)
y_dist = A.pixel_z-B.pixel_z

return abs(x_dist)+abs(y_dist)
// [/CELADON-ADD]

/datum/overmap/New(position, ...)
SHOULD_NOT_OVERRIDE(TRUE) // Use [/datum/overmap/proc/Initialize] instead.
if(!position)
Expand Down
Loading

0 comments on commit 5c1de22

Please sign in to comment.