#include "C:\Game Files\Fallout 2\HEADERS\sfall.h"
#include "C:\Game Files\Fallout 2\HEADERS\Perk_Inc.h"
#include "C:\Game Files\Fallout 2\HEADERS\ItemPID.h"
variable one := 0;
variable two := 0;
variable three := 0;
variable four := 0;
variable five := 0;
variable six := 0;
variable seven := 0;
variable eight := 0;
variable nine := 0;
variable ten := 0;
variable eleven := 0;
variable twelve := 0;
variable thirteen := 0;
variable fourteen := 0;
variable fifteen := 0;
variable sixteen := 0;
variable droppable := 0;
procedure start;
procedure ConvertToBinary(variable value);
procedure Scrounger_Perks(variable critter);
procedure Drop_Weapons(variable critter);
procedure Not_Dropable(variable weapon);
procedure Lootable_Armor(variable critter);
procedure Gecko_Items(variable critter);
procedure Delete_Worn_Armor(variable critter);
procedure start begin
variable critter;
if (game_loaded) /*or (init_hook)*/ then
begin
set_sfall_global("megamod1", get_ini_setting("megamod.ini|SETTINGS|weapon_drop"));
set_sfall_global("megamod2", get_ini_setting("megamod.ini|SETTINGS|lootable_armor"));
set_sfall_global("megamod3", get_ini_setting("megamod.ini|SETTINGS|armor_pieces"));
set_sfall_global("gecko_01", get_ini_setting("megamod.ini|SETTINGS|gecko_meat_drop"));
//display_msg("meat " + get_sfall_global_int("gecko_01"));
set_sfall_global("gecko_02", get_ini_setting("megamod.ini|SETTINGS|gecko_pelt_drop"));
//display_msg("hide " + get_sfall_global_int("gecko_02"));
register_hook(HOOK_ONDEATH);
end
else
begin
critter:=get_sfall_arg;
call Delete_Worn_Armor(critter);
call Scrounger_Perks(critter);
if(get_sfall_global_int("megamod2") == 1)then
begin
call Lootable_Armor(critter);
end
if(get_sfall_global_int("gecko_02") == 1)then
begin
display_msg("Fired");
call Gecko_Items(critter);
end
if(get_sfall_global_int("megamod1") == 1)then
begin
call Drop_Weapons(critter);
end
end
end
procedure ConvertToBinary(variable value) begin
one := 0;
two := 0;
three := 0;
four := 0;
five := 0;
six := 0;
seven := 0;
eight := 0;
nine := 0;
ten := 0;
eleven := 0;
twelve := 0;
thirteen := 0;
fourteen := 0;
fifteen := 0;
sixteen := 0;
if(value >= 32768) then
begin
value := value - 32768;
sixteen := 1;
//display_msg("value " + value);
end
if(value >= 16384) then
begin
value := value - 16384;
fifteen := 1;
//display_msg("value " + value);
end
if(value >= 8192) then
begin
value := value - 8192;
fourteen := 1;
//display_msg("value " + value);
end
if(value >= 4096) then
begin
value := value - 4096;
thirteen := 1;
//display_msg("value " + value);
end
if(value >= 2048) then
begin
value := value - 2048;
twelve := 1;
//display_msg("value " + value);
end
if(value >= 1024) then
begin
value := value - 1024;
eleven := 1;
//display_msg("value " + value);
end
if(value >= 512) then
begin
value := value - 512;
ten := 1;
//display_msg("value " + value);
end
if(value >= 256) then
begin
value := value - 256;
nine := 1;
//display_msg("value " + value);
end
if(value >= 128) then
begin
value := value - 128;
eight := 1;
//display_msg("value " + value);
end
if(value >= 64) then
begin
value := value - 64;
seven := 1;
//display_msg("value " + value);
end
if(value >= 32) then
begin
value := value - 32;
six := 1;
//display_msg("value " + value);
end
if(value >= 16) then
begin
value := value - 16;
five := 1;
//display_msg("value " + value);
end
if(value >= 8) then
begin
value := value - 8;
four := 1;
//display_msg("value " + value);
end
if(value >= 4) then
begin
value := value - 4;
three := 1;
//display_msg("value " + value);
end
if(value >= 2) then
begin
value := value - 2;
two := 1;
//display_msg("value " + value);
end
if(value >= 1) then
begin
value := value - 1;
one := 1;
//display_msg("value " + value);
end
end
procedure Scrounger_Perks(variable critter) begin
call ConvertToBinary(get_proto_data(obj_pid(critter), 32));
if(seven == 0) then
begin
//display_msg("flag not set");
if(has_fake_perk(ExtraGold) and (get_sfall_global_int(182) == 1) )then
begin
//display_msg("has gold perk");
item_caps_adjust(critter, (get_sfall_global_int(183) * has_fake_perk(ExtraGold)));
end
if(has_fake_perk(ExtraAmmo) and (get_sfall_global_int(185) == 1) )then
begin
//display_msg("has ammo perk");
if(obj_pid(critter_inven_obj(critter, 1)) > 0)then
begin
//display_msg("has weapon 1");
if(get_weapon_ammo_pid(critter_inven_obj(critter, 1)) > 0) then
begin
//display_msg("has ammo 1");
add_mult_objs_to_inven(critter, create_object_sid(get_weapon_ammo_pid(critter_inven_obj(critter, 1)), 0, 0, -1), (get_sfall_global_int(186) * has_fake_perk(ExtraAmmo)));
end
end
if(obj_pid(critter_inven_obj(critter, 2)) > 0)then
begin
//display_msg("has weapon 2");
if(get_weapon_ammo_pid(critter_inven_obj(critter, 2)) > 0) then
begin
//display_msg("has ammo 2");
add_mult_objs_to_inven(critter, create_object_sid(get_weapon_ammo_pid(critter_inven_obj(critter, 2)), 0, 0, -1), (get_sfall_global_int(186) * has_fake_perk(ExtraAmmo)));
end
end
end
end
end
procedure Drop_Weapons(variable critter) begin
variable weapon := 0;
if (critter_inven_obj(critter, 1)) then
begin
weapon := critter_inven_obj(critter, 1);
call Not_Dropable(weapon);
if (droppable) then
begin
rm_obj_from_inven(critter, weapon);
move_to(weapon, tile_num_in_direction(tile_num(critter), random(0, 5), random(1, 2)), elevation(critter));
end
end
if (critter_inven_obj(critter, 2)) then
begin
weapon := critter_inven_obj(critter, 2);
call Not_Dropable(weapon);
if (droppable) then
begin
rm_obj_from_inven(critter, weapon);
move_to(weapon, tile_num_in_direction(tile_num(critter), random(0, 5), random(1, 2)), elevation(critter));
end
end
end
procedure Not_Dropable(variable weapon) begin
if(obj_pid(weapon) != 270) and (obj_pid(weapon) != 274) and (obj_pid(weapon) != 290) and (obj_pid(weapon) != 291) and (obj_pid(weapon) != 365)
and (obj_pid(weapon) != 371) and (obj_pid(weapon) != 372) and (obj_pid(weapon) != 427) and (obj_pid(weapon) != 372) and (obj_pid(weapon) != 489)
and (obj_pid(weapon) != 498) and (obj_pid(weapon) != 518) and (obj_pid(weapon) != 520) and (obj_pid(weapon) != 530) and (obj_pid(weapon) != 531)
and (obj_pid(weapon) != 644) and (obj_pid(weapon) != 645) and (obj_pid(weapon) != 654) and (obj_pid(weapon) != 675) then begin
droppable := 1;
end
else
begin
droppable := 0;
end
end
procedure Lootable_Armor(variable critter) begin
variable random_roll;
variable armor_piece;
variable random_armor_piece;
if(get_sfall_global_int("megamod5") == 0) then
begin
if (((obj_art_fid(critter) % 512) == 2) or ((obj_art_fid(critter) % 512) == 26) or ((obj_art_fid(critter) % 512) == 31)
or ((obj_art_fid(critter) % 512) == 56) or ((obj_art_fid(critter) % 512) == 84)) then begin
if (has_skill(dude_obj, 13) >= 30) or (has_trait(0, dude_obj, 44)) then
begin
add_obj_to_inven(critter, create_object_sid(113, 0, 0, -1));
end
end
else
if (((obj_art_fid(critter) % 512) == 6) or ((obj_art_fid(critter) % 512) == 13) or ((obj_art_fid(critter) % 512) == 34)
or ((obj_art_fid(critter) % 512) == 45) or ((obj_art_fid(critter) % 512) == 116) or ((obj_art_fid(critter) % 512) == 121)) then begin
if (has_skill(dude_obj, 13) >= 50) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll <75>= 60) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll <75>= 80) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll < 34) then
begin
add_obj_to_inven(critter, create_object_sid(2, 0, 0, -1));
end
else
if (random_roll <67>= 110) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll < 34) then
begin
add_obj_to_inven(critter, create_object_sid(17, 0, 0, -1));
end
else
if (random_roll <67>= 130) and (has_skill(dude_obj, 12) >= 110)) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll <75>= 140) and (has_skill(dude_obj, 12) >= 120)) or (has_trait(0, dude_obj, 44)) then
begin
random_roll := random(1, 100);
if (random_roll <75>= 160) and (has_skill(dude_obj, 12) >= 145)) or (has_trait(0, dude_obj, 44)) then
begin
add_obj_to_inven(critter, create_object_sid(554, 0, 0, -1));
end
end
end
else
if(get_sfall_global_int("megamod3") == 1) then
begin
if (((obj_art_fid(critter) % 512) == 31) or ((obj_art_fid(critter) % 512) == 2) or ((obj_art_fid(critter) % 512) == 84)
or ((obj_art_fid(critter) % 512) == 56) or ((obj_art_fid(critter) % 512) == 26)) then begin
if (has_skill(dude_obj, 13) >= 30) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 811) < obj_is_carrying_obj_pid(dude_obj, 809)) then
begin
armor_piece := 811;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 809) <obj_is_carrying_obj_pid>= 50) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 850) < obj_is_carrying_obj_pid(dude_obj, 812)) then
begin
armor_piece := 850;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 812) <obj_is_carrying_obj_pid>= 50) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 850) < obj_is_carrying_obj_pid(dude_obj, 812)) then
begin
armor_piece := 850;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 812) <obj_is_carrying_obj_pid>= 80) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 842) < obj_is_carrying_obj_pid(dude_obj, 841)) and
(obj_is_carrying_obj_pid(dude_obj, 842) < obj_is_carrying_obj_pid(dude_obj, 840)) then begin
armor_piece := 842;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 841) < obj_is_carrying_obj_pid(dude_obj, 842)) and
(obj_is_carrying_obj_pid(dude_obj, 841) < obj_is_carrying_obj_pid(dude_obj, 840)) then begin
armor_piece := 841;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 840) < obj_is_carrying_obj_pid(dude_obj, 842)) and
(obj_is_carrying_obj_pid(dude_obj, 840) <obj_is_carrying_obj_pid>= 110) and (has_skill(dude_obj, 12) >= 75)) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 843) < obj_is_carrying_obj_pid(dude_obj, 845)) and
(obj_is_carrying_obj_pid(dude_obj, 843) < obj_is_carrying_obj_pid(dude_obj, 844)) then begin
armor_piece := 843;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 845) < obj_is_carrying_obj_pid(dude_obj, 843)) and
(obj_is_carrying_obj_pid(dude_obj, 845) < obj_is_carrying_obj_pid(dude_obj, 844)) then begin
armor_piece := 845;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 844) < obj_is_carrying_obj_pid(dude_obj, 843)) and
(obj_is_carrying_obj_pid(dude_obj, 844) <obj_is_carrying_obj_pid>= 130) and (has_skill(dude_obj, 12) >= 110)) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 848) < obj_is_carrying_obj_pid(dude_obj, 847)) and
(obj_is_carrying_obj_pid(dude_obj, 848) < obj_is_carrying_obj_pid(dude_obj, 846)) then begin
armor_piece := 848;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 847) < obj_is_carrying_obj_pid(dude_obj, 848)) and
(obj_is_carrying_obj_pid(dude_obj, 847) < obj_is_carrying_obj_pid(dude_obj, 846)) then begin
armor_piece := 847;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 846) < obj_is_carrying_obj_pid(dude_obj, 848)) and
(obj_is_carrying_obj_pid(dude_obj, 846) <obj_is_carrying_obj_pid>= 130) and (has_skill(dude_obj, 12) >= 110)) or (has_trait(0, dude_obj, 44)) then
begin
armor_piece := 0;
if(random(1, 100) > (85 - luck))then
begin
if(obj_is_carrying_obj_pid(dude_obj, 848) < obj_is_carrying_obj_pid(dude_obj, 847)) and
(obj_is_carrying_obj_pid(dude_obj, 848) < obj_is_carrying_obj_pid(dude_obj, 846)) then begin
armor_piece := 848;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 847) < obj_is_carrying_obj_pid(dude_obj, 848)) and
(obj_is_carrying_obj_pid(dude_obj, 847) < obj_is_carrying_obj_pid(dude_obj, 846)) then begin
armor_piece := 847;
end
else
if(obj_is_carrying_obj_pid(dude_obj, 846) < obj_is_carrying_obj_pid(dude_obj, 848)) and
(obj_is_carrying_obj_pid(dude_obj, 846) <obj_is_carrying_obj_pid>= 160) and (has_skill(dude_obj, 12) >= 145)) or (has_trait(0, dude_obj, 44)) then
begin
add_obj_to_inven(critter, create_object_sid(554, 0, 0, -1));
end
end
end
end
procedure Gecko_Items(variable critter) begin
variable temp_box;
variable item;
variable decide;
if((obj_art_fid(critter) % 512) == 67) or ((obj_art_fid(critter) % 512) == 68) or ((obj_art_fid(critter) % 512) == 81)then
begin
temp_box := create_object_sid(128, 0, 0, -1);
move_obj_inven_to_obj(critter, temp_box);
destroy_object(temp_box);
decide := random(1, 2);
if (has_trait(0, dude_obj, 73)) then
begin
if ((obj_art_fid(critter) % 512) == 67) then
begin
item := create_object_sid(276, 0, 0, -1);
end
else
if ((obj_art_fid(critter) % 512) == 68) then
begin
item := create_object_sid(277, 0, 0, -1);
if(global_var(686) == 1)then
begin
add_obj_to_inven(critter, create_object_sid(640, 0, 0, -1));
end
end
else
if ((obj_art_fid(critter) % 512) == 81) then
begin
item := create_object_sid(552, 0, 0, -1);
end
add_obj_to_inven(critter, item);
end
if(get_sfall_global_int("gecko_01") == 1) then
begin
if (has_trait(0, dude_obj, 40)) then
begin
if(random(1, 100) > (85 - luck))then
begin
if(decide == 1)then
begin
item := create_object_sid(803, 0, 0, -1);
end
else
if(decide == 2)then
begin
item := create_object_sid(804, 0, 0, -1);
end
end
else
begin
item := create_object_sid(800, 0, 0, -1);
end
end
add_obj_to_inven(critter, item);
end
end
end
procedure Delete_Worn_Armor(variable critter) begin
variable delete_item;
if (obj_pid(critter_inven_obj(critter, 0)) > 0) then
begin
delete_item := critter_inven_obj(critter, 0);
rm_obj_from_inven(critter, delete_item);
if(tile_contains_obj_pid(1, 0, obj_pid(delete_item))) then
begin
delete_item := tile_contains_pid_obj(1, 0, obj_pid(delete_item));
destroy_object(delete_item);
end
end
end