Skip to content

Commit

Permalink
ываыв
Browse files Browse the repository at this point in the history
  • Loading branch information
Anorak2024 committed Sep 9, 2024
1 parent a195a20 commit 2aebba5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,38 @@
START_PROCESSING(SSprocessing, src)

/mob/living/simple_animal/hostile/plant/pea_shooter/proc/rotate_to(mob/living/target)
setDir(get_dir(src, target))
var/dx = target.x - x
var/dy = target.y - y
var/bigger_X = abs(dx) >= abs(dy) * 2.5
var/bigger_Y = abs(dy) >= abs(dx) * 2.5
if (dx > 0 && bigger_X)
setDir(EAST)
else if (dy > 0 && bigger_Y)
setDir(NORTH)
else if (dx < 0 && bigger_X)
setDir(WEST)
else if (dy < 0 && bigger_Y)
setDir(SOUTH)
else if (dx > 0 && dy > 0)
setDir(NORTHEAST)
else if (dx < 0 && dy > 0)
setDir(NORTHWEST)
else if (dx < 0 && dy < 0)
setDir(SOUTHWEST)
else
setDir(SOUTHEAST)

/mob/living/simple_animal/hostile/plant/pea_shooter/proc/fire(mob/living/target)
if (!target)
return
SEND_SIGNAL(src, COMSIG_GUN_FIRED, src, target)
rotate_to(target)
icon_state = "peagun-attack"
chambered.fire(target = target, user = src, firer_source_atom = src)
sleep(2)
SEND_SIGNAL(src, COMSIG_GUN_FIRED, src, target)
chambered.fire(target = target, user = src, firer_source_atom = src, params = "y_of_shot=0.6")
chambered = new bullet_type()
sleep(4)
sleep(2)
rotate_to(target)
icon_state = "peagun-static"

/mob/living/simple_animal/hostile/plant/pea_shooter/process()
Expand Down
11 changes: 10 additions & 1 deletion code/modules/projectiles/firing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@

if(params)
var/list/mouse_control = params2list(params)
if(mouse_control["y_of_shot"]) // Протестировать этот иф
var/y_of_shot = text2num(mouse_control["y_of_shot"])
pixel_y = world.icon_size * y_of_shot
var/angle = ATAN2(y * world.icon_size - (oy * world.icon_size + (y_of_shot - 0.5) * orld.icon_size), x * world.icon_size - ox * world.icon_size)

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oy"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "orld"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "ox"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "ox"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oy"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "orld"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oy"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "orld"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oy"

Check failure on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "orld"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"

Check warning on line 96 in code/modules/projectiles/firing.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "icon_size"
Angle = angle
if(mouse_control["icon-x"])
p_x = text2num(mouse_control["icon-x"])
if(mouse_control["icon-y"])
Expand All @@ -109,8 +114,12 @@
//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 = getviewsize(user.client.view)

var/y_of_shot = 0.5
if(mouse_control["y_of_shot"])
y_of_shot = text2num(mouse_control["y_of_shot"])
pixel_y = world.icon_size * y_of_shot
var/ox = round((screenview[1] * world.icon_size) / 2) - user.client.pixel_x //"origin" x
var/oy = round((screenview[2] * world.icon_size) / 2) - user.client.pixel_y //"origin" y
var/oy = round((screenview[2] * world.icon_size) * y_of_shot) - user.client.pixel_y //"origin" y
var/angle = ATAN2(y - oy, x - ox)
Angle = angle
if(spread)
Expand Down

0 comments on commit 2aebba5

Please sign in to comment.