Need help with scripts for dialogue/items
#1
Posté 18 décembre 2009 - 10:12
After "making" an area where I want the items to be found, I put them inside a chest.
But I want this chest to fire off a dialogue.
I can do that easily enough, with an invisible placeable over the chest, and having the chest as inactive.
Now, I want the dialogue to activate the chest again, and then remove or disable the invisible "dialogue-chest"-placeable.
Now, how do I do this? I've tried mixing what little I know of scripting, but it doesn't work. Not so strange, considering I know next to nothing.
I would like this script to use a plot-check, too, which I already use in the dialogue.
Anyone who can help out a poor fellow here?
#2
Posté 19 décembre 2009 - 03:23
#3
Posté 19 décembre 2009 - 08:42
conversation. But no matter what I do, I can't get it to work. I could
use some help with designing a script that adds the items after the
conversation, and de-activates the conversation-chest, so that it can't
be talked to again.
As it is, I can talk to it, then nothing happens.
I'm using a script, slightly modified to what I thought would
work, which it apparently did not. I could post it, I suppose, to see
if someone could point out what I should do to get it to work. As I
said, I've never really scripted before, so my head is drowning in
stuff it doesn't understand.
-------
#include "utility_h"
#include "plt_motw_box_plot"
void main()
{
if ( WR_GetPlotFlag( PLT_MOTW_BOX_PLOT, BOX_SEAL_GONE_FLAG ) == FALSE )
return;
( WR_GetPlotFlag( PLT_MOTW_BOX_PLOT, BOX_SEAL_GONE_FLAG ) == TRUE )
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
switch ( nEventType )
{
case EVENT_TYPE_MODULE_LOAD:
{
UT_AddItemToInventory(R"arm_motw_bot_arc.uti", 1);
UT_AddItemToInventory(R"arm_motv_glv_arc.uti", 1);
WR_SetPlotFlag( PLT_MOTW_BOX_PLOT, BOX_SEAL_GONE_FLAG, FALSE );
break;
}
default:
break;
}
}
------
That's it.
Now, how much of it is utterly wrong? It isn't that much different
from weriKK's script provided in one of his/hers tutorials. Should I
use that, or must I make a new script from the ground? How shall that
script look, then?
Modifié par FictionalBreger, 19 décembre 2009 - 08:45 .
#4
Posté 19 décembre 2009 - 12:29
Well, I have never tried that. But if you select File->New->Placeable that would allow to define the shape of the placeable and a script that would override the placeable_core script. So, that sould be able to launch a dialogue (a conversation).
In a conversation it's possible to run a specific script whan a proper replay is selected. In that script you could call OpenInventory() function that should allow you to browse the content of the chest. But I have never tried OpenInventory() call. This could be good scripting practice so I give it a try and see if it works.
Modifié par BioSpirit, 19 décembre 2009 - 02:08 .
#5
Posté 19 décembre 2009 - 01:19
A Script for the chest:
#include "placeable_h"
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
switch (nEventType)
{
//----------------------------------------------------------------------
// Sent by engine when player clicks on object.
//----------------------------------------------------------------------
case EVENT_TYPE_PLACEABLE_ONCLICK:
{
BeginConversation(GetHero(), OBJECT_SELF);
return;
}
}
HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
And the second script run from the conversation:
void main()
{
object oChest = GetObjectByTag("magic_chest");
SetPlaceableActionResult(oChest, PLACEABLE_ACTION_UNLOCK, TRUE);
OpenInventory(oChest, GetHero());
}
#6
Posté 19 décembre 2009 - 01:48
Also, how have you learned so much about scripting? Trial and error?
I haven't exactly looked around, but I don't know what to look for, either.
#7
Posté 19 décembre 2009 - 02:06
1. It could be better to use SetPlaceableState instead of SetPlaceableActionResult
2. Container state must be checked before launching a conversation. No point if the container is already open.
3. The second script can be placed in a Plot_Script:
......
if(nType == EVENT_TYPE_SET_PLOT) // actions -> normal flags only
{
int nValue = GetEventInteger(eParms, 2); // On SET call, the value about to be written (on a normal SET that should be '1', and on a 'clear' it should be '0')
int nOldValue = GetEventInteger(eParms, 3); // On SET call, the current flag value (can be either 1 or 0 regardless if it's a set or clear event)
// IMPORTANT: The flag value on a SET event is set only AFTER this script finishes running!
switch(nFlag)
{
case BOX_SEAL_GONE_FLAG:
{
if (nValue==1) {
object oChest = GetObjectByTag("magic_chest");
SetPlaceableState(oChest,PLC_STATE_CONTAINER_STATIC_UNLOCKED);
OpenInventory(oChest, GetHero());
}
}
}
}
.....
#8
Posté 24 décembre 2009 - 05:14
The first script isn't that hard to understand. Basically copy/paste into a new script, right?
But the second one is the one I'm having a hard time understanding.
How exactly do I make it work? Put it in a new script, obviously, with the correct starting line (void main()), but then? I take my plot and exchange the script, replacing the old "_core"-script with the new one, right? Is there anything I should change? The tag in the second script I changed, of course. But is there anything else I have to do?
I've given it a try, but it still doesn't work. Now the chest does not fire up a dialogue, and I can't do anything with it. I click on it, and nothing happens. It's as if the script refuses to start. I don't get it. I'm not a scripting kind of guy, so I fail to see what's wrong.
Perhaps I've used the scripts wrong somehow, but if so, you'll probably have to explain it to me, almost step-by-step.
Also, when I compile the second script, it complains about an error of some kind.
"motw_for_boxscript.nss(12): Variable defined without type (while compiling var_constants_h.nss)"
Which points to this part: --> if(nType == EVENT_TYPE_SET_PLOT)
Anyway, I'll try it without the first script, and see if it can do anything without it.
Modifié par FictionalBreger, 24 décembre 2009 - 05:26 .





Retour en haut






