Aller au contenu

Photo

Custom AI event


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
anakin5

anakin5
  • Members
  • 258 messages
Hi, i am trying to make my first script working, and here are problems :
  • When i load a game, the first DisplayFloatyMessage display "event 99". What is event 99 ? It is not events.xls.
  • Then, the EVENT_TYPE_MODULE_LOAD does not occur, or maybe i can't see it
  • When I enter combat mode, the EVENT_TYPE_HANDLE_CUSTOM_AI does not occur. I can see that some events are raised, but not the EVENT_TYPE_HANDLE_CUSTOM_AI event.
Here is my source code :

#include "cai_h"

void main()
{
    object oPC = GetHero();

    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    DisplayFloatyMessage(oPC, "event "+IntToString(nEventType), FLOATY_MESSAGE, 16777215, 5.0);
   
    switch(nEventType)
    {
        case EVENT_TYPE_MODULE_LOAD:
        {
            DisplayFloatyMessage(oPC, "EVENT_TYPE_MODULE_LOAD", FLOATY_MESSAGE, 16777215, 5.0);

            object[] aPartyList = GetPartyList();

            int i;
            for (i = 0; i < GetArraySize(aPartyList); i++)
            {
                CAI_SetCustomAI(aPartyList[i], CAI_INITIATE);
            }

            break;
        }
        case EVENT_TYPE_HANDLE_CUSTOM_AI:
        {
            DisplayFloatyMessage(oPC, "EVENT_TYPE_HANDLE_CUSTOM_AI", FLOATY_MESSAGE, 16777215, 5.0);
            break;
        }
    }
}

#2
weriKK

weriKK
  • Members
  • 106 messages
From what I can see, EventType 99 is actually the 13th event that is fired during loading the game ( at least for me).



In order:

68 - UNKNOWN

63 - UNKNOWN

20 - EVENT_TYPE_MODULE_LOAD ( The module loads from a save game )

08 - EVENT_TYPE_ENTER ( You enter the area )

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

84 - EVENT_TYPE_GUI_OPENED

69 - UNKNOWN

99 - UNKNOWN



Considering that the first string you can see popping up on the screen shows that the current event type is 99, I'd assume that - whatever it does - this is the very first point where you get access to the GUI (which seems to make sense looking at all those GUI related events beforehand),



If I am anywhere near the truth this explains why the MODULE_LOAD did not print anything on your screen, simply because the GUI was not constructed yet at that point in time.



About your EVENT_TYPE_HANDLE_CUSTOM_AI issue:

This event is not caught by your module's event handler simply because this is sent to creatures not modules. You will mostly likely need an event override to process this.

#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
EVENT_TYPE_HANDLE_CUSTOM_AI is best handled in a custom creature script, just make sure that you set the local variable AI_CUSTOM_AI_ACTIVE to something greater than 0.

#4
anakin5

anakin5
  • Members
  • 258 messages
Alright, I see.

But what a "creature script" ? I mean, in the toolset I can create a script or a client script. There is a "Custom creature event.txt" template, is it what you mean ?

I probably have to affect a script to a creature, or type of creature. How to do such things ?



Thank you for your help

#5
AND04

AND04
  • Members
  • 154 messages
if you create a creature - you can chose the event-script - i guess thats what craig meant.

Modifié par AND04, 24 novembre 2009 - 10:14 .


#6
anakin5

anakin5
  • Members
  • 258 messages
No way to have one script managing A.I for all party members (like ai_main_h_2) ? I don't want to create a new creature, I just want to customise AI of party members.

"player_core" seems to be the creature script affected to player and followers. So if I put a case EVENT_TYPE_HANDLE_CUSTOM_AI, it will probably work. But I don't want to edit core script and I don't want to loose what is done in the "player_core" file.

EDIT: well, overriding the event should solve my problem, I am going to test that.

Modifié par anakin5, 24 novembre 2009 - 10:53 .


#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
Overriding that event will break most of the heavily customized fights in the game.

#8
anakin5

anakin5
  • Members
  • 258 messages
Which file handle EVENT_TYPE_HANDLE_CUSTOM_AI ? I mean, it seems that this event is not handle by any part of script in the toolset. How can I break something if I decide to override it ?

#9
Craig Graff

Craig Graff
  • Members
  • 608 messages
That event is used in the script assigned to individual creatures. You won't see it in the files currently available with the toolset because we haven't yet released the main campaign files. Editing the core script is better in this case than overriding - though that will be fixed if we can add a GetEventScript function.

#10
anakin5

anakin5
  • Members
  • 258 messages
ok, I fully understand what you are talking about now. So, I am going to override core script in a first time.

Thank you

EDIT: do you think it can work if I set CustomAI to a private constant (CAI_CUSTOM = 4) at start of combat, then set it back to 0 at the end, then override the EVENT_TYPE_HANDLE_CUSTOM_AI and calling HandleEvent(ev) if the CustomAI is not CAI_CUSTOM ?
It should only override how followers are fighting and let all ather king of CustomAI append ?

Modifié par anakin5, 28 novembre 2009 - 12:54 .