Files
Paradise/code/modules/projectiles/firing.dm
PollardTheDragon cd7cb01a1f Meet the Smith - New Supply Role (#28273)
* Smith role, access, access helpers, spawn point, comms, and IDs

* Area defines

* Hammertime

* Cyberiad Smith's office

* Forgot some atmos stuff

* Autolathable Hammers

* Formatting

* Toolbelts can hold hammers

* Initial work on smith machines

* Farragus Smith Office

* Placeholder sprites, mapping

* Smart hopper points and console messages

* More work on smithing machines

* Fixed mapping, added qualities, added smithed items, fixed sizing, fixed access

* Smith components, new materials

* New ores, material datums, furnace, power hammer, kinetic assembler, hammer act, item creation

* Missed one

* Grrr map conflicts begone

* Dirt begone

* Casts and smelting

* Linters

* Attack chain linters!

* Better grip to throw people into your industrial machines

* Placeholder spots in the DMIs

* UpdatePaths - Space ruins now spawn new space ores in their rocks

* Small changes - removed excess tgui code from hopper

* Fixed a button on emerald

* Attaching inserts and lenses. Tool bits are pain.

* Tool bit initial implementation

* Merge conflict resolution

* Attack chain grrr

* Fixed a pair of minor mapping issues

* Tool bit implementation, efficiency, failure rate

* Hot things burn hands

* Points fix on hopper

* New mining rocks for space exploration

* Areas on asteroids

* Machinery icons 1

Adds basic icons for the new machinery

* Vendor iconstate update

* Crucible touchups

* Hammer touchups

* Crucible Input Animation

Adds an animation when you deposit ores

* Added scanning the crucible with multitool to get mineral count

* clothing sprites part 1

* locker sprite

* job icons

* garment bag

* Smith locker mapping

* Insert and Bit removal fix

* Job menu alignment fix, Allowed_items and small spriting path fixes

* Adds new asteroid ruins to config

* Ore Sprites

* Hammer Sprite

* Item Sprites 1

* Sheets, Wall Ores and Trim

* Sheet iconstate names

* species uniforms

* Tabs

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Lens spelling fix

* Signalizes attaching and detaching modifications, fixes inserting items into smith machines, fixes cast bugs

* Fixed type lists

* Smithing machine bug fixes.

* Fixed adding modifications to items

* Crucible Lava Idle

Adds an idle animation for the crucible, but it needs overlay code to work.

* Fixed eguns

* Magma Crucible overlays and animations

* Machine broken/Off states

Adds broken, wires exposed (and on/off where appropriate) states to machines.

* Castivend recolor and Hot Items

* Overlays for all machines, new sprites for hot items, new checks, fixes

* Woe, farragus merge conflict

* update_appearance linters

* I have fat fingers.

* Forgot one

* transfer_item_to and qdel null check

* Usr to User

* Modsuits should not have inserts.

* Adds casting lip overlay

* Balance pass on movement debuffs and buffs

* Material movespeed changes

* Config Adjustments - USED FOR TESTMERGING. REVERT BEFORE FULL MERGE

* Math fixes for lenses and bits.

* Mobility suit no longer speeds you up, but negates suit-based slowdown like an oil slick potion. Fixed movement mods in material datums

* Bad var. Bad.

* Various fixes to bugs revealed in initial TM

* TYPO

* Lavaland base turf fix

* Paths in examine fix

* Adds an intercom to the workshop.

* Stamina-hybrid damage oversight fix for det revolver, uion, etc.

* Currently Operating Message fix

* Allows glass to show different turfs beneath. Adds plasmaglass section to workshop.

* Armor and upgrade fixes

* RCD tool bit equip fix

* Adds smith access to a few lists in access.dm that were missed in an oversight

* Indent fixes

* Fixes vending machine, allows tool bit use on mining equipment

* CI, you make me mad sometimes

* Removed duplicate code

* Name fix for CI again

* ORM now can handle space ores

* Adds space ores to Vetus drop and to trader inventories

* Fixes runtime with open hand attacking a lava furnace with nothing in it

* Adds crewvend kit to Castivend

* Fixes not being able to see new ores

* Adds drill and RCS to smith locker

* Map changes. Added cargo pad. Expanded catwalk. Moved vendors. Added recharger.

* Plant fixes

* Fixes doubled-up catwalk

* Emerald cargo windoor fix, small lavaland adjustment

* Small oversight for overlay fix

* Missing lightswitches

* Fixed stock parts mismatch in casting basin recipe

* Better support for power tools, grrr attackchain

* Better attack chain handling. Better handling for bit insertion

* Fixes handling of inserts with storage suits (like labcoats)

* sprites for bomber + plasmeme outfit

* Adds missing adjacency checks

* Buffs speed boost from upgrade - max upgrade reduces cycle to 2 seconds.

* Fixed floating lights, brightened the explorer's new room, expanded smith workshop slightly.

* Small hallway adjustment

* Illuminates metastation smith office

* Removes excessive decimals in magma crucible scan output

* Berserker should not have inserts.

* Buffs bit durability significantly, nerfs amplifier lens and densifier lense slightly

* Adds smith bomber jacket to loadout panel

* Adds random spawners for smithed items, adds random low-quality items to maints loot

* Adds traitor version of bulldog shotgun

* Revert "Adds traitor version of bulldog shotgun"

This reverts commit 1d39c59f07.

* Added check to assembler, moved desc changes to examine()

* plasmaman suit fix

* Fixed hot check when removing items from hammer and furnace

* Remaps lavaland workshop, fixed deltastation light switch

* Improper's the smith office name

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Compacts extra ore drops from Vetus

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* better looping

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Better loop

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>

* Multitools don't need tool bits.

* Better variable names, fixed missing parenthesis

* Recursive hammering, removed attack animations when inserting items or using multitool on smithing machines

* window

* Update deltastation.dmm

* Update deltastation.dmm

* Update deltastation.dmm

* Fixes small oversights

* Minor lavaland remap

* Reverts TM-required changes in preparation for full merge

* Begone, stray font!

* Damn you cable CI

---------

Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com>
Co-authored-by: ExusA <67055922+ExusA@users.noreply.github.com>
Co-authored-by: Christasmurf <25437893+Christasmurf@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: Fordoxia <143041327+Fordoxia@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
2025-03-15 21:35:21 +00:00

181 lines
7.1 KiB
Plaintext

/obj/item/ammo_casing/proc/fire(atom/target, mob/living/user, params, distro, quiet, zone_override = "", spread, atom/firer_source_atom)
distro += variance
for(var/i = max(1, pellets), i > 0, i--)
var/targloc = get_turf(target)
ready_proj(target, user, quiet, zone_override, firer_source_atom)
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((i / pellets - 0.5) * distro)
if(isnull(throw_proj(target, targloc, user, params, spread, firer_source_atom)))
return FALSE
if(i > 1)
newshot()
if(click_cooldown_override)
user.changeNext_move(click_cooldown_override)
else
user.changeNext_move(CLICK_CD_RANGE)
user.newtonian_move(get_dir(target, user))
update_icon()
return TRUE
/obj/item/ammo_casing/proc/ready_proj(atom/target, mob/living/user, quiet, zone_override = "", atom/firer_source_atom)
if(!BB)
return
BB.original = target
BB.firer = user
BB.firer_source_atom = firer_source_atom
if(zone_override)
BB.def_zone = zone_override
else
BB.def_zone = user.zone_selected
BB.suppressed = quiet
if(reagents && BB.reagents)
reagents.trans_to(BB, reagents.total_volume) //For chemical darts/bullets
qdel(reagents)
/obj/item/ammo_casing/proc/throw_proj(atom/target, turf/targloc, mob/living/user, params, spread, atom/firer_source_atom)
var/turf/curloc = get_turf(firer_source_atom)
if(!istype(curloc)) // False-bottomed briefcase check / shell launch system check.
var/obj/item/holding = user.get_active_hand()
if(istype(holding, /obj/item/storage/briefcase/false_bottomed))
curloc = get_turf(holding)
if(istype(firer_source_atom, /obj/item/gun/projectile/revolver/doublebarrel/shell_launcher))
curloc = get_turf(user)
if(!istype(targloc) || !istype(curloc) || !BB)
return
BB.ammo_casing = src
if(istype(BB.ammo_casing, /obj/item/ammo_casing/energy))
var/obj/item/ammo_casing/energy/energy_casing = BB.ammo_casing
BB.damage = BB.damage * energy_casing.lens_damage_multiplier
BB.stamina = BB.stamina * energy_casing.lens_damage_multiplier
BB.speed = BB.speed * energy_casing.lens_speed_multiplier
if(target && get_dist(user, target) <= 1) //Point blank shot must always hit
BB.starting = curloc
BB.prehit(target)
target.bullet_act(BB, BB.def_zone)
QDEL_NULL(BB)
return TRUE
if(targloc == curloc)
if(target) //if the target is right on our location we go straight to bullet_act()
BB.prehit(target)
target.bullet_act(BB, BB.def_zone)
QDEL_NULL(BB)
return TRUE
var/modifiers = params2list(params)
BB.preparePixelProjectile(target, user, modifiers, spread)
if(BB)
BB.fire()
BB = null
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)
/**
* Aims the projectile at a target.
*
* Must be passed at least one of a target or a list of click parameters.
* If only passed the click modifiers the source atom must be a mob with a client.
*
* Arguments:
* - [target][/atom]: (Optional) The thing that the projectile will be aimed at.
* - [source][/atom]: The initial location of the projectile or the thing firing it.
* - [modifiers][/list]: (Optional) A list of click parameters to apply to this operation.
* - deviation: (Optional) How the trajectory should deviate from the target in degrees.
* - //Spread is FORCED!
*/
/obj/item/projectile/proc/preparePixelProjectile(atom/target, atom/source, list/modifiers = null, deviation = 0)
if(!(isnull(modifiers) || islist(modifiers)))
stack_trace("WARNING: Projectile [type] fired with non-list modifiers, likely was passed click params.")
modifiers = null
var/turf/source_loc = get_turf(source)
var/turf/target_loc = get_turf(target)
if(isnull(source_loc))
stack_trace("WARNING: Projectile [type] fired from nullspace.")
qdel(src)
return FALSE
trajectory_ignore_forcemove = TRUE
forceMove(source_loc)
trajectory_ignore_forcemove = FALSE
starting = source_loc
pixel_x = source.pixel_x
pixel_y = source.pixel_y
original = target
if(length(modifiers))
var/list/calculated = calculate_projectile_angle_and_pixel_offsets(source, target_loc && target, modifiers)
p_x = calculated[2]
p_y = calculated[3]
set_angle(calculated[1] + deviation)
return TRUE
if(target_loc)
yo = target_loc.y - source_loc.y
xo = target_loc.x - source_loc.x
set_angle(get_angle(src, target_loc) + deviation)
return TRUE
stack_trace("WARNING: Projectile [type] fired without a target or mouse parameters to aim with.")
qdel(src)
return FALSE
/**
* Calculates the pixel offsets and angle that a projectile should be launched at.
*
* Arguments:
* - [source][/atom]: The thing that the projectile is being shot from.
* - [target][/atom]: (Optional) The thing that the projectile is being shot at.
* - If this is not provided the source atom must be a mob with a client.
* - [modifiers][/list]: A list of click parameters used to modify the shot angle.
*/
/proc/calculate_projectile_angle_and_pixel_offsets(atom/source, atom/target, modifiers)
var/angle = 0
var/p_x = LAZYACCESS(modifiers, ICON_X) ? text2num(LAZYACCESS(modifiers, ICON_X)) : world.icon_size / 2 // ICON_(X|Y) are measured from the bottom left corner of the icon.
var/p_y = LAZYACCESS(modifiers, ICON_Y) ? text2num(LAZYACCESS(modifiers, ICON_Y)) : world.icon_size / 2 // This centers the target if modifiers aren't passed.
var/mob/user = source
if(ismob(user) && user?.client && LAZYACCESS(modifiers, SCREEN_LOC))
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
var/list/screen_loc_params = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",")
//Split X+Pixel_X up into list(X, Pixel_X)
var/list/screen_loc_X = splittext(screen_loc_params[1],":")
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
var/list/screen_loc_Y = splittext(screen_loc_params[2],":")
var/x = (text2num(screen_loc_X[1]) - 1) * world.icon_size + text2num(screen_loc_X[2])
var/y = (text2num(screen_loc_Y[1]) - 1) * world.icon_size + text2num(screen_loc_Y[2])
//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/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
angle = ATAN2(y - oy, x - ox)
return list(angle, p_x, p_y)
if(!target)
CRASH("Can't make trajectory calculations without a target or click modifiers and a client.")
var/turf/source_loc = get_turf(source)
var/turf/target_loc = get_turf(target)
var/dx = ((target_loc.x - source_loc.x) * world.icon_size) + (target.pixel_x - source.pixel_x) + (p_x - (world.icon_size / 2))
var/dy = ((target_loc.y - source_loc.y) * world.icon_size) + (target.pixel_y - source.pixel_y) + (p_y - (world.icon_size / 2))
angle = ATAN2(dy, dx)
return list(angle, p_x, p_y)