I realize that this question was asked four years ago, and that the person asking has almost certainly either figured it out by now or else doesn't care anymore. But, since nobody else had answered, and I happen to know how to do this, I figured that I'd offer my two pieces o' eight in case anyone else was wondering. I got the code from TJ's random adventures script and now include it in all my custom games. I like it a lot better than having a patron give me captives.
In your initial setup, where
action enable_game_data_override {} is located, add this:
action assert_float { name: "shipwreck_chance"; value: 0.0; }
action assert_int { name: "shipwreck_check_tick"; value: (game_tick + 150); }
Then, after your other rules, add this:
//
// Rule: shipwrecked_mariners_check
// Description: Checks every <N> ticks whether a shipwreck should occur. The chance of
// a shipwreck starts at 0% and increases <DELTA> amount every check.
//
rule shipwrecked_mariners_check
{
frequency tick;
conditions
{
game_tick >= shipwreck_check_tick;
}
actions
{
action assert_int { name: "shipwreck_check_tick"; value: (shipwreck_check_tick + 300); }
action evaluate_rule { name: "shipwrecked_mariners_check_sub1"; }
}
}
rule shipwrecked_mariners_check_sub1
{
frequency invokation;
conditions
{
always_true;
}
actions
{
action assert_float { name: "shipwreck_chance"; value: (shipwreck_chance + 0.01); }
action evaluate_rule { name: "shipwrecked_mariners_check_sub2"; }
}
}
rule shipwrecked_mariners_check_sub2
{
frequency invokation;
conditions
{
random_0_to_1 < shipwreck_chance;
}
actions
{
action assert_int { name: "num_survivors"; value: random_number(1, 5); }
action create_message_dialog
{
title: "/text/dial/scen/ship/titl";
body: pattern_string("/text/dial/scen/ship/mess", num_survivors);
artType: "illu";
pictureID: "wrec";
}
action add_unskilled { amount: num_survivors; species: "ugen"; nationality: random_nationality; }
action assert_float { name: "shipwreck_chance"; value: 0.0; }
action retract { name: "num_survivors"; }
}
}
Good luck!