Files
Polaris/code/modules/projectiles/projectile/bullets.dm
Rykka 3fd5296682 TGMC Ammo HUD Port
Ports over TGMC's Ammo HUD and all relevant code, adapted to work for Polaris's guns. This took me several days, but hey, I learned a bunch. <:
Time to port Aim Mode + Mentorhelp. :3c 
- All guns now have an ammo HUD sprite. If one lacks one, it will be ??? or blank, at which point, make an issue report, as all guns should be working by now.
- Guns will display how many rounds they have left until ammunition runs dry.
- Ammo will only count the casings that CURRENTLY have a projectile in them. This is slightly unrealistic, yes, but it is better and more intuitive for the player. This also enables guns like the revolver to work, given they recycle casings.
- Up to 4 ammo HUDs can be displayed at once, but given we lack TGMC's attachments and guncode, you'll only ever usually see 2. TBD on porting over TGMC guncode. <:
- Ammunition for multiple guns has different colors in the HUD based on what you currently have loaded.
- If you're looking at this later on to add new things. DON'T USE _FLASH IN THE HUD_STATE_EMPTY. THE _FLASH IS ADDED ON BY CODE.
- Grenades have a hud_state, pending us ever porting over a grenade launcher. Rockets ALSO have a hud_state.


Example of Laser/Energy Weapons:
https://i.imgur.com/MGvqGxh.mp4
Captain's Gun:
https://i.imgur.com/Wd0SS3C.gif

Full Test of all weapons:
https://streamable.com/usp4dy

Upstream port of https://github.com/CHOMPStation2/CHOMPStation2/pull/4033
2022-04-07 01:00:23 -06:00

426 lines
12 KiB
Plaintext
Raw Blame History

/obj/item/projectile/bullet
name = "bullet"
icon_state = "bullet"
fire_sound = 'sound/weapons/Gunshot4.ogg'
damage = 60
damage_type = BRUTE
nodamage = 0
check_armour = "bullet"
embed_chance = 20 //Modified in the actual embed process, but this should keep embed chance about the same
sharp = 1
hitsound_wall = "ricochet"
impact_effect_type = /obj/effect/temp_visual/impact_effect
excavation_amount = 20
var/mob_passthrough_check = 0
hud_state = "pistol_lightap"
hud_state_empty = "pistol_empty" // Just in case we somehow have no hud_state_empty defined
muzzle_type = /obj/effect/projectile/muzzle/bullet
/obj/item/projectile/bullet/on_hit(var/atom/target, var/blocked = 0)
if (..(target, blocked))
var/mob/living/L = target
shake_camera(L, 3, 2)
/obj/item/projectile/bullet/attack_mob(var/mob/living/target_mob, var/distance, var/miss_modifier)
if(penetrating > 0 && damage > 20 && prob(damage))
mob_passthrough_check = 1
else
mob_passthrough_check = 0
return ..()
/obj/item/projectile/bullet/can_embed()
//prevent embedding if the projectile is passing through the mob
if(mob_passthrough_check)
return 0
return ..()
/obj/item/projectile/bullet/check_penetrate(var/atom/A)
if(!A || !A.density) return 1 //if whatever it was got destroyed when we hit it, then I guess we can just keep going
if(istype(A, /obj/mecha))
return 1 //mecha have their own penetration handling
if(ismob(A))
if(!mob_passthrough_check)
return 0
if(iscarbon(A))
damage *= 0.7 //squishy mobs absorb KE
return 1
var/chance = damage
if(istype(A, /turf/simulated/wall))
var/turf/simulated/wall/W = A
chance = round(damage/W.material.integrity*180)
else if(istype(A, /obj/machinery/door))
var/obj/machinery/door/D = A
chance = round(damage/D.maxhealth*180)
if(D.glass) chance *= 2
else if(istype(A, /obj/structure/girder))
chance = 100
if(prob(chance))
if(A.opacity)
//display a message so that people on the other side aren't so confused
A.visible_message("<span class='warning'>\The [src] pierces through \the [A]!</span>")
return 1
return 0
/* foam dart projectiles */
/obj/item/projectile/bullet/foam_dart
name = "foam dart"
desc = "I hope you're wearing eye protection."
damage = 0 // It's a damn toy.
damage_type = OXY
nodamage = TRUE
icon = 'icons/obj/gun_toy.dmi'
icon_state = "foamdart_proj"
range = 15
impact_effect_type = null
fire_sound = 'sound/items/syringeproj.ogg'
/obj/item/projectile/bullet/foam_dart/on_impact(var/atom/A)
. = ..()
var/turf/T = get_turf(loc)
if(istype(T))
new /obj/item/ammo_casing/afoam_dart(get_turf(loc))
/obj/item/projectile/bullet/foam_dart/on_range(var/atom/A)
. = ..()
var/turf/T = get_turf(loc)
if(istype(T))
new /obj/item/ammo_casing/afoam_dart(get_turf(loc))
/* short-casing projectiles, like the kind used in pistols or SMGs */
/obj/item/projectile/bullet/pistol // 9mm pistols and most SMGs. Sacrifice power for capacity.
fire_sound = 'sound/weapons/gunshot2.ogg'
damage = 20
hud_state = "pistol"
hud_state_empty = "pistol_empty"
/obj/item/projectile/bullet/pistol/ap
damage = 15
armor_penetration = 30
hud_state = "pistol_light_ap"
/obj/item/projectile/bullet/pistol/hp
damage = 25
armor_penetration = -50
hud_state = "pistol_ap"
/obj/item/projectile/bullet/pistol/medium // .45 (and maybe .40 if it ever gets added) caliber security pistols. Balance between capacity and power.
fire_sound = 'sound/weapons/gunshot3.ogg' // Snappier sound.
damage = 25
hud_state = "pistol"
/obj/item/projectile/bullet/pistol/medium/ap
damage = 20
armor_penetration = 15
hud_state = "pistol_light_ap"
/obj/item/projectile/bullet/pistol/medium/hp
damage = 30
armor_penetration = -50
hud_state = "pistol_ap"
/obj/item/projectile/bullet/pistol/strong // .357 and .44 caliber stuff. High power pistols like the Mateba or Desert Eagle. Sacrifice capacity for power.
fire_sound = 'sound/weapons/gunshot4.ogg'
damage = 60
hud_state = "pistol_heavy"
/obj/item/projectile/bullet/pistol/rubber/strong // "Rubber" bullets for high power pistols.
fire_sound = 'sound/weapons/gunshot3.ogg' // Rubber shots have less powder, but these still have more punch than normal rubber shot.
damage = 10
agony = 60
embed_chance = 0
sharp = 0
check_armour = "melee"
hud_state = "pistol_special"
/obj/item/projectile/bullet/pistol/rubber // "Rubber" bullets for all other pistols.
name = "rubber bullet"
damage = 5
agony = 40
embed_chance = 0
sharp = 0
check_armour = "melee"
hud_state = "pistol_special"
fire_sound ='sound/weapons/Gunshot_pathetic.ogg' // Rubber shots have less powder in the casing.
/* shotgun projectiles */
/obj/item/projectile/bullet/shotgun
name = "slug"
fire_sound = 'sound/weapons/Gunshot_shotgun.ogg'
damage = 50
armor_penetration = 20
hud_state = "shotgun_slug"
hud_state_empty = "shotgun_empty"
/obj/item/projectile/bullet/shotgun/beanbag //because beanbags are not bullets
name = "beanbag"
damage = 20
agony = 60
embed_chance = 0
sharp = 0
check_armour = "melee"
hud_state = "shotgun_beanbag"
//Should do about 80 damage at 1 tile distance (adjacent), and 50 damage at 3 tiles distance.
//Overall less damage than slugs in exchange for more damage at very close range and more embedding
/obj/item/projectile/bullet/pellet/shotgun
name = "shrapnel"
fire_sound = 'sound/weapons/Gunshot_shotgun.ogg'
damage = 13
pellets = 6
range_step = 1
spread_step = 10
hud_state = "shotgun_buckshot"
/obj/item/projectile/bullet/pellet/shotgun/flak
damage = 2 //The main weapon using these fires four at a time, usually with different destinations. Usually.
range_step = 2
spread_step = 30
armor_penetration = 10
hud_state = "shotgun_flechette"
//EMP shotgun 'slug', it's basically a beanbag that pops a tiny emp when it hits. //Not currently used
/obj/item/projectile/bullet/shotgun/ion
name = "ion slug"
fire_sound = 'sound/weapons/Laser.ogg' // Really? We got nothing better than this?
damage = 15
embed_chance = 0
sharp = 0
check_armour = "melee"
hud_state = "shotgun_ion"
combustion = FALSE
/obj/item/projectile/bullet/shotgun/ion/on_hit(var/atom/target, var/blocked = 0)
..()
empulse(target, 0, 0, 0, 0) //Only affects what it hits
return 1
/* "Rifle" rounds */
/obj/item/projectile/bullet/rifle
fire_sound = 'sound/weapons/Gunshot_generic_rifle.ogg'
armor_penetration = 15
penetrating = 1
hud_state = "rifle"
hud_state_empty = "rifle_empty"
/obj/item/projectile/bullet/rifle/a762
fire_sound = 'sound/weapons/Gunshot_heavy.ogg'
damage = 35
hud_state = "rifle_heavy"
/obj/item/projectile/bullet/rifle/a762/sniper // Hitscan specifically for sniper ammo; to be implimented at a later date, probably for the SVD. -Ace
fire_sound = 'sound/weapons/Gunshot_sniper.ogg'
hitscan = 1 //so the ammo isn't useless as a sniper weapon
hud_state = "hivelo"
/obj/item/projectile/bullet/rifle/a762/ap
damage = 30
armor_penetration = 50 // At 30 or more armor, this will do more damage than standard rounds.
hud_state = "rifle_ap"
/obj/item/projectile/bullet/rifle/a762/hp
damage = 40
armor_penetration = -50
penetrating = 0
hud_state = "hivelo_iff"
/obj/item/projectile/bullet/rifle/a762/hunter // Optimized for killing simple animals and not people, because Balance(tm)
damage = 20
SA_bonus_damage = 50 // 70 total on animals.
SA_vulnerability = SA_ANIMAL
hud_state = "rifle_heavy"
/obj/item/projectile/bullet/rifle/a545
fire_sound = 'sound/weapons/Gunshot_light.ogg'
damage = 25
hud_state = "rifle"
/obj/item/projectile/bullet/rifle/a545/ap
damage = 20
armor_penetration = 50 // At 40 or more armor, this will do more damage than standard rounds.
hud_state = "rifle_ap"
/obj/item/projectile/bullet/rifle/a545/hp
damage = 35
armor_penetration = -50
penetrating = 0
hud_state = "hivelo_iff"
/obj/item/projectile/bullet/rifle/a545/hunter
damage = 15
SA_bonus_damage = 35 // 50 total on animals.
SA_vulnerability = SA_ANIMAL
hud_state = "rifle_heavy"
/obj/item/projectile/bullet/rifle/a145 // 14.5<EFBFBD>114mm is bigger than a .50 BMG round.
fire_sound = 'sound/weapons/Gunshot_cannon.ogg' // This is literally an anti-tank rifle caliber. It better sound like a fucking cannon.
damage = 80
stun = 3
weaken = 3
penetrating = 5
armor_penetration = 80
hitscan = 1 //so the PTR isn't useless as a sniper weapon
hud_state = "sniper"
icon_state = "bullet_alt"
tracer_type = /obj/effect/projectile/tracer/cannon
/obj/item/projectile/bullet/rifle/a145/highvel
damage = 50
stun = 1
weaken = 0
penetrating = 15
armor_penetration = 90
hud_state = "sniper_flak"
/obj/item/projectile/bullet/rifle/a44rifle
fire_sound = 'sound/weapons/gunshot4.ogg'
damage = 50
hud_state = "revolver"
/* Mech rounds */
/obj/item/projectile/bullet/mech/autocannon // Splitting it off from the original pistol/medium to give it its own sprite and potentially separate damage values later on.
icon_state = "mech_autocannon"
fire_sound = 'sound/weapons/mech_autocannon.ogg' // Doesn't actually work for the mech autocannon normally in my testing, putting it here in case anything else wants to use the sound.
light_range = 2
light_power = 0.5
light_color = "#FF7F01"
plane = PLANE_LIGHTING_ABOVE // I don't know if this actually does anything here but nothing breaks and the end result works soooo
damage = 25
/* Miscellaneous */
/obj/item/projectile/bullet/suffocationbullet//How does this even work?
name = "co bullet"
damage = 20
damage_type = OXY
hud_state = "pistol_tranq"
/obj/item/projectile/bullet/cyanideround
name = "poison bullet"
damage = 40
damage_type = TOX
hud_state = "pistol_tranq"
/obj/item/projectile/bullet/burstbullet
name = "exploding bullet"
fire_sound = 'sound/effects/Explosion1.ogg'
damage = 20
embed_chance = 0
edge = TRUE
hud_state = "pistol_fire"
/obj/item/projectile/bullet/burstbullet/on_hit(var/atom/target, var/blocked = 0)
if(isturf(target))
explosion(target, -1, 0, 2)
..()
/* Incendiary */
/obj/item/projectile/bullet/incendiary
name = "incendiary bullet"
icon_state = "bullet_alt"
damage = 15
damage_type = BURN
incendiary = 0.5
flammability = 2
hud_state = "pistol_fire"
/obj/item/projectile/bullet/incendiary/flamethrower
name = "ball of fire"
desc = "Don't stand in the fire."
icon_state = "fireball"
damage = 10
embed_chance = 0
incendiary = 2
flammability = 4
agony = 30
range = 4
vacuum_traversal = 0
hud_state = "flame"
/obj/item/projectile/bullet/incendiary/flamethrower/large
damage = 5
incendiary = 3
flammability = 2
range = 6
hud_state = "flame"
/obj/item/projectile/bullet/incendiary/flamethrower/tiny
damage = 2
incendiary = 0
flammability = 2
modifier_type_to_apply = /datum/modifier/fire/stack_managed/weak
modifier_duration = 20 SECONDS
range = 6
agony = 0
hud_state = "flame"
/* Practice rounds and blanks */
/obj/item/projectile/bullet/practice
damage = 5
hud_state = "smg_light"
/obj/item/projectile/bullet/pistol/cap // Just the primer, such as a cap gun.
name = "cap"
damage_type = HALLOSS
fire_sound = 'sound/effects/snap.ogg'
damage = 0
nodamage = 1
embed_chance = 0
sharp = FALSE
hud_state = "monkey"
combustion = FALSE
/obj/item/projectile/bullet/pistol/cap/process()
loc = null
qdel(src)
/obj/item/projectile/bullet/blank
name = "blank"
damage_type = HALLOSS
fire_sound = 'sound/weapons/Gunshot_generic_rifle.ogg' // Blanks still make loud noises.
damage = 0
nodamage = 1
embed_chance = 0
sharp = FALSE
hud_state = "smg_light"
/obj/item/projectile/bullet/blank/cap/process()
loc = null
qdel(src)
/* BB Rounds */
/obj/item/projectile/bullet/bb // Generic single BB
name = "BB"
damage = 0
agony = 0
embed_chance = 0
sharp = FALSE
silenced = TRUE
hud_state = "pistol_light"
/obj/item/projectile/bullet/pellet/shotgun/bb // Shotgun
name = "BB"
damage = 0
agony = 0
embed_chance = 0
sharp = FALSE
pellets = 6
range_step = 1
spread_step = 10
silenced = TRUE