Syntax/script flow and destroy_object(Self_obj); problems

Sirren67

Look, Ma! Two Heads!
I'm having troubles wit a couple of scripts:

Code:
procedure talk_p_proc begin
   if (global_var(GVAR_CLEAR_BASEMENT) == 0) then begin
      if (local_var(LVAR_Herebefore) == 0) then begin
         set_local_var(LVAR_Herebefore,1);
          start_gdialog(NAME,self_obj,4,-1,-1);
          gSay_Start;
            call Node001;
            gSay_End;
            end_dialogue;
            end
            else begin
            start_gdialog(NAME,self_obj,4,-1,-1); 
            gSay_Start; 
               call Node006; //pc talked once, didn't accept the quest
            gSay_End; 
            end_dialogue; 
       end
   end //script compiles until this block
         if (GVAR_CLEAR_BASEMENT) >= 1)  then begin
               if (local_var(LVAR_Herebefore) == 0) then begin
                   start_gdialog(NAME,self_obj,4,-1,-1);
                   gSay_Start;
                     call Node010;  //pc wasn't assigned the quest, started on his own
                   gSay_End;
                   end_dialogue;
               end
                  else begin 
                      start_gdialog(NAME,self_obj,4,-1,-1);
                      gSay_Start;
                        call Node005;  //pc accepted quest, not finished yet
                      gSay_End;
                      end_dialogue;
                 end
         end        
                        
       if ((global_var(GVAR_CLEAR_BASEMENT) == 10) and (global_var(GVAR_CLEARED_BASEMENT) == 0)) then begin
            set_global_var(GVAR_CLEARED_BASEMENT,1);
               start_gdialog(NAME,self_obj,4,-1,-1); 
               gSay_Start; 
                  call Node008; //pc's over with the quest, he wants his due 
               gSay_End; 
               end_dialogue;
      end
            if ((global_var(GVAR_CLEAR_BASEMENT) == 11) and (global_var(GVAR_CLEARED_BASEMENT) == 1)) then begin         
               start_gdialog(NAME,self_obj,4,-1,-1); 
               gSay_Start; 
                  call Node009; //quest's over, general dialogue
               gSay_End; 
               end_dialogue;
            end
end
I can't compile this piece of code (only the first var block is o.k.). The mistake is in this procedure, the rest of the script is fine. The error message says: Error! Expected "then". I couldn't find any wrong if/then/begin/parenthesis/comments. What's wrong?

Second script:
Code:
#include "..\headers\define.h"
#define NAME                    SCRIPT_FLIHOLE
#include "..\headers\flreside.h"
#include "..\headers\command.h"

procedure start;
procedure map_update_p_proc;
procedure use_skill_on_p_proc;
procedure description_p_proc;
procedure look_at_p_proc;
procedure use_p_proc;
procedure destroy_p_proc;

import variable Hole_Fixed;

procedure start begin
end

procedure destroy_p_proc begin
 
end
 
procedure use_p_proc begin
 
end
 
procedure look_at_p_proc begin 
script_overrides;
   display_msg(mstr(100));
end
 
procedure description_p_proc begin
 script_overrides;
   display_msg(mstr(101));
end
 
procedure use_skill_on_p_proc begin
   variable Skill_Used;
   script_overrides;
   
   Skill_Used := action_being_used;
  if( Skill_Used == SKILL_SCIENCE ) then begin
         if( is_success(roll_vs_skill(dude_obj, SKILL_SCIENCE, 0)) ) then
      display_msg(mstr(102));
      give_exp_points(30);
   end
   else if( Skill_Used == SKILL_REPAIR ) then begin
      if( is_success(roll_vs_skill(dude_obj, SKILL_REPAIR, 0)) ) then
      fadeout(8);
       set_map_var(MVAR_Hole_Fixed,1);              
         inc_global_var(GVAR_CLEAR_BASEMENT);
         fadein(8);               
   end
 
end
 
procedure map_update_p_proc begin
      if (map_var(MVAR_Hole_Fixed) == 1) then begin              
          destroy_object(Self_obj);
          display_msg(mstr(103));
      give_exp_points(30);
      end
end

This script is meant to destroy a scenery element (a hole), but doesn't behave as intended: in this form the hole can either desappear or desappear after a while. Fadein/fadeout seldom work, xp and msg are not handled. I tried to destroy the hole with or without using a MVAR, I put the "destroy_object(Self_obj);" bit in several procedure: no correct behaviour. Any leads?
 
I apologize for the double post, but for once I'm able to give an answer to my problems.

First script:
Code:
procedure talk_p_proc begin
   if ((global_var(GVAR_CLEAR_BASEMENT) == 0) and (map_var(MVAR_Rat_Quest_Ongoing) == 0)) then begin
      if (local_var(LVAR_Herebefore) == 0) then begin
         set_local_var(LVAR_Herebefore,1);
         start_dialog_at_node(Node001);//Pc and Npc don't know each other, quest not started
      end
            else begin
               start_dialog_at_node(Node006); //Pc and Npc talked once, Pc didn't accept the quest 
            end
   end
         else if ((global_var(GVAR_CLEAR_BASEMENT) == 0) and (map_var(MVAR_Rat_Quest_Ongoing) <=8)) then begin
            start_dialog_at_node(Node010); //pc wasn't assigned the quest, not finished, started on his own
         end
               else if ((global_var(GVAR_CLEAR_BASEMENT) == 0) and (map_var(MVAR_Rat_Quest_Ongoing) ==9)) then begin
                     start_dialog_at_node(Node011); //pc wasn't assigned the quest, finished, started on his own
               end
                  else if ((global_var(GVAR_CLEAR_BASEMENT) == 1) and (map_var(MVAR_Rat_Quest_Ongoing) <=9)) then begin
                     start_dialog_at_node(Node005); //pc accepted quest, not finished yet
                  end
                     else if ((global_var(GVAR_CLEAR_BASEMENT) == 1) and (map_var(MVAR_Rat_Quest_Ongoing) == 10)) then begin     
                        start_dialog_at_node(Node008); //pc's over with the quest, reward wanted 
                     end
                        else if (global_var(GVAR_CLEAR_BASEMENT) == 11) then begin          
                           start_dialog_at_node(Node009); //quest over, reward given, general dialogue
                         end
end

I couldn't understand what was wrong but I managed to get a fully functional and complete talk procedure. I was trying to use the GVAR used for PipBoy logging to handle the dialogue, then added another GVAR and a MVAR or two... Apparently, the simpler the better: I used only one GVAR for quest logging and only one MVAR for dialogue handling. If you have any other advice/tip, please let me know.

Second script:
Code:
procedure use_skill_on_p_proc begin
   variable Skill_Used;
   script_overrides;
   
   Skill_Used := action_being_used;
  if( Skill_Used == SKILL_SCIENCE ) then begin
         if( is_success(roll_vs_skill(dude_obj, SKILL_SCIENCE, 0)) ) then begin
            display_msg(mstr(102));
            give_exp_points(30);
         end else begin
               display_msg(mstr(104));
            end
  end
      if( Skill_Used == SKILL_REPAIR ) then begin
         if( is_success(roll_vs_skill(dude_obj, SKILL_REPAIR, 0)) ) then begin    
            inc_map_var(MVAR_Rat_Quest_Ongoing);
            display_msg(mstr(103));
            give_exp_points(30);
            game_time_advance(ONE_GAME_HOUR);
            gfade_out(ONE_GAME_SECOND);         
            gfade_in(ONE_GAME_SECOND);
            destroy_object(Self_obj);                               
            end else begin
              display_msg(mstr(105));
            end
      end
end

No MVAR needed, the "destroy_object(Self_obj);" bit must be outside "gfade_in/gfade". If you are using either inc_map_var or inc_global_var in your scripts make sure you add a failure message. Otherwise you could spoil your quest mechanics.
Bye.
 
Back
Top