Aller au contenu

Photo

Creating an add-in for the game - script basics?


2 réponses à ce sujet

#1
Lady of Lore

Lady of Lore
  • Members
  • 104 messages
I'm creating an add in for the single player game.

Question: What thing will I need to create a script for in my add in?
Example: to have an npc in an area I created?

This is what I've go so far:
// Alistiar flirt plot events


void main()
{
}

I'm opening up and looking at scripts in the game and came across this one:

#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "2da_constants_h"


void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nEventHandled = FALSE;

    switch(nEventType)
    {
        ///////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: for things you want to happen while the load screen is still up,
        // things like moving creatures around
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_AREALOAD_PRELOADEXIT:
        {
            //Start conversation here
            if (GetLocalInt(OBJECT_SELF, AREA_DO_ONCE_A) == FALSE)
            {
                SetLocalInt(OBJECT_SELF, AREA_DO_ONCE_A, TRUE);

                object oMage = UT_GetNearestCreatureByTag(oPC, "ran100cr_mage");
                UT_Talk(oMage, oPC);
            }
            break;
        }

    }
    if (!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }
}


And looking at this object oMage = UT_GetNearestCreatureByTag(oPC, "ran100cr_mage") is this a command that spawns the creature or is part of triggering him to talk?

What I want to do is have the npc I created show up in the game area I craeted and be able to talk to him. He has a dialog file associated with him but he doesn't show up in the area at all.

Thanks so much! Sorry if I am totally off, but I'm a new to this and am learning as much as I can.

Modifié par Lady of Lore, 31 janvier 2010 - 10:29 .


#2
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
If it's an area you created, there's no need to use a script to spawn the create. Open the area in the area editor, select the creature from the resource pallet and then place it in the area.



Spawning creatures with scripts is used to add creatures into existing areas, otherwise you run into compatabiltiy issues with other mods and with existing save games.



The above script first does a check to make sure it only runs ones. Second, it finds the creature with teh tag ran100cr_mage and third it starts a conversation between the PC and that creature.



There are tutorials out there if you want to learn how to spawn a creature using a script, but I think in this case you don't have to.

#3
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Example of making a creature start a conversation:

#include "utility_h"
...

object oCreature = GetObjectByTag("bob");
UT_Talk(oCreature, GetHero());

Modifié par DavidSims, 02 février 2010 - 04:14 .