Page 1 of 1

Trouble with AI's

Posted: Wed May 25, 2011 1:33 am
by Mandos
Does anybody know if it is possible to start a new AIscript through the "start_script" command?

I want 2 while loops working on different time delays. Something like:

-> For every a miliseconds, run to x.
-> For every b miliseconds, fight y.

The easiest idea seemed to have 2 AIscripts attached to the same npc.

Re: Trouble with AI's

Posted: Wed May 25, 2011 2:20 am
by mr bubbles
What is it you want your AI to do? From the looks of it, you want it to travel to a certain destination while fighting any enemies on the way?

Don't need 2 seperate scripts for that

Re: Trouble with AI's

Posted: Wed May 25, 2011 5:30 am
by Mandos
I think I see how to avoid the problem. Nevertheless, I am still curious to know if it is possible to do it the other way...

Re: Trouble with AI's

Posted: Wed May 25, 2011 2:22 pm
by *Edwards
I would strongly recommand you to look over the "Fantasia Zulu" scripts. You might find a "pathfinding" for brainAI.

Re: Trouble with AI's

Posted: Wed May 25, 2011 2:30 pm
by Mandos
Hi Edwards,

Thanks for the suggestion! Nevertheless, the link in http://forums.polserver.com/viewtopic.php?f=43&t=2607 doesn't seem to be working. When I try to unzip it says the file is corrupt :(

Re: Trouble with AI's

Posted: Wed May 25, 2011 10:56 pm
by mr bubbles
Mandos wrote:I think I see how to avoid the problem. Nevertheless, I am still curious to know if it is possible to do it the other way...
++

Well I guess you could. Like you said, using the start_script function, you could have as many scripts running on and npc as you want. It would greatly confuse things though :P

Re: Trouble with AI's

Posted: Thu May 26, 2011 2:55 am
by CWO
I think you're better off having it in one script, this way if the NPC is fighting, you don't have the two scripts conflicting with eachother. One will be running the NPC away from the person to go to the location, the other will be running the NPC toward the person to fight them.


something along the lines of...

Code: Select all

var nextfighttimer := ReadGameClock() + (however long until the NPC fights)
while(me)
     RunTowardLocation(x);
     if (ReadGameClock() >= nextfighttimer)
          Fight(y);
          nextfighttimer := ReadGameClock() + (however long until the NPC fights)
     endif
     sleep
endwhile

Re: Trouble with AI's

Posted: Thu May 26, 2011 5:35 am
by Turley
And If you want a more advanced ai script you remove all readgameclock checks and write it completely eventbased. This will speedup your ai's but having less instructions per minutes

Re: Trouble with AI's

Posted: Thu May 26, 2011 8:35 pm
by *Edwards
brainAI from distro097 is simply awesome in my opinion.

Re: Trouble with AI's

Posted: Thu May 26, 2011 10:10 pm
by Mandos
mr bubbles wrote:
Mandos wrote:I think I see how to avoid the problem. Nevertheless, I am still curious to know if it is possible to do it the other way...
++

Well I guess you could. Like you said, using the start_script function, you could have as many scripts running on and npc as you want. It would greatly confuse things though :P
It seems like scripts initiated through start_script can't use npc.em :(

Re: Trouble with AI's

Posted: Fri May 27, 2011 12:32 am
by mr bubbles
ah ok, learn something new every day :) Not a big deal though, like everyone says, it will just confuse things anyway.