Aller au contenu

Photo

Conversation won't fire


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

#1
BioSpirit

BioSpirit
  • Members
  • 261 messages
There is some trouble to get a conversation to work. The scenario is very simple one: There is a NPC that must run to the Player and initiate a conversation. I have added following lines in area_script in EVENT_TYPE_AREALOAD_POSTLOADEXIT section.

command cmd = CommandStartConversation(GetHero());
AddCommand(GetObjectByTag("npc_nea"), cmd, FALSE, TRUE );


As a result the NPC will run to the Player when entering the area. But the conversation won't fire. I have also tried to enter the resource name of the conversation in the  CommandStartConversation() but it won't help.

I tried to get around the problem using an alternative way to setup a conversation by using creature script but it won't work either.

Here's the creature script:

#include "events_h"
#include "rules_h"

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    PrintToLog("Nea_Script_Called: EventType="+ToString(nEventType));

    switch (nEventType)
    {
        case EVENT_TYPE_COMMAND_COMPLETE:
        {
            PrintToLog("EVENT_TYPE_COMMAND_COMPLETE");

            object oActor = GetEventCreator(ev); // creature acting
            object oTarget = GetEventObject(ev, 1); // The target that command was applied to
            int nLastCommand = GetEventInteger(ev, 0); // Type of the last command (e.g. COMMAND_TYPE_ATTACKED)

            if (nLastCommand == COMMAND_TYPE_MOVE_TO_OBJECT) {
                PrintToLog("COMMAND_TYPE_MOVE_TO_OBJECT");
                BeginConversation(GetHero(), oActor);
            }
            break;
        }
    }

    HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}


This is all that's printed into a Log. (related to the script above)

Script    Nea_Script_Called: EventType=11
Script    Nea_Script_Called: EventType=3


And that would be equal to: EVENT_TYPE_EQUIP,  EVENT_TYPE_SPAWN. Unfortunately EVENT_TYPE_COMMAND_COMPLETE won't fire. Of course, the CommandStartConversation() was replaced with CommandMoveToObject()

AddCommand(GetObjectByTag("npc_nea"), CommandMoveToObject(GetHero(),TRUE,3.0));


Of course, the Player can initiate the conversation by right-clicking the NPC,  in that case event  18 is printed into the log.

Modifié par BioSpirit, 17 décembre 2009 - 09:17 .


#2
Qkrch

Qkrch
  • Members
  • 128 messages
You know, i also tried that and it was impossible.



My guess is that is not feasible that a NPC interacts with a PC, if you'd do the inverse, PC talks to NPC, it will work perfectly.



Yeah , i'd give my 50 cents... any npc in the campaign makes that? is a simple move , but i didn't see it in the whole game :)

#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
EVENT_TYPE_COMMAND_COMPLETE is directed to rules_core in events.xls. You can use EVENT_TYPE_CUSTOM_COMMAND_COMPLETE, but the creature must have a value assigned to the local integer AI_CUSTOM_AI_ACTIVE. Any value other than 0 should work, but 1 would be the most common in this case.



For the original command - I have noticed it is a bit strange. I'll try to investigate it a bit more and file a bug if appropriate and see if I can update the documentation on it otherwise.

#4
BioSpirit

BioSpirit
  • Members
  • 261 messages

Craig Graff wrote...

EVENT_TYPE_COMMAND_COMPLETE is directed to rules_core in events.xls. You can use EVENT_TYPE_CUSTOM_COMMAND_COMPLETE, but the creature must have a value assigned to the local integer AI_CUSTOM_AI_ACTIVE. Any value other than 0 should work, but 1 would be the most common in this case.


Thank you for help. It's working. :o


Here's the script I have used for NPC:

//:://///////////////////////////////////////////////////////
//:: Core AI Script override for NPC to initiate conversation
//:://///////////////////////////////////////////////////////

#include "events_h"
#include "rules_h"

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    switch (nEventType)
    {
        case EVENT_TYPE_CUSTOM_COMMAND_COMPLETE:
        {
            object oActor = GetEventCreator(ev); // creature acting
            int nLastCommand = GetEventInteger(ev, 0); // Type of the last command

            if (nLastCommand == COMMAND_TYPE_MOVE_TO_OBJECT)
            {
                BeginConversation(GetHero(), oActor);
            }
        }
    }
    HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}


The conversation is launched with:

AddCommand(GetObjectByTag("tag_of_npc"), CommandMoveToObject(GetHero(),TRUE,3.0));



#5
DLAN_Immortality

DLAN_Immortality
  • Members
  • 481 messages
Ah! thumbs up for this one! Very useful :-D