GetCombatTarget

Post » Sun Aug 08, 2010 7:14 pm

I'm trying to use player.GetCombatTarget to tell if the player is currently aiming at an NPC, but it doesn't seem to be working. It's in the gamemode block of an object script running in the NPC's inventory. Anyone know of any quirks regarding that function? If nobody does, and I can't get it to work, I'll just use getangle, getpos, and some trig to figure it out, but that's a lot of work for something that should be possible with a single function call.

I need it for two projects. One is a new system for the power armor explosions in Powered Power Armor (scoring a torso shot from behind an NPC will automatically detonate their microfusion pack if the damage is high enough), and the other is a perk that will let you disarm your opponent by pressing the grab key if you're within range and using fists or an unarmed weapon.
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Sun Aug 08, 2010 4:58 pm

I'm trying to use player.GetCombatTarget to tell if the player is currently aiming at an NPC, but it doesn't seem to be working. It's in the gamemode block of an object script running in the NPC's inventory. Anyone know of any quirks regarding that function? If nobody does, and I can't get it to work, I'll just use getangle, getpos, and some trig to figure it out, but that's a lot of work for something that should be possible with a single function call.

I need it for two projects. One is a new system for the power armor explosions in Powered Power Armor (scoring a torso shot from behind an NPC will automatically detonate their microfusion pack if the damage is high enough), and the other is a perk that will let you disarm your opponent by pressing the grab key if you're within range and using fists or an unarmed weapon.


GetCombatTarget on the player returns nothing usable as its impossible for the game to determine what the player is deciding to attack -> easiest method of getting a probable Player combat target is with collecting actor refs around the player and just seeing who is closest to Player.GetHeadingAngle Actor == Nearest to 0 wins, no need for Trig or any real math.

Now for getting if the player is behind said NPC you just check NPC.GetHeadingAngle Player and if its near "0" then the player is high tailing it (being chased) and if its near -180/180 then the player is behind the NPC.
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am

Post » Sun Aug 08, 2010 10:03 pm

I've tested this on a NPC script and Player.GetCombatTarget returns values sporatically. When it has returned a value, is when the crosshair is on an enemy close by or i've taken one shot at it. I think auto-aim plays a role in this because in vanilla this seems to work more often than with mods that change auto-aim gamesettings. Though this is just subjective.
User avatar
Scott
 
Posts: 3385
Joined: Fri Nov 30, 2007 2:59 am

Post » Sun Aug 08, 2010 9:22 am

This is correct, as far as I can recall, player.getCombatTarget returns the ref your are targeting if auto aim picks it up. I think there was a way to pick up your reticle's target though (although SaidenStorm's method is probably the best)... let me think on that :P
User avatar
Emily Jones
 
Posts: 3425
Joined: Mon Jul 17, 2006 3:33 pm

Post » Sun Aug 08, 2010 10:09 pm

a perk that will let you disarm your opponent by pressing the grab key if you're within range and using fists or an unarmed weapon.

For this you might have use of FOSE's http://fose.silverlock.org/fose_command_doc.html#GetCrosshairRef.
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm

Post » Sun Aug 08, 2010 9:57 pm

For this you might have use of FOSE's http://fose.silverlock.org/fose_command_doc.html#GetCrosshairRef.


Nice! I kept trying to find this function but couldn't remember the name :D Is there a way to increase the activation range maybe???
User avatar
NEGRO
 
Posts: 3398
Joined: Sat Sep 01, 2007 12:14 am

Post » Sun Aug 08, 2010 5:50 pm

Nice! I kept trying to find this function but couldn't remember the name :D Is there a way to increase the activation range maybe???


Set OldRange to GetGameSetting iActivatePickLength ; Default Range is 150
SetNumericGameSetting iActivatePickLength 30000
Get CrossHairRef -> Do Stuff
SetNumericGameSetting iActivatePickLength OldRange

Allows you to briefly set the Activate Range to basically Max, and reset it to Default or whatever it was set to before.
User avatar
Sweets Sweets
 
Posts: 3339
Joined: Tue Jun 13, 2006 3:26 am

Post » Sun Aug 08, 2010 5:12 pm

Does that work if it's all in the same frame?
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Sun Aug 08, 2010 5:27 pm

Does that work if it's all in the same frame?


I have not had any issues with it happening in the same frame though seperating it by frames it not difficult.
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Sun Aug 08, 2010 10:06 pm

Set OldRange to GetGameSetting iActivatePickLength ; Default Range is 150
SetNumericGameSetting iActivatePickLength 30000
Get CrossHairRef -> Do Stuff
SetNumericGameSetting iActivatePickLength OldRange

Allows you to briefly set the Activate Range to basically Max, and reset it to Default or whatever it was set to before.


I'll get some very tricky stuff out of this mesa thinks :P Thnx a lot :D
User avatar
Ella Loapaga
 
Posts: 3376
Joined: Fri Mar 09, 2007 2:45 pm

Post » Sun Aug 08, 2010 6:31 pm

Thanks, the getheadingangle command works for the power armor explosions, and getcrosshairref should work for the disarming.
User avatar
Lew.p
 
Posts: 3430
Joined: Thu Jun 07, 2007 5:31 pm


Return to Fallout 3