Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Basic Scriptable AI  (Read 664 times)

Zemat

  • Bay Watcher
  • Zemat, programmer, cancels coding: Too insane.
    • View Profile
Basic Scriptable AI
« on: October 23, 2007, 07:26:00 pm »

I searched but the search terms for AI scripting are too varied so, if it has been mentioned before, sorry.

It would be good if there could be a way to create simple ai scripts for particular creatures as part of the modding capabilities instead of just modifying flags so that a modder could integrate some basic logic operations that could trigger flags or actions for custom creatures. For example, certain flags could be activated for a particular hunting creature like this (Pardon my ignorance of the use of actual DF flags):

If [CARNIVORE] and [HUNGRY]:
  [RECKLESS]

So that the creature will not flee a battle when particularly hungry.

This system could also be used to integrate custom conversations so that modders could integrate to the game more complex random quests without the need for toady to do all the job by himself.

Logged
You too can help bring to life the RogueLife Project!

Lyndon

  • Bay Watcher
    • View Profile
Re: Basic Scriptable AI
« Reply #1 on: October 28, 2007, 07:30:00 am »

Sounds good     :D
Would make modding more creative and fun.
You could make the dragons seek out treasure and risk their lives if the dont have enough.
code:
if(Treasure < 100)
   find(Silver)
else
   defend(Treasure)


(Pardon the bad example)
Creatures could be scripted in really complicated ways so Goblins could ally with wolves etc. Fun    :D

[ October 28, 2007: Message edited by: Lyndon ]

[ October 28, 2007: Message edited by: Lyndon ]

Logged
The Dwarf Fortress Forum has been attacked with the toolbox by The Signature.
The Dwarf Fortress Forum has been knocked unconscious!

You hear a gunshot.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Basic Scriptable AI
« Reply #2 on: October 28, 2007, 03:35:00 pm »

like this?


note: it assumes that all actions have a priority, 1 to 100, and resetallpriorities sets them all to 50

code:
dragon: :ondaypass()
{
   treasurewanted++;
   resetsetallpriories();
   if(damagelevel>hurt){setpriority(heal,1);setpriority(combat,100);}
   else if(treasurehad>treasurewanted)setpriority(guard,1);
   else
   {
       //check for smart creatures and adventurers here
       else setpriority(getloot,1);//look for loot for the day
   }
}
dragon: :ongetloot(loot)
{
   treasurehad+=getvalue(loot);
}


Logged
Eh?
Eh!