Building: Minimissions
Minimissions are written in lua.
There is an object in mini_zone for each lua minimission. It is called mini_%s, where %s is whatever you like, but is probably the same as the 'mname'.
There are three new traps.
lua.minican
is called on the minimission template, which
should return true if and only if it is currently possible to create
a minimission of that type. For example, the simulator fixing
minimissions returns 1 if there are no currently broken simulator,
and lua.minicreate
, which should set up the mission. More
about this later. The lua.minidestroy
trap is called when
the mission is destroyed, whether by booting, timeout or completion (but
not due to a reboot). This can be used to place any cleanup code.
A few other properties should be set on the template.
- "mname" should be the short name of the mini, e.g. "loony", "cleanup","inspect".
- "mzone" should be the zone of boards it is available on, for example "level2", "lstone", or "*" (for all).
- "reward" should be the normal reward in cash for completing it. Note: for minimissions with at least 1 questpoint, or a rank.min attribute, mission rewards are adjusted according to player rank. Minis with no questpoints or rank.min attributes don't get their rewards adjusted.
- "questpoints" is the number of points the mini is worth. If you don't explicitly define this, it defaults to 1. Civilian minis shoudl have questpoints set to zero.
The minicreate
trap is called with o1 and pl equal to the
template. o2 is the actual minimission that is being created, and o3 is the board it is being posted at.
You are safe to assume that minicreate will not be called if minican would return false.
The mission will be shown on boards which have a matching nation, and an appropriate zone attribute. The mission's nation and bzone properties are automatically set to the values of the board the mission is being posted on. This can be overridden in minicreate... you might want to add additional zone names to bzone so the mini can be accepted from multiple different locations. bzone follows the same syntax as mzone described above.
Any objects or mobiles that this trap clones for the purposes of the mission should have their mission set with setmission(obj, o2), so they are destroyed properly. If you want the cloned objects to leave silently when the mission is deleted, set the SilentQuit flag on them. This is used for piles of sick, etc.
The mission object itself will need a few things setting by the trap, notably the "desc.external", which should be the long description you get when you accept or examine the mission. If this is long, it should set a "short_brief", which is a shorter version of this that appears on the missions board. It must also set "deadline", to a time value. For example, set(o2, "deadline", now()+10*60) to set the deadline to be in ten minutes in the future.
You can modify the reward, type (which defaults to value of mname), and bzone (which defaults to contents of mzone), if you want, but there's not usually a reason to do this.
The lua functions object mission(object of)
and givemission(object who,
object mission)
will probably be useful.