View unanswered posts | View active topics It is currently Sat Apr 20, 2024 12:38 am



Reply to topic  [ 5 posts ] 
 Use of goto AI mode 
Author Message
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Use of goto AI mode
How can I set the target for the AI goto mode in a scene's lua file?


Mon Dec 22, 2008 3:52 pm
Profile
User avatar

Joined: Sat Jun 30, 2007 4:39 am
Posts: 521
Reply with quote
Post 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;


Mon Dec 22, 2008 7:19 pm
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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)


Mon Dec 22, 2008 9:52 pm
Profile

Joined: Sat Jun 16, 2007 8:04 pm
Posts: 42
Reply with quote
Post 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.


Sun Dec 28, 2008 8:51 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Tue Dec 30, 2008 12:40 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.090s | 15 Queries | GZIP : Off ]