Page 1 of 1

Deploy capsules as real follower robots?

Posted: Sun Apr 17, 2016 2:50 pm
by slindenau
Is it possible to deploy a destroyer capsule as actual follow robots with the API?

You can do a surface.create_entity on a "destroyer-capsule", but that just leaves them hanging in the air.
You can also make a group with surface.create_unit_group, but then you're just implementing your own follower AI (might also be fun?)

Is there a way to deploy a destroyer capsule like an actual player would by "throwing" a capsule?

Re: Deploy capsules as real follower robots?

Posted: Sun Apr 17, 2016 3:14 pm
by Adil
There's additional parameter field to .create_entity: target.

Code: Select all

game.player.surface.create_entity{name="defender",position=game.player.position, force=game.player.force, target=game.player.character}

Re: Deploy capsules as real follower robots?

Posted: Sun Apr 17, 2016 3:23 pm
by slindenau
Aha, that seems to work. If you create a capsule it spawns the 5 bots, but not as followers.
This way the single destroyer becomes a real followers...thanks!

This is what i had created myself, but like i said...it spawns 5 non follower destroyers???
/c player = game.local_player;
surface = game.surfaces.nauvis;
deployed = surface.create_entity({
name="destroyer-capsule",
amount=1,
position={player.position.x,player.position.y},
force=player.force,
source=player.character,
target=player.character,
speed=1
});

Re: Deploy capsules as real follower robots?

Posted: Sun Apr 17, 2016 8:45 pm
by Adil
The target field seems not to be accessible after entity is created already.
If you want five followers, use create_entity five times.
If you want capsule projectile first, create dummy copy of that in your data lua, and use trigger_created_entity event to detect when it's time to spawn five followers. Off the top of the head, the example of trigger_created_entity can be seen in my DroneHome mod, albeit there it is used for despawning of drones.