Weapon reducing AC - possible?

Code:
obj_pid(0)
causes a script to crash - that means currently executed procedure will be interrupted and error message is written to debug log.
 
Code:
obj_pid(0)
causes a script to crash - that means currently executed procedure will be interrupted and error message is written to debug log.
Huh. Then I was right in my assumption all along. But why did he get a -1 then?
 
Huh. Then I was right in my assumption all along. But why did he get a -1 then?

Looked the function, it actually doesn't crash the script if argument is 0. Only writes to debug log and returns -1. However it should crash (script, not the game) if you pass non-integer argument.
 
You could also increase their maximum range. I believe it is 15 hexes, which is really quite short and one of the reasons why they are so hard to aim with. Giving them a max range of 30 will let you reap the benefits of increasing your Strength.
 
@Magnus I think this it's done already in both f2wr and ecco? I agree that limiting the range is strange, though.
I wish there was a possibility to toss a grenade to a specific hex (not necessarily with a crittter present), because sometimes it's what the situation requires. But this is probably not going to happen.
 
Last edited by a moderator:
@Magnus I think this it's done already in both f2wr and ecco? I agree that limiting the range is strange, though.
I wish there was a possibility to toss a grenade to a specific hex (not necessarily with a crittter present), because sometimes it's what the situation requires. But this is probably not going to happen.
@JimTheDinosaur has managed to bend the engine in mysterious ways before, you should ask him.
 
Last edited by a moderator:
@Magnus I think this it's done already in both f2wr and ecco? I agree that limiting the range is strange, though.
I wish there was a possibility to toss a grenade to a specific hex (not necessarily with a crittter present), because sometimes it's what the situation requires. But this is probably not going to happen.

I actually have this feature in work for some time. I was fairly confident that it is possible to implement without engine hacking. (basically you create a "door" object that follows cursor)
 
Here's what I come up with in the end. Any criticism?
Code:
// hs_tohit.ssl

procedure start;
#include ".\headers\DEFINE.H"
#include ".\_sfall37_headers\sfall.h"
#include ".\!pbs_rebalance_sources\_pbs_main\mod.h"

#define usewpn(PID)(obj_pid(critter_inven_obj(attacker, INVEN_TYPE_RIGHT_HAND)) == PID)
#define useammo(PID)(get_weapon_ammo_pid(critter_inven_obj(attacker, INVEN_TYPE_RIGHT_HAND)) == PID)
#define usewpn_dude(PID) (active_hand==0 and (obj_pid(critter_inven_obj(attacker, INVEN_TYPE_LEFT_HAND)) == PID)) or (active_hand==1 and (obj_pid(critter_inven_obj(attacker, INVEN_TYPE_RIGHT_HAND)) == PID))
#define useammo_dude(PID) (active_hand==0 and (get_weapon_ammo_pid(critter_inven_obj(attacker, INVEN_TYPE_LEFT_HAND)) == PID)) or (active_hand==1 and (get_weapon_ammo_pid(critter_inven_obj(attacker, INVEN_TYPE_RIGHT_HAND)) == PID))

procedure start begin
    variable tohit;
    variable attacker;
    variable target;
    if not init_hook then begin
        tohit := get_sfall_arg;
        attacker := get_sfall_arg;
        target := get_sfall_arg;

        if (obj_pid(attacker)==obj_pid(dude_obj)) then begin
          if (usewpn_dude(PID_MOLOTOV_COCKTAIL) or usewpn_dude(PID_FRAG_GRENADE) or usewpn_dude(PID_PULSE_GRENADE) or usewpn_dude(PID_PLASMA_GRENADE) or usewpn_dude(PID_PBS_HOMEMADE_GRENADE) or usewpn_dude(PID_PBS_M79) or usewpn_dude(PID_PBS_MGL) or (usewpn_dude(PID_ROCKET_LAUNCHER) and useammo_dude(PID_EXPLOSIVE_ROCKET))) then begin
            tohit := tohit + get_critter_stat(target, STAT_ac);
          end
        end else if (usewpn(PID_MOLOTOV_COCKTAIL) or usewpn(PID_FRAG_GRENADE) or usewpn(PID_PULSE_GRENADE) or usewpn(PID_PLASMA_GRENADE) or usewpn(PID_PBS_HOMEMADE_GRENADE) or usewpn(PID_PBS_M79) or usewpn(PID_PBS_MGL) or (usewpn(PID_ROCKET_LAUNCHER) and useammo(PID_EXPLOSIVE_ROCKET))) then begin
          tohit := tohit + get_critter_stat(target, STAT_ac);
        end

        if (tohit > 95) then begin
            set_sfall_return(95);
        end else begin
            set_sfall_return(tohit);
        end
    end
end
 
Back
Top