_
Note: this code is from Fallout 1, but should work just fine in Fallout 2. If it doesn't, please let me know.
1) You can name these variables whatever you want, the names I use below are just suggestions.
2) These instructions assume you are at least rudimentarily familiar with Fallout scripting.
THE PROBLEM: Fallout and Fallout 2 engine treats Flares as weapons, but unfortunately when scripts check "is subtype == weapon?" they don't take this into account. Leading to situations such as being told to holster your sidearm if you're walking around holding a flare, or even being attacked for holding a flare.
Put these above the start procedure:
Put this below the start procedure:
Next, the process for making this work is to call items_held during critter_proc as appropriate, and at the beginning of dialog. For example you could call items_held whenever the player is in sight, or when the player is wearing a certain type of armor, or has no party members, etc etc.
This last check will be performed within the critter_proc or/and talk_proc. If there was already code for this NPC, we're just replacing the "if subtype == 3" checks with our own checks. Otherwise the code you're adding after the check is going to be brand new.
----------------------EXAMPLE:
BEFORE:
AFTER:
Note: this code is from Fallout 1, but should work just fine in Fallout 2. If it doesn't, please let me know.
1) You can name these variables whatever you want, the names I use below are just suggestions.
2) These instructions assume you are at least rudimentarily familiar with Fallout scripting.
THE PROBLEM: Fallout and Fallout 2 engine treats Flares as weapons, but unfortunately when scripts check "is subtype == weapon?" they don't take this into account. Leading to situations such as being told to holster your sidearm if you're walking around holding a flare, or even being attacked for holding a flare.
Put these above the start procedure:
Code:
procedure items_held;
variable RightHand := 0;
variable LeftHand := 0;
variable PIDright := 0;
variable PIDleft := 0;
variable SubtypeWEP := 0;
Put this below the start procedure:
Code:
procedure items_held
begin
SubtypeWEP := 0;
if critter_inven_obj(dude_obj, 1) then begin
RightHand := critter_inven_obj(dude_obj, 1);
PIDright := obj_pid(RightHand);
if obj_item_subtype(RightHand) == 3 then begin
SubtypeWEP := 1;
end
end
else begin
RightHand := 0;
PIDright := 0;
end
if critter_inven_obj(dude_obj, 2) then begin
LeftHand := critter_inven_obj(dude_obj, 2);
PIDleft := obj_pid(LeftHand);
if obj_item_subtype(LeftHand) == 3 then begin
SubtypeWEP := 1;
end
end
else begin
LeftHand := 0;
PIDleft := 0;
end
end
Next, the process for making this work is to call items_held during critter_proc as appropriate, and at the beginning of dialog. For example you could call items_held whenever the player is in sight, or when the player is wearing a certain type of armor, or has no party members, etc etc.
This last check will be performed within the critter_proc or/and talk_proc. If there was already code for this NPC, we're just replacing the "if subtype == 3" checks with our own checks. Otherwise the code you're adding after the check is going to be brand new.
Code:
if (PIDright != 79) and (PIDright != 205) and (PIDleft != 79) and (PIDleft != 205) and (SubtypeWEP == 1) then begin
(tell player to holster their legit weapon)
end
----------------------EXAMPLE:
BEFORE:
Code:
procedure start;
procedure critter_p_proc; // "critter_proc" in Fallout 2
procedure start
begin
if (script_action == 12) then begin
call critter_p_proc; // "critter_proc" in Fallout 2
end
end
procedure critter_p_proc // "critter_proc" in Fallout 2
begin
if obj_can_see_obj(self_obj, dude_obj) then begin
if tile_distance_objs(self_obj, dude_obj) < 6) then begin
if (obj_item_subtype(critter_inven_obj(dude_obj, 1)) == 3) or (obj_item_subtype(critter_inven_obj(dude_obj, 2)) == 3) then begin
float_msg(self_obj, "Hey you! Drop your weapon!", 0);
// This doesn't check if the item is a Flare (ID 79 and 205) so the message will display even if player is holding a Flare.
end
end
end
end
AFTER:
Code:
procedure start;
procedure critter_p_proc; // "critter_proc" in Fallout 2
procedure items_held;
variable RightHand := 0;
variable LeftHand := 0;
variable PIDright := 0;
variable PIDleft := 0;
variable SubtypeWEP := 0;
procedure start
begin
if (script_action == 12) then begin
call critter_p_proc; // "critter_proc" in Fallout 2
end
end
procedure critter_p_proc // "critter_proc" in Fallout 2
begin
if obj_can_see_obj(self_obj, dude_obj) then begin
if tile_distance_objs(self_obj, dude_obj) < 6) then begin
call items_held;
if (PIDright != 79) and (PIDright != 205) and (PIDleft != 79) and (PIDleft != 205) and (SubtypeWEP == 1) then begin
float_msg("self_obj, Hey you! Drop your weapon!", 0);
end
end
end
end
procedure items_held
begin
SubtypeWEP := 0;
if critter_inven_obj(dude_obj, 1) then begin
RightHand := critter_inven_obj(dude_obj, 1);
PIDright := obj_pid(RightHand);
if obj_item_subtype(RightHand) == 3 then begin
SubtypeWEP := 1;
end
end
else begin
RightHand := 0;
PIDright := 0;
end
if critter_inven_obj(dude_obj, 2) then begin
LeftHand := critter_inven_obj(dude_obj, 2);
PIDleft := obj_pid(LeftHand);
if obj_item_subtype(LeftHand) == 3 then begin
SubtypeWEP := 1;
end
end
else begin
LeftHand := 0;
PIDleft := 0;
end
end
Last edited: