Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gunz update #4774

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define COMSIG_MOVABLE_MOVED "movable_moved" //from base of atom/movable/Moved(): (/atom, dir)



#define COMSIG_XENO_SLIME_CLICK_CTRL "xeno_slime_click_ctrl" //from slime CtrlClickOn(): (/mob)
#define COMSIG_XENO_SLIME_CLICK_SHIFT "xeno_slime_click_shift" //from slime ShiftClickOn(): (/mob)
#define COMSIG_XENO_TURF_CLICK_SHIFT "xeno_turf_click_shift" //from turf ShiftClickOn(): (/mob)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* item/afterattack(atom,user,adjacent,params) - used both ranged and adjacent
* mob/RangedAttack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed
*/
/mob/proc/ClickOn( atom/A, params )
/mob/proc/ClickOn(atom/A, params)
if(world.time <= next_click)
return
next_click = world.time + 1
Expand Down
14 changes: 14 additions & 0 deletions code/datums/uplinks_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@
cost = 7
uplink_types = list("nuclear") */

/datum/uplink_item/dangerous/mozambique
name = "SA-3 Mozambique"
desc = "A triple-barreled shotgun pistol. Uses 16g ammunition in 6-round magazines."
item = /obj/item/weapon/gun/projectile/automatic/mozambique
cost = 11
uplink_types = list("nuclear")

/datum/uplink_item/dangerous/bulldog
name = "V15 Bulldog shotgun"
desc = "A compact, mag-fed semi-automatic shotgun for combat in narrow corridors. Uses various 12g magazines."
Expand Down Expand Up @@ -274,6 +281,13 @@
item = /obj/item/ammo_box/a357
cost = 3

/datum/uplink_item/ammo/mozambique
name = "Ammo-16g Special"
desc = "Magazine for use in Mozambique pistol"
item = /obj/item/ammo_box/magazine/g16
cost = 3
uplink_types = list("nuclear")

/datum/uplink_item/ammo/smg
name = "Ammo-.45 ACP"
desc = "A 20-round .45 ACP magazine for use in the C-20r submachine gun. These rounds have a short stunning effect and medium impact damage."
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/changeling/powers/Whip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
else
LE.agony = 15
LE.host = user
LE.Fire(A, user)
LE.Fire(A, user, shooting_object = src)

/obj/item/projectile/changeling_whip
name = "Whip"
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@
/mob/living/carbon/proc/swap_hand()
var/obj/item/item_in_hand = src.get_active_hand()
if(item_in_hand) //this segment checks if the item in your hand is twohanded.
if(istype(item_in_hand, /obj/item/weapon/twohanded) || istype(item_in_hand, /obj/item/weapon/gun/projectile/automatic/l6_saw)) //OOP? Generics? Hue hue hue hue ...
if(item_in_hand:wielded)
if(istype(item_in_hand, /obj/item/weapon/twohanded)) //OOP? Generics? Hue hue hue hue .
var/obj/item/weapon/twohanded/two_handed_object = item_in_hand
if(two_handed_object.wielded)
to_chat(usr, "<span class='warning'>Your other hand is too busy holding the [item_in_hand.name]</span>")
return
else if(istype(item_in_hand, /obj/item/weapon/gun/energy/sniperrifle))
Expand Down
8 changes: 8 additions & 0 deletions code/modules/projectiles/ammunition/bullets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
projectile_type = /obj/item/projectile/bullet/buckpellet
pellets = 7

/obj/item/ammo_casing/shotgun/weakbuckshot
name = "16g shell"
desc = "A 16 gauge shell"
icon_state = "gshell"
projectile_type = "/obj/item/projectile/bullet/buckpellet"
variance = 0.5
pellets = 5

/obj/item/ammo_casing/shotgun/beanbag
name = "beanbag shell"
desc = "A weak beanbag shell."
Expand Down
8 changes: 8 additions & 0 deletions code/modules/projectiles/ammunition/magazines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@
..()
icon_state = "[initial(icon_state)]-[round(ammo_count(),3)]"

/obj/item/ammo_box/magazine/g16
name = "magazine (16-Gauge Special)"
icon = 'icons/obj/ammo.dmi'
icon_state = "75"
ammo_type = /obj/item/ammo_casing/shotgun/weakbuckshot
caliber = "shotgun"
max_ammo = 6

/obj/item/ammo_box/magazine/m12mm
name = "magazine (.45)"
icon_state = "12mm"
Expand Down
4 changes: 2 additions & 2 deletions code/modules/projectiles/firing.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/obj/item/ammo_casing/proc/fire(atom/target, mob/living/user, params, distro, quiet)
/obj/item/ammo_casing/proc/fire(atom/target, mob/living/user, params, distro, quiet, shooting_object)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

наверное ты и в других местах в билде(ещё двух) добавил новый аргумент

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это фикс рантайма связанного со стрельбой. Когда я тестил плазмаганы СБшные они рантаймили, проблема была с этим shooting_object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я говорю что постоянство в аргументах функции должно быть, и если ты добавляешь какой-то функции аргумент - будь добр, добавь его везде.

var/boolet_number = 0
distro += variance

BB.shot_from = loc
BB.shot_from = shooting_object

for(var/i = max(1, pellets), i > 0, i--)
boolet_number++
Expand Down
33 changes: 33 additions & 0 deletions code/modules/projectiles/full_auto.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
client
var/atom/selected_target

/client/MouseDown(object, location, control, params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Прежде чем писать своё решение, ты просматривал другие кодбазы?

if(isatom(location))
var/delay = 0
var/mob/living/user = usr
var/obj/item/weapon/gun/machine_gun = user.get_active_hand()
if(istype(machine_gun))
delay = machine_gun.GunFullAutoSpeed()
if(delay > 0)
selected_target = object
while(selected_target)
if(!machine_gun.fire_checks(user))
break
user.face_atom(selected_target)
machine_gun.DoShooting(selected_target, user, params, FALSE, FALSE)
if(machine_gun.full_auto_break)
machine_gun.full_auto_break = FALSE
selected_target = null
break
sleep(delay)
machine_gun.full_auto_amount_shot = 0

/client/MouseUp(object, location, control, params)
selected_target = null

/client/MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params)
if(selected_target)
selected_target = over_object

/obj/item/weapon/gun/proc/GunFullAutoSpeed()
return full_auto
68 changes: 53 additions & 15 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,26 @@
var/fire_delay = 6
var/last_fired = 0

var/burst_size = 0
var/full_auto = 0
var/full_auto_break = FALSE //If something happens during shooting, it sets to TRUE, allowing shooting loop to break, and set it back to FALSE

var/burst_amount_when_switch = 0 //0 if no burst fire mode, amount of bullets shot otherwise
var/full_auto_speed_when_switch = 0 //0 if no full auto mode, full auto speed otherwise.

var/full_auto_amount_shot = 0 //For stuff like increasing spread for long shootings, or overheating gun.
var/full_auto_spread_coefficient = 0

lefthand_file = 'icons/mob/inhands/guns_lefthand.dmi'
righthand_file = 'icons/mob/inhands/guns_righthand.dmi'


/obj/item/weapon/gun/proc/ready_to_fire()
if(world.time >= last_fired + fire_delay)
last_fired = world.time
return 1
return TRUE
else
return 0
return FALSE

/obj/item/weapon/gun/proc/process_chamber()
return 0
Expand All @@ -53,6 +64,8 @@
/obj/item/weapon/gun/proc/shoot_with_empty_chamber(mob/living/user)
to_chat(user, "<span class='warning'>*click*</span>")
playsound(user, 'sound/weapons/guns/empty.ogg', VOL_EFFECTS_MASTER)
if(full_auto)
full_auto_break = TRUE
return

/obj/item/weapon/gun/proc/shoot_live_shot(mob/living/user)
Expand All @@ -66,7 +79,10 @@
announce_shot(user)

/obj/item/weapon/gun/proc/announce_shot(mob/living/user)
user.visible_message("<span class='danger'>[user] fires [src]!</span>", "<span class='danger'>You fire [src]!</span>", "You hear a gunshot!")
if(!full_auto)
user.visible_message("<span class='danger'>[user] fires [src]!</span>", "<span class='danger'>You fire [src]!</span>", "You hear a gunshot!")
else if (!full_auto_amount_shot)
user.visible_message("<span class='danger'>[user] starts shooting from [src]!</span>", "<span class='danger'>You start firing [src]!</span>", "You hear a volley of gunshots!")

/obj/item/weapon/gun/emp_act(severity)
for(var/obj/O in contents)
Expand All @@ -78,8 +94,12 @@
return ..()

/obj/item/weapon/gun/afterattack(atom/A, mob/living/user, flag, params)
if(flag) return //It's adjacent, is the user, or is on the user's person
if(istype(target, /obj/machinery/recharger) && istype(src, /obj/item/weapon/gun/energy)) return//Shouldnt flag take care of this?
if(flag)
return //It's adjacent, is the user, or is on the user's person
if(istype(target, /obj/machinery/recharger) && istype(src, /obj/item/weapon/gun/energy))
return//Shouldnt flag take care of this?
if(full_auto)
return
if(user && user.client && user.client.gun_mode && !(A in target))
PreFire(A,user,params) //They're using the new gun system, locate what they're aiming at.
else
Expand All @@ -101,8 +121,10 @@
return
..()

/obj/item/weapon/gun/proc/Fire(atom/target, mob/living/user, params, reflex = 0, point_blank = FALSE)//TODO: go over this
//Exclude lasertag guns from the CLUMSY check.

/obj/item/weapon/gun/proc/fire_checks(mob/living/user)
if(!user)
return
if(!user.IsAdvancedToolUser())
to_chat(user, "<span class='red'>You don't have the dexterity to do this!</span>")
return
Expand Down Expand Up @@ -138,35 +160,51 @@
qdel(src)
return

add_fingerprint(user)

if(!special_check(user, target))
return

if (!ready_to_fire())
if (world.time % 3) //to prevent spam
to_chat(user, "<span class='warning'>[src] is not ready to fire again!</span>")
return

add_fingerprint(user)

return TRUE


/obj/item/weapon/gun/proc/DoShooting(atom/target, mob/living/user, params, reflex = 0, point_blank = FALSE)
if(chambered)
if(point_blank)
if(!chambered.BB.fake)
user.visible_message("<span class='red'><b> \The [user] fires \the [src] point blank at [target]!</b></span>")
chambered.BB.damage *= 1.3
if(!chambered.fire(target, user, params, , silenced))
shoot_with_empty_chamber(user)
else
if(chambered.fire(target, user, params, , silenced, src))
shoot_live_shot(user)
user.newtonian_move(get_dir(target, user))
if(full_auto)
++full_auto_amount_shot
else
shoot_with_empty_chamber(user)

process_chamber()
update_icon()

if(user.hand)
user.update_inv_l_hand()
else
user.update_inv_r_hand()

/obj/item/weapon/gun/proc/Fire(atom/target, mob/living/user, params, reflex = 0, point_blank = FALSE)//TODO: go over this
if(!fire_checks(user))
return

if(burst_size > 1)
for(var/i = 1 to burst_size)
addtimer(CALLBACK(src, .proc/DoShooting, target, user, params, reflex, point_blank, 0.3), i-1)
else
DoShooting(target, user, params, reflex, point_blank)



/obj/item/weapon/gun/proc/can_fire()
return
Expand All @@ -184,7 +222,7 @@

/obj/item/weapon/gun/attack(mob/living/M, mob/living/user, def_zone)
//Suicide handling.
if (M == user && def_zone == O_MOUTH)
if(M == user && def_zone == O_MOUTH)
if(user.is_busy())
return
if(!can_suicide_with)
Expand Down Expand Up @@ -229,7 +267,7 @@
click_empty(user)
return

if (can_fire())
if(can_fire())
//Point blank shooting if on harm intent or target we were targeting.
if(user.a_intent == "hurt")
Fire(M, user, null, null, TRUE)
Expand Down
Loading