mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
BTW I USE (FIXED) ARC
This commit is contained in:
@@ -207,12 +207,14 @@
|
||||
animate(src, pixel_x = trajectory.return_px(), pixel_y = trajectory.return_py(), time = 1, flags = ANIMATION_END_NOW)
|
||||
Range()
|
||||
|
||||
/obj/item/projectile/Crossed(atom/movable/AM) //A mob moving on a tile with a projectile is hit by it.
|
||||
..()
|
||||
if(isliving(AM) && !(pass_flags & PASSMOB))
|
||||
var/mob/living/L = AM
|
||||
if(can_hit_target(L, permutated, (AM == original)))
|
||||
Bump(AM)
|
||||
//sets the click point of the projectile using mouse input params
|
||||
/obj/item/projectile/proc/set_clickpoint(var/params)
|
||||
var/list/mouse_control = params2list(params)
|
||||
if(mouse_control["icon-x"])
|
||||
p_x = text2num(mouse_control["icon-x"])
|
||||
if(mouse_control["icon-y"])
|
||||
p_y = text2num(mouse_control["icon-y"])
|
||||
<<<<<<< HEAD
|
||||
|
||||
/obj/item/projectile/proc/process_homing() //may need speeding up in the future performance wise.
|
||||
if(!homing_target)
|
||||
@@ -317,21 +319,52 @@
|
||||
START_PROCESSING(SSprojectiles, src)
|
||||
pixel_move(1, FALSE) //move it now!
|
||||
|
||||
/obj/item/projectile/Move(atom/newloc, dir = NONE)
|
||||
. = ..()
|
||||
if(.)
|
||||
if(temporary_unstoppable_movement)
|
||||
temporary_unstoppable_movement = FALSE
|
||||
DISABLE_BITFIELD(movement_type, UNSTOPPABLE)
|
||||
if(fired && can_hit_target(original, permutated, TRUE))
|
||||
Bump(original)
|
||||
=======
|
||||
if(mouse_control["screen-loc"])
|
||||
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
|
||||
var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",")
|
||||
|
||||
//Split X+Pixel_X up into list(X, Pixel_X)
|
||||
var/list/screen_loc_X = splittext(screen_loc_params[1],":")
|
||||
|
||||
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
|
||||
var/list/screen_loc_Y = splittext(screen_loc_params[2],":")
|
||||
var/x = text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32
|
||||
var/y = text2num(screen_loc_Y[1]) * 32 + text2num(screen_loc_Y[2]) - 32
|
||||
|
||||
//Calculate the "resolution" of screen based on client's view and world's icon size. This will work if the user can view more tiles than average.
|
||||
var/list/screenview = user.client? getviewsize(user.client.view) : world.view
|
||||
var/screenviewX = screenview[1] * world.icon_size
|
||||
var/screenviewY = screenview[2] * world.icon_size
|
||||
|
||||
var/ox = round(screenviewX/2) - user.client.pixel_x //"origin" x
|
||||
var/oy = round(screenviewY/2) - user.client.pixel_y //"origin" y
|
||||
angle = ATAN2(y - oy, x - ox)
|
||||
return list(angle, p_x, p_y)
|
||||
|
||||
/obj/item/projectile/proc/redirect(x, y, starting, source)
|
||||
old_style_target(locate(x, y, z), starting? get_turf(starting) : get_turf(source))
|
||||
|
||||
/obj/item/projectile/proc/old_style_target(atom/target, atom/source)
|
||||
if(!source)
|
||||
source = get_turf(src)
|
||||
starting = get_turf(source)
|
||||
>>>>>>> f083fba... Merge pull request #5977 from Neerti/btw_i_use_fixed_arc
|
||||
original = target
|
||||
def_zone = target_zone
|
||||
|
||||
/obj/item/projectile/proc/after_z_change(atom/olcloc, atom/newloc)
|
||||
|
||||
/obj/item/projectile/proc/before_z_change(atom/oldloc, atom/newloc)
|
||||
|
||||
/obj/item/projectile/proc/before_move()
|
||||
return
|
||||
<<<<<<< HEAD
|
||||
//called to launch a projectile from a gun
|
||||
/obj/item/projectile/proc/launch_from_gun(atom/target, mob/user, obj/item/weapon/gun/launcher, var/target_zone, var/x_offset=0, var/y_offset=0)
|
||||
if(user == target) //Shooting yourself
|
||||
user.bullet_act(src, target_zone)
|
||||
on_impact(user)
|
||||
qdel(src)
|
||||
return 0
|
||||
|
||||
/obj/item/projectile/proc/after_move()
|
||||
return
|
||||
@@ -382,8 +415,14 @@
|
||||
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
|
||||
var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",")
|
||||
|
||||
//Split X+Pixel_X up into list(X, Pixel_X)
|
||||
var/list/screen_loc_X = splittext(screen_loc_params[1],":")
|
||||
//Called when the projectile intercepts a mob. Returns 1 if the projectile hit the mob, 0 if it missed and should keep flying.
|
||||
/obj/item/projectile/proc/attack_mob(var/mob/living/target_mob, var/distance, var/miss_modifier=0)
|
||||
if(!istype(target_mob))
|
||||
=======
|
||||
/obj/item/projectile/proc/generate_hitscan_tracers(cleanup = TRUE, duration = 5, impacting = TRUE)
|
||||
if(!length(beam_segments))
|
||||
>>>>>>> f083fba... Merge pull request #5977 from Neerti/btw_i_use_fixed_arc
|
||||
return
|
||||
|
||||
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
|
||||
var/list/screen_loc_Y = splittext(screen_loc_params[2],":")
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
/obj/item/projectile/arc
|
||||
name = "arcing shot"
|
||||
icon_state = "fireball" // WIP
|
||||
speed = 2 // Travel a bit slower, to really sell the arc visuals.
|
||||
movement_type = UNSTOPPABLE
|
||||
plane = ABOVE_PLANE // Since projectiles are 'in the air', they might visually overlap mobs while in flight, so the projectile needs to be above their plane.
|
||||
var/target_distance = null // How many tiles the impact site is.
|
||||
var/fired_dir = null // Which direction was the projectile fired towards. Needed to invert the projectile turning based on if facing left or right.
|
||||
var/distance_to_fly = null // How far, in pixels, to fly for. Will call on_range() when this is passed.
|
||||
var/visual_y_offset = -16 // Adjusts how high the projectile and its shadow start, visually. This is so the projectile and shadow align with the center of the tile.
|
||||
var/projectile_speed_modifier = 0.5 // Slows it down to make the arcing more noticable, and improve pixel calculation accuracy.
|
||||
var/obj/effect/projectile_shadow/shadow = null // Visual indicator for the projectile's 'true' position. Needed due to being bound to two dimensions in reality.
|
||||
|
||||
/obj/item/projectile/arc/Bump()
|
||||
@@ -27,6 +28,14 @@
|
||||
QDEL_NULL(shadow)
|
||||
return ..()
|
||||
|
||||
<<<<<<< HEAD
|
||||
/obj/item/projectile/arc/Bump(atom/A, forced=0)
|
||||
return 0
|
||||
// if(get_turf(src) != original)
|
||||
// return 0
|
||||
// else
|
||||
// return ..()
|
||||
|
||||
// This is a test projectile in the sense that its testing the code to make sure it works,
|
||||
// as opposed to a 'can I hit this thing' projectile.
|
||||
/obj/item/projectile/arc/test/on_impact(turf/T)
|
||||
@@ -80,6 +89,78 @@
|
||||
|
||||
// Update our shadow.
|
||||
shadow.forceMove(loc)
|
||||
=======
|
||||
|
||||
/obj/item/projectile/arc/proc/calculate_initial_pixel_distance(atom/user, atom/target)
|
||||
var/datum/point/A = new(user)
|
||||
var/datum/point/B = new(target)
|
||||
|
||||
// Set the pixel offsets if they exist.
|
||||
A.x += (p_x - 16)
|
||||
A.y += (p_y - 16)
|
||||
|
||||
return pixel_length_between_points(A, B)
|
||||
|
||||
/obj/item/projectile/arc/proc/distance_flown()
|
||||
var/datum/point/current_point = new(src)
|
||||
var/datum/point/starting_point = new(starting)
|
||||
return pixel_length_between_points(current_point, starting_point)
|
||||
|
||||
/obj/item/projectile/arc/on_range()
|
||||
if(loc)
|
||||
on_impact(loc)
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/projectile/arc/launch_projectile(atom/target, target_zone, mob/user, params, angle_override, forced_spread = 0)
|
||||
fired_dir = get_dir(user, target) // Used to determine if the projectile should turn in the air.
|
||||
distance_to_fly = calculate_initial_pixel_distance(user, target) // Calculates how many pixels to travel before hitting the ground.
|
||||
..() // Does the actual launching. The projectile will be out after this.
|
||||
|
||||
// For legacy.
|
||||
/obj/item/projectile/arc/old_style_target(atom/target, atom/source)
|
||||
..()
|
||||
fired_dir = get_dir(source, target)
|
||||
distance_to_fly = calculate_initial_pixel_distance(source, target)
|
||||
|
||||
|
||||
/obj/item/projectile/arc/fire(angle, atom/direct_target)
|
||||
..() // The trajectory must exist for set_pixel_speed() to work.
|
||||
set_pixel_speed(projectile_speed_modifier) // Slows it down and makes the distance checking more accurate.
|
||||
|
||||
/obj/item/projectile/arc/pixel_move(trajectory_multiplier, hitscanning = FALSE)
|
||||
// Do the other important stuff first.
|
||||
..(trajectory_multiplier, hitscanning)
|
||||
|
||||
// Test to see if its time to 'hit the ground'.
|
||||
var/pixels_flown = distance_flown()
|
||||
|
||||
if(pixels_flown >= distance_to_fly)
|
||||
on_range() // This will also cause the projectile to be deleted.
|
||||
|
||||
else
|
||||
// Handle visual projectile turning in flight.
|
||||
var/arc_progress = between(0, pixels_flown / distance_to_fly, 1)
|
||||
var/new_visual_degree = LERP(45, 135, arc_progress)
|
||||
|
||||
if(fired_dir & EAST)
|
||||
adjust_rotation(new_visual_degree)
|
||||
else if(fired_dir & WEST)
|
||||
adjust_rotation(-new_visual_degree)
|
||||
|
||||
// Now for the fake height.
|
||||
var/arc_max_pixel_height = distance_to_fly / 2
|
||||
var/sine_position = arc_progress * 180
|
||||
var/pixel_z_position = (arc_max_pixel_height * sin(sine_position)) + visual_y_offset
|
||||
animate(src, pixel_z = pixel_z_position, time = 1, flags = ANIMATION_END_NOW)
|
||||
|
||||
// Update our shadow.
|
||||
if(shadow)
|
||||
shadow.forceMove(loc)
|
||||
shadow.pixel_x = pixel_x
|
||||
shadow.pixel_y = pixel_y + visual_y_offset
|
||||
|
||||
>>>>>>> f083fba... Merge pull request #5977 from Neerti/btw_i_use_fixed_arc
|
||||
|
||||
/obj/effect/projectile_shadow
|
||||
name = "shadow"
|
||||
@@ -87,11 +168,18 @@
|
||||
icon = 'icons/obj/projectiles.dmi'
|
||||
icon_state = "arc_shadow"
|
||||
anchored = TRUE
|
||||
animate_movement = 0 // Just like the projectile it's following.
|
||||
|
||||
//////////////
|
||||
// Subtypes
|
||||
//////////////
|
||||
|
||||
// This is a test projectile in the sense that its testing the code to make sure it works,
|
||||
// as opposed to a 'can I hit this thing' projectile.
|
||||
/obj/item/projectile/arc/test/on_impact(turf/T)
|
||||
new /obj/effect/explosion(T)
|
||||
T.color = "#FF0000"
|
||||
|
||||
// Generic, Hivebot related
|
||||
/obj/item/projectile/arc/blue_energy
|
||||
name = "energy missile"
|
||||
@@ -99,6 +187,10 @@
|
||||
damage = 15
|
||||
damage_type = BURN
|
||||
|
||||
/obj/item/projectile/arc/blue_energy/on_impact(turf/T)
|
||||
for(var/mob/living/L in T)
|
||||
attack_mob(L) // Everything on the turf it lands gets hit.
|
||||
|
||||
// Fragmentation arc shot
|
||||
/obj/item/projectile/arc/fragmentation
|
||||
name = "fragmentation shot"
|
||||
@@ -125,11 +217,9 @@
|
||||
|
||||
/obj/item/projectile/arc/emp_blast/on_impact(turf/T)
|
||||
empulse(T, 2, 4, 7, 10) // Normal EMP grenade.
|
||||
return ..()
|
||||
|
||||
/obj/item/projectile/arc/emp_blast/weak/on_impact(turf/T)
|
||||
empulse(T, 1, 2, 3, 4) // Sec EMP grenade.
|
||||
return ..()
|
||||
|
||||
// Radiation arc shot
|
||||
/obj/item/projectile/arc/radioactive
|
||||
@@ -139,4 +229,4 @@
|
||||
var/rad_power = 50
|
||||
|
||||
/obj/item/projectile/arc/radioactive/on_impact(turf/T)
|
||||
radiation_repository.radiate(T, rad_power)
|
||||
radiation_repository.radiate(T, rad_power)
|
||||
|
||||
Reference in New Issue
Block a user