Fallout 2 mod Place items/scenery on the ground on successful attack?

QuantumApprentice

Where'd That 6th Toe Come From?
Me again, with another odd scripting question.
I've been looking through a lot of the original Fallout scripts and haven't found an answer yet,
is it possible to place an item on the ground when attacking?

A specific example I can think of is the flare...when thrown it will hit the critter and drop to the ground, spears and rocks do the same thing.
I'd like to duplicate this effect, but with other scenery/items, and for some reason I can't find anything that directly describes how the flare does this.

Any help please?

edit:
Actually, to be more specific, what I want to do is create a grenade that explodes and spawns poop around it (I found the poop generating script for the cow and wanted to do something fun with it :P)
 
Last edited:
Flares aren't scripted, it's in-engine.

Without having tried it, I guess you would have to use one of the combat / attack hooks and then spawn a new item / scenery wherever you want it.
 
does it need to hit the critter?
Perhaps try to add your weapon PID the new atack-on-any-hex weapon PIDs in sfall-mods.ini
as to what I'm aware it is present in Fo:EtTu uses external global script for that, Haven't seen the function in Crafty's sfall2 or Mr.Stalin's sfall-extended, it is only in Phobos/NovaRain build, but only comes bundled with certain games, as I haven't seen the script in standard release nor in moder's pack. You'd probably have to download Et Tu and *borrow* the script, and the sfall-mods.ini, on top of that there'd need to be a script attached to spawn stuff on destroy_p_proc i guess
 
Flares aren't scripted, it's in-engine.

Without having tried it, I guess you would have to use one of the combat / attack hooks and then spawn a new item / scenery wherever you want it.

hmm...ok I was afraid of that.
Well, here's my first attempt, it loads and the debug message displays, but it doesn't seem to create the poop yet:
Code:
procedure start begin
    if game_loaded then begin
    display_msg("Debug: Poop_bomb script loaded...");
    register_hook_proc(HOOK_AFTERHITROLL, poop_bomb);
    end
end

procedure poop_bomb begin
    variable
        hit      := get_sfall_arg,
        attacker := get_sfall_arg,
        target   := get_sfall_arg;
    variable temp_poo;
    // if(fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
    if (hit >= 2) then begin
        temp_poo := create_object_sid(random(PID_SMALL_GOO_1, PID_SMALL_GOO_3), 0, 0, SCRIPT_ZIBRAPOO);
        move_to(temp_poo, tile_num_in_direction(tile_num(target), self_inv_rot, 1), 0);
    end
end
I figure there must be a step missing, any clues?

does it need to hit the critter?
Perhaps try to add your weapon PID the new atack-on-any-hex weapon PIDs in sfall-mods.ini
as to what I'm aware it is present in Fo:EtTu uses external global script for that, Haven't seen the function in Crafty's sfall2 or Mr.Stalin's sfall-extended, it is only in Phobos/NovaRain build, but only comes bundled with certain games, as I haven't seen the script in standard release nor in moder's pack. You'd probably have to download Et Tu and *borrow* the script, and the sfall-mods.ini, on top of that there'd need to be a script attached to spawn stuff on destroy_p_proc i guess
Well, I think Lexx is the person in charge of Et Tu? So if he's willing to share I'll try to figure it out :)

EDIT: Also, as an interesting side note, the spear/flare/rock items must have something in their proto files that tells the engine to drop the item at the target's feet when thrown. Have you (or anybody) seen anything describing how the proto files are implemented?
 
Last edited:
I think just spawn the poop withouth ZIBRAPOO it's a script that generates poops from brahmins, I think it isn't as consistent as: spawn poo, call brahminpoop script, as that script probably has delays as how often bramins do poop, better to force create brahmin poop by calling to create scenery object, just like any other action that creates stuff, I'm no expert, but it seemes more logical this way.
 
ZIBRAPOO is just a script attached to the poop itself.
It destroys the poop on map_enter and when a shovel is used on it, but that's it.
Its possible create_object_sid() has some compatibility issues with the sfall hook though, any thoughts?
 
ok, crazy thing happened last weekend, I was trying out a different script with this one running in the background and it totally started working. Don't know why it won't work on my sand-box map though.
 
Ok, so the script seems to work more or less consistently, on successful hit the engine will spawn one of the random goo types on the ground (though it doesn't work sometimes, and only seems to work on first hit, not subsequent attacks).

HOOK_AFTERHITROLL doesn't give you the weapon used though, so I added another hook in to try and get that information:
HOOK_COMBATDAMAGE and HOOK_ITEMDAMAGE both return this information.

Testing out the "weapon used" sfall arg in both seems to return a semi-random number that doesn't seem to match any item_pid's or anything else I'm aware of.
Here's the script I have so far:

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

procedure start;
procedure poop_bomb;
procedure poop_explosion;
procedure poop_combat;
procedure poop_itemdamage;

procedure start begin
    if game_loaded then begin
    display_msg("Debug: Poop_bomb script loaded...");
    register_hook_proc(HOOK_AFTERHITROLL, poop_bomb);
    register_hook_proc(HOOK_COMBATDAMAGE, poop_combat);
    register_hook_proc(HOOK_ITEMDAMAGE, poop_itemdamage);
    register_hook_proc(HOOK_ONEXPLOSION, poop_explosion);

    end
end

procedure poop_bomb begin
    variable
        hit      := get_sfall_arg,
        attacker := get_sfall_arg,
        target   := get_sfall_arg;
    variable temp_poo;
    // if(fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
    if (hit >= 2) then begin
        temp_poo := create_object_sid(random(PID_SMALL_GOO_1, PID_SMALL_GOO_3), 0, 0, SCRIPT_ZIBRAPOO);
        move_to(temp_poo, tile_num_in_direction(tile_num(target), self_inv_rot, 1), 0);
    end
end

procedure poop_combat begin
variable
     target       := get_sfall_arg,
     attacker     := get_sfall_arg,
     target_dmg   := get_sfall_arg,
     attacker_dmg := get_sfall_arg,
     target_flg   := get_sfall_arg,
     attacker_flg := get_sfall_arg,
     weapon_used  := get_sfall_arg;

     float_msg(dude_obj, "Weapon Used: " + weapon_used, FLOAT_COLOR_WHISPER);

     return weapon_used;
end

procedure poop_itemdamage begin
variable
    min_dmg     := get_sfall_arg,
    max_dmg     := get_sfall_arg,
    weapon_used := get_sfall_arg;

    display_msg("Weapon Used: " + weapon_used);
//    float_msg(dude_obj, "Weapon Used: " + weapon_used, FLOAT_COLOR_WHISPER);


end


procedure poop_explosion begin

end

Part of the problem may be my unfamiliarity with how sfall interprets the return values, but the value being returned is definitely not consistent for the same item, even in the same combat turn.
Am I using these hooks incorrectly?
 
Code:
#include "..\headers\define.h"
#include "..\headers\command.h"
#include "..\headers\sfall.h"

procedure start;
procedure poop_explosion;
procedure poop_combatdamage;

procedure start begin
    if game_loaded then begin
    display_msg("Debug: Poop_bomb script loaded...");
    register_hook_proc(HOOK_COMBATDAMAGE, poop_combatdamage);
    register_hook_proc(HOOK_ONEXPLOSION, poop_explosion);

    end
end

procedure poop_combatdamage begin
variable
    target       := get_sfall_arg_at(0),
     weapon_used = obj_pid(get_sfall_arg_at(6)),
     hit := get_sfall_arg_at(9);

   if(weapon_used == PID_FLARE) then begin
            if (hit == 1) then begin
                variable temp_poo;

                temp_poo := create_object_sid(random(PID_SMALL_GOO_1, PID_SMALL_GOO_3), 0, 0, SCRIPT_ZIBRAPOO);
                move_to(temp_poo, tile_num_in_direction(tile_num(target), self_inv_rot, 1), 0);
            end
   end

     float_msg(dude_obj, "Hit? " + hit, FLOAT_COLOR_WHISPER);
     return weapon_used;
end

procedure poop_explosion begin
end
Ok, got some new discoveries today:
First, HOOK_COMBATDAMAGE and HOOK_ITEMDAMAGE both have weapon_used returns that are actually pointers to the object, not the item pid or anything directly useful. So once I had mrowr_purr explain how to get the PID from the pointer using obj_pid() I finally got this script to work...basically.
Also, cleaned up the code, figured out how to get just one of the sfall_args instead of each on in turn using get_sfall_arg_at().
And it looks like "Arg 9", which returns the number of bullets that hit the target, can be used in place of hit/miss calculation for grenades...and probably melee.

Will continue to work on this next weekend. Have a good one everybody!
 
Ahh.. FFS.. do i have to arrange everything for everybody...

@NovaRain @phobos2077

Could You please assist @QuantumApprentice here in the thread with his problem in scripting?

the thing is, Quantum is making a video series on this, and often shows our forum in his videos, the fact that nobody helped him, literally does makes us look bad to the outside world. Don't we have enaugh bad press from bethesda fanboys from reddit and similar sites? and the fact nothing is going on in this matter here literally feels like reddit fanboys were right. NMA is in no position to allow that we do this to ourselves. So Please..
 
aw thanks for the support! its fine though.
I often get people dropping by the stream helping me out with the scripting, so this hasn't been nearly as difficult as the lack of responses would suggest.

For instance, here's my latest version of this script:
Code:
#include "..\headers\define.h"
#include "..\headers\command.h"
#include "..\headers\sfall.h"

procedure start;
procedure poop_combatdamage;

procedure start begin
    if game_loaded then begin
    display_msg("Debug: Poop_bomb script loaded...");
    register_hook_proc(HOOK_COMBATDAMAGE, poop_combatdamage);
    end
end

procedure poop_combatdamage begin
variable
     target       := get_sfall_arg_at(0),
     weapon_used := obj_pid(get_sfall_arg_at(6)),
     hit         := get_sfall_arg_at(9);

   if(weapon_used == PID_POOP_BOMB) then begin
            if (hit == 1) then begin
                variable temp_poo, i;
                for (i := 0; i<3; i++) begin

                temp_poo := create_object_sid(random(PID_SMALL_GOO_1, PID_SMALL_GOO_3), 0, elevation(dude_obj), SCRIPT_ZIBRAPOO);
                move_to(temp_poo, tile_num_in_direction(tile_num(target), random(0,5), random(0,2)), 0);
                end
            end
   end

     float_msg(dude_obj, "Insert random poop msg here." + hit, FLOAT_COLOR_WHISPER);
     return weapon_used;
end
If anybody who sees this wants to test this script out, just replace PID_POOP_BOMB with your own pick (I suggest PID_FLARE for ease of use).

The next thing I want to figure out is if it's necessary to have the items in the inventory.lst/item.lst files or if the sfall hooks allow for arbitrary art insertions. Right now I'm just checking for the PID_POOP_BOMB which I created and running the script from there.
Also, for some reason "hit := get_sfall_arg_at(9);" always seems to be calculated at the moment of attack, not when the actual animation runs.
So how would I delay the placement until after the animation/explosion occurs?
Also, similar to the art question, can I get it to play custom sound effects without them having to be in the SNDLIST.LST file?
 
Last edited:
I actually have no idea but you could try using:

;Set to 1 to automatically search for alternative formats (mp3/wma/wav) when Fallout tries to play an ACM
;Alternative music files will play even if original ACM files are not present in the music folder
;This does not effect the play_sfall_sound and stop_sfall_sound script functions
AllowDShowSound=1

in your ddraw.ini

a lot less fuss when no acm converter is needed

EDIT: sillly me just copypasted those lines from ddraw.ini and forgot to set it so it would be right 4 U..

as for the poops being spawned at the attack animation and not after explosion itself.. Well my uneducated opinion is, it's because you would have to to make new damage type called for example "poop explosion", and add explosion animation + poop spawn in one script probably the poop sound would have to be attached there too, since in your vid i saw the poop sound effect beeing played when you throw, and not when the poop grenade explodes am I right?

Thing is, if you attach the poop script to a weapon it's triggered just after it's use, in case of throwin weapons you have a delay before it reaches the target, and since it's explosive weapon it's another delay, so it's best to attach to new damage type, but that's hardcoded, so You'd need to modify the explosion animation script so that it triggers a poop spawn if it's a certain pid number ( so that rockets , frag, and plasma grenades wouldn't throw shit everywhere) and that the poop spawn triggered after a small delay ( trial and error for this one i guess)

it's better to set the delay after the explosion itself because:
1. the amount of time before the poop projectile reaches target varies depending on distance of the enemy..
2. the explosion itself has a constant amount of time so it's easier to set a proper delay to trigger the poop spawn after the explosion animation in the correct timeframe. rather than after the throwarm animation.

TL:DR
I'd assume you need to set a hook script to whenever explosion animation is triggered, and check for the weapon's pid that was used, if it was poop grenade. that way ony the last poop grenade won't trigger the shit outburst, and set the delay for the poop to be not at the beggining of the explosion but few ticks after it ( remember 10 ticks per second in fo2 engine rignt..). and it should be it. if i were you i'd also set the sound effect to match poop spawn not after initiating throw animation (although it is funny).
 
Last edited:
Back
Top