BTW I USE (FIXED) ARC

This commit is contained in:
Anewbe
2019-02-21 12:49:00 -06:00
committed by Novacat
parent e5fdafd56e
commit 38c4b88ded
4 changed files with 179 additions and 26 deletions

View File

@@ -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)