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.