Page 29 of 56

Distress calls and their consequences

Posted: Mon Nov 22, 2010 4:52 pm
by CheeseRedux
A few hours have passed, and my mind has had a chance to sort through this thing. Before I bring you my conclusions, please bear in mind that I have only a cursory knowledge of programming in general and Oolite programming in particular. What I write is based solely on logic, realism, what makes sense, call it what your like.

1. The ability (technology) to send and receive distress calls exists in the Ooniverse.

2. Thargoids may or may not possess the ability (technology) to receive distress calls sent by non-Thargoids. I have no firm opinion either way. However, in order to save myself - and more importantly you! - from a bucketful of "with the possible/probable exception of Thargoids", the rest of this post will ignore them completely.

3. Every single class (role) of ship/station/entity/whatever should be able to receive (and send) distress calls. It makes no sense whatsoever for a trader to be equipped with only a one-way panic button. I can see no conceivable reason why any governing body would want to restrict two-way communication to police and bounty hunters. "I'd like to buy a radio, please." "Occupation?" "Trader." "Sorry, you can't have one. Next!" "I'd like to buy a radio, please." "Occupation?" "Tr... er, Bounty Hunter." "Here you go. Please pay at the cashier." Even if they for some unfathomable reason were restricted, otherwise law abiding people would get their hand on one just for their sheer usefulness.

4. Every ship within range of a distress call should react to it, only the type of reaction should be different. Again looking at a Trader, in the vast majority of cases it would be extremely stupid to simply ignore the pirate attacking some prey between the Trader and its destination. Nature provides the answer: Fight or flee. Don't just keep ambling along as if nothing is going on.

To rephrase myself from earlier:
Should this (lack of!) behaviour be changed? Absolutely.
Is it important enough to start messing with? That's up to the fellows doing the messing...

Re: Distress calls and their consequences

Posted: Mon Nov 22, 2010 5:19 pm
by Disembodied
CheeseRedux wrote:
4. Every ship within range of a distress call should react to it, only the type of reaction should be different. Again looking at a Trader, in the vast majority of cases it would be extremely stupid to simply ignore the pirate attacking some prey between the Trader and it's destination. Nature provides the answer: Fight or flee. Don't just keep ambling along as if nothing is going on.
A good point! It might require the creation of two different types of trader: "Old traders" and "Bold traders" (in that there are old traders, and bold traders, but there are no old, bold traders ... ;)). "Old traders" would avoid trouble, angling away from the calls for help before regaining their previous course. "Bold traders" might decide to lend a hand.

This might start a chain of pleas for help, of course, as bold traders jump in to a fight then start squawking themselves. Mind you, it shouldn't happen too often, and would be entertaining to witness too ...
CheeseRedux wrote:
To rephrase myself from earlier:
Should this (lack of!) behaviour be changed? Absolutely.
Is it important enough to start messing with? That's up to the fellows doing the messing...
The ₢64,000 question!

Posted: Mon Nov 22, 2010 5:50 pm
by Smivs
This got me thinking a bit. It does seem silly that a Trader will never answer a distress call, but I can see that it wouldn't be common. Most Traders are pretty weedy in terms of their ship's spec. and it wouldn't be wise for them to go looking for trouble.
The 'problem' is actually us, the players. I'm sure many (most?) of us are basically Traders, but are happy to do a bit of Bounty Hunting on the side, and of course we all 'Iron-Ass' our ships as well, so it makes sense for us to intervene. We like the bounty and we've got the ships that allow us to do this relatively safely.
In other words there is not an NPC equivalent to us, a Hunter/Trader. Perhaps there should be, but this would mean introducing multiple changes to the game both in terms of code but gameplay as well.
Do we want this? I'm personally open minded on this point, but considering the amount of work needed, and the (unpredictable) effects on game-play, I suppose on balance it makes sense to leave things as they are.

Posted: Mon Nov 22, 2010 5:53 pm
by Commander McLane
I think you're making the thing over-complex. Please bear in mind that there actually are no traders buying equipment and being denied certain types of equipment. There is only clever programming creating the illusion of certain things happening. The rest happens in your head.

So, there exists a set of AI commands which create the illusion that there are police ships (and bounty hunters) patrolling the space lanes. But patrolling alone obviously isn't enough. They also have to intervene if something illegal happens, or the illusion of police patrol will be broken. Therefore there exists one command in this set which enables police ships (and bounty hunters) to confirm that something illegal has happened and take action.

That's what we're talking about. Nothing less and nothing more. It is working exactly as it should (and as advertised), so there is no need whatsoever to change anything with that command. It is simply part of the inner workings of Oolite, and it isn't broken in any way.

I also see no need for traders to act like bounty hunters. There are already bounty hunters in the game, so why make the behaviour of traders into the behaviour of bounty hunters, thereby effectively just decreasing the number of traders and increasing the number of bounty hunters in the game. That's all you would achieve. And the player wouldn't even notice, because he has no way to distinguish between a genuine bounty hunter and a trader-acting-as-bounty-hunter. So why bother?

Posted: Mon Nov 22, 2010 6:17 pm
by Switeck
Commander McLane wrote:
What has scanForHostiles to do with either the ACCEPT_DISTRESS_CALL-message or the communication between NPC-traders? I don't understand the entire paragraph. :oops:
What I wanted was something like this:
"ACCEPT_DISTRESS_CALL" = ("setStateTo: FLEE");
So traders not only would not try to fight...they'd attempt to flee from nearby fights already in progress.
Of course this won't work and isn't designed to work...for reasons already bluntly pointed out. :evil:

I would use "scanForHostiles" to silently do the equivalent, ("silently" because no broadcastDistressMessage is needed) but it only checks for pirates/attackers/Thargoids targeting them. If the pirates are targeting+attacking a nearby soon-to-die trader..."scanForHostiles" will find nothing (except maybe Thargoids). So other traders blunder right into the fight and die as well. In short, it's stupid.
Commander McLane wrote:
If you want to change that behaviour for some traders, you are free to do it via JS-scripting. Personally I wouldn't find this a sensible change, though.
While writing a complex js script in a OXP to simulate this might be viable...that doesn't sound like a good choice either. Much of the code that is needed is already there, if only this worked:
"ACCEPT_DISTRESS_CALL" = ("setStateTo: FLEE");
...Or if "scanForHostiles" actually scanned for hostiles in the area rather than just counting only the subset of hostiles that are attacking you personally.

Posted: Mon Nov 22, 2010 7:10 pm
by Kaks
Well, you'll be pleased to know you can make distress calls in trunk, and you can target exactly who's going to receive them and how they're going to react to it, depending on how many ships are nearby & which type of ships they are:

http://wiki.alioth.net/index.php/Oolite ... geReceived

All you need to do is send 'coded' messages as long as you agree on the meaning of the first word, you can decide that any message starting with 'ahoy' and 'arr' means a pirate is asking for help from other pirates. After that you need to code their AI to send a random message starting with those two words, and set up a few iron ass pirates that listen specifically for those code words.

JS's string parsing abilities are pretty powerful, you could even set a script up to react to messages that contain both dinner & cake, in any random order, so you could have pirates saying 'save some dinner for me!' 'I fancy a cake' & 'after dinner tonight I might just tuck into my gran's cake'. And only the last message will be interpreted as 'guys, come over, there's a big trader with a ton of escorts!'

One thing that possibly isn't entirely obvious, but perfectly doable via js, is that you can trigger events in all ships in a system, regardless of distance: while commsMessageReceived will only trigger 'naturally' if a ship's broadcast is in range, doing

Code: Select all

aDistantShip.script.commsMessageReceived('helloooo!', this.ship) 
will trigger the commsMessageReceived event for the ship identified with aDistantShip, no matter how far they are...

And again, via js you can fairly easily select all ships in a system with a specific role, and either send them a 'proper' comms message, or just call a script function directly. There's quite a range of choices already... :)

Posted: Mon Nov 22, 2010 7:24 pm
by Switeck
I can already see it now...traders holding "conversations" with each other, sometimes talking about pirate conditions where they've been (which might trigger mission conditions/extra pirates if you visit there)...but mostly just squawking back-and-forth smalltalk.

Posted: Mon Nov 22, 2010 10:01 pm
by Thargoid
I still don't see what's wrong with following up the receipt of a distress call with a weighing up of the odds. If the odds are good then go help, if bad (or even) then run away.

Then iron-assed traders can automagically help out others, whilst more pure-merchant ones will run for it. That way we also kinda emulate the two main groups of players (traders and bounty hunters), and if we include the original pirates (as the third group of players) we then have a nice situation where the player character isn't that unusual compared to NPCs in helping (or not) other people who may trade.

And all of that functionality is already in AI commands. Kaks' JS bolt-on to that then broadens things considerably for "set piece encounters" etc.

Posted: Mon Nov 22, 2010 10:18 pm
by Switeck
Thargoid wrote:
And all of that functionality is already in AI commands.
Except it doesn't fully work. :cry:

Posted: Mon Nov 22, 2010 10:26 pm
by Thargoid
Switeck wrote:
Thargoid wrote:
And all of that functionality is already in AI commands.
Except it doesn't fully work. :cry:
I know. My meaning was to support the call to expand who receives that AI command, as has previously been mentioned. Everything else is already in the toolbox.

Posted: Mon Nov 22, 2010 10:41 pm
by LittleBear
Had a similar problem with making the bounty hunters in Random Hits (not added by the role police or hunter), none the less perform law enforcement. Scaning nearby ship's bounty is one way to do it as 99 times out of 100 a bad guy attacking another trader will have a bounty. You can also scan for Thargoids and Pirates by role. These are the only NPC (apart from some special OXP ships) which will attack NPC traders.

If therefore you have your traders do a peroidic scan for ships in range with these roles and / or a bounty and if they find one set the state to "MAKE_CHOICE".

Under "MAKE_CHOICE", do a D roll giving chances to ignoring the fight, helping the trader in distress or legging it. You could even add a chance of an appropriate comms hail if you like "Sorry mate, I'd love to help but my cargo of edible poets must reach the station by midnight!", "Frightful Blackguard! I have my fellow merchantman's back!" etc.

The Scan gives the trader a target so you can tell it to attack or flee from it. The effect would be when one of your ships comes in scanner range of a scrap involving NPC Traders v NPC pirates (or a pack of pirates appears), the AI detects them and can then engage, flee or ignore.

Have a poke around the AIs in Random Hits if you like. :wink:

Posted: Tue Nov 23, 2010 8:29 am
by Eric Walch
Having looked more in depth in the broadcastDistressMessage, I also think that it makes no sense to only send it to very specific roles. It should go to all 16 nearby ships and than it is up to the AI to decide if it should react. I think it is code written for a very early Oolite version.
e.g. when the target is in 1 of the attack modes it also does not get an interruption. But its only checking for 3 of the 6 possible attack modes, so I assume that it was added quite early. But when a "ATTACK_SHIP" state has no reaction programmed for a distress call it will not react in the first place.

All 16 nearby ships do get the expanded message "[beg-for-mercy]". Starting from 1.75 these massages are now received by JS, but a script can't do anything with it because the text can be anything, specially when a localised Oolite version is used.

Using the 16 ships from the internal [checkScanner] routine has as advantage that is uses a very optimised way to fast select 16 nearby ships based on the internal z-coordinate sorted z-list. Doing an entity search with JS will take several times longer. I already had pondered if [checkScanner] should be available as array to JS. Than JS can use a filter function on that array. I just think most scripters would ignore a method that can miss ships in a crowded sky, even when it would be fast.

Posted: Tue Nov 23, 2010 7:30 pm
by Eric Walch
Eric Walch wrote:
Having looked more in depth in the broadcastDistressMessage, I also think that it makes no sense to only send it to very specific roles.
I just tried to change the code to send the distress message to all ships in range. Doing that, I noticed that it won't work. The essence of a distress call is that it transfers the aggressor as found_target to the nearby ships. But what if that nearby ship was as miner looking for splinters. He will suddenly start trying to scoop the aggressor. So the function can only transfer the found_target to ships with roles were it is known that any found_target is a target he can attack. So that should exclude custom roles and only include police/hunter-like roles. Even sending it to stations other than the main one is risky.

Hunters do have a state were they are looking for cargo, but because that state will react to a distress calls, any cargo search will be interrupted by the distress call, that comes as a reactToMessage, taking the right found target.

Posted: Tue Nov 23, 2010 9:11 pm
by Thargoid
That's always seemed rather odd to me anyway.

Surely that kind of switch should be under the control of the receiving ship's AI anyway? Although I accept that will also require some AI re-writing probably if the targetting was transferred over.

It's one of those things where I'd support having freedom and option to do things and change things at the higher (OXP/AI/script) level rather than deeper down in the trunk code where it's "hard-wired". More flexibility and allowance for more creativity.

Posted: Tue Nov 23, 2010 10:10 pm
by Switeck
Eric Walch wrote:
Hunters do have a state were they are looking for cargo,
...though they're extremely unlikely to be in such a state in Oolilte v1.74.2 :lol: