combat_p_proc doesn't work for OBJ_DUDE?

dude_obj

Vault Senior Citizen
Moderator
I've been playing around with combat_p_proc and testing for combat hits like this:

procedure combat_p_proc begin
if (fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
display_msg(mstr(100));
end
end

If I do that on a critter script, it works, I get a message for each hit. But if I try to do this in OBJ_DUDE script, it doesn't work :( I was hoping to be able to trigger script action when the player hits in combat. That way I could do things like this:

Check if wielding spasm neurodisrupter, if so modify agility and perception on target
Check if wielding poison spear, if so apply poison on target
etc

Does anyone know why this wouldn't work on OBJ_DUDE but works on every other critter?
Any ideas on how to apply extra/special damage via script for combat hits? (so special weapons can be made?)
 
Make a subroutine that can be inserted into every critter's damage_p_proc, checking for weapon used and/or critter (in)vulnerability?
 
Correction... I am now succeeding in triggering script action when the player hits a critter, example:

procedure combat_p_proc begin
if (fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
display_msg(mstr(100));
critter_injure(target_obj,DAM_CRIP_ARM_LEFT);
end
end

Not sure what was wrong before, but this is good news. I can now do special types of damage on hit including specific damage amounts, poison, radiation. I can even do specific damage like crippling left arm, blinding, etc.

#define DAM_KNOCKED_OUT (1)
#define DAM_KNOCKED_DOWN (2)
#define DAM_CRIP_LEG_LEFT (4)
#define DAM_CRIP_LEG_RIGHT (8) // this is an 8, shows up as smilie LOL
#define DAM_CRIP_ARM_LEFT (16)
#define DAM_CRIP_ARM_RIGHT (32)
#define DAM_BLIND (64)
#define DAM_DEAD (128)
#define DAM_HIT (256)
#define DAM_CRITICAL (512) // could be a critical hit or critical miss
#define DAM_ON_FIRE (1024)
#define DAM_BYPASS (2048)
#define DAM_EXPLODE (4096)
#define DAM_DESTROY (8192)
#define DAM_DROP (16384)
#define DAM_LOSE_TURN (32768)
#define DAM_HIT_SELF (65536)
#define DAM_LOSE_AMMO (131072)
#define DAM_DUD (262144)
#define DAM_HURT_SELF (524288)
#define DAM_RANDOM_HIT (1048576)
#define DAM_CRIP_RANDOM (2097152)
#define DAM_BACKWASH (4194304)

Those can be used in critter_injure(target_obj,DAM_CRIP_LEG_RIGHT). It seems that a lot of these don't do what is listed (grrr) so I will have to test them all, but the crippling works. Right now I have it set up so every time I punch someone they are crippled.

And here's a wild one, I could do healing too. Healing gun anyone? Remember those times when vic was about to die but you couldn't reach him with a stimpak? :) A dart gun that shoots stimpaks? LOL

There's lots of interesting possibilities here using combat_p_proc in obj_dude script to make special weapons.

But that's only the first part of the puzzle. The second part is how to be sure of what weapon is being used. There is a critter_inven_obj command that can accept parameters INVEN_TYPE_WORN, INVEN_TYPE_LEFT_HAND and INVEN_TYPE_RIGHT_HAND. So I can check if the fancy is weapon is in one of the hands. But what if the player has a brass knuckle in one hand and my special weapon in the other. Then even if he uses brass knuckles it would appear like he is using the special weapon. grrr.

I'm not aware of a parameter that specifies what weapon hit a target, that's really what I need. Anyone know? Is there a script command that returns the "active" weapon or which weapon slot is currently selected?
 
Don't party members turn hostile when you hit them too often (damaging or not)?
 
Ashmo said:
Don't party members turn hostile when you hit them too often (damaging or not)?

Party members? I'm trying to make special weapons to use on enemies. The HIT_SUCCEEDED is self hitting someone else.

EDIT: I guess you are talking about the healing gun idea, sorry. A gun can be made that does no damage, but instead does healing. Whether a "hit" counts against eventually making a party member hostile I'm not sure. Perhaps you couldn't even target a friendly anyways. Just playing with ideas here.
 
dude_obj said:
#define DAM_KNOCKED_OUT (1)

It seems that a lot of these don't do what is listed (grrr) so I will have to test them all, but the crippling works.

This actually relates to something I tested in Fo1 recently. If you sneak into the Military Base and reach the Lieutenant, he tells his guards to capture you and sets a variable. When this is set, mutants have a combat_p_proc that tries to knock you out so you can be taken alive. Only it doesn't work - just one of many examples of scripters and programmers apparently being somewhat out of synch.
 
This seems to work for associating a weapon with a scripted hit:

// define weapon wielded
#define dude_wielding_neurodisrupter ((obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_RIGHT_HAND)) == PID_NEURO_DISRUPTER) or \ (obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_LEFT_HAND)) == PID_NEURO_DISRUPTER))

procedure combat_p_proc begin
// Check for hit
if (fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
if (dude_wielding_neurodisrupter) then begin
// Do specialized damage
end
end
end


Now here's the really sucky part. I tried to make this neuro disrupter subtract perception points on a target, and it doesn't work! I can use set_critter_stat on the dude_obj, but it doesn't seem to work on critters.

I made a script that displays the perception in the status window, before and after hit. When applied to a critter (target_obj) the perception never changes. If I change it to modify my own perception (self_obj or dude_obj) it works fine.

Really strange how set_critter_stat doesn't work on critters other than the player. Searching the FO script source code I only see it used on the player (dude_obj) or in one case self_obj.

Well I'll try some other things like critter_add_trait and the poison and radiation with this gun. I'm PO that I can't modify perception though because that's pretty cool. You could make a target harmless without having to kill them.
 
dude_obj said:
// define weapon wielded
#define dude_wielding_neurodisrupter ((obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_RIGHT_HAND)) == PID_NEURO_DISRUPTER) or \ (obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_LEFT_HAND)) == PID_NEURO_DISRUPTER))

So if I hold a Neurodisrupter in my left hand and hit someone with a Wrench in my right hand...?

Now here's the really sucky part. I tried to make this neuro disrupter subtract perception points on a target, and it doesn't work! I can use set_critter_stat on the dude_obj, but it doesn't seem to work on critters.

A workaround could be to create a Beer item and use it on the critter, if possible.

Really strange how set_critter_stat doesn't work on critters other than the player.

Doesn't work for the player either for all stats. For instance, there are several damage resistance bonuses in Fo1/Fo2 scripts that have no effect (MacRae in Fo1, stupid character zapped by the computer in VC in Fo2). Scripters also disagree on whether the command sets the stat to the specified value, or adds the specified value to the stat.

Well I'll try some other things like critter_add_trait and the poison and radiation with this gun.

I'm pretty sure critters don't have poison counters.
 
Per said:
mutants have a combat_p_proc that tries to knock you out so you can be taken alive. Only it doesn't work - just one of many examples of scripters and programmers apparently being somewhat out of synch.

I've been trying all of those DAM_ parameters with critter_injure, and the only ones I have seen work so far are the crippling ones, so I'm not surprised.

I just tried this ... on hit the target does obj_drop_everything ... it works, the target drops its entire inventory at its feet ... the ultimate thieving tool LOL

I'm trying all the script commands that can affect the target to see what kind of special attacks might be possible.
 
Per said:
So if I hold a Neurodisrupter in my left hand and hit someone with a Wrench in my right hand...?

I tried this and apparently its not a problem. I guess its a bit misleading because the real effect seems to be that the weapon must be in the active slot for it to pass that test during combat.

If I have boxing gloves and the neurodisrupter in my 2 two weapon slots, and I punch with the gloves, they do normal damage. If I switch to the neurodisrupter, it does the special damage (which is death in the test: 100 hit points damage via critter_damage(target_obj,100)
 
You could emulate the blue grav gun from Half-Life 2:

move_obj(target_obj, tile_in_direction(dude_obj, random(5, 10))
damage_critter(a_lot)
 
Per said:
A workaround could be to create a Beer item and use it on the critter, if possible.

When I tried this in the obj_dude script, the game froze immediately after saying "you used the beer on". So I tried calling a timer event on the target object, and had it create and use the beer. That seems to work, and perception goes down. But even with very low perception these damn critters can still hit me. Its almost as if perception values aren't factored into their to hit rolls.

Per said:
Scripters also disagree on whether the command sets the stat to the specified value, or adds the specified value to the stat.

My testing shows that set_critter_stat expects a modifier amount, a positive integer (increment) or negative integer (decrement). It does not set the stat to a specific value.

EDIT: And the mapper docs seem to be wrong for this. They state: sets the value of a desired attribute/stat in a critter (who) to a given value (val). That just isn't true. I put in debug messages that show the perception before and after set_critter_stat calls. A number 3 increases it 3 points. A -2 decreases it 2 points.

This should not be confused with critter_add_trait which is different (it doesn't deal with SPECIAL, it deals with perks and skills).

Per said:
I'm pretty sure critters don't have poison counters.

Crap. Looks like you are right. Say it with me: LAME!
 
I looked through the various script commands to see what could be done on a critter as a special attack. These are what worked:

critter_damage(target_obj,amount) - apply hit point damage.

critter_heal(target_obj,amount) - this works too. Could make a healing weapon, or for the psycho in you: let me heal you so I can keep on pummeling you LOL

critter_injure(target_obj,DAM_CRIP_LEG_LEFT); - Crippling gun. The only parameters that seeem to work are the cripple ones which are:
DAM_CRIP_LEG_LEFT
DAM_CRIP_LEG_RIGHT
DAM_CRIP_ARM_LEFT
DAM_CRIP_ARM_RIGHT
DAM_BLIND - Critter Runs Away

critter_set_flee_state(target_obj,1); - It's a fear gun! In the middle of active combat, when shot, the critter runs away.

terminate_combat - It's a happy gun! In the middle of the battle, shooting a critter makes the combat stop. This command doesn't prevent other scripts from restarting combat though, so hostile flags would have to be changed to make it work properly. It seems to work though when fighting a critter in the mapper.

critter_stop_attacking(target_obj); - same as above

use_obj_on_obj(create_object(PID_JET,0,0),target_obj); - Game freezes if you do this to target directly in obj_dude script, however, you can call a timer event on the target's script, and have them use the obj on self, this seems to work.

obj_drop_everything(target_obj) - target drops its entire inventory at its feet. No need to say "give me your wallet".

set_light_level(amount) - This works, I'm thinking it might be cool to make a very bright flare that works on a timer.

obj_set_light_level(target_obj,100,7); - This makes just the critter that is targeted light up, pretty cool. The 100 is light level and the 7 is distance in hexes to light up (radius around critter). Some kind of lamp type item that when used lights up the player would be cool.

Unfortunately, these don't seem to work on critters triggered from
the obj_dude combat_p_proc on hit:

explosion
set_critter_stat
radiation_inc
radiation_dec
poison

I'm PO that the above don't work on critters!

It may be possible to make a kind of spock tricorder thing, shoot a critter and get info about it (what its skills, perks, stats are).
 
It seems pretty clear that drugs don't affect critters to anywhere near the same degree they affect the player character.

I remember taking that nasty healing powder in FO2, which reduces perception by one point. Even with a 1 point loss of perception I was having trouble hitting targets. Granted this was a level 1 one character with very low skills, but the effect was very obvious.

So I made a new drug for the neuro disrupter gun effect. This drug does -10 to PE, AG, and ST. And even with all 3 of these stats down to a measly 1 point, a wild dog can still hit me and in fact kill me. Oh well, it does have some effect, but with all 3 of those stats at 1 the dog should pretty much be harmless I think. The way I made the neurodisrupter work:

In obj_dude script:

#define dude_wielding_neurodisrupter ((obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_RIGHT_HAND)) == PID_NEURO_DISRUPTER) or \
(obj_pid(critter_inven_obj(dude_obj,INVEN_TYPE_LEFT_HAND)) == PID_NEURO_DISRUPTER))

procedure combat_p_proc begin
if (fixed_param == COMBAT_SUBTYPE_HIT_SUCCEEDED) then begin
if (dude_wielding_neurodisrupter) then begin
flush_add_timer_event(target_obj,1,601);
end
end
end

I had to call a timer event on the critter or the game will crash, so this is what was done on the critter:

procedure timed_event_p_proc begin
if (fixed_param == 601) then begin
use_obj_on_obj(create_object(PID_NEURO_DISRUPTER_EFFECT,0,0), self_obj);
end
end

I'm not sure if the neuro disrupter used ammo in FoT, but I made it run on small energy cells, and gave it the sound of the alien blaster.
 
I was thinking of using this to make more types of incendiary grenades; then I realised for the script to work on a throwing weapon, the item would have to be wielded after hitting its target.

Is there any way to script it so it recognises the item PID it was hit with rather than recognising the PID of the item wielded?
 
Corpse said:
I was thinking of using this to make more types of incendiary grenades; then I realised for the script to work on a throwing weapon, the item would have to be wielded after hitting its target.

Well that would depend on when the check for critter_inven_obj is done in the engine during combat. I had an incediary grenade set up from the FoT stuff. I changed its damage to 0 and changed the obj_dude script to check its PID. It seems to work even though its a thrown weapon. It passes the "am I wielding grenade" test and triggers the timer on the target on hit. So I think you can use this type of check. What I wish I could figure out is how to trigger the various damage type animations (both the originals and ones from FoT). I found these interesting lines in define.h:

// Fallout 2:
#define DAM_PERFORM_REVERSE 8388608
#define critter_uninjure(WHO, FLAGS) critter_injure(WHO, (FLAGS BWOR DAM_PERFORM_REVERSE))

#define DMG_normal_dam 0
#define DMG_laser 1
#define DMG_fire 2
#define DMG_plasma 3
#define DMG_electrical 4
#define DMG_emp 5
#define DMG_explosion 6
// These are BWOR'd into the above damage type
#define DMG_BYPASS_ARMOR (256)
#define DMG_NOANIMATE (512)

//#define critter_damage(WHO,AMT) critter_dmg(WHO,AMT,(DMG_normal_dam BWOR DMG_NOANIMATE))
#define critter_damage(WHO,AMT) critter_dmg(WHO,AMT,DMG_normal_dam)

Notice that critter_damage is actually a call to critter_dmg with some parameters. Also notice the interesting BWOR masking to bypass armor and such. And what the hell is reverse injure? (critter uninjure)

I played around with trying this critter_dmg command directly (rather than the usual critter_damage or critter_injure) and basically just managed to freeze the game. Then I did a search on keyword critter_dmg in the FO2 script source to see if it's used directly. It is used in traps like this:

critter_dmg(source_obj,Crowbar_Strain,(DMG_normal_dam BWOR DMG_BYPASS_ARMOR));

Interesting huh? So I played around with this and again just managed to freeze the game.

I will revisit playing with these special weapons and effects later, because I'm getting distracted from my goal here. I'm going back to finishing items and critters for the expansion pack, and then working on reordering scenery for now. Later I will come back to trying to implement things like special grenades and mines etc.
 
Crap I was mistaken ... I had multiple grenades in inventory when I ran that test ... duh. I was wrong ... if you have just one grenade the wielding check doesn't work. But if you have another it does hee hee. I'll try to figure out a better way to determine what weapon is used in special attacks. I wonder if source_obj has any use here ....
 
Corpse said:
Is there any way to script it so it recognises the item PID it was hit with rather than recognising the PID of the item wielded?

Not sure about that but ... in combat_p_proc you can test for:

- HIT_SUCCEEDED
- SEQUENCING - combat sequencing is being checked
- TURN - combat turn is about to start

So I think that with some extra work you could save the PIDs of what was in the weapon slots, then check on hit to see if a new weapon was used. If it was a grenade, but on HIT_SUCCEEDED there is a new weapon in the slot, then you fail the wielding check. If the slot is empty, or has another grenade, you pass? This might work. They really should have a command that saves the PID of the weapon that hit, but they don't.

BTW in define.h there are a couple of extras:
// script.h: Script Combat Procedure SubTypes //
#define COMBAT_SUBTYPE_WEAPON_USED (1)
#define COMBAT_SUBTYPE_HIT_SUCCEEDED (2)
#define COMBAT_SUBTYPE_SEQUENCING (3)
#define COMBAT_SUBTYPE_TURN (4)
#define COMBAT_SUBTYPE_NONCOM_TURN (5)

That first one WEAPON_USED ... I think just indicates that it was a weapon not unarmed ... but that may be useful ... that is not mentioned in the mapper docs. The last one NOCOM_TURN is listed as unused in the mapper docs.

The COMBAT_SUBTYPE_TURN check can be useful in critter scripts to make them do something special rather than a normal attack too. They could decide not to attack, run away, run for help, maybe even heal a friend with stimpak ....
 
dude_obj said:
So I made a new drug for the neuro disrupter gun effect. This drug does -10 to PE, AG, and ST. And even with all 3 of these stats down to a measly 1 point, a wild dog can still hit me and in fact kill me. Oh well, it does have some effect, but with all 3 of those stats at 1 the dog should pretty much be harmless I think.

Does PE have any effect on non-ranged attacks?

When I tested the effects of drunk critters shooting at me, they were depressingly insignificant. That is, the difference from the normal case. I'd hate to think that the game doesn't use the same to hit calculation for critters (and formulae for derived stats) as for the PC. Then again, one point of PE should "only" lower to hit by 8%. A critter with PE 5 and a combat skill above 100 could still end up hovering near the 95% cap. We should test it perhaps, and by "we" I mean you.
 
How do you edit these scripts? Do you use the fallout2 mapper or some other program to edit them?

Im hoping there might be some way to edit ap ammo in this script:

#define DAM_HIT (256)
 
Back
Top