Aller au contenu

Photo

Basic script problems-merchants+object tags


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

#1
maudlin27

maudlin27
  • Members
  • 8 messages
Apologies if this has already been asked - is anyone able to help me with how to make a simple script for a merchant? I've tried the wiki merchant section but that only looks like it gives part of the code. In particular I'm having issue with how to select the creature you're having the conversation with. I tried the following but it doesn't seem to work:
#include "core_h"
object oMerchant = GetEventCreator(); [also tried oMerchant = OBJECT_SELF;]
object oStore = GetObjectByTag(GetTag(oMerchant)&"_st");
if(IsObjectValid(oStore))
{
      ScaleStoreItems(oStore);
      OpenStore(oStore);
}
else
{
      Log_Trace(LOG_CHANNEL_SYSTEMS, GetCurrentScriptName(), "INVALID STORE OBJECT");
}

The store tag is the same as the merchant NPC's but with _st on the end. I'm guessing the geteventcreator function isn't getting the merchant connected to the relevant conversation but aren't sure. This is my first attempt at a script in DA - my only previous experience was with the nwn toolset - so I'm probably missing something obvious - for example is there an OBJECT_SELF option for objects, or some other way of getting a non-PC creature without needing the exact tag ref?

Also as a general question with the script editor, is there anyway to enable 'quick selection' of functions by typing in their name in the list? For example with nwn if I typed in GetT it'd bring up gettag. However with DA:O it only goes by the first letter so g brings up all of the G functions, without ever narrowing it down further, which makes it a real pain for getting functions.

Finally is there anywhere that provides various completed scripts? I tried dragon age nexus and the builder wiki but wasn't able to find anything obvious there

Modifié par maudlin27, 20 février 2010 - 11:21 .


#2
Phaenan

Phaenan
  • Members
  • 315 messages

maudlin27 wrote...
Apologies if this has already been asked - is anyone able to help me with how to make a simple script for a merchant?


Since I'm not sure of what you wish to do, and where, I must ask before I'm able to get my head around this. How is the script called, and what's its purpose ? Is it called from a dialog line ? If your store resource follow the naming convention, doesn't the gen00pt_generic_actions plot flag (gen_open_stores) suffice ? :?

While I'm at it, the naming convention seems to be rather store_ownertag than ownertag_st, according to the plot script. ( http://pastie.org/834056 )

maudlin27 wrote...
Also as a general question with the script editor, is there anyway to enable 'quick selection' of functions by typing in their name in the list?


As in code completion ?
Not that I know of. Would love that, tho. ^.^

maudlin27 wrote...
Finally is there anywhere that provides various completed scripts? I tried dragon age nexus and the builder wiki but wasn't able to find anything obvious there


Aside from the tutorials here and there, and the wiki... Maybe the various dadbdata builder resources modders often provide. But it doesn't provide a nicely sorted library of scripts.

Modifié par Phaenan, 20 février 2010 - 11:39 .


#3
maudlin27

maudlin27
  • Members
  • 8 messages
I use my own naming convention at the moment so I'm creating a custom script rather than using an existing one (if I have to I guess I could change the naming convention to be compatible with that, although I'd rather not in part just because doing it in a customised version would probably help me better understand how things work).
There were a couple of basic errors I only just noticed with my original script attempt, but even when working off the existing gen00pt_generic_actions script I'm having problems, no doubt due to my lack of properly understanding how the DA scripting works - essentially what I wanted is to have a conversation on my merchant creature that when a certain dialogue option is chosen will launch a script that will open up a store (using the creature's tag with _st at the end) - I'd thought it'd just mean putting in a script into the action part of the plots+scripting section of the conversation and having that script open up the store, but it just crashes the game:

void main()
{
event eParms = GetCurrentEvent();
object oConversationOwner = GetEventObject(eParms, 0);
object oStore = GetObjectByTag(GetTag(oConversationOwner) + "_st");
OpenStore(oStore);
}

- - -

Is what I'm trying to do possible or should I just go with how it's done normally?

Modifié par maudlin27, 20 février 2010 - 01:05 .


#4
Phaenan

Phaenan
  • Members
  • 315 messages
Thing is, if you use a script and not a plot action (which can be scripted anyway) you won't have access to the event and its properties. Thus no GetEventObject to get the conversation owner.
So, what I would do if I were trying to achieve the same thing is :
- Create a new plot (I'll use the plot name "phae_eg" later on)
- Create a new core conditional script for this plot ("phae_eg_handler" later on)
- Set up a new main flag in the plot editor ("PHAE_EG_OPENSTORE" yada yada)
- Use the plot custom core to hook some code to the plot flag
- In your dialog, use the "action" panel to set up the store GUI opening. Select your plot in there, and your open store flag.
This should do the trick.

Your phae_eg_handler script could be something like :
- http://pastie.org/834152
Haven't tried that myself, tho, but since it works that way for the OC generic_actions plot this one should be working as well. :blush:

Modifié par Phaenan, 20 février 2010 - 01:57 .


#5
Magic

Magic
  • Members
  • 187 messages
I recommend doing it how it is done "normally" first, then go for a custom method. You'll find errors a lot easier if you can compare step-by-step which difference lead to an error.

Your script should work. Additionally, you might want to check the following:
- The merchant resource name is correct.
- There's a merchant actually placed in the active area.
- All resources (plot, conv, script, merc, area) are exported, of course.
- If you changed something while playing, you might need to restart the game.

Edit: Misunderstood you're using the script field.

Modifié par Magic, 20 février 2010 - 01:54 .


#6
maudlin27

maudlin27
  • Members
  • 8 messages
Thanks, managed to get it working now :)