-
-
Notifications
You must be signed in to change notification settings - Fork 553
/
Copy path_firing.dm
100 lines (90 loc) · 3.29 KB
/
_firing.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/obj/item/ammo_casing/proc/fire_casing(atom/target, mob/living/user, params, distro, quiet, zone_override, spread, atom/fired_from, misfire = FALSE)
distro += variance
var/targloc = get_turf(target)
ready_proj(target, user, quiet, zone_override, fired_from, misfire)
if(pellets == 1)
if(distro) //We have to spread a pixel-precision bullet. throw_proj was called before so angles should exist by now...
if(randomspread)
spread = round((rand() - 0.5) * distro)
else //Smart spread
spread = round(1 - 0.5) * distro
if(!throw_proj(target, targloc, user, params, spread, fired_from))
return FALSE
else
if(isnull(BB))
return FALSE
AddComponent(/datum/component/pellet_cloud, projectile_type, pellets)
SEND_SIGNAL(src, COMSIG_PELLET_CLOUD_INIT, target, user, fired_from, randomspread, spread, zone_override, params, distro)
if(user)
if(click_cooldown_override)
user.changeNext_move(click_cooldown_override)
user.newtonian_move(get_dir(target, user))
var/obj/item/gun/ballistic/foulmouth = fired_from
if(istype(foulmouth))
foulmouth.gun_wear = round(clamp(foulmouth.gun_wear + foulmouth.wear_rate * wear_modifier, 0, 300), 0.01)
update_appearance()
return TRUE
/obj/item/ammo_casing/proc/ready_proj(atom/target, mob/living/user, quiet, zone_override = "", atom/fired_from, misfire = FALSE)
if (!BB)
return
BB.original = target
BB.firer = user
BB.misfire = misfire
BB.fired_from = fired_from
if (zone_override)
BB.def_zone = zone_override
else
if(user)
BB.def_zone = user.zone_selected
BB.suppressed = quiet
if(isgun(fired_from))
var/obj/item/gun/G = fired_from
BB.damage *= G.projectile_damage_multiplier
if(reagents && BB.reagents)
reagents.trans_to(BB, reagents.total_volume, transfered_by = user) //For chemical darts/bullets
qdel(reagents)
/obj/item/ammo_casing/proc/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread, atom/fired_from)
var/modifiers = params2list(params)
var/turf/curloc
if(user)
curloc = get_turf(user)
else
curloc = get_turf(src)
if (!istype(targloc) || !istype(curloc) || !BB)
return FALSE
var/firing_dir
if(BB.firer)
firing_dir = BB.firer.dir
if(!BB.suppressed && firing_effect_type)
new firing_effect_type(get_turf(src), firing_dir)
var/direct_target
if(targloc == curloc)
if(target) //if the target is right on our location we'll skip the travelling code in the proj's fire()
direct_target = target
if(!direct_target)
if(user)
BB.preparePixelProjectile(target, user, modifiers, spread)
else
BB.preparePixelProjectile(target, curloc, modifiers, spread)
BB.fire(null, direct_target)
BB = null
return TRUE
#define BULLET_POP_CHANCE 30
/obj/item/ammo_casing/fire_act(exposed_temperature, exposed_volume)
. = ..()
if(!prob(BULLET_POP_CHANCE) || !BB)
return
ready_proj()
BB.trajectory_ignore_forcemove = TRUE
BB.forceMove(get_turf(src))
BB.trajectory_ignore_forcemove = FALSE
BB.starting = get_turf(src)
BB.fire(rand(0,360))
BB = null
playsound(src, 'sound/weapons/gun/pistol/shot.ogg', 100, TRUE)
update_appearance()
return TRUE
/obj/item/ammo_casing/proc/spread(turf/target, turf/current, distro)
var/dx = abs(target.x - current.x)
var/dy = abs(target.y - current.y)
return locate(target.x + round(gaussian(0, distro) * (dy+2)/8, 1), target.y + round(gaussian(0, distro) * (dx+2)/8, 1), target.z)