Jump to content

[Mod] MilitaryMissions (contains "Pirate Warlord")


Hammelpilaw

Recommended Posts

MilitaryMissions

 

To me it was always frustrating that missions from military outpost was hard coded in the Merchant script, or to say it in easy words: adding new missions to military outpost is not very nice in vanilla game. So I created a mod wich makes you able to add new missions to military outpost as plugins. That's what this mod basicly does.

 

As an example plugin this mod contains the old but gold modded mission "Pirate Warlord" by Theoman02.

 

Also it is possible to add the mod XsotanDreadnought as a plugin for this mod.

Installation

 

Extract contents of the Avorion directory in zip file into your local Avorion directory.

 

Add the following code to the very bottom of the file `data/scripts/entity/merchants/militaryoutpost.lua`:

 

if not pcall(require, 'mods.MilitaryMissions.scripts.entity.merchants.militaryoutpost') then print('Mod: MilitaryMissions, failed to extend militaryoutpost.lua!') end

Optional: Configuration

Take a look into the file `mods/MilitaryMissions/config/MilitaryMissionsConfig.lua`. There some settings in the Config section to balance the pirate warlord mission.

 

Optional: Activate XsotanDreadnought

If you are using the XsotanDreadnought mod you can use it as plugin for the military outpost. Just open the config file (path above). Find the XsotanDreadnought settings in Missions section and remove the leading "--". The comments in the file will help you.

Requires XsotanDreadnought 0.3.0 or higher!

 

 

Add new missions

To add a new mission you need 2 files: `yourmission.lua` and `yourmissionBulletin.lua`. Replace "yourmission" by the mission name.

 

It does not matter where you place these files, but you should keep file structure. I recommand to create a new mod directory: `mods/yourmission/scripts/player/missions/`.

 

 

Add the path to the bulletin file below the "Custom missions below" comment. The syntax is like this:

 

{bulletin = "mods/yourmission/scripts/player/missions/yourmissionBulletin"},

 

Important is not to change any signs of that line, only the path and name of your file. Also you must NOT add the .lua part of the filename.

Hint: for testing enable dev mode of your test galaxy - this makes bulletin update every 5 seconds.

 

Optional: Configuration for missions

 

For this step you should watch config file. All vanilla missions, the Pirate Warlord and XsotanDreadnought are already configured correctly.

 

bulletin = script to bulletin file without lua ending. Required!

 

You can set optional configurations for every mission:

 

probability = % chance that outposts offer this missin. Values: 0-100. Leave blank to use 100%

maxDistance = The mission will not be offered when distance to core is below this. Leave blank for not limiting.

 

Example for using optional values (50% chance to find, max distance from core 250):

{bulletin = "mods/yourmission/scripts/player/missions/yourmissionBulletin", probability = 50, maxDistance = 250},

 

 

Create a new mission

Guide for craeting new missions may come sooner or later. You may use Pirate Warlord Plugin as axample. Taking a look into some vanilla missions or events may also help.

The XsotanDreadnought can also help, but because it is both, random event and a mission in one script, it's too complicated to be a good example.

 

Compatibility

This mod overwrites the script of the military outpost, so it should not be compatible with any mod that overwrites the same file. If you already got a modded mission for military outpost you may publish a plugin for this mod to add it to the game.

 

Credits

The mod itself, and especially the included mission "Pirate Warlord" uses some code snippets from "Pirate Warlord" mod by Theoman02.

 

This mission was designed and coded by Theoman02. I converted it to be a plugin for this mod and and updated for current Avorion version.

 

Version History

0.3.4

- Bugfixing

- Improved performance of military outpost

- Improved mod config

 

0.3.3

- Fixed an issue wich threw out a harmless error when a mission bulletin could not be loaded

 

0.3.2

- Fixed an issue wich may broke the mod on linux. Should work on all OS now.

 

0.3.1

- Initial release

 

 

Roadmap

Make this mod independent from military outpost, so that it can be added to any type of station. Each station can have its own mission types. This would highly improve compatibility and flexibility of the mod.

MilitaryMissions-0.3.4.zip

Link to comment
Share on other sites

  • 2 weeks later...

Thanks again for an awesome mod!

 

Will try it out and put it on the servers :)

 

Players are loving the dreadnought!

Nice to hear that  :) Please be aware that i just figured out a bug on the MilitaryMissions mod today wich seems to depend on OS. It could break the mod. Will upload a fix tomorrow. -> Fixed

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

File "mods\MilitaryMissions\scripts\player\missions\pirateWarlord.lua" - please add

local generator = require ("shipgenerator")

Otherwise lines 64-70 will throw an error:

PirateGenerator.createRaider(generator:getPositionInSector(5000))

for i = 1, numShips do
    PirateGenerator.createMarauder(generator:getPositionInSector(5000))
    PirateGenerator.createPirate(generator:getPositionInSector(5000))
    PirateGenerator.createBandit(generator:getPositionInSector(5000))
end

 

---

 

Also, just curious, why the update interval is 5 times per second instead of 1 per second like the default one?

function MilitaryOutpost.getUpdateInterval()
    return 0.2--1
end

 

I'm asking because on the Rusty's Galaxy servers "data/scripts/entity/merchants/militaryoutpost.lua" takes 1st-3rd place by execution time and I'm not sure why. Maybe because of this? Or because when sectors loads game tries to simulate 50 minutes of bulletin changes. I get that it's vanilla behaviour but maybe something can be done here?

local minutesSimulated = 50
for i = 1, minutesSimulated do -- simulate bulletin posting / removing
    MilitaryOutpost.updateBulletins(60)
end

 

UPD: Maybe replace it with something like this?

local minutesSimulated = 50
minutesSimulated = minutesSimulated * 60 -- convert to seconds
local simulations = math.floor(minutesSimulated / updateFrequency)
minutesSimulated = minutesSimulated - simulations * updateFrequency
for i = 1, simulations do -- simulate bulletin posting / removing
    MilitaryOutpost.updateBulletins(updateFrequency)
end
-- add the rest
MilitaryOutpost.updateBulletins(minutesSimulated)

 

This way with "updateFrequency = 60 * 30" and "minutesSimulated = 50" we will call "MilitaryOutpost.updateBulletins" function only two times.

First we will pass "updateFrequency" as an argument which will result in update.

Second - the rest of it (60 * 20 seconds)

Link to comment
Share on other sites

Thanks for the report.

 

First thing is a known issue and will be fixed in upcoming update of this mod. Most times the script will work though, not really sure why. I think the SectorGenerator script is loaded from another script and the generator variable is still set.

 

Second thing is... funny. I really dont know why update interval is 0.2. Should be 1. When you get the high execution time? On updating or initializing?

However, I never watched performance of this mod, looks like if I should do. Updating up to a very few missions every hour should not take much performance.

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...