EMP and Disabled Ship Timing

I’ve had some ideas for EMP weapons, but I’ve run into some barriers.

1) How do I edit the disabled ship time from say, 20 seconds to 4 seconds?

2) Can a ship have a disabled time of 0 seconds?

3) How can I edit what is or isn’t affected by the EMP in terms of ship stats/abilities/etc?

4) Does the EMP Shield regenerate during combat with or without delay, and how can I edit this?

5) Is there a way to edit a ship such that is is invulnerable until the ship is ‘disabled’?

6) Is there a way to have EMP damage linked to the energy bar of another ability such as the defense field?

My plans, or hopes at least, are to add a shielding system that can recharge during combat with ship armor only taking damage once the EMP shield is eliminated. The other idea I had involved use of an invisible EMP weapon coupled with any other weapon that can penetrate defense shields, while making normal weapons incapable of piercing through the shield. If the ship can translate EM damage to the defense field energy reserves, then a shield system will be in place.

Any thoughts or help? I haven’t found a good tutorial on the EMP system yet.

1 Like

I believe you change the last number in this line from the .wepn file:
AddWeaponResult(NewWeaponType,“Hit”,“Disable”,“Target”,20,20,"");

I believe you change the last number in this line from the .ship file to adjust the regen time:
addShield(NewShipType,“EMP”,220,20)

That’s all the help I can offer for the moment, though here are the relevant mirrors of Karos wiki info:
http://hwmod.wikia.com/wiki/AddAbility
http://hwmod.wikia.com/wiki/AddShield
http://hwmod.wikia.com/wiki/StartWeaponConfig
http://hwmod.wikia.com/wiki/AddWeaponResult

Yeah, I’ve been digging through those but can’t seem to find quite what I’m looking for. Thanks though.

I think the EMP shield isn’t going to work alone, unless I can tie it to the defense field energy reserves somehow.

This actually depends on the value of the “EMP Shield” of the target.

Not really, no. But technically, I suppose you could get close to this.

You can’t.

Yes, and no…

With scripting, yes.

Not likely.

For additional information, see this thread on that other site.

1 Like

Bummer. Now if there were a way to make damage taken from the defense field deplete energy reserves…

Also, it appears that the recharge time of the bar once disabled is fixed and the EMP damage overshoots. so if you take 100 emp damage and you have 20, it will have to repair from -80 before becoming active again, sustained EMP bombardment will continue to push the value more negative greatly increasing the disabled time.

1 Like

Well that’s good to know that’s fixed. :slight_smile:

Could there perhaps be a way to to make a custom lua for a ship in which all damage received would be dumped on a subsystem first before the actual ships armor?

1 Like

Yes, that can happen. If you’d like, I can whip one up…

Oh please do friend! I lack the know-how to do this, unfortunately.

I do appreciate the offer!

Alright, give me a bit…

Create data:scripts/lib/subsystem_shield.lua with the following contents:

SHIP_HEALTH = 170000 -- hgn_battlecruiser health
HP_HEALTH = 20000 -- Hiigaran Carrier/Battlecruiser module health

function Update_ShieldedShip(CustomGroup, playerIndex, shipID)
    local ship_health_pct = SobGroup_HealthPercentage(CustomGroup)
    local hp_health_pct = SobGroup_GetHardPointHealth(CustomGroup, "HardpointArmor")
    
    if (hp_health_pct <= 0) then
        return
    end
    
    local ship_damage = (1 - ship_health_pct) * SHIP_HEALTH
    local hp_health = hp_health_pct * HP_HEALTH
    
    local new_hp_health = hp_health - ship_damage
    local new_ship_health = SHIP_HEALTH
    
    if (new_hp_health < 0) then
        -- add, because new_hp_health is negative, effectively subtracting
        new_ship_health = new_ship_health + new_hp_health 
        new_hp_health = 0
    end
    
    if (hp_health > 0 and ship_health < 1) then
        SobGroup_SetHealth(CustomGroup, new_ship_health / SHIP_HEALTH)
        SobGroup_SetHardPointHealth(CustomGroup, "HardpointArmor", new_hp_health / HP_HEALTH)
    end
end

Note: “HardpointArmor” is an arbitrary hardpoint name I came up with. You’ll have to replace it with the name of a hardpoint that actually exists on the ship.


In the ship file, add:

addCustomCode(NewShipType,"data:scripts/lib/subsystem_shield.lua","","","Update_ShieldedShip","","ShieldedShip",0.2)


Also note: I haven’t tested this yet…


Various features could be added, such as:

  • Allowing some damage to bleedthrough to the ship, or having subsystems be more effective at reducing damage
  • multiple layers of subsystem armor/shields (each one possibly allowing a scenario of the above point?)
  • calculating upgraded health based on completed research
  • … others?
3 Likes

I’m gonna put this into play in a few moment. Thanks for that note at the end, that answered my first question.

As far as your third bullet point, that was actually my plan all along. Upgrades for both the shield module and the ship armor are desired, though I don’t know how to add to this to make it happen.

One question though, will each ship have to have their own individual lua such as this due to the different hardpoint labels?

Yes, and the differing health amounts for each ship/subsystem.

No problem there! Is there a get ship health command of some type to avoid typing in each ships armor values?

1 Like

Unfortunately, I do not believe so…


At least, not efficiently… I think I could come up with an absolutely ugly hack if motivated enough…

Don’t worry about it, you’ve done more than enough!

I’m running the test run now, I’ll edit this if it goes well.

Should I keep the quotations or not for the hardpoint name?

1 Like

Yes, keep the quotes.

Wrong: SobGroup_GetHardPointHealth(CustomGroup, HardpointArmor)
Correct: SobGroup_GetHardPointHealth(CustomGroup, "HardpointArmor")

I got the crashes to halt (user error), however the ship appears to be absorbing all of the damage.

1 Like

Just checking, does the ship have a subsystem in that slot?