Sorry to bother you so soon but I have a problem with more than one scripts: they work, but only the second time I enter a map; they are supposed to work the * first * time. This is an exemple:
#include "..\headers\define.h"
#include "..\headers\florenc.h"
#include "..\headers\floffice.h"
#define NAME SCRIPT_FCJASON
#include "..\headers\command.h"
#include "..\headers\ModReact.h"
procedure start;
procedure timed_event_p_proc;
procedure critter_p_proc;
procedure use_p_proc;
procedure look_at_p_proc;
procedure description_p_proc;
procedure use_skill_on_p_proc;
procedure use_obj_on_p_proc;
procedure damage_p_proc;
procedure map_enter_p_proc;
procedure map_update_p_proc;
procedure talk_p_proc;
#define LVAR_Herebefore (4)
#define LVAR_Hostile (5)
#define LVAR_Personal_Enemy (6)
variable Only_Once:=0;
variable talkCount := 0;
#define TIMER_FLOAT 1
procedure start begin
end
procedure timed_event_p_proc begin
if (is_loading_game == false) then begin
if (local_var(LVAR_Herebefore) == 1) then begin
destroy_object(self_obj);
end
end
end
procedure use_p_proc begin
end
procedure look_at_p_proc begin
script_overrides;
if (local_var(LVAR_Herebefore) == 0) then
display_msg(mstr(100));
else
display_msg(mstr(101));
end
procedure description_p_proc begin
script_overrides;
display_msg(mstr(102));
end
procedure use_skill_on_p_proc begin
end
procedure use_obj_on_p_proc begin
end
procedure damage_p_proc begin
end
procedure map_enter_p_proc begin
Only_Once:=0;
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_TEAM_NUM,TEAM_POSEIDON_OIL);
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_AI_PACKET,AI_LONER_CITIZEN);
end
procedure map_update_p_proc begin
end
procedure talk_p_proc begin
talkCount := 90;
end
procedure critter_p_proc begin
if (tile_num(self_obj) != 33506) then begin
animate_move_to_tile(33506);
if (game_time > talkCount) then begin
float_msg(self_obj, mstr(103 + Random(0, 4)), FLOAT_MSG_BLACK);
talkCount := game_time + (ONE_GAME_SECOND * 2);
end
end
if (tile_num(self_obj) == 33506) then begin
set_local_var(LVAR_Herebefore,1);
end
end
The related critter walks from point A to point B, where he "leaves" the map. I tested the script in-game: the first time I leave the map and reenter it I find that my critter is leaving the map again, while from the second time on I find no trace of the critter (as it should be). The map has two outdoors areas and I have to cross the "middle" area to actully leave the map: is this related in any way? I have the same problem with a script which creates a weapon in a guard's inventory: first time I run the map scripts does not work, the second time the guard has the weapon in his hand (same map). Is this related to map vars/script?
#include "..\headers\define.h"
#include "..\headers\florenc.h"
#include "..\headers\floffice.h"
#define NAME SCRIPT_FCJASON
#include "..\headers\command.h"
#include "..\headers\ModReact.h"
procedure start;
procedure timed_event_p_proc;
procedure critter_p_proc;
procedure use_p_proc;
procedure look_at_p_proc;
procedure description_p_proc;
procedure use_skill_on_p_proc;
procedure use_obj_on_p_proc;
procedure damage_p_proc;
procedure map_enter_p_proc;
procedure map_update_p_proc;
procedure talk_p_proc;
#define LVAR_Herebefore (4)
#define LVAR_Hostile (5)
#define LVAR_Personal_Enemy (6)
variable Only_Once:=0;
variable talkCount := 0;
#define TIMER_FLOAT 1
procedure start begin
end
procedure timed_event_p_proc begin
if (is_loading_game == false) then begin
if (local_var(LVAR_Herebefore) == 1) then begin
destroy_object(self_obj);
end
end
end
procedure use_p_proc begin
end
procedure look_at_p_proc begin
script_overrides;
if (local_var(LVAR_Herebefore) == 0) then
display_msg(mstr(100));
else
display_msg(mstr(101));
end
procedure description_p_proc begin
script_overrides;
display_msg(mstr(102));
end
procedure use_skill_on_p_proc begin
end
procedure use_obj_on_p_proc begin
end
procedure damage_p_proc begin
end
procedure map_enter_p_proc begin
Only_Once:=0;
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_TEAM_NUM,TEAM_POSEIDON_OIL);
critter_add_trait(self_obj,TRAIT_OBJECT,OBJECT_AI_PACKET,AI_LONER_CITIZEN);
end
procedure map_update_p_proc begin
end
procedure talk_p_proc begin
talkCount := 90;
end
procedure critter_p_proc begin
if (tile_num(self_obj) != 33506) then begin
animate_move_to_tile(33506);
if (game_time > talkCount) then begin
float_msg(self_obj, mstr(103 + Random(0, 4)), FLOAT_MSG_BLACK);
talkCount := game_time + (ONE_GAME_SECOND * 2);
end
end
if (tile_num(self_obj) == 33506) then begin
set_local_var(LVAR_Herebefore,1);
end
end
The related critter walks from point A to point B, where he "leaves" the map. I tested the script in-game: the first time I leave the map and reenter it I find that my critter is leaving the map again, while from the second time on I find no trace of the critter (as it should be). The map has two outdoors areas and I have to cross the "middle" area to actully leave the map: is this related in any way? I have the same problem with a script which creates a weapon in a guard's inventory: first time I run the map scripts does not work, the second time the guard has the weapon in his hand (same map). Is this related to map vars/script?