[angelscript] Re: Game scripting question

  • From: "gvozdoder" <gvozdoder@xxxxxxxxxxxx>
  • To: <angelscript@xxxxxxxxxxxxx>
  • Date: Wed, 3 Mar 2004 18:39:23 +0300

What am I need from AI script?

I need coroutines (threads) with manual time distribution and exception-like
mechanism to break execution of current action.

Example 1.

Walk(target);   // suspends until character reaches target
Shoot(enemy);   // suspends until character shoots enemy

Example 2.

MainThinkLoop()
{
        while(Alive)
        {
                call(ThinkLoop(),ExceptionHandler);     // usual think
sequence here
        }
}

ThinkLoop()
{
        for(;;)
        {
                switch(ThinkState)
                {
                        case "normal" : ThinkNormal();
                        case "retreat" : ThinkRetreat();
                }
        }
}

Retreat()
{
        SetThinkState("retreat");
        Raise("wound"); // raising exception here
}

ExceptionHandler(cause) // raised exception brings here
{
        if(cause == "wound")
        {
                Retreat();
        }
}

-----Original Message-----
From: angelscript-bounce@xxxxxxxxxxxxx
[mailto:angelscript-bounce@xxxxxxxxxxxxx] On Behalf Of Daniel Krenn
Sent: Wednesday, March 03, 2004 3:37 PM
To: angelscript@xxxxxxxxxxxxx
Subject: [angelscript] Game scripting question

I was wondering if anyone has any real world examples of using an embedded
scripting language such as AngelScript to control character AI..
This is something I've been pondering for some time, but I'm a little lost
as to the direction I should take since there are numerous ways to integrate
scripting support into a game.
What I'm trying to do is set up a server side application that contains
multiple scripted entities that interact with one another, and with their
environment.  Characters should be able to follow routines such as waking
up, going to work at a designated time, heading home at a designated time,
going to sleep, reacting when attacked by either attacking back or fleeing
if the attacker is too great a challenge.

Should the character framework be event based, and if so, should scripts be
used for simple decision making?  or should there be 2 types of scripts..
one for the character's routine, which contains a list of commands / tasks
such as "Move("<Location Name>")", "Pickup("<Item Name>")" etc.. and the
other set of scripts which are event activated e.g. "OnHeartbeat",
"OnAttacked" etc.

I'm really quite lost as to which direction to take - as I mentioned, I've
put a fair amount of thought into this, but I'm still looking to find a
solid solution.

If anyone has any real world examples of integrating AngelScript with a FSM,
setting up event driven scripts / routines etc.. I would be extremely
appreciative if they share them with me (and others) or possibly provide a
breakdown of a solid scripted character framework for me to look at.

Regards,
Daniel.



AngelScript - AngelCode Scripting Library
http://www.angelcode.com/angelscript/


AngelScript - AngelCode Scripting Library
http://www.angelcode.com/angelscript/

Other related posts: