Aller au contenu

Photo

Yet another noob


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

#1
pizzapicante

pizzapicante
  • Members
  • 122 messages
I just dont understand how to use the functions of the compiler the instructions just dont make sense to me:

#include "plot_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
void main()
{                
    object  oPC = GetHero();
    event eCurrent = GetCurrentEvent();
    int iEventType = GetEventType(eCurrent);     
   
   
    switch(iEventType)
    {
        case EVENT_TYPE_AREALOAD_SPECIAL:
        {
         UT_Talk(fam_oldlady //Owner of the conversation , GetHero() //Listener (the player), R"old_lady_conv.dlg" //The conversation);
        break;
        }  
        default:
        {
            // Fall through to rules_core
            HandleEvent(eCurrent, RESOURCE_SCRIPT_AREA_CORE);

            break;
        }
    }  
}

help please:blush:...

#2
Proleric

Proleric
  • Members
  • 2 343 messages
I assume you're asking about how to use UT_Talk?

The help for this function doesn't appear in the toolset, owing to a coding error in utility_h. If you open that file, you'll see

/** @brief Instantly initiate dialog with 2 objects
*
* Calling this function will instantly trigger dialog between 2 objects. The dialog
* can be ambient or not.
*
* @param oInitiator - The main talking creature - owner of the default dialog file, if any
* @param oTarget - The creature being spoken to. Should be the player object most of the time
* @returns TRUE on success, FALSE on error
* @author Yaron
*/
void UT_Talk(object oInitiator, object oTarget, resource rConversation = R"", int nPartyResurrection = TRUE);

To get your script to work, there are a couple of things to fix.

Embedded comments must start with /* (not //) and end with */. Otherwise, the compiler doesn't know what's script and what's comment. Better still, remove the comments, break them out into a comment line, or group them at the end of the line.

fam_oldlady is presumably the creature object who will start talking to the player, so you need to declare the variable and initialise it to a value first. For example,

object fam_oldlady = GetObjectByTag("xxxx");
UT_Talk(fam_oldlady, GetHero(), R"old_lady_conv.dlg");


where xxxx is the unique tag of the creature.

You can omit the third parameter if old_lady_conv is the conversation specified in the creature template.

Presumably, only one area will have this script, so that it only executes in that particular area.

As it stands, the old lady will talk to the player every time they enter the area. If that's not what you want, you can either make the call to UT_Talk conditional on a plot flag, or ensure that the conversation only has one opening line with a visibility setting of "once per game".

The latter technique depends on the fact that UT_Talk will do nothing if it can't find a suitable opening line in the conversation. Easier, but potentially more fragile.

Modifié par Proleric1, 09 juillet 2011 - 08:38 .


#3
pizzapicante

pizzapicante
  • Members
  • 122 messages
yup, that worked, so I have to declare all objects as GetObjectByTag then, didnt knew that. thank you very much

#4
Proleric

Proleric
  • Members
  • 2 343 messages
Let's break that statement down into two steps!

Firstly, we always have to declare variables, so that the compiler knows whether they're integers, objects, strings or whatever.

object fam_oldlady;

Secondly, we need to give the variable an initial value before we can use it. So far, we've said that fam_oldlady is an object, but which object? In this instance, we can identify the object by tag:

fam_oldlady = GetObjectByTag("xxxx");

The compiler allows us to combine those two statements into one.

GetObjectByTag is often used, but there are other options - for example, the nearest creature, or the creature that triggered the event.