Ship Patching - Stage One

Same here. v2.205

There‘s a built-in function in Lua: rad()
So you can use things like “rot = { rad(45), rad(45), rad(45) }” to convert degrees to radians.

2 Likes

i didn’t realize there was a new version and will update to 2.205 to see what happens then

I thought steam updated automatically. Since when do we have to manually update?

2 Likes

steam does when you’reconnected. i have really slow internet and meager download limits so i keep my game computer offline except when necessary (things like the windows login page needlessly use up bandwidth that i’d like to save for other things).

since this :smiley: Announcement - Public Patch Preview

2 Likes

Just opt-ed in to the patch preview… Downloading now…

2 Likes

i updated HWRM and tried your code and it still doesn’t work.

with -taceHODs on, i get a log error w “data:\Ship\HGN_BATTLECRUISER\Patches\HARPOINTS.LUA” – parameter: expected…

i even changed the weapon to hgn_KinetcBirstCannonDestroyer to make it more noticeable if it did work. no crash, but no luck

I think you need to add one } to end of your hardpoints.lua

Because i did not paste it into code which i previously posted here.

I actually tried it without } and got same result.

LUA 'data:Ship\HGN_BATTLECRUISER\Patches\PATCH_BATTLECRUISER.LUA' -- parameter: <name> or `[' expected;
  last token read: `<eof>' at line 495 in string ""

Fixed original code reply.

Linky to code reply

1 Like

Version 2.205: rot = {0, 3.14, 0} and rot = {3.14, 0, 3.14} both have no effect.

See if the LUA rad function works:

I don’t see why it would have an effect if straight numbers don’t.

And it didn’t.

Interestingly enough, I can effect rotation changes to pre-existing hardpoints, just not new ones.

Did you add new hardpoints to ship file?

Because if you can rotate existing ones it sounds like you are missing something from ship file.

sigh

ship/sp_tanker/patches/patch.lua:

Patch_Priority = 3.0
Patch_Exclusive = 0
Patch_Ops = 
{
    hp_def = 
    {
        root = "Root",
        name = "NavLightR6",
        pos = { -132.7466, -14.2374, -240.2300 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_0 = 
    {
        root = "Root",
        name = "Hardpoint_Turret1_Position",
        pos = { 0, 17, 280 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_1 =
    {
        root = "Root",
        name = "Hardpoint_Turret2_Position",
        pos = { 0, 17, -207 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_20 =
    {
        root = "Root",
        name = "Hardpoint_Turret3_Position",
        pos = { 0, 17, -300 },
        rot = { rad(45), 3.141593, rad(180) },
        axis = { 0, 0, 0 },
    },
    hp_2 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft1_Position",
        pos = { 60, 13, -400 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_3 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft2_Position",
        pos = { 60, 13, -300 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_4 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft3_Position",
        pos = { 60, 13, -200 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_5 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft4_Position",
        pos = { 60, 13, -100 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_6 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft5_Position",
        pos = { 60, 13, 0 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_7 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft6_Position",
        pos = { 60, 13, 100 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_8 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft7_Position",
        pos = { 60, 13, 200 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_9 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft8_Position",
        pos = { 60, 13, 300 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_10 = 
    {
        root = "Root",
        name = "Hardpoint_TurretLeft9_Position",
        pos = { 60, 13, 400 },
        rot = { 0, rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_11 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight1_Position",
        pos = { -60, 13, -400 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_12 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight2_Position",
        pos = { -60, 13, -300 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_13 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight3_Position",
        pos = { -60, 13, -200 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_14 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight4_Position",
        pos = { -60, 13, -100 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_15 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight5_Position",
        pos = { -60, 13, 0 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_16 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight6_Position",
        pos = { -60, 13, 100 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_17 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight7_Position",
        pos = { -60, 13, 200 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_18 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight8_Position",
        pos = { -60, 13, 300 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_19 = 
    {
        root = "Root",
        name = "Hardpoint_TurretRight9_Position",
        pos = { -60, 13, 400 },
        rot = { 0, -rad(90), 0 },
        axis = { 0, 0, 0 },
    },
    hp_21 =
    {
        root = "Root",
        name = "Weapon_Torpedo1_Position",
        pos = { -7.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_22 =
    {
        root = "Root",
        name = "Weapon_Torpedo1Slave_Position",
        pos = { -22.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_23 =
    {
        root = "Root",
        name = "Weapon_Torpedo1Slave1_Position",
        pos = { -37.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_24 =
    {
        root = "Root",
        name = "Weapon_Torpedo1Slave2_Position",
        pos = { -52.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_25 =
    {
        root = "Root",
        name = "Weapon_Torpedo2_Position",
        pos = { 7.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_26 =
    {
        root = "Root",
        name = "Weapon_Torpedo2Slave_Position",
        pos = { 22.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_27 =
    {
        root = "Root",
        name = "Weapon_Torpedo2Slave1_Position",
        pos = { 37.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_28 =
    {
        root = "Root",
        name = "Weapon_Torpedo2Slave2_Position",
        pos = { 52.5, 3, 430 },
        rot = { 0, 0, 0 },
        axis = { 0, 0, 0 },
    },
    hp_29 =
    {
        root = "Root",
        name = "Weapon_HullDefense1_Position",
        pos = {73.39441, 3.002552, -264.4487},
        rot = { 0, rad(90), -0.48103232679489661923132169163975 },
        axis = { 0, 0, 0 },
    },
    hp_30 =
    {
        root = "Root",
        name = "Weapon_HullDefense2_Position",
        pos = {-73.88965, 5.299879, -264.7062},
        rot = { 0, -rad(90), 0.00904032679489661923132169163975 },
        axis = { 0, 0, 0 },
    },
}

print("rotx : " .. Patch_Ops["hp_20"]["rot"][1])
print("roty : " .. Patch_Ops["hp_20"]["rot"][2])
print("rotz : " .. Patch_Ops["hp_20"]["rot"][3])

(Comment out the hp_29 and hp_30 hardpoints to see the default rotation of those hardpoints.)

ship/sp_tanker/sp_tanker.ship:

NewShipType = StartShipConfig()
NewShipType.displayedName="$1900"
NewShipType.sobDescription="$1901"
NewShipType.maxhealth=1800000
NewShipType.regentime=0
NewShipType.minRegenTime=0
NewShipType.sideArmourDamage=1.2
NewShipType.rearArmourDamage=1.4
NewShipType.isTransferable=1
setTacticsMults(NewShipType, "DAMAGEAPPLIED", 0.90, 0.90, 0.90)
NewShipType.paradeData="dummy_parade"
NewShipType.defaultROE="Defensive"
NewShipType.defaultStance="Aggressive"
NewShipType.mass=1000
NewShipType.collisionMultiplier=1
NewShipType.thrusterMaxSpeed=40
NewShipType.mainEngineMaxSpeed=40
NewShipType.rotationMaxSpeed=9
NewShipType.thrusterAccelTime=6
NewShipType.thrusterBrakeTime=2
NewShipType.mainEngineAccelTime=6
NewShipType.mainEngineBrakeTime=2
NewShipType.rotationAccelTime=0.5
NewShipType.rotationBrakeTime=0.2
NewShipType.thrusterUsage=1
NewShipType.accelerationAngle=30
NewShipType.mirrorAngle=0
NewShipType.secondaryTurnAngle=0
NewShipType.maxBankingAmount=20
NewShipType.descendPitch=10
NewShipType.goalReachEpsilon=25
NewShipType.slideMoveRange=350
NewShipType.controllerType="Ship"
NewShipType.tumbleStaticX=0
NewShipType.tumbleStaticY=0
NewShipType.tumbleStaticZ=0
NewShipType.tumbleDynamicX=0
NewShipType.tumbleDynamicY=0
NewShipType.tumbleDynamicZ=0
NewShipType.tumbleSpecialDynamicX=0
NewShipType.tumbleSpecialDynamicY=0
NewShipType.tumbleSpecialDynamicZ=0
NewShipType.relativeMoveFactor=2
NewShipType.swayUpdateTime=2
NewShipType.swayOffsetRandomX=10
NewShipType.swayOffsetRandomY=10
NewShipType.swayOffsetRandomZ=10
NewShipType.swayBobbingFactor=0
NewShipType.swayRotateFactor=0
setTargetBox(NewShipType, 0, -0.8,-0.7,-1, 0.8,0.5,0.95)
NewShipType.dustCloudDamageTime=0
NewShipType.nebulaDamageTime=0
NewShipType.MinimalFamilyToFindPathAround="MotherShip"
NewShipType.BuildFamily="NotBuildable"
NewShipType.AttackFamily="BigCapitalShip"
NewShipType.DockFamily="Transport"
NewShipType.AvoidanceFamily="Frigate"
NewShipType.DisplayFamily="Utility"
NewShipType.AutoFormationFamily="Fighter"
NewShipType.CollisionFamily="Big"
NewShipType.ArmourFamily=getShipStr(NewShipType, "ArmourFamily", "MediumArmour")
setSupplyValue(NewShipType, "SinglePlayerMisc", 1.0)
NewShipType.fighterValue=0
NewShipType.corvetteValue=0
NewShipType.frigateValue=0
NewShipType.neutralValue=0
NewShipType.antiFighterValue=0
NewShipType.antiCorvetteValue=0
NewShipType.antiFrigateValue=0
NewShipType.totalValue=0
NewShipType.buildCost=480
NewShipType.buildTime=30
NewShipType.buildPriorityOrder=20
NewShipType.retaliationRange=1600
NewShipType.retaliationDistanceFromGoal=160
NewShipType.visualRange=3000
NewShipType.prmSensorRange=3000
NewShipType.secSensorRange=3000
NewShipType.detectionStrength=1
NewShipType.TOIcon="Parallelogram"
NewShipType.TOScale=1
NewShipType.TODistanceFade0=14000
NewShipType.TODistanceDisappear0=12000
NewShipType.TODistanceFade1=5500
NewShipType.TODistanceDisappear1=5000
NewShipType.TODistanceFade2=12000
NewShipType.TODistanceDisappear2=35000
NewShipType.TOGroupScale=1
NewShipType.TOGroupMergeSize=0
NewShipType.mouseOverMinFadeSize=0.045
NewShipType.mouseOverMaxFadeSize=0.1
NewShipType.healthBarStyle=2
NewShipType.nlips=0
NewShipType.nlipsRange=75000
NewShipType.nlipsFar=0
NewShipType.nlipsFarRange=0
NewShipType.SMRepresentation="Mesh"
NewShipType.meshRenderLimit=25000
NewShipType.dotRenderLimit=10
NewShipType.visibleInSecondary=1
NewShipType.minLOD=0.25
NewShipType.goblinsStartFade=3500
NewShipType.goblinsOff=3500
NewShipType.minimumZoomFactor=0.5
NewShipType.preciseATILimit=0
NewShipType.selectionPriority=65
NewShipType.militaryUnit=0
NewShipType.SMHighlightDistMin=20000
NewShipType.SMHighlightDistMax=25000
addAbility(NewShipType,"MoveCommand",1,0);
addAbility(NewShipType,"CanDock",1,0);
NewShipType.dockTimeBetweenTwoFormations=1
NewShipType.dockTimeBeforeStart=2
NewShipType.dockNrOfShipsInDockFormation=1
NewShipType.dockFormation="delta"
NewShipType.queueFormation="dockline"
NewShipType.dontDockWithOtherRaceShips=0
NewShipType.ignoreRaceWhenDocking=1
addAbility(NewShipType,"CanLaunch");
NewShipType.launchTimeBetweenTwoFormations=1
NewShipType.launchTimeBeforeStart=1
NewShipType.launchNrOfShipsInDockFormation=1
NewShipType.launchFormation="delta"
addAbility(NewShipType,"ShipHold",1,150,0,"rallypoint","",150);
addAbility(NewShipType,"ParadeCommand",1);
addAbility(NewShipType,"WaypointMove");
addAbility(NewShipType,"HyperSpaceCommand",1,1,1,1,1,1);
addAbility(NewShipType,"CanAttack",1,1,0,0,0.35,1,"Fighter, Corvette, Frigate, SmallCapitalShip, BigCapitalShip, Mothership","Broadside");
NewShipType.active=1
addAbility(NewShipType,"HyperspaceViaGateCommand",1,3,1,0.3);
LoadModel(NewShipType,1);
-- StartShipWeaponConfig(NewShipType,"Hgn_MSHullDefenseGun","Weapon_HullDefense1","Weapon_HullDefense1");
-- StartShipWeaponConfig(NewShipType,"Hgn_TransportHullDefenseGun","Weapon_HullDefense2","Weapon_HullDefense2");

StartShipHardPointConfig(NewShipType,"Weapon_HullDefense1","Weapon_HullDefense1","Weapon","Innate","Ship","hgn_pulsar","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_HullDefense2","Weapon_HullDefense2","Weapon","Innate","Ship","hgn_pulsar","","","","","","","","");

StartShipWeaponConfig(NewShipType,"hgn_destroyertorpedolauncher","Weapon_Torpedo1","Weapon_Torpedo1");
StartShipWeaponConfig(NewShipType,"hgn_destroyertorpedolauncher","Weapon_Torpedo2","Weapon_Torpedo2");

StartShipHardPointConfig(NewShipType,"Weapon IonBeam 1","Hardpoint_Turret1","Weapon","Innate","Damageable","Hgn_BattleCruiserIonBeamTurret","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon IonBeam 2","Hardpoint_Turret2","Weapon","Innate","Damageable","Hgn_BattleCruiserIonBeamTurret","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon IonBeam 3","Hardpoint_Turret3","Weapon","Innate","Damageable","Hgn_BattleCruiserIonBeamTurret","","","","","","","","");

StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft1","Hardpoint_TurretLeft1","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft2","Hardpoint_TurretLeft2","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft3","Hardpoint_TurretLeft3","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft4","Hardpoint_TurretLeft4","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft5","Hardpoint_TurretLeft5","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft6","Hardpoint_TurretLeft6","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft7","Hardpoint_TurretLeft7","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft8","Hardpoint_TurretLeft8","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretLeft9","Hardpoint_TurretLeft9","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight1","Hardpoint_TurretRight1","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight2","Hardpoint_TurretRight2","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight3","Hardpoint_TurretRight3","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight4","Hardpoint_TurretRight4","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight5","Hardpoint_TurretRight5","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight6","Hardpoint_TurretRight6","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight7","Hardpoint_TurretRight7","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight8","Hardpoint_TurretRight8","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");
StartShipHardPointConfig(NewShipType,"Weapon_TurretRight9","Hardpoint_TurretRight9","Weapon","Innate","Ship","hgn_vulcankineticturretheavy","","","","","","","","");



NewShipType.battleScarCoverage=4
NewShipType.battleScarBudgetLow = 800
NewShipType.battleScarBudgetNext = 1200
NewShipType.sobDieTime=3.6
NewShipType.sobSpecialDieTime=3.6
NewShipType.specialDeathSpeed=40
NewShipType.chanceOfSpecialDeath=0
NewShipType.deadSobFadeTime=0
NewShipType.trailLinger=3
NewShipType.canSurround=1
NewShipType.canJoinStrikeGroup=0
setEngineGlow(NewShipType,1,1,1.02,20,300,50,1.5,{0.27, 0.47, .69, 0.25});
loadShipPatchList(NewShipType,"data:sound/sfx/ship/misc/",0,"Engines/CCivilianEng","marker6",1,"Ambience/CKundeTankerAmb","");

hwrm.log output:

rotx : 0.7853981633974483
roty : 3.141593
rotz : 3.141592653589793

Note that none of the side turrets are rotated, the back ion cannon is not rotated, but the the pulsar turret is rotated.

I don’t get it

EDIT: does this show that rotation ONLY works when editing existing hardpoints?

No because rotation works fine for me

Even my hiigaran destroyer has some 90 degree angled custom turrets at it’s hull

For me and @gthompsn, apparently that is the case. For @unifin, not so much.

I’m just demonstrating my lack of ability to get hardpoint rotation to work, while @unifin and @sastrei showcase their mad skillz.

And as a side note: This patching system really pissing me off; how it works for some people, and in some cases, but not universally. This is likely going to be yet another reason why I refuse to touch any post-patch HODs (with the exception of the default joint positions I yanked from the files). However, this may piss me off enough to get my hands dirty (or more dirty, i suppose).


Has anyone else actually tried my code to see if it works on their system?

@radar3301 I did some more tests based on @unifin’s findings, here’s what a negative 180 rotation looks like:

rot = { 0, 0, -3.141 },

using regular angle values will give unpredictable results, but you can also use

rot = { 0, 0, rad(-180) },

Patch_Priority = 3.0
Patch_Exclusive = 0
Patch_Ops = {
hp_1 = {
    root = "Root",
    name = "Hardpoint_Af1_Position",

	--WIDTH(x) HEIGHT(y) LENGHT(z)
	--In Blender 3D lenght(z) is (y) and it is inversed.

    pos = { 20, 20, 20 },

	--RADIANS Z is inversed in Blender.
	-- 3.141R = 180D
	-- 1.570R = 90D
--x,y,z
	rot = {  0, 0, -3.141 },
    axis = { 0, 0, 0 },

    subs = {
        hp_2 = {
            root    = "Hardpoint_Af1_Position",
            name    = "Hardpoint_Af1_Rest",
            pos        = { 0, 0, 10 },
            rot        = { 0, 0, 0 },
            axis    = { 0, 0, 0 },
        },
        hp_3 = {
            root    = "Hardpoint_Af1_Position",
            name    = "Hardpoint_Af1_Direction",
            pos        = { 0, 10, 0 },
            rot        = { 0, 0, 0 },
            axis    = { 0, 0, 0 },
        },
    },
},
}

Try adding Hardpoint_*_Direction and Hardpoint_*_Rest as sub points of Hardpoint_*_Position.
Without Direction and Rest points, rotation won’t work. I think that’s why you can effect rotation changes to pre-existing hardpoints, because they have their Direction and Rest points

i had noticed that and made the fix when i first copied your code. in fact, since i don’t have hgn_pds_turret i used the assault frigate turret insetead in the battlecruise .ship file.

it still doesn’t work for me.