Loading AI with scripts?
#1
Posté 12 février 2010 - 03:36
So what I'm looking for is a way to load the commands from the 2DA into the creature's tactics table with a script. I noticed _AI_LoadTacticsIntoGUI, but I'm not sure if this is what I'm looking for and I don't understand how to use it; I don't know how to indicate which creature object it should effect since it doesn't take any parameters.
I'm also wondering if there is a way to use some of the tactics conditions that you can't select in the in game GUI but are in the tactics conditions 2DA? Things like "if 3 enemies dead" or "Move away from enemy." I'm guessing the answer is no, but it would be nice.
#2
Posté 13 février 2010 - 05:24
FergusM wrote...
I've made an AIP 2DA for a party member I'm creating. Some of the abilities referenced in the tactics are granted to the creature only after he is recruited. This causes a problem in that the game seems to delete all the tactics referencing abilities not yet granted. Another problem is that the creature starts with only 4 tactics slots; I'm using setNumTactics to increase this to the number of tactics in my AIP (10), but it seems like any tactics above 4 get cut off even when I increase the number of slots.
So what I'm looking for is a way to load the commands from the 2DA into the creature's tactics table with a script. I noticed _AI_LoadTacticsIntoGUI, but I'm not sure if this is what I'm looking for and I don't understand how to use it; I don't know how to indicate which creature object it should effect since it doesn't take any parameters.
I'm also wondering if there is a way to use some of the tactics conditions that you can't select in the in game GUI but are in the tactics conditions 2DA? Things like "if 3 enemies dead" or "Move away from enemy." I'm guessing the answer is no, but it would be nice.
You're on the right track. The function, _AI_LoadTacticsIntoGUI is what you're looking for. While it's true you cannot pass parameters to it, it's assumed to be used directly on the calling creature, like during spawn logic. So for instance, if you're looking to load the tactics after giving out the ability, then you would have something like this, perhaps through a convo:
AddAbility(OBJECT_SELF, ABILITY_TALENT_AIM); _AI_LoadTacticsIntoGUI();
I used to use scripts like this in my on-spawn scripts for party members, until I decided to go the 2DA route, with defining all abilities in the auto-level tables and whatnot. But yeah, this should work for you.
As far as calling SetNumTactics I personally haven't had any issues with that. Mind posting your scripts?
As for your final question, I actually never realized there were extra ones in there. Perhaps leftover stuff they never got a chance to implement? You can check out ai_conditions_h to see what is really defined, and what isn't.
Hope this helps.
#3
Posté 13 février 2010 - 08:57
I did look into the auto-level tables and am using it elsewhere, but here I need to cheat and give some abilities without prerequisites (I don't anticipate this party member ever levelling up).
I also managed to get LoadTactics to work with your suggestion of a conversation. What other ways can I call scripts 'from' a certain creature? Ideally I'd like something I could do at pretty much any time, rather than just with conversations or spawning.
Thanks for the help!
Modifié par FergusM, 13 février 2010 - 08:57 .
#4
Posté 13 février 2010 - 11:22
FergusM wrote...
I also managed to get LoadTactics to work with your suggestion of a conversation. What other ways can I call scripts 'from' a certain creature? Ideally I'd like something I could do at pretty much any time, rather than just with conversations or spawning.
Thanks for the help!
Glad it worked.
As for calling it anytime, without resorting to conversations and such... Well, one thing you could do it create your own event. It's annoying in my opinion, but one way to get it done. So, let's assume you have a script that you want to put this logic in. It would look something like this:
...
//Make sure this doesn't conflict with any other events defined in events_h.nss
//This would probably be better defined in your own constants file, like [b][i]my_events_h.nss[/i][/b]
const int EVENT_TYPE_LOAD_TACTICS = 70000;
...
event ev = Event(EVENT_TYPE_LOAD_TACTICS);
object oFollower = GetObjectByTag("your_followers_tag");
SignalEvent(oFollower, ev);
...
Next step is to make sure you have a custom core script for your follower, which overrides player_core.nss. Then, you would have something like this:
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
// Setting this to true will prevent the script from invoking player_core
int bEventHandled = FALSE;
switch(nEventType)
{
case EVENT_TYPE_LOAD_TACTICS :
{
_AI_LoadTacticsIntoGUI();
break;
}
}
if (!bEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_PLAYER_CORE);
}
}
That would take care of the problem. The only potential issue is, how comfortable are you with adding followers and whatnot? Currently, the game explicitly sets the follower script to player_core.nss when you add them through the function, UT_HireFollower. There are many ways around this (for instance, I gutted out that script and only kept what I needed, then created my own function), but the easiest is to just make sure to call SetEventScript at any point after you have hired them.
Anyway, hope this helps, and if you have any questions, let me know.
Modifié par Challseus, 13 février 2010 - 11:23 .
#5
Posté 13 février 2010 - 11:36
If you do it like that you shouldn't pass it on to any core script however.
Modifié par Craig Graff, 13 février 2010 - 11:36 .
#6
Posté 14 février 2010 - 01:31
Craig Graff wrote...
You don't need to replace the follower's script to use an event script like the one above. Just call it with DelayEvent(0.0, oPC, evEvent, "my_event_script");
If you do it like that you shouldn't pass it on to any core script however.
Definitely nice to know. Good call.
#7
Posté 14 février 2010 - 03:30





Retour en haut







