assigning a weapon to a weapon position by script

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

assigning a weapon to a weapon position by script

Post by dybal »

Ship Storage Helper assigns weapon string to the restored ship's weapon position:

Code: Select all

ship.forwardWeapon = storedShipArray[3];
If that weapon has a condition_script, the context that is passed to its allowAwardEquipment is "purchase" instead of "scripted"
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: assigning a weapon to a weapon position by script

Post by dybal »

Changing line 1865 of src/Core/Scripting/OOJSShip.m from

Code: Select all

            [entity setWeaponMount:facing toWeapon:sValue];
to

Code: Select all

            if (entity == PLAYER) {
                [entity setWeaponMount:facing toWeapon:sValue inContext:@"scripted"];
            } else {
                [entity setWeaponMount:facing toWeapon:sValue];
            }
solved it, but I don't know if that's the best solution, or changing the ship outfitting code in the core game to call setWeaponMount with the context "purchase" and changing the version of setWeaponMount without context (called from OJSShip.m) to default to context "scripted".
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: assigning a weapon to a weapon position by script

Post by dybal »

I have been using this fix for two weeks, so I created a Pull Request for it.
Post Reply