Page 1 of 2

Wormhole followers

Posted: Sun Mar 21, 2010 12:07 pm
by Cmdr James
Now that we have the ability to follow ships through a wormhole, would it be nice to have a chance (10%?) that a hostile would follow a player?

Posted: Sun Mar 21, 2010 12:11 pm
by Commander McLane
Or why not a non-hostile?

Whenever the player jumps out, the ships in scanner range could get a certain probability to follow him. This could also work if he jumps after launching from the main station, which is the point where every commander would scan the surrounding wormholes and use one leading in his direction.

Posted: Sun Mar 21, 2010 12:12 pm
by Diziet Sma
Cmdr James wrote:
Now that we have the ability to follow ships through a wormhole, would it be nice to have a chance (10%?) that a hostile would follow a player?
I'm not sure nice is the term I'd use.. :lol: but it makes sense, and even has precedent, in The Dark Wheel.

Posted: Sun Mar 21, 2010 12:19 pm
by Cody
Yes... I like that idea.

Posted: Sun Mar 21, 2010 12:20 pm
by Cmdr James
The way I fly, everyone is hostile ;)

I like the idea of just scraping out with a sliver of energy, sigh of relief then, wtf flashing red here he is again!

It would be nice to have some people hitch a ride, but I dont want it all the time, I think it should only be hostiles, or when the AI is trying to do something like jump, so maybe if you are around a station, and lots of traders are trying to get clear of the aegis they all follow you...

Posted: Sun Mar 21, 2010 12:59 pm
by Commander McLane
Now it becomes a question for the AI-wizards. (Eric, please have a look!)

In pirateAI.plist we already have:

Code: Select all

    "ENTER_WORMHOLE" = {
        "DESIRED_RANGE_ACHIEVED" = ("setStateTo: LURK"); 
        ENTER = (
            setDestinationToTarget, 
            "setDesiredRangeTo: 1.0", 
            "setSpeedFactorTo: 1.0", 
            performFlyToRangeFromDestination
        ); 
        "PLAYER WITCHSPACE" = (enterTargetWormhole); 
        "TARGET_LOST" = ("setStateTo: LURK"); 
    };

In this AI-state, if the player leaves the system, the pirate should follow him automatically.

The pirateAI enters into the ENTER_WORMHOLE-state whenever it receives an ENTER WORMHOLE message in one of its other states, for instance in the ATTACK_SHIP-state. What I don't know is under which circumstances the ENTER WORMHOLE message is sent to NPCs. I would have to do some testing to find that out.

But I'd say that the pirateAI is already capable of following the player, although it seems that de facto it doesn't. So there is probably just some bug to squash in order to make the suggestion a reality.

Posted: Sun Mar 21, 2010 1:15 pm
by Commander McLane
Addendum to previous post: I overlooked it, but also the pirateAI's ATTACK_SHIP state contains code to make a pirate follow the player

Code: Select all

    "ATTACK_SHIP" = {
        ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP"); 
        "ATTACKED_BY_CLOAKED" = ("setStateTo: FLEE_FOR_CLOAKED"); 
        "ENERGY_LOW" = ("setStateTo: FLEE"); 
        ENTER = (performAttack); 
        "ENTER WORMHOLE" = ("setStateTo: ENTER_WORMHOLE"); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE"); 
        "PLAYER WITCHSPACE" = (enterTargetWormhole); 
        "TARGET_DESTROYED" = ("setStateTo: COLLECT_LOOT"); 
        "TARGET_LOST" = ("setStateTo: COLLECT_LOOT"); 
    };

in the PLAYER WITCHSPACE line.


However, I did a quick test: I spawned a pirate and attacked it, then I jumped out. It didn't follow me. But the AI-debug is revealing:

Code: Select all

[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'TRAVEL_TO_LURK_AREA' receives message 'DESIRED_RANGE_ACHIEVED'
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: LURK
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'TRAVEL_TO_LURK_AREA' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action setSpeedTo: 0.0
  [ai.takeAction]: Tiger Mark I 265 to take action performIdle
[ai.takeAction]: Tiger Mark I 265 to take action scanForRandomMerchantmen
[ai.takeAction]: Tiger Mark I 265 to take action pauseAI: 5.0
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'TARGET_FOUND'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToFoundTarget
[ai.takeAction]: Tiger Mark I 265 to take action checkGroupOddsVersusTarget
[ai.takeAction]: Tiger Mark I 265 to take action scanForRandomMerchantmen
[ai.takeAction]: Tiger Mark I 265 to take action pauseAI: 5.0
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'TARGET_FOUND'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToFoundTarget
[ai.takeAction]: Tiger Mark I 265 to take action checkGroupOddsVersusTarget
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'ODDS_BAD'
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'LURK' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ODDS_LEVEL'
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ATTACKED'
[ai.takeAction]: Tiger Mark I 265 to take action setTargetToPrimaryAggressor
[ai.takeAction]: Tiger Mark I 265 to take action setStateTo: ATTACK_SHIP
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'EXIT'
  [ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'ENTER'
  [ai.takeAction]: Tiger Mark I 265 to take action performAttack
[ai.message.receive]: AI pirateAI.plist for Tiger Mark I 265 in state 'ATTACK_SHIP' receives message 'PLAYER WITCHSPACE'
[ai.takeAction]: Tiger Mark I 265 to take action enterTargetWormhole
(One funny note first: It seems my ship is pretty scary to a usual pirate. Do you note how it finds me before I start the attack, and decides that its odds are bad in a one-on-one dogfight? :lol: )

Anyway, the interesting thing is the last lines: Throughout the whole short fight the Tiger is in state ATTACK_SHIP. When I jump out it receives the PLAYER WITCHSPACE message and is about to take action enterTargetWormhole. However, it doesn't do so and the target inspector shows it as a dead entity as soon as I arrive in the new system.

My guess is that there simply isn't enough time between the PLAYER WITCHSPACE message and the setup of my new system, to actually perform and finish the enterTargetWormhole method. The whole system and the Tiger with it suffer an existence failure before it could enter my wormhole. Therefore it doesn't appear on the other side.

I think this would have to be rectified somewhere in the code. The AI must be given time to actually perform the enterTargetWormhole, before the system is cleared and re-populated as a different system.

Posted: Sun Mar 21, 2010 1:22 pm
by Eric Walch
Commander McLane wrote:
What I don't know is under which circumstances the ENTER WORMHOLE message is sent to NPCs. I would have to do some testing to find that out.
It is the command "wormholeEscorts" or "wormholeGroup" that sends a "ENTER WORMHOLE" to all group members. Only than they are in a state to react on a player leaving the system.

And when the player leaves they do an "enterTargetWormhole". This name is wrong at the current targeted wormhole is ignored. Instead the commands scans for all wormholes in scanner range and jumps trough the closest. (That is a reason why sometimes not all ships are found at the other side. Some found a wormhole closer by. But this is probably rare)

The only real problem is that the player himself does not generate a wormhole (in scripting terms) when normal hyperspacing. So pirates will only be able to follow when there happens to be another wormhole in their range that also points to the system the player went for.

(enterTargetWormhole was broken in 1.73 but works again in trunk)

Posted: Sun Mar 21, 2010 2:19 pm
by Eric Walch
I liked the idea. And it is already possible with the current scripting:
I added the following to my test worldScript:

Code: Select all

this.shipWillEnterWitchspace = function(cause)
{
    if (cause === "standard jump")
    {
        var allPirates = system.shipsWithPrimaryRole("pirate", player.ship, 25E3);
        if (allPirates.length > 0)
        {
            allPirates[0].AIState = "EXIT_SYSTEM";
            allPirates[0].reactToAIMessage("UPDATE");
        }
    }
}
This code looks for pirates around and when present, it forces one to create a wormhole (Probably should add fuel also, or would that be cheating?). That wormhole does not need to go to the player system. It needs the pirate to use the default pirateAI, or a similar AI that contains above "EXIT_SYSTEM " state.

After about 5 jump, I got a group of pirates that followed into my system :wink:

(for the whole group following it needs 1.72 or trunk as 1.73 has a bug.)

Posted: Sun Mar 21, 2010 2:56 pm
by Commander McLane
Eric Walch wrote:
The only real problem is that the player himself does not generate a wormhole (in scripting terms) when normal hyperspacing.
So this is the culprit. Is it possible to change/circumvent this? As it is now, the

Code: Select all

        "PLAYER WITCHSPACE" = (enterTargetWormhole);

is meaningless. Could we replace it with something like a followPlayer method, which recreates the pirate in the player's new system with the same amount of fuel, thereby simulating him following the player through a wormhole? Also attach a certain probability to it, so that it doesn't happen every time?

Posted: Sun Mar 21, 2010 4:58 pm
by Disembodied
Fro a gameplay point of view, I don't think I'd like to have the chance of other traders hitch-hiking through my wormhole. Presumably that would mean they'd be masslocking me as soon as I arrived at the beacon, which would be a pain. It might be more "realistic", but I don't think it would improve the game.

Having pirates follow you from time to time is fine, though – especially if the probability could somehow be linked to the value of your on-board cargo. If you're jumping out of an Anarchy system with a hold full of luxuries, or computers, or a special cargo contract load of gold, then maybe you shouldn't be surprised to find you've gathered an enthusiastic following ... :twisted: Apart from anything else it could make the high-end cargo contracts a lot more interesting!

Posted: Sun Mar 21, 2010 5:10 pm
by Commander McLane
Good point concerning the traders. My last suggestion was centred around pirateAI, so it wouldn't apply for traders.

On the other hand, as far as following traders are concerned, it would be logical to implement a certain delay. If we're talking about jumping out from a station, the wormhole would be located at least 10 km away from it, and any trader would have to reach it first. So they would only jump in about 10 to 15 seconds after the player, which normally gives you enough time to fire up your torus drive and be gone. And if there happens to be another ship at the witchpoint as you arrive, you would be mass-locked anyway.

Posted: Sun Mar 21, 2010 5:24 pm
by Disembodied
Commander McLane wrote:
Good point concerning the traders. My last suggestion was centred around pirateAI, so it wouldn't apply for traders.

On the other hand, as far as following traders are concerned, it would be logical to implement a certain delay. If we're talking about jumping out from a station, the wormhole would be located at least 10 km away from it, and any trader would have to reach it first. So they would only jump in about 10 to 15 seconds after the player, which normally gives you enough time to fire up your torus drive and be gone. And if there happens to be another ship at the witchpoint as you arrive, you would be mass-locked anyway.
True ... I hadn't thought about the delay. In which case there's not much point in bothering to implement any routine for traders following you, as you'd never see them! Unfortunately the same would apply for pirates following the player with a view to ambushing them. The only way a hostile ship could feasibly follow a player through a wormhole would be if the player is fleeing from combat via witchspace.

Which is not to say that we couldn't build in a system whereby players hauling valuable cargoes through dodgy systems don't run in to more trouble than they might expect, because news of their progress has preceded them – but that's a different topic altogether.

Posted: Sun Mar 21, 2010 5:25 pm
by Thargoid
Not to mention arriving fresh in the new system only to be smacked around the back of the head by the incoming Krait or Cobra that tried to jump you originally and has now just emerged on your tail from your wormhole...

Press space Commander
:twisted:

Posted: Sun Mar 21, 2010 5:43 pm
by snork
So do I or don't I create a wormhole on witchjumping ? :?

I liked the idea that by witchjuming from witchpoint vicinity, sometimes an unsuspecting pilot might enter the system only to find themselves immediately entering witchspace again and end up somewhere different than where they wanted to go.

Just the thought alone made me :twisted: