Aller au contenu

Photo

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


7 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
Lady of Lore

Lady of Lore
  • Members
  • 104 messages
Ah, so a script is only needed in an existing area.



So I shouldn't need a script to add an npc to an area I created, even if the level was pulled from an existing one? Created a new area using the level from the random encounters. For some reason any npc I place in the area does not appear in game.



I thought maybe the script was the issue.



I still need to create a script for my add-in though, correct?



The script above was one I was looking at from the single player game. The mage npc name I was going to go in and replace it with the NPC I wanted to be in the conversation.



Thanks for the reply! The scripting tutorials and explanations in the wiki are pretty good but it takes a while to break down everything that is said but I'll keep at it.

#4
TreDawn

TreDawn
  • Members
  • 76 messages
 Here is a short list of tutorials:
01. www.damods.com/forums/index.php
02. thenexusforums.com/index.php
03. dragonagemodding.wordpress.com/category/tutorials/
04. social.bioware.com/wiki/datoolset
05. www.dragongaming.co.uk/category/gaming/tutorials/

Modifié par TreDawn, 01 février 2010 - 08:04 .


#5
Lady of Lore

Lady of Lore
  • Members
  • 104 messages
Thanks for the post TreDawn.



I've actually been to all of these sites, the dragon gaming tutorials are really great and helpful, I've had them bookmarked for a while.



What I was looking for was more of tutorials or explanations of parts of scripting such as a script to make an npc initiate a conversation (which, thinking about this, should be able to be done using a trigger).



The damods forum I had somehow overlooked the section on scripting and am reading through that now.



Thanks again. ^_^

#6
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 .


#7
TreDawn

TreDawn
  • Members
  • 76 messages

DavidSims wrote...

Example of making a creature start a conversation:

#include "utility_h"
...

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


Pasted on npc-talk-first.txt Thank you.

#8
Lady of Lore

Lady of Lore
  • Members
  • 104 messages
Thanks DavidSims, I appreciate your post.