Fallout 2 mod FO2 Engine Tweaks (Sfall)

Timeslip said:
Josan12 said:
1) Did you see my previous post asking if you think it would be possible to use sfall to make human critters drop their weapons when killed or KO'd??
Script it.

Actually, he wants to know if you could devise a shortcut. I've already provided the scripting. Unfortunately, in order for it to work that way, it means redoing a lot of scripts individually.
 
Nirran said:
what scripting function tells sfall when a party member leveled?
huh? Not sure what you're asking for. sfall doesn't call scripting functions...

Actually sfall doesn't care when party members level up at all. There's nothing in there that tracks it.
 
damn,thnx anyway

edit : ive been trying to make additional perks for specific party members,when they level they lose the added stats,need a way to determine if they have leveled,then i can re-apply the perks,to fully answer your question
 
1.47 is up.
>New script functions set_proto_data, set_self, register_hook
>Further file system script functions
>Hook script changes to aid in mod compatibility; multiple scripts can now attach to one hook point
The extra file system functions are for reading existing files, when used with fs_copy.

MIB88 said:
Actually, he wants to know if you could devise a shortcut. I've already provided the scripting. Unfortunately, in order for it to work that way, it means redoing a lot of scripts individually.
I'd have thought you could just rig up a global script to do it, rather then having to edit the script of every critter. Using 1.47 functions, it's only a few lines.

Code:
#include "..\headers\sfall.h"

procedure start;

procedure start begin
	variable critter;
	variable weapon;

	if (game_loaded) then begin
		register_hook(HOOK_ONDEATH);
	end else begin
		critter:=get_sfall_arg;
		weapon:=critter_inven_obj(critter, 1);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
		weapon:=critter_inven_obj(critter, 2);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
	end
end

You'd probably want to check against a list of allowed pid's to make sure that what's being dropped is a legal player usable weapon or something, but that's the basics of it.
 
Timeslip said:
Code:
#include "..\headers\sfall.h"

procedure start;

procedure start begin
	variable critter;
	variable weapon;

	if (game_loaded) then begin
		register_hook(HOOK_ONDEATH);
	end else begin
		critter:=get_sfall_arg;
		weapon:=critter_inven_obj(critter, 1);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
		weapon:=critter_inven_obj(critter, 2);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
	end
end

Thanks Timeslip. But where would i put this code?
 
Josan12 said:
Timeslip said:
Code:
#include "..\headers\sfall.h"

procedure start;

procedure start begin
	variable critter;
	variable weapon;

	if (game_loaded) then begin
		register_hook(HOOK_ONDEATH);
	end else begin
		critter:=get_sfall_arg;
		weapon:=critter_inven_obj(critter, 1);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
		weapon:=critter_inven_obj(critter, 2);
		if(weapon) then begin
			set_self(critter);
			drop_obj(weapon);
		end
	end
end

Thanks Timeslip. But where would i put this code?

in a script labled GL_whatever

Timeslip : would it be possible to hook into critter_p_proc?
 
Harahvaiti said:
i have a question mate; could be the "push" npc function (like in fo2) introduced with sfall?
Given that sfall is a fallout 2 mod, that would seem rather silly. :P

Nirran said:
Josan12 said:
Thanks Timeslip. But where would i put this code?
in a script labled GL_whatever
But only after you understand what that script is doing, my comment about pid's, and why it would be a very bad idea to use that script as it is.

Nirran said:
Timeslip : would it be possible to hook into critter_p_proc?
What for? I can't think of anything that you might want to do with that that you wouldn't be better off doing some other way, so if you tell me what you want to do I might be able to suggest something.

I would guess your difficulty mod. Is there any existing way to loop over all critters on a map, short of checking the tiles one by one?
 
i am making a mod that modified critter stats based on player level,and was hoping i wouldnt have to edit the 850 critter scripts in MegaMod to do it

not that im aware of
 
i may be able to do the mod i want with hs_calcapcost.int,with this code,it is altering the max hit points(as far as i know the other alteration are happening,i havent checked) ,however only the first critter is being healed

Code:
#include "C:\Game Files\Fallout 2\HEADERS\Perk_Inc.h"

procedure start;

procedure start begin
variable critter;
   if(init_hook) then begin
   end else begin
      critter:=get_sfall_arg;
      if((obj_pid(critter) != obj_pid(dude_obj)) and (obj_pid(critter) != 16777376) and (obj_pid(critter) != 16777377) and (obj_pid(critter) != 16777305)
      and (obj_pid(critter) != 16777313) and (obj_pid(critter) != 16777323) and (obj_pid(critter) != 16777352) and (obj_pid(critter) != 16777217)
      and (obj_pid(critter) != 16777368) and (obj_pid(critter) != 16777379) and (obj_pid(critter) != 16777380) and (obj_pid(critter) != 16777381)
      and (obj_pid(critter) != 16777295) and (obj_pid(critter) != 16777278) and (obj_pid(critter) != 16777407) and (obj_pid(critter) != 16777411)
      and (obj_pid(critter) != 16777412) and (obj_pid(critter) != 16777413) and (obj_pid(critter) != 16777481) and (obj_pid(critter) != 16777558)
      and (obj_pid(critter) != 16777597) and (obj_pid(critter) != 16777596) and (obj_pid(critter) != 16777595) and (obj_pid(critter) != 16777600)
      and (obj_pid(critter) != 16777687) and (obj_pid(critter) != 16777342) and (obj_pid(critter) != 16777348) and (obj_pid(critter) != 16777346)
      and (obj_pid(critter) != 16777718) and (obj_pid(critter) != 16777720) and (obj_pid(critter) != 16777719) and (obj_pid(critter) != 16777717)
      and (obj_pid(critter) != 16777785) and (obj_pid(critter) != 16777749) and (obj_pid(critter) != 16777748) and (obj_pid(critter) != 16777747)
      and (obj_pid(critter) != 16777766) and (obj_pid(critter) != 16777762) and (obj_pid(critter) != 16777799)) then begin
         if (has_trait(TRAIT_PERK, critter, PERK_animal_friend) == 0) then begin
            critter_add_trait(critter, TRAIT_PERK, PERK_animal_friend, 1);
	    set_critter_extra_stat(critter, STAT_max_hit_points, get_critter_extra_stat(critter, STAT_max_hit_points) + (dude_level * get_sfall_global_int("health_1")));
	    critter_mod_skill(critter, SKILL_SMALL_GUNS, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    critter_mod_skill(critter, SKILL_BIG_GUNS, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    critter_mod_skill(critter, SKILL_ENERGY_WEAPONS, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    critter_mod_skill(critter, SKILL_UNARMED_COMBAT, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    critter_mod_skill(critter, SKILL_MELEE, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    critter_mod_skill(critter, SKILL_THROWING, dude_level / get_sfall_global_int("skills_1") * get_sfall_global_int("skills_2"));
	    set_critter_extra_stat(critter, STAT_max_move_points, get_critter_extra_stat(critter, STAT_max_move_points) + (dude_level / get_sfall_global_int("action_1") * get_sfall_global_int("action_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist, get_critter_extra_stat(critter, STAT_dmg_resist) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist_laser, get_critter_extra_stat(critter, STAT_dmg_resist_laser) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist_fire, get_critter_extra_stat(critter, STAT_dmg_resist_fire) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist_plasma, get_critter_extra_stat(critter, STAT_dmg_resist_plasma) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist_electrical, get_critter_extra_stat(critter, STAT_dmg_resist_electrical) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_resist_explosion, get_critter_extra_stat(critter, STAT_dmg_resist_explosion) + (dude_level / get_sfall_global_int("resist_1") * get_sfall_global_int("resist_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh, get_critter_extra_stat(critter, STAT_dmg_thresh) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh_laser, get_critter_extra_stat(critter, STAT_dmg_thresh_laser) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh_fire, get_critter_extra_stat(critter, STAT_dmg_thresh_fire) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh_plasma, get_critter_extra_stat(critter, STAT_dmg_thresh_plasma) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh_electrical, get_critter_extra_stat(critter, STAT_dmg_thresh_electrical) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_dmg_thresh_explosion, get_critter_extra_stat(critter, STAT_dmg_thresh_explosion) + (dude_level / get_sfall_global_int("thresh_1") * get_sfall_global_int("thresh_2")));
	    set_critter_extra_stat(critter, STAT_ac, get_critter_extra_stat(critter, STAT_ac) + (dude_level / get_sfall_global_int("armor_01") * get_sfall_global_int("armor_02")));
	    critter_heal(critter, 999);
	    while(has_trait(TRAIT_PERK, critter, PERK_bonus_ranged_damage) < (dude_level / get_sfall_global_int("ranged_1") * get_sfall_global_int("ranged_2"))) do begin
	       critter_add_trait(critter, TRAIT_PERK, PERK_bonus_ranged_damage, 1);
	    end
         end
      end
   end
end

Nirran
 
i gotta say thats fucking awesome,the compiler and decompiler from your site both run in vista 64,been using a virtual of win xp for those now i can do them in my reg enviornment,koodo's

Nirran
 
Nirran said:
i may be able to do the mod i want with hs_calcapcost.int,with this code,it is altering the max hit points(as far as i know the other alteration are happening,i havent checked) ,however only the first critter is being healed

Code:
<snip>
I'm not sure if the get ap cost hook is a good place to run it, when it gets fired would be a bit unpredictable outside of combat.

I was thinking about adding first_critter and next_critter functions as an easy way to loop over all the critters on a map. I thought you could do it it by looping over each tile; I thought there was an existing function that would return the critter standing on a tile, but looking at the mapper docs I seem to be misremembering. The only functions there require you to know the pid beforehand...

Alternatively, if you want to make changes to specific pids, you could fs_copy and then modify the relevant proto files.

Nirran said:
i gotta say thats fucking awesome,the compiler and decompiler from your site both run in vista 64,been using a virtual of win xp for those now i can do them in my reg enviornment,koodo's
Yeah, they're 32 bit. The original compiler was 16 bit, so wouldn't run in a 64 bit OS. :)

Harahvaiti said:
there is a fallout 1 version too, as far as i know...:P
Not really. The fallout 1 version is built from exactly the same code as that fallout 2 version, except with everything that depends on a specific version of the fallout exe stripped out, which leaves very little besides the graphics options and the mouse wheel/middle mouse button. It works equally well for fallout 1, 2 or probably any other game that uses the same directx version and creates the interface in the same way.

Which is actually a good point... I should update it to include the new gpublt option.
 
Timeslip said:
I was thinking about adding first_critter and next_critter functions

that would be awesome,many times i wished this language had a way to loop objects

Nirran
 
this code works,i will have to code each critter pid though

Code:
#include "..\..\HEADERS\sfall.h"

#include "..\..\HEADERS\Perk_Inc.h"

#include "..\..\HEADERS\Scale_Diff.h"

procedure start;

procedure start begin
   variable cycle_tile := 1;
   variable critter_to_modify;
   set_global_script_repeat(1);
   if (game_loaded) then begin
      set_perk_name(4, "Bonus Ranged Damage");
      set_perk_desc(4, "Your training in firearms and other ranged weapons has made you more deadly in ranged combat.  For each level of this Perk, you do +2 points of damage with ranged weapons.");
      set_perk_ranks(4, 100);
      set_perk_level(4, 100);
   end else begin
      if(cur_map_index != get_sfall_global_int("map_indx")) then begin
         set_sfall_global("map_indx", cur_map_index);
         while(cycle_tile < 40000) do begin
            if(tile_contains_obj_pid(cycle_tile, 0, 16777598)) then begin
               critter_to_modify := tile_contains_pid_obj(cycle_tile, 0, 16777598);
               modify_critter(critter_to_modify);;
            end
            if(tile_contains_obj_pid(cycle_tile, 1, 16777598)) then begin
               critter_to_modify := tile_contains_pid_obj(cycle_tile, 1, 16777598);
               modify_critter(critter_to_modify);;
            end
            if(tile_contains_obj_pid(cycle_tile, 2, 16777598)) then begin
               critter_to_modify := tile_contains_pid_obj(cycle_tile, 2, 16777598);
               modify_critter(critter_to_modify);;
            end
            cycle_tile := cycle_tile + 1;
         end
      end else begin
         cycle_tile := 1;
      end
   end
end

edit : works fine but if i add checks for all critter pid's it hangs for about a min on map loads,i could check map index and only put pid of the critters on it,was hoping for a universal script that would work for any mod
 
1.47b is up. There's some bug fixes for hook scripts when using register_hook, and new functions to allow looping over objects. (Just critters or ground items atm.)

An important point when using global and hook scripts that me and killap have only just noticed is that they don't work unless the start procedure is the first one in the script. Since define.h declares some procedures, that means that including it before the 'procedure start;' line will break the scripts. Just remember to move the procedure declaration above the #include if you need to include any of the default fallout headers, and everything is fine. I may try and build that special case into sslc at some point, but for now I've just added a note to the documentation.

Nirran said:
edit : works fine but if i add checks for all critter pid's it hangs for about a min on map loads,i could check map index and only put pid of the critters on it,was hoping for a universal script that would work for any mod
Yeah, that was what I meant about the existing functions needing you to know the pid beforehand. You can use the new list functions instead though, and they'll be a heck of a lot faster.

As an example, here's the testcase script I've been using. It simply kills everything on the map when you hit left ctrl.
Code:
procedure start;

variable down;

#include "..\headers\sfall.h"

procedure start begin
	variable list;
	variable critter;

	if (game_loaded) then begin
		set_global_script_repeat(1);
		set_global_script_type(1);
		down:=0.0;
	end

	if(key_pressed(29)) then begin
		if(not down) then begin
			down:=1;

			list:=list_begin(LIST_CRITTERS);
			while(list != 0) do begin
				critter:=list_next(list);
				if (critter) then begin
					if(critter!=dude_obj) then begin
						critter_damage(critter, 999);
					end
				end else begin
					list_end(list);
					list:=0;
				end
			end
		end
	end else begin
		down:=0;
	end
end
 
that is freaking awesome Timeslip,now my difficulty mod is universal for any mod :D *happy* Thank You


Nirran
 
checks to not apply to dude_obj arent stopping my code from giving player a perk,though none of the other bonuses are being applied to dude_obj

this is the check for it to not be dude_obj

(critter != dude_obj) and (obj_pid(critter) != obj_pid(dude_obj))

Nirran


edit : deleted code i added
 
Alright, Timeslip, here's a request for you:

You've added several hook scripts already, the one I'm finding most useful is the ondeath one. (It works great for causing enemies to drop their weapons when they are killed... thanks.) I don't really know how all these work, but, am I to understand that a hook script could be made for any procedure inside a critter's script? If so, is it possible to add one for the critter and use_object_on procedures?
 
Back
Top