Making the car break down

Discussion in 'Fallout General Modding' started by Josan12, May 27, 2010.

  1. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Here's a simple thing i want to do:

    When the player goes to use the car, have a random chance it will not start, minus the players repair skill. Then have the player make a repair check to get it going again. Simple as that.

    Here's the appropriate part of the car script:

    Code:
    procedure use_p_proc begin
       stop_car_use := false;
       if (global_var(GVAR_PLAYER_GOT_CAR) != 0) then begin
          if (get_stolen_car(stolen_car_stolen)) then begin
             if (chop_shop_boy_obj != 0) then begin
                if (critter_state(chop_shop_boy_obj) != CRITTER_IS_DEAD) then begin
                   if (obj_can_see_obj(chop_shop_boy_obj, dude_obj)) then begin
                      stop_car_use := true;
                      nr_add_timer_event(chop_shop_boy_obj, 0, attack_param);
                   end
                end
             end
          end
       end else begin
          stop_car_use := true;
          display_mstr(100 + (smitty_part(state_smitty_part_unknown) == false));
       end
    
       if (stop_car_use == false) then begin
          set_took_car_off_den_bus_1;
          if (get_stolen_car(stolen_car_none) == false) then begin
             set_stolen_car(stolen_car_drive_away);
          end
          car_was_used_to_exit := true;
          play_sfx("carstart");
    
          // DJS - Added this flag to handle creation/deletion of car
          // from multiple Raiders map entrances on RAIDERS1.
          if( cur_map_index == MAP_RAIDERS_CAMP1 ) then
             set_global_var( GVAR_LEFT_CAR_AT_RAIDERS, 0 );
    
          car_give_to_party;
          debug_msg("Party has the car");
       end else begin
          script_overrides;
          debug_msg("car use stopped by script");
       end
    end
    
    What do i need to change to make this happen? Can it even be done?
     
  2. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Interesting idea.

    Seeing as the script is already using a script override, I would say it should be doable (partly anyway).
    I don't quite understand why you want the repair skill to be a factor in if the car breaks down or not though (servicing?). Do you want the player to manually repair the car? Then you should use both "procedure use_skill_on_p_proc" and "procedure use_obj_on_p_proc"
    Also, what happens if the player is not skilled enough to get the car started again? Will this not cause problems out on the random encounter maps, as you cant leave it there? And you will be driving the car even if you just walk out onto the exit grids anyway.
    So as far as I know it could only work on 'regular' maps that gets saved and not the random ones. Some of the special random encounters should work too.
     
  3. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Good points. Thanks Darek. I didn't think about the random encounter maps. That's a bit of a problem. I suppose one solution would be to make sure the break-down check doesn't come up on any map where the player could 'loose' the car (as they can just walk off the map as you say)

    I was thinking that it seems appropriate to have the chance of break-down reduced by the players skill to represent care and maintenance of the vehicle. But yes - as he'll have to make a repair check anyway to get it going this could be overkill.

    What is the relevance of a 'script ovveride' anyway? And do i need to use a GVAR to store the value of the car repaired/broken? I'm not quite sure how to go about modifying this script to acheive the above - any tips?
     
  4. smilodom

    smilodom Look, Ma! Two Heads!

    344
    Apr 17, 2008
    The car could probably be shot during a battle and thus the player has to fix it with some junk or other spare parts

    These ideas make me think of repairing the "PA"?

    Thus there were finally a use of this manuals...

    Just my two cents...
     
  5. Darek

    Darek is currently unavailable

    Jan 7, 2008
    @ Josan

    To answer your questions...
    You do not need to use a global variable, a local will suffice.
    As for script overrides, it just means that the script can override the engine or the proto file.
    But it doesn't always work, some things are hardcoded to ignore overrides, like the doctors bag (I think, at least it doesn't work).

    Anyway I gave it a go to see what I could do. What do you think, is this something that could be helpful?


    Code:
    variable broken;                                                                       // at the top of the script
    
    
    procedure use_p_proc
    begin
    	variable LVar0 := 0;
    	if (not(metarule3(110, 0, 0, 0))) then begin
    		stop_car_use := 0;
    		if (global_var(18) != 0) then begin
    			if (global_var(348) == 1) then begin
    				if (chop_shop_boy_obj != 0) then begin
    					if (critter_state(chop_shop_boy_obj) != 1) then begin
    						if (obj_can_see_obj(chop_shop_boy_obj, dude_obj)) then begin
    							stop_car_use := 1;
    							last_timed_obj := chop_shop_boy_obj;
    							last_timed_param := last_timed_param;
    							metarule3(100, chop_shop_boy_obj, 8, 0);
    							add_timer_event(chop_shop_boy_obj, game_ticks(0), 8);
    						end
    					end
    				end
    			end
    			else begin                                                                    // This part added by me
    				if (cur_map_index == 54) or (cur_map_index == 55) then begin	            // just keep adding map numbers here
    					if ((local_var(3) != 1) and (broken == 0)) then begin		
    						set_local_var(3, random (1, 10));	                                 // random 1 to 10, change to your liking
    					end
    					if (local_var(3) == 1) then begin
    						broken := 1;
    						stop_car_use := 2;
    					end
    				end
    			end                                                                           // stop
    		end
    		else begin
    			stop_car_use := 1;
    			display_msg(message_str(304, 100 + ((global_var(162) == 0) == 0)));
    		end
    		if (stop_car_use == 0) then begin
    			if (global_var(550) < 2) then begin
    				set_global_var(550, 2);
    			end
    			set_global_var(447, global_var(447) bwor 32768);
    			if (global_var(348) == 1) then begin
    				if (global_var(348) < 3) then begin
    					set_global_var(348, 3);
    				end
    				debug_msg("stolen_car state == " + global_var(348));
    				display_msg(message_str(445, 1001));
    				give_exp_points(750);
    				display_msg(message_str(14, 100) + 750 + message_str(14, 101));
    				set_global_var(55, global_var(55) + 2);
    			end
    			if ((party_member_obj(455) != 0) == 0) then begin
    				if (tile_contains_pid_obj(tile_num_in_direction(tile_num_in_direction(tile_num(self_obj), 5, 2), 4, 1), elevation(self_obj), 455) != 0) then begin
    					debug_msg("car never added to the party, adding now");
    					party_add(tile_contains_pid_obj(tile_num_in_direction(tile_num_in_direction(tile_num(self_obj), 5, 2), 4, 1), elevation(self_obj), 455));
    				end
    			end
    			car_was_used_to_exit := 1;
    			play_sfx("carstart");
    			if (cur_map_index == 92) then begin
    				set_global_var(586, 0);
    			end
    			debug_msg("car_give_to_party");
    			set_global_var(633, 0);
    			metarule(31, 0);
    			set_global_var(633, -1);
    			debug_msg("Party has the car");
    		end
    		if (stop_car_use == 2) then begin                                                 // This part added by me
    			script_overrides;
    			//	play_sfx - stalling engine perhaps?
    			//	display_msg - either float or text box.
    		end                                                                               // stop
    		else begin
    			script_overrides;
    			debug_msg("car use stopped by script");
    		end
    	end
    end
    
    
    procedure use_obj_on_p_proc
    begin
    	if (global_var(18) == 0) then begin
    		if (smitty_obj != 0) then begin
    			script_overrides;
    			display_msg(message_str(304, 400));
    			last_timed_obj := smitty_obj;
    			last_timed_param := last_timed_param;
    			metarule3(100, smitty_obj, 11, 0);
    			add_timer_event(smitty_obj, game_ticks(0), 11);
    		end
    		else begin
    			if (obj_pid(obj_being_used_with) == 253) then begin
    				script_overrides;
    				gfade_out(10);
    				game_time_advance(60 * (60 * 10));
    				if (is_success(roll_vs_skill(source_obj, 13, -100))) then begin
    					debug_msg("CAR WAS JUST STOLEN!!!");
    					play_sfx("carrepar");
    					destroy_object(obj_being_used_with);
    					set_global_var(18, 1);
    					display_msg(message_str(304, 200));
    				end
    				else begin
    					display_msg(message_str(304, 210));
    				end
    				gfade_in(10);
    			end
    		end
    	end
    	else begin
    		if (obj_pid(obj_being_used_with) == 254) then begin
    			script_overrides;
    			gfade_out(10);
    			game_time_advance(60 * (60 * 10));
    			if (is_success(roll_vs_skill(source_obj, 13, -100))) then begin
    				debug_msg("Upgrade was a success");
    				play_sfx("carrepar");
    				set_global_var(453, 1);
    				destroy_object(obj_being_used_with);
    				display_msg(message_str(304, 220));
    			end
    			else begin
    				display_msg(message_str(304, 230));
    			end
    			gfade_in(10);
    		end
    		else begin                                                                        // This part added by me
    			if ((local_var(3) == 1) and ((obj_pid(obj_being_used_with) == 308) or (obj_pid(obj_being_used_with) == 75))) then begin
    				script_overrides;
    				gfade_out(10);
    				game_time_advance(60 * (60 * 10));
    				if (is_success(roll_vs_skill(source_obj, 13, -20))) then begin              // change stat requirement
    					play_sfx("carrepar");
    					set_local_var(3, 0);
    					display_msg(message_str(304, 220));                                      // change message success
    				end
    				else begin
    					display_msg(message_str(304, 230));                                      // change message fail
    				end
    				gfade_in(10);
    			end
    		end                                                                               // stop
    	end
    end
    
    
    procedure use_skill_on_p_proc
    begin
    	if (global_var(18) == 0) then begin
    		if ((action_being_used == 13) and ((global_var(162) == 0) == 0)) then begin
    			script_overrides;
    			display_msg(message_str(304, 300));
    		end
    	end
    	else begin                                                                            // This part added by me
    		if ((local_var(3) == 1) and (action_being_used == 13)) then begin
    			script_overrides;
    			gfade_out(10);
    			game_time_advance(60 * (60 * 10));
    			if (is_success(roll_vs_skill(source_obj, 13, -50))) then begin                  // change stat requirement
    				play_sfx("carrepar");
    				set_local_var(3, 0);
    				display_msg(message_str(304, 220));                                          // change message success
    			end
    			else begin
    				display_msg(message_str(304, 230));                                          // change message fail
    			end
    			gfade_in(10);
    		end
    	end                                                                                   // stop
    end
    I used the variable "broken" so the car won't break down just after you've fixed it. It will not be saved, but other than that I don't know how long until it gets reset.
     
  6. OzzymO

    OzzymO First time out of the vault

    77
    Sep 19, 2009
    There is already a breakdown mod with Megamod, is this just an alternative?
     
  7. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Wow! You the man, Darek! :cool: +50 karma for helping out a noob.

    But i'm a little confused - which script are you editing? Some parts look the same as ZSDRVCAR.ssl but some parts don't. Can you explain?

    Whaaaa ?!!? Seriously?!? What does it do, and how does it work?
     
  8. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Thanks. I needed a little break from only playing. :)
    I decompiled ZSDRVCAR.INT from the latest RP version. To get the latest bug fixes you know. I hope that is the only difference. As long as they both use the same global variables (or map_vars), there shouldn't be any compatibility problems.

    But if there already is a breakdown mod available this is probably redundant.
     
  9. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    the scripts i edited to make the breakdown sub-mod are

    ZSDRVCAR.INT
    GL_Breakdown.int
    and the map script for the breakdown map
    breakdwn.int

    i used force_encounter_with_flags() and only trigger it while on the worldmap

    took a while to do it,and it has a bug i cant get rid of,when the encounter is forced,the car correctly is placed and is not usable(untill new part is installed) but when you leave the breakdown map for the first time after car breaks,the car is with you on the worldmap untill you enter a new mpa that is not forced,then it goes away,even tho the car remains in the breakdown map

    edit : i also added code to vic,to allow for players to have a 100% install rate if he is in party,the dialog for the parts is scattered across all of the reasonable npc's in the game,allowing for buying or repairing,to recieve the new parts

    Nirran
     
  10. .Pixote.

    .Pixote. Carbon Dated and Proud
    Modder

    Sep 14, 2009
    This sounds like another crazy Josan idea that just might work…and if it does, we will all be extremely grateful for it. Keep them coming. :wink:
     
  11. earthdude

    earthdude First time out of the vault

    69
    May 11, 2008
    I brought this idea up some time ago and people thought it would be cool. Since you all/y'all/all you are working on the car, I'd bring it up again:

    When looking at the car, it would be cool if you could see what modifications have been done on it. e.g. Fuel Cell Regulator, Claudia, grav plates, T-rays gold rope around the license plate, etc.

    More apropos this thread.... Maybe the more repairs that are done on the car, you could have a progression of statements going from "a nice well-preserved car" to "a patchwork car that seems to have been cannibalized from many other cars... you wonder if any original parts remain." This could make junkyards that much more useful.
     
  12. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Ah ha. Now i understand .... ;)

    Yes, it sounds like Nirran has made a fine mini-mod already. But i was angling for something simpler that would just make repair a more tag-able skill (and Vic a better NPC)

    I may be able to make something out of Darek's script yet - the only thing holding me back is my noob-level scripting skillz .... :mrgreen:

    Two nice ideas there. I have actually made new graphics for the car with it's various stages of being 'pimped'. In fact, i strongly suspect an sfall global script would be just the trick for making the game replace all instances of the car with it's pimped up version when the player gets the appropriate upgrades. Unfortunately, i am as i said above, held back by being an artist pretending to be a scripter, and the fact that it takes me about 2 days to figure out 2 lines of code .... :( :confused:
     
  13. MIB88

    MIB88 So Old I'm Losing Radiation Signs
    Modder

    Feb 22, 2005
    Yes, Nirran did an awesome job with this. Basically, one of five things can go wrong with the car and you will have to buy replacement parts. The car will wear down over time, but having a high repair skill and/or having Vic in your party will slow down this process. (I also wanted Vic to be more useful. :wink: )