Data Realms Fan Forums
http://45.55.195.193/

Use of goto AI mode
http://45.55.195.193/viewtopic.php?f=73&t=13138
Page 1 of 1

Author:  piipu [ Mon Dec 22, 2008 3:52 pm ]
Post subject:  Use of goto AI mode

How can I set the target for the AI goto mode in a scene's lua file?

Author:  Electroclan [ Mon Dec 22, 2008 7:19 pm ]
Post subject:  Re: Use of goto AI mode

First, you set waypoints for the ACTOR in question, who should have a name.

Code:
ACTOR:AddAISceneWaypoint( Vector( X, Y ) );

Examples:
cliffLemming:AddAISceneWaypoint( Vector( 700 , 100 ) );

EnemyUpperPatrol:AddAISceneWaypoint( Vector( UpperPatrol4:GetRandomPoint().X, UpperPatrol4:GetRandomPoint().Y ) );


You can also clear the ACTOR's waypoints.

ACTOR:ClearAIWaypoints();



Then, set the AIMode:

Code:
ACTOR.AIMode = Actor.AIMODE_GOTO;

EnemyUpperPatrol.AIMode = Actor.AIMODE_GOTO;

Author:  piipu [ Mon Dec 22, 2008 9:52 pm ]
Post subject:  Re: Use of goto AI mode

Okay, thanks, got it working now. Btw, is it possible to load TDExplosives into dropships with lua? At least ACDropShip:AddInventoryItem gives a weird error saying that none of it's overrides matches arguments(ACDropShip, TDExplosive)

Author:  ScifiSpirit [ Sun Dec 28, 2008 8:51 pm ]
Post subject:  Re: Use of goto AI mode

Quote:
Btw, is it possible to load TDExplosives into dropships with lua?


Yeah it is. I just tried and this code works:

Code:
Myactor = ActivityMan:GetActivity():GetControlledActor(0); Explosive = CreateTDExplosive("Frag Grenade"); Myactor:AddInventoryItem(Explosive);


Myactor = ActivityMan:GetActivity():GetControlledActor(0); // Gets actor that is currently under player control in team 0 (or use some other way to ID the actor that gets the stuff)
Explosive = CreateTDExplosive("Frag Grenade"); // Assigns the grenade type to variable Explosive
Myactor:AddInventoryItem(Explosive); // Adds stuff from variable to inventory

However you get that error you describe if you try to add stuff into inventory more than 1 time. Each time you add, you must do the assignment to Explosive variable again if you want to add again. For example:

Code:
for I = 1, 5 do Explosive = CreateTDExplosive("Frag Grenade"); Myactor:AddInventoryItem(Explosive); end


I've practically just started experimenting with Lua in Cortex Command so i don't know why you have to do it like this. Maybe because of scope, or garbage collection.

And also, in this case it adds the first instance of Frag Grenade that appears in Tradestar order list. I don't know how to add the Coalition grenades.

Author:  TheLastBanana [ Tue Dec 30, 2008 12:40 am ]
Post subject:  Re: Use of goto AI mode

Code:
CreateTDExplosive("Frag Grenade","Coalition.rte");

The second argument can be set to the name of any data module.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/