Page 1 of 1

Ship Damage Mod

Posted: Sat Mar 10, 2018 3:32 am
by harpy eagle
Hi everyone! I made a mod that tweaks the way ship damage works in the game.

It was kind of bothering me how SiS had this interesting battle damage mechanic that tracks how damage affects ships (by disabling weapons and other ship systems), but it wasn't as relevant as it could be most of the time since ships typically got destroyed before taking major systems or crew damage in regular combat.

What this mod does:

Instead of every weapon dealing the same amount of damage to systems and structures, weapons that deal small amounts of damage in many hits (e.g. defence lasers, PD coilguns) deal more damage to systems (i.e. the same as vanilla) and less damage to structures.

Weapons the deal a lot of damage per hit (e.g. torpedoes), deal damage more equally to structures and systems.

The result:

There's a lot more variation in what can happen to a ship in combat. Ships might sometimes become crippled instead of destroyed, basically taken out of the fight but can be captured or recovered later. You'll see ships with a lot of damaged weapons or disabled engines more often.

Because the damage to systems isn't changed, this mod does not affect game balance at all. All it means is that ships that might have exploded in vanilla sometimes are left completely disabled, but still alive.

I find combat is more varied as a result of this mod, and personally prefer it over vanilla.

To install, unzip the "ShipDamageMod" folder into your "steamapps/common/Stars in Shadow/Mods" folder

Re: Combat Damage Mod

Posted: Tue Mar 13, 2018 5:31 pm
by harpy eagle
In case anyone is interested, here is the full source code of the mod.

Anyone know how I can get existing local functions to be included in the ENV when the mod loads? That way I wouldn't have to reduplicate get_hull() etc.

Code: Select all

local Log, log0, log in gui.BattleLog
local min,max,ceil in math

local function min_hull_integrity(target)
  return floor(target.structure*.3)
end

local function get_hull(target)
  return target.structure-(target.structure_damage or 0)
end


local function clamp(value, min_value, max_value)
  return max(min(value, max_value), min_value)
end

function deal_structure_and_system_damage(damage,ship)

  local max_health = ship.structure
  local structure = max_health-ship.structure_damage
  
  local systems_damage=damage

  -- reduce structure damage according to the damage/max_health ratio
  -- this will make system damage relevant more often in combat
  local destruction_ratio = clamp(0.25*(damage*damage)/max_health, 0.2, 1.0)
  local struct_damage = ceil(damage * destruction_ratio)

  if(struct_damage>structure) 
    struct_damage=structure
  end

  log("%d structure damage (%d)",struct_damage,structure)

  -- check to see whether the implied systems damage causes the
  -- ship to explode.
  munitions_death = damage_systems(systems_damage,ship)

  if(structure<=0) 
    ship.structure_damage=max_health

    return  munitions_death or "Structural integrity" 
  else
    ship.structure_damage=ship.structure_damage+struct_damage
    structure = max_health-ship.structure_damage
    
    if( get_hull(ship) < min_hull_integrity(ship) )
      ship.structure_damage=min(ship.structure_damage,max_health)
      return munitions_death or "Structural integrity" 
    end 

  end

  return munitions_death

end

Re: Combat Damage Mod

Posted: Tue Mar 13, 2018 5:43 pm
by sven
harpy eagle wrote: Anyone know how I can get existing local functions to be included in the ENV when the mod loads? That way I wouldn't have to reduplicate get_hull() etc.
It's possible to extract locals from other functions using Lua's debugging hooks, but, the method is very obscure, and, almost always not worth the trouble. get_hull() and friends are tiny helper functions, and replicating them shouldn't hurt anything.

On the other hand, if, in course of your modding adventures, you discover local functions that are more substantial that you'd like included in the global _ENV, just let me know, and (in most cases), I'll be happy to patch the main-line game so they get inserted into _G by default.

Re: Combat Damage Mod

Posted: Thu Mar 15, 2018 9:10 pm
by siyoa
I like this one ... now I am wondering, if you have the time and it is something you like to implement as well

I always liked the way how MOO 2 had shield absorption implemented, I wanted to look into it a year ago for SiS, and I want to look into it now, I just don't have that much time

Re: Combat Damage Mod

Posted: Fri Mar 16, 2018 3:52 pm
by harpy eagle
How did shield absorption work in MOO2?

Re: Combat Damage Mod

Posted: Fri Mar 16, 2018 4:57 pm
by siyoa
harpy eagle wrote:How did shield absorption work in MOO2?
first X amount of damage for each weapon hitting shields was ignored ... so absorption of 2 (for example) and firing at that shield with a weapon of damage range 3-8 actually made that weapon 1-6 effectively

I like it, because it promotes quality over quantity, it makes much higher advanced technology really superior as it should be

right now, if you have one titan ship with very best technology, it still can be nibbled by a 100 small frigates with very basic weapons ... but if, let's say that titan has absorption of 10 in its shields, laser beams of 1-10 damage are useless against it

as Neil deGrasse Tyson said (I think it was him), at certain difference between technology level of two civilizations, the more advanced seems like magic to the one less advanced

on unrelated note, I also really liked how miniaturization worked in MOO2 ... I am kind of getting around in SiS by expanding tech tree with Mk.2, Mk.3,... version of weapons, shields and changing num_mult (among other things) for them so you can pack more weapons per slot to kind of replicate MOO2 feel

also, somewhere on the list is to have shields on fighters/bombers and base their health on armor (I think I had this one done at some point a year ago, I don't have my old files anymore though)

Re: Combat Damage Mod

Posted: Fri Apr 20, 2018 6:01 pm
by zolobolo
The mod has so far achieved what you have set out for it do and since there is larger chance of ships escaping or being captured it also helps to keep the game flow better

Where I found it wasn't helping are the below:
1. Basic Harpy units got a huge boost to survivalist even if they cannot put up a fight - due to their basic regen ability it can become tiresome for the players to shoot them down though this can be mitigated with auto-turn button
2. Starbases - they are way tougher increasing the chance of being captured which is good but also benefit the defender which is not always optimal
3. Planetary Defenses- I would deactivate the affect for these as they cannot be captured to begin with

Re: Combat Damage Mod

Posted: Sun Apr 22, 2018 2:26 am
by harpy eagle
zolobolo wrote:1. Basic Harpy units got a huge boost to survivalist even if they cannot put up a fight - due to their basic regen ability it can become tiresome for the players to shoot them down though this can be mitigated with auto-turn button
Yeah the space harpies were something that I hadn't considered at all at the time. The harpies are supposed to be kind of more like living beings than ships so the vanilla damage mechanics probably make more sense for them anyways.
zolobolo wrote:2. Starbases - they are way tougher increasing the chance of being captured which is good but also benefit the defender which is not always optimal
3. Planetary Defenses- I would deactivate the affect for these as they cannot be captured to begin with
How big of a difference does it really make? I always sort of thought that by the time they would have died in the vanilla game, they are sort of crippled and without many functioning weapons in this mod. At least, that was the goal.

I guess it is true though that the mod does favour larger ships (of all kinds, starbases included) to some extent. I don't think it's very much of an extent though.

Re: Combat Damage Mod

Posted: Sun Apr 22, 2018 8:37 am
by zolobolo
Yes, in case of Harpies it could argued that their various organs constitute the whole of the being so when thee are 100% destroyed, they do not have anything left worth salvaging (and mechanically they can also not be salvaged)

In case of ships it could make sense to say there is a sort of base structure that is left behind even when the various systems are "dead"

Same for starbases: I generally found the effect of them being taken over by the invader as a cool result
The problem is also not their increased survivability but:
1. Once they get taken over they are automatically restored to full strength in the same turn (unlike captured starships) - though this might be a bug
2. Destroying them can be tedious for the player (but not as much as harpies as those regenerate while wearing down their remaining HP)

I am not saying that favoring large ships is a bad thing - though I also do not think this is the case with the mod
What I meant to say is that the halted damage in some scenarios lead to pointless filler shooting. I would hence suggest removing this effect from harpies and planetary defenses. Not sure about star-bases: Like the fact that they are often captured now but it would help a lot if they would at least be damaged for at least a turn

Re: Combat Damage Mod

Posted: Sun Apr 22, 2018 6:28 pm
by harpy eagle
zolobolo wrote:1. Once they get taken over they are automatically restored to full strength in the same turn (unlike captured starships) - though this might be a bug
I noticed that as well. I wonder how difficult it would be to make them need to be repaired like regular ships.

Re: Ship Damage Mod

Posted: Wed Apr 25, 2018 12:03 am
by harpy eagle
Update: Space harpies now take damage normally, although the code to determine exactly what is and what isn't a space harpy is a bit sketchy.

Re: Ship Damage Mod

Posted: Sat May 26, 2018 3:26 pm
by zolobolo
Can you please also set normal damage for planets?

Note: the mod gives consdierable advantage to ships using repair module which Tinkers do per default :)

Re: Ship Damage Mod

Posted: Sat Aug 25, 2018 9:08 am
by harpy eagle
zolobolo wrote:Can you please also set normal damage for planets?

Note: the mod gives consdierable advantage to ships using repair module which Tinkers do per default :)
I should pay closer attention to how well those ships do, but I did play some battles against AI Tinker and didn't notice them being that much harder to kill. In theory by the time the ship would have been destroyed in vanilla the repair modules should all be broken.

Re: Ship Damage Mod

Posted: Sat Aug 25, 2018 12:08 pm
by zolobolo
Noticed the Tinket advantage on the AI: it is always the Tinker AI that is the strongest among them since a couple of updates (and the mod)
The player can mostly handle the situation but the AI seems to have trouble countering them especially when using warhead based tech (which Tinkers churm out in endless stream)