Author Topic: AI scripting - ChangeAiScript Function  (Read 851 times)

SmithiE

  • Guest
AI scripting - ChangeAiScript Function
« on: October 25, 2005, 09:20:56 PM »
Not sure if this is the best forum to place this post on but i dont know of any other forums that are good.

Anyway..

I've made a Ai script for my bg characters and i need some help with the call ChangeAIScript(S:ScriptFile*,I:Level*Scrlev) and how to use it correctly.

currently to get this to work i have to rename the script that the Ai's going to change to to blah.bcs and place it in the override folder.

Im currently using this function to effectively create nested if statements within the ai script because the ai compiler provided with BG2 cannot do this, this allows me to have the ai change under different circumstances within battle and never let my script interfear with characters already performing and action (e.g. casting a spell). The scripts change so fast its as if they never change at all.. so all in all it works pretty well.

heres and psuedo code example to try and clarify whats going on
-----------------------------
If
   condition
Then
   load new ai script
         ---------------------------------------
         If
            condition
         Then
             do something
         End
         If
            other condition
         Then
             change back to previous Ai script
         End
         ---------------------------------------
End
-----------------------------

..so basically my question is how can i use the ChangeAiScript function without having to rename my script file and place it in the override directory???

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: AI scripting - ChangeAiScript Function
« Reply #1 on: October 26, 2005, 01:46:01 AM »
I really don't think the scripting engine is robust enough to have that work as smoothly as you would like it.

Anyways, ChangeAIScript("blah",OVERRIDE) would make blah.bcs the script used in the character's override slot.  The others, in order of priority are CLASS, RACE, GENERAL, DEFAULT.  OVERRIDE has the highest priority.
Earn Money Sleeping.

SmithiE

  • Guest
Re: AI scripting - ChangeAiScript Function
« Reply #2 on: October 26, 2005, 05:56:40 PM »
Can characters only have one override script??? That would explain a problem i encountered when trying to have two.

I was experimenting with multiple script files for one character, kinda like OOD design, if you know what i mean but as soon as you have more than one it takes about 2to3 seconds to change between them which is way too slow for battles.

Anyhow i got it to do what i wanted it to do, if my characters are away from the battle they will now run to help others in the team with player1 as the highest priority. By changing scripts it allows them to interupt they're movement command once they spot someone to attack, but it wont allow the interupt to interupt any command that any user may have given the character.

Is there anyway(a better/easier way than above) to have characters run to attack things out of their sight, Attack() & AttackRevaulate() wont seem to allow me to do this. I try to tell them to attack the nearest ememy of player 1 but instead they just sit idly off screen while he gets killed.

Offline Salk

  • Planewalker
  • *****
  • Posts: 848
Re: AI scripting - ChangeAiScript Function
« Reply #3 on: November 23, 2005, 06:19:17 AM »
To my knowledge, there can be only one override script...

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: