Skip to content

Commit

Permalink
partial calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Oct 19, 2023
1 parent 2155475 commit 83c1056
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
8 changes: 6 additions & 2 deletions code/__DEFINES/materials/dynamics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
//* Significance; This is how much material is in something

/// used for shards
#define MATERIAL_SIGNIFICANCE_SHARD 2.5
#define MATERIAL_SIGNIFICANCE_SHARD 3.5
/// baseline significance of material calculations done on material-side / default computations
#define MATERIAL_SIGNIFICANCE_BASELINE 10

#define MATERIAL_SIGNIFICANCE_WEAPON_LIGHT 8.5
#define MATERIAL_SIGNIFICANCE_WEAPON_MEDIUM 10
#define MATERIAL_SIGNIFICANCE_WEAPON_HEAVY 12.5

#define MATERIAL_SIGNIFICANCE_ARMOR_LIGHT 8.5
#define MATERIAL_SIGNIFICANCE_ARMOR_MEDIUM 10
#define MATERIAL_SIGNIFICANCE_ARMOR_HEAVY 12.5

/// used for most doors
#define MATERIAL_SIGNIFICANCE_DOOR 15
#define MATERIAL_SIGNIFICANCE_DOOR 20
/// significance used for normal wall layer
#define MATERIAL_SIGNIFICANCE_WALL 20
/// significance used for reinforcing wall layer
Expand Down
8 changes: 7 additions & 1 deletion code/game/atoms/defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,13 @@
*/
/atom/proc/fetch_armor()
RETURN_TYPE(/datum/armor)
return armor || (armor = fetch_armor_struct(armor_type))
return armor || (armor = generate_armor())

/**
* get default armor datum
*/
/atom/proc/generate_armor()
return fetch_armor_struct(armor_type)

/**
* calculates the resulting damage from an attack, taking into account our armor and soak
Expand Down
45 changes: 43 additions & 2 deletions code/modules/materials/dynamics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,49 @@
* @return /datum/armor instance
*/
/datum/material/proc/create_armor(significance = MATERIAL_SIGNIFICANCE_BASELINE, mob_armor)
#warn params
#warn impl - this requires caching
var/cache_key = "[significance]_[!!mob_armor]"
if(!isnull(armor_cache[cache_key]))
return armor_cache[cache_key]

//! Not even Desmos will save you now. !//
// absorbing kinetic energy
var/kinetic_damping = toughness * ((density ** 0.5) * (1 / 3))
// stopping kinetic penetrators
var/kinetic_hardness = hardness * ((density ** 0.5) * (1 / 8) + 0.7)
// absorbing energy blasts
var/ablation_damping =

Check failure on line 26 in code/modules/materials/dynamics.dm

View workflow job for this annotation

GitHub Actions / Run Linters

got ';', expected one of: operator, term
// spreading energy blasts from going through
var/ablation_diffusion =
// exotic 'energy' armor
var/exotic_absorption =
// bomb values : from kinetic damping and hardness
var/direct_bomb =
// direct values
// todo: integrate significance
var/direct_bio = relative_permeability > 1? -relative_permeability : relative_permeability
// todo: integrate significance
var/direct_acid = relative_reactivity > 1? -relative_reactivity : relative_reactivity
// todo: integrate significance
var/direct_fire = relative_reactivity > 1? -relative_reactivity : relative_reactivity
var/direct_rad = (density * (1 / 16))**2 * ((MATERIAL_SIGNIFICANCE_BASELINE + (significance - MATERIAL_SIGNIFICANCE_BASELINE)) * 0.1)
#warn FUCK
// we don't allow deflection for now
return (armor_cache = fetch_armor_struct(list(
ARMOR_MELEE = ,
ARMOR_MELEE_TIER = ,
ARMOR_MELEE_SOAK = ,
ARMOR_BULLET = ,
ARMOR_BULLET_TIER = ,
ARMOR_BULLET_SOAK = ,
ARMOR_LASER = ,
ARMOR_LASER_TIER = ,
ARMOR_LASER_SOAK = ,
ARMOR_BOMB = direct_bomb,
ARMOR_BIO = direct_bio,
ARMOR_ACID = direct_acid,
ARMOR_FIRE = direct_fire,
ARMOR_RAD = direct_rad,
)))

/**
* combines multiple material armors into one
Expand Down
4 changes: 3 additions & 1 deletion code/modules/materials/material.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
var/pass_stack_colors = FALSE

//* Armor
/// caching of armor. text2num(significance) = armor datum instance
/// caching of armor. text2num(significance)_[mob_armor? 1 : 0] = armor datum instance
var/tmp/list/armor_cache = list()

//* Attacks
Expand Down Expand Up @@ -107,6 +107,8 @@
/// * impacts radiation armor (major)
/// * impacts bomb armor
/// * impacts blunt / crush damage
/// * impacts sharp / blade damage (minor)
/// * impacts kinetic damage resistance (minor)
var/density = 8 * 1
/// weight multiplier - allowing for materials that behave like a high-density material but are light
/// * basically, low values = high density stats without the penalties from weight
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/projectile/rocket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

/obj/item/gun/ballistic/rocket/tyrmalin/attackby(var/obj/item/A as obj, mob/user as mob)
. = ..()
if(istype(A, /obj/item/stack/material) && A.get_material_name() == MAT_PLASTEEL)
if(A.is_material_stack_of(/datum/material/plasteel))
var/obj/item/stack/material/M = A
if(M.use(1))
var/obj/item/tyrmalin_rocket_assembly/R = new /obj/item/tyrmalin_rocket_assembly(get_turf(src))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/species/xenomorphs/alien_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
else
if(istype(O, /turf/simulated/wall))
var/turf/simulated/wall/W = O
if(W.material.flags & MATERIAL_UNMELTABLE)
if(W.material_outer.material_flags & MATERIAL_FLAG_UNMELTABLE)
cannot_melt = 1
else if(istype(O, /turf/simulated/floor))
/* var/turf/simulated/floor/F = O //Turfs are qdel'd to space (Even asteroid tiles), will need to be touched by someone smarter than myself. -Mech
Expand Down

0 comments on commit 83c1056

Please sign in to comment.