I have started learning how to create md scripts and wanted to start by adding something that is holding back my pirate playthroughs. I thought that it would be awesome if i could just chase down my enemies after they bailed from their ships, and capture them from the escape pod!
This is necessary when i'm playing as certain factions that are hated all around. I can't talk to anyone, so the only way to get crew would be to bait certain pirates into boarding an abandoned ship which i would claim before the pods reach. You guys may know about that exploit, and it takes a long time to find certain faction ships and get them into that situation.
So long story short, i need some examples of certain logic which i thought more experienced members may be able to direct me to. I'm not expecting anyone to do the work for me, of course i am actively looking through unpacked md scripts like boarding.xml and trying to find the relevant logic. Scriptproperties has a ton of info, and i have visual studio completing code but the fact that the scriptproperties.html doesnt work anymore is making it hard to read through the xml and find exactly what i'm looking for.
How to set_value the players current target, (edit: I found player.target identified in the player properties)
how to query the distance to target, (edit: I found the section in scriptproperties explaining that distanceto is a property of a position in relation to another position, so it's: $object.position.distanceto{$targetobject.position}
how to check empty crew slots, (edit: $object.people.free does this)
how to transfer specific number of crew from npc ship to player ship, (edit: transfer_people function does a transfer and takes capacity into account)
how to change faction relations, (edit: i found the add_faction_relation function in the common xml)
how to create notifications (edit: i found the show_notification function in the common xml)
If anyone has examples off-hand, like "hey look in blahblah.xml" that would help me out.
Below is my little work so far, pulling conditions from better piracy mod and Euclid's advice to other people. Not sure if i'm using instantiate correctly, but i'd like it to be watching for conditions pretty much all the time.
Edit: I updated the code with what i think will work, just looking to figure out how to make the crew prisoners at first, for immersion.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<mdscript name="Dandy_Capture_Crew" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<!-- Dans script to enable capturing boarding pods by targeting and approaching them
When the player target is an escapepod
if the player controlled ship is within 10m
If there is free space,
transfer crew from the escape pod into the player ship as prisoners (up to the free crew slots available)
Reduce the player rep with owner faction of the captured crew.
create a notification regarding the capture..
If the player has a full crew complement,
issue a message that there is no free space on their ship -->
<cues>
<cue name="CueDandyCapturePod" instantiate="true" namespace="this">
<!-- the cue will fire when the conditions are met-->
<conditions>
<!-- dim a variable "target" and set it to the player's current target -->
<set_value name="$target" exact="player.target"/>
<!-- the target needs to exist and be operational (not destroyed) -->
<check_value value="$target and $target.isoperational"/>
<!-- the target should be a ship -->
<check_value value="$target.isclass.ship" />
<!-- if the player target has shiptype == "escapepod" -->
<check_value value="$target.type == escapepod"/>
<!-- if the distance to the player target is less than 10m -->
<check_value value="($target.position.distanceto{player.ship.position} < 10m"/>
<!-- the target should not be player owned -->
<check_value value="not $target.isplayerowned" />
<!-- EUCLID: does player ship exists, is it not docked, is he not just standing in the ship, is it his ship -->
<check_value value="player.ship and player.ship.parent.isclass.zone and player.occupiedship and player.ship.isplayerowned"/>
</conditions>
<!-- perform the specified actions below, when the above conditions are met -->
<actions>
<!-- set up variables to be used in the actions namespace-->
<set_value name="$target" exact="player.target"/>
<set_value name="$capturedcrew"/>
<!-- if the player has free crew space -->
<do_if value="player.ship.people.free > 0">
<!-- transfer the crew, from the pod to the player ship (as prisoners), until the player ship is full, or the pod is empty-->
<transfer_people object="player.ship" otherobject="$target" result="$capturedcrew"/>
<!-- destroy the pod -->
<!-- lower relations with offended faction -->
<add_faction_relation faction="$target.trueowner" otherfaction="player" value="-1"/>
<!-- notify the player about the capture -->
<show_notification text="'%s captured %s on %s', [player.name,player.ship,$capturedcrew]"/>
<!-- if the player has no free space -->
<do_if value="player.ship.people.free == 0">
<!-- notify the player that they dont have any crew space left -->
<show_notification text="'%s has no more crew space available', player.ship"/>
<!-- delay so that the message doesnt just keep appearing -->
<delay exact="5s"/>
</do_if>
<delay exact="1s"/>
</actions>
</cue>
</cues>
</mdscript>