Aller au contenu

Photo

Perception and Starting Conversation


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
edmogt1

edmogt1
  • Members
  • 52 messages
I modified creature_core and placed this at the top of the main switch to start the NPC's assigned conversation but it isn't working.

Am I doing this right?
Image IPBImage IPB
case EVENT_TYPE_PERCEPTION_APPEAR:
        {
            if(GetEventObject(ev, 0) == GetHero())
            {
                BeginConversation(OBJECT_SELF, GetHero());
            }

            break;
        }


#2
FergusM

FergusM
  • Members
  • 460 messages
A few things:

1) You shouldn't edit creature_core (or any core resource) unless you have a very good reason. What you should really do here is write a wrapper script, as below, and set it as the creature's script.
void main()
{
    event ev = GetCurrentEvent();
    int bHandled = FALSE;
    switch (GetEventType(ev))
    {
        case EVENT_TYPE_PERCEPTION_APPEAR:
        {
               if(GetEventObject(ev, 0) == GetHero())
               {
                             BeginConversation(GetHero(), OBJECT_SELF);
                }
               //Set bHandled to true if you don't want this event to go to the core
               //script. (but in this case we do want to pass it on)
        }
    }
    if (!bHandled)
        HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}

This will run your particular code for your creature, and then pass on events to creature core.

Of course, maybe this is what you meant, but just checking because it is quite important.


2) It looks like BeginConversation grabs the conversation of the target creature if no conversation is specified. The function is defined as (right click -> go to definition):

int BeginConversation (
object oInitiator,
object oTarget,
resource rDialogFile = R ""
)


So you can see you've set the initiator as the creature and the target as the player; but the script uses the target's conversation (again, in the definition) and the player has no conversation, so nothing happens. I think it will work if you swap the order, e.g. BeginConversation(oHero,OBJECT_SELF), or if you manually reference a conversation e.g. BeginConversation(OBJECT_SELF,Hero,R"myconversation.dlg").

3) You also might want to investigate using UT_Talk, which you can get by putting #include "utility_h" at the top of your script. It's a wrapper script (like I talked about above) that handles various things to make the start of the conversation 'nicer', rather than just calling BeginConversation directly. (although note that, contrary to point 2, UT_Talk seems to go Speaker, Listener, e.g. UT_Talk(OBJECT_SELF,Hero))

Modifié par FergusM, 18 juillet 2010 - 06:34 .