Jump to content


Photo
- - - - -

Ai Command Stack


  • Please log in to reply
52 replies to this topic

#21 Potnop

Potnop

    GMC Member

  • GMC Member
  • 3101 posts

Posted 25 March 2008 - 09:20 AM

Platform AI pathfinding?

Did you make that yourself? Just wondering cuz i'm the only person I know so far who made something like that and I want to make it better, and if yours is better it saves me the trouble...
  • 0

#22 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 25 March 2008 - 09:37 PM

Platform AI pathfinding?

Did you make that yourself? Just wondering cuz i'm the only person I know so far who made something like that and I want to make it better, and if yours is better it saves me the trouble...


I left you a post in your platform A* path finding about it a while back...

You just wait a little... I solved your node based system problem in my upcoming node path finding dll. You can make a platform node system in 5 minutes with it with no hard coded linking of nodes.

This (platform pathfinding) method here is workable but slow to set up and tweak.
  • 0

#23 Novice_helper

Novice_helper

    GMC Member

  • New Member
  • 64 posts

Posted 07 April 2008 - 02:55 PM

so is there a way to have my AI randomly feel like wandering in a given amount of space and not attacking unless he sees the player object using these scripts? :)
  • 0

#24 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 07 April 2008 - 09:17 PM

so is there a way to have my AI randomly feel like wandering in a given amount of space and not attacking unless he sees the player object using these scripts? :)



Sure but I do recommend you learn to make your own scripts to match your need. Understand how the command scripts work is the key.
  • 0

#25 kearel

kearel

    GMC Member

  • GMC Member
  • 52 posts

Posted 17 April 2008 - 11:12 PM

I downloaded this before, and when I tryed it, I was totally impressed! It makes any AI seem better.
impressive work
-Kearel
  • 0

#26 weylin

weylin

    GMC Member

  • Banned Users
  • 1327 posts

Posted 07 August 2008 - 01:40 AM

create_effect cannot be done in gm6
causes a compilation error that has to be aborted.

#27 ilmari22

ilmari22

    GMC Member

  • New Member
  • 3 posts

Posted 06 October 2008 - 01:33 PM

___________________________________________
ERROR in
action number 1
of Create Event
for object BulletObj:

Error in code at line 2:
effect_create_above(ef_smoke,x,y,0,c_gray);

at position 2: This function is only available in the Pro Edition.
:P

i have lite and this came in 2nd room in unregversion :ph34r:
you should not use effect_create
first room works great!

That is great tutorial and helped me a lot! =) :)
sry my english if wrote something wrong
  • 0

#28 Relinquished

Relinquished

    GMC Member

  • New Member
  • 265 posts

Posted 06 October 2008 - 04:20 PM

Another good addition to this is adding a feature where the AI can remove certain things off the stack when a certain event is met. For example, when encountering an extremely strong boss, anything like patrolling or gathering items, you can make the AI find things such as those and remove them off the stack, Or even better, a single action or event can cause more events to be pushed onto the stack. Stack commanding is very versitle I must say.
  • 0

#29 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 06 October 2008 - 08:47 PM

You can clear the stack or list yourself, then add your boss attack commands... When it's done, the AI would simply default to adding the standard commands (from the step event)...


Everything you need is right there

in patrol command

if(BigBossFound) HandleBigBoss

HandleBigBoss script

Clear The Stack
Clear the list

add RunHome to list or add FightBoss to list
  • 0

#30 MonoLegalStudios

MonoLegalStudios

    GMC Member

  • New Member
  • 40 posts

Posted 12 December 2009 - 06:49 AM

Very good tutorial. This can be great use to somebody.
PS: YAY!!!! First post!!!!!!!!

now don't you feel stupid?
  • 0

#31 duaccelsostat

duaccelsostat

    GMC Member

  • New Member
  • 7 posts

Posted 12 December 2009 - 02:24 PM

IMHO it would be better to convert this all to a database structure. Stefano already made a nice concept for that.
but this is probably something that never gets done anyway, so.....EXCELLENT LIST

Roel
  • 0

#32 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 13 August 2011 - 08:24 PM

From another topic....

You don't realy need a command stack or list and I would not jump in this sort of thing before having done a few AIs first...

I can tell you about script switching which is how the command stack started and it's much more managable than a bunch of case statements

AI object
on create
curscript = WalkArround;

on step
script_execute(curscript);

script WalkArround
xx = random(room_width)
yy = random(room_height)
curscript = WalkToXY;

script WalkToXY
direction = point_direction(x,y,xx,yy);
speed = 3;
if(point_distance(x,y,xx,yy)< 10)
	curscript = WalkArround;


So now you have 2 scripts that switch between each other. One decides where to go, the other goes to it and when it's done, ressets the script to the original;

This method uses instance variables curscript and xx,yy, so no parameters to confuse you.

Now you can elaborate to a patrol and enemy (player) hunt

AI object
on create
curscript = PatrolArround;

on step
script_execute(curscript);

script PatrolArround
xx = random(room_width)
yy = random(room_height)
curscript = PatrolToXY;

script PatrolToXY
speed = 3;
player = instance_nearest(x,y,PlayerObj)
if(player)
{
	if(point_distance(x,y,player.x,player.y)<200)
	{
		curscript = AttackPlayer;
		exit;
	} 
}
direction = point_direction(x,y,xx,yy);
if(point_distance(x,y,xx,yy)< 10)
	curscript = PatrolArround;

scrip AttackPlayer
if(!instance_exists(player))
{
	curscript = PatrolToXY;
	exit;
}
if(point_distance(x,y,player.x,player.y)>200)
{
	curscript = PatrolToXY;
	exit;
}
speed = 5;
direction = point_direction(x,y,player.x,player.y)


The setup selects a random spot to patrol to. Patrols to it while checking if the player is near. If the player is near, he is attacked until he move too far. at that point, the patroltoXY continues and then when the patrol point is reached, another patrol point is randomly selected.


Hope it helps.

The command stack is a huge elaboration of this method and, in retrospect, this simpler method should have been explained first. It's much easier to implement, even if it does not allow for parameters (that can be remembered), you can use instance variables instead...
  • 0

#33 AtaKVeKtoR

AtaKVeKtoR

    GMC Member

  • New Member
  • 2 posts

Posted 18 November 2011 - 02:41 AM

Hi,

Just wondering if someone can help me, I get the following error when trying to use the script:

___________________________________________
ERROR in
action number 1
of Step Event
for object obj_orb_drone_cs:

Illegal argument count calling script "CommandStackPush".
Script requires 16 arguments, 6 have been supplied.

I have copied in all the CommandStack scripts into my project + the cmdComandObj.

I see that the CommandStackPush requires 16 arugments, however when checking out the tutorials, only the arguments used by the function to be put on the stack are used (ie. not 16 of them are required). Why can't I seem to replicate this in my scripts? do I need to pass 16 dummy arguments to the function?

Many thanks in advance.
  • 0

#34 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 18 November 2011 - 03:22 AM

pass 0s for the missing arguments. darn gm8.1 broke the flexible argument system... or change the way the arguments are referenced inside
  • 0

#35 Sir

Sir

    Jedi Poodoo

  • GMC Member
  • 380 posts
  • Version:GM:Studio

Posted 17 December 2011 - 11:08 PM

pass 0s for the missing arguments. darn gm8.1 broke the flexible argument system... or change the way the arguments are referenced inside


I am attempting to use your suggestion, but its not working... Can you specify what you mean by passing 0's?
  • 0

#36 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 18 December 2011 - 12:22 AM

GM6,7,8 allowed passing a variable number of arguments, if one (trailing) argument was committed, 0 was assumed.

It sort of like in c++ where you can specify a default value from omitted arguments in the function declaration, but the default is 0 in GM


For example

Script DoIt

var count; count = argument0;

if(count == 0) count = 1;

repeat(count) ShowMessage("Hello")


if you call
DoIt(10), you would see a message 10 times
DoIt(1), you would see it 1 time
DoIt(), you would see it 1 time because the missing argument0 is converted to 0 in the script and the if in there sets it to default to 1.


Now gm8.1 broke this variable number of arguments feature to the detriment of many 3rd party extensions. So, CommandStackPush CAN takes up to 16 arguments. But most commands only take a few, like MoveToXY takes x,y,speed... that is 3, plus the script id, 4... so add ,0,0,0,0,0,0... as many as are missing to abide by the 16 argument gm8.1 thinks the script needs.

change
CommandStackPush (MoveToXY, destx, desty, speed)

to
CommandStackPush (MoveToXY, destx, desty, speed,0,0,0,0,0,0,0,0,0,0,0,0)

There is a way to fix the CommandStackPush And CommandListAdd and in another few places I think.

change
data.arg1 = argument1;
data.arg2 = argument2;
and so on

to
data.arg1 = 0;
if (argument_count > 1) data.arg1 = argument[1];
data.arg2 = 0;
if (argument_count > 2) data.arg2 = argument[2];

and so on all the way to 15... for all core functions that set the data.args using argumentN naming convention...


I cant test this as I am afraid to update my earlier release of gm8.1 to the latest release and loose my key. My gm8.1 does not have this bug... I mean feature.
  • 0

#37 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16784 posts
  • Version:GM:Studio

Posted 18 December 2011 - 12:38 AM

Icuurd, this can be turned off in the global game settings... it was changed to permit backwards compatibility in just this type of scenario.
  • 0

#38 Sir

Sir

    Jedi Poodoo

  • GMC Member
  • 380 posts
  • Version:GM:Studio

Posted 18 December 2011 - 01:13 AM

I can uploud a new, edited version just for GM81 if you want. I fully edited it. But i wont be able to host it indefinitly. You will have to find a mirror... Here

http://dl.dropbox.co...mmandstack.gm81

Edited by SirGuy, 18 December 2011 - 01:36 AM.

  • 0

#39 Sir

Sir

    Jedi Poodoo

  • GMC Member
  • 380 posts
  • Version:GM:Studio

Posted 18 December 2011 - 02:05 AM

Since i got it working, Can you please post an example of a more "complex" command stack? The ones you have in your example seem very basic. I need something far more advanced to see what I can actually do with it. Please and thank you.
  • 0

#40 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 18 December 2011 - 03:38 AM

Desktop Death Match is a good example, see main post


Here is a very complicated setup

http://www.host-a.ne...2/station16.gmk


arrows move, shift and z to shoot, t to tractor on and off

Move to the bottom, tag a cylinder with your tractor beam. then use the tractor beam to move and attach another cylinder to the first one, tractor and push it and release before it hits the cylinder, both should snap together. add modules (on top of the cylinders) to your station, a power source, a radar (it will tag you as friendly if you avoided the already built station at the top), a asteroid beam, a processing platform.... Once tagged by your station, the other ships should attack you if too close. Meanwhile they gather resources.

The AI ships are controlled with the command stack. The player ship also is. that way you could take control of another ship byt simply adding the pleyer control script to the ai ship stack.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users