Barter problem.

8-Ball

First time out of the vault
OK, so I created the scripts for a new character, and he's going to be a shopkeep. So from the "show me what you have" dialog choice, I linked procedure003. The code was simply:

procedure Node003 begin
gdialog_barter;
end


When I pick the "show me..." dialog option, the barter screen comes up, but his inventory shows empty, and none of the buttons work. Clicking on the talk button doesn't bring me back to the dialog. I can't do anything except hit escape and exit the game. I tried adding "call Node999" on the off-chance it just didn't know what to do after it started bartering, but no luck. I added dialog, as well, with the PC's NOption calling Node999, but again, it just "freezes" when the barter screen shows up. The only thing I didn't do is set up a box off-screen for him to interact and stock himself with, but I'm a bit unclear as to how that works, which is why I didn't do it.
 
You must give the shopkeeper his/her boxes in order to get the thing work.
You need a temporary box (attach the standard ready script)
The shopkeep box (what will be for sale, attach your own script)
Export the two as M_VAR in the map script and import them (always as map vars) in the shopkeeper script. Look at the scripts used for Tubby in The Den as a reference.
The trick is more easily done than explained.
Good luck.
 
8-Ball said:
OK, so I created the scripts for a new character, and he's going to be a shopkeep. So from the "show me what you have" dialog choice, I linked procedure003. The code was simply:

procedure Node003 begin
gdialog_barter;
end


When I pick the "show me..." dialog option, the barter screen comes up, but his inventory shows empty, and none of the buttons work. Clicking on the talk button doesn't bring me back to the dialog. I can't do anything except hit escape and exit the game. I tried adding "call Node999" on the off-chance it just didn't know what to do after it started bartering, but no luck. I added dialog, as well, with the PC's NOption calling Node999, but again, it just "freezes" when the barter screen shows up. The only thing I didn't do is set up a box off-screen for him to interact and stock himself with, but I'm a bit unclear as to how that works, which is why I didn't do it.

You need to set the AI packet to merchant, or you will get that error.
 
Well, I fired up the game today and the bartering worked without the box. I'm not sure why, but I'm not complaining. However, even after looking at examples from, say, Renesco or Tubby, I'm still not sure how to properly set up the temp box and inventory box (scripting-wise, of course). I'm noticing they have "import variable whoever_box_obj" at the top, where is that referencing? Any chance someone can write a short example script to help me out here?


EDIT: Now I'm having problems with all my scripts suddenly. The talk_p_proc section for one character was copied straight from the Arroyo Villager script, except with the (REP_ENEMY_ARROYO) removed. So it said:

procedure talk_p_proc begin
GetReaction;

if (local_var(LVAR_Personal_Enemy) == 1) then begin
call Node009;
end else begin
start_gdialog(NAME,self_obj,4,-1,-1);
gSay_Start;
// if (map_var(MVAR_Talked_Villager) == 0) then begin
// set_map_var(MVAR_Talked_Villager,1);
// call Node000;
// end
// else

call Node997;
gSay_End;
end_dialogue;
end
end

And it's worked since I made it. Then while poking around in the file, I deleted the lines with // in front of them, thinking they were comments which weren't actually being read. When I tried to compile, it told me it couldn't, so I re-copied those lines back in from acvillgr.ssl. But now it won't compile. :cry: And with my other character, his script compiled fine and ran fine. Then I added "set_herebefore" to the end of the talk_p_proc, and it wouldn't compile. So I removed it, and now FSE is giving me some error about TOWN_REP_VAR, and highlighting "end_dialogue;" as the error. :?: What the hell is going on here? dude_obj, got any idea?
 
These are bits and pieces of scripts of the only merchant I made up to
now. The thing works in-game and is built after dctubby.ssl.

My map script:

#include "..\headers\define.h"
#include "..\headers\fltrap2.h"
#include "..\headers\updatmap.h"

#define NAME SCRIPT_FLTRAP2

#include "..\headers\command.h"
#include "..\headers\florenc.h"

procedure start;
procedure map_exit_p_proc;
procedure map_enter_p_proc;
procedure map_update_p_proc;

export variable generic_temp_box;
export variable po_luke_box_obj;
export variable luke_obj;

procedure start begin
end

procedure map_enter_p_proc begin
if (is_loading_game == false) then begin
if (map_first_run) then begin
display_mstr(100);
end
end

Lighting;
end

procedure map_update_p_proc begin
Lighting;
end

procedure map_exit_p_proc begin

end


Note you have to export the temporary box, the merchant box and the merchant
as variables. florenc.h is the town's header file. It must be included in
the merchant's script as well. It reads as follows:

/*
Copyright 1998-2003 Interplay Entertainment Corp. All rights reserved.
*/

#ifndef FLORENC,_H
#define FLORENC,_H

// Map vars for the town of Florenc

// Comments

//MAP_GLOBAL_VARS:

//GLOBAL NUMBER

// store defines
#define store_def_luke (1)

// business hearts
#define luke_heart (17709)

//

# define Mvar_Town_Rep (0)



#endif // FLORENC,_H

/*I made it after the Den header (I made this stuff more than 4 months ago
and I really can't remember why I defined the merchant in the town
header instead of the map one...Anyway remeber to define it. Along with
town reputation...).*/

Now, these are the bits and pieces for the merchant:


#define NAME SCRIPT_FCLUKE

#include "..\headers\command.h"
#include "..\headers\florenc.h" // I included the header, remember?

import variable generic_temp_box;
import variable po_luke_box_obj;
import variable luke_obj;
/*After procedure declaration I imported the variables from the map script.
NEVER EXPORT variables from critters scripts, strange things happen*/


#define do_luke_barter begin \
gdialog_barter; \
Reply(130); // Thanks for your patronage \
NOption(103,Node999,001); //Goodbye... \
end
/*Here I defined a personal procedure: after closing the trade window
the dialogue one appears.*/

procedure start begin
luke_obj := self_obj; //I "define" luke_object, see below.
end


procedure talk_p_proc begin
script_overrides;
move_obj_inven_to_obj(self_obj,generic_temp_box);
move_obj_inven_to_obj(po_luke_box_obj,self_obj);
start_gdialog(NAME,self_obj,4,-1,-1);
gSay_Start;
call Node001
gSay_End;
end_dialogue;
move_obj_inven_to_obj(self_obj,po_luke_box_obj);
move_obj_inven_to_obj(generic_temp_box,self_obj);
set_local_var(LVAR_Herebefore,1);

end

procedure Node001 begin
Reply(200); // Wanna barter?
NOption(201,Node002,001); // Yep.
NOption(202,Node999,001); // Nope.
end

procedure Node002 begin
do_luke_barter
end

A simplified procedure talk_p_proc:
The engine grabs the merchant's pokets content and puts it in the
temporary box, fills the merchant box and puts the content in the newly
empty pokets. After dialogue and bartering end the process is reversed.

If you want to allow the players to loot a merchant's corpse:

procedure destroy_p_proc begin
luke_obj := 0;
move_obj_inven_to_obj(po_luke_box_obj,self_obj);
inc_good_critter // Evil, whatever...
end

Make your merchant box script (or save a ready one with anoter name, for now),
attach it to a box, do the same with the other scripts (map, merchant, temp
box). Test in-game and good luck.

Disclaimer: even if this stuff works I know I am not the code guru here.
If I made mistakes, or somebody knows better ways to get the job done, or
simply wants to pinpoint something, then let me/us know.
 
Back
Top