Get muzzle position

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Get muzzle position

Postby satoon101 » Fri Nov 10, 2017 9:32 pm

I have done some research, but have not found any very clean methods of getting the muzzle position on a weapon. This is the best solution I have found, but I was wondering if anyone knew of a better way:
https://github.com/MitchDizzle/WeaponAt ... mentAPI.sp
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sat Nov 11, 2017 12:46 am

To get the muzzle location of an equipped weapon, you would need to get the position of the ValveBiped.weapon_bone bone of the player's model, get a rotation matrix to convert its position to world coordinates based on the player's origin/angles, then get the local bone associated with the muzzle attachment (which is ValveBiped.flash) of the weapon's model, then get a rotation matrix to then finally move to that point from the player's weapon_bone coordinates. Basically need to move from point to point in the parenting hierarchy (player's origin → weapon_bone's origin → muzzle's origin) because a parented entity carries the origin/angles of its parent and that a carried weapon also carries its owner origin/angles as absolute coordinates. However, this would only works if the player is not moving, otherwise you would also need to take into consideration the movement by getting the current frame of the bone controller and move accordingly. We currently have a good portion of the tools needed to achieve that into the studio package (matrix3x4_t would still needs to be exported) but I really don't think it would worth the effort to do all that manually.

The easiest way is definitely to let the engine do the works for you by parenting an entity and then retrieve its coordinates. Tho, I would not go with a prop_dynamic, like used in the code you linked but would rather use an info_null entity and spawn it afterword (they remove themselves once spawned). And the reason being that info_null are never networked to clients unlike props. Sig-scanning CBaseAnimating::GetAttachment could also be a solution.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Get muzzle position

Postby Ayuto » Sat Nov 11, 2017 8:46 am

As for the signature of CBaseAnimating::GetAttachment(). Yesterday, I also took a look at it by getting the location of the attachment muzzle_flash. However, the location was always somewhere near to the players feets.

Syntax: Select all

server = memory.find_binary('server')

# bool CBaseAnimating::GetAttachment(int attachment, Vector& origin, QAngle& angles)
GetAttachment = server[b'\x55\x8B\xEC\x8B\x01\x8D\x55\xD0'].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.INT, DataType.POINTER, DataType.POINTER],
DataType.BOOL
)

player = Player(1)
attachment = player.lookup_attachment('muzzle_flash')
origin = Vector()
angles = QAngle()
result = GetAttachment(player, attachment, origin, angles)
print(result)
print(origin)
print(angles)


Edit: matrix3x4_t is now exposed. https://github.com/Source-Python-Dev-Te ... 91156f55fa
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Get muzzle position

Postby satoon101 » Sat Nov 11, 2017 3:43 pm

Thank you both. Since you exposed matrix3x4_t, I gave the virtual function for CBaseAnimating::GetAttachment() a shot. Unfortunately, it fared no better.

Syntax: Select all

# In ../data/source-python/entities/orangebox/CBaseAnimating.ini
[virtual_function]

# _ZN14CBaseAnimating13GetAttachmentEiR11matrix3x4_t
[[get_attachment]]
offset_linux = 206
offset_windows = 205
arguments = INT, POINTER
return_type = BOOL

Syntax: Select all

player = Player(1)
attachment_index = player.lookup_attachment('muzzle_flash')
obj = Matrix3x4(Vector(), Vector(), Vector(), Vector())
result = player.get_attachment(attachment_index, obj)
print(result)
print(obj)

# This is exactly the same value as the origin using GetAttachment from Ayuto's post
print(Vector(obj[0][3], obj[1][3], obj[2][3])
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Get muzzle position

Postby Ayuto » Sat Nov 11, 2017 5:29 pm

L'In20Cible wrote:[...] then get the local bone associated with the muzzle attachment (which is ValveBiped.flash) of the weapon's model [...]

I can't seem to find ValveBiped.flash. This is all I found:

Code: Select all

# Bones for player
ValveBiped.Bip01_Pelvis
ValveBiped.Bip01_L_Thigh
ValveBiped.Bip01_L_Calf
ValveBiped.Bip01_L_Foot
ValveBiped.Bip01_L_Toe0
ValveBiped.Bip01_R_Thigh
ValveBiped.Bip01_R_Calf
ValveBiped.Bip01_R_Foot
ValveBiped.Bip01_R_Toe0
ValveBiped.Bip01_Spine
ValveBiped.Bip01_Spine1
ValveBiped.Bip01_Spine2
ValveBiped.Bip01_Spine4
ValveBiped.Bip01_Neck1
ValveBiped.Bip01_Head1
ValveBiped.Bip01_L_Clavicle
ValveBiped.Bip01_L_UpperArm
ValveBiped.Bip01_L_Forearm
ValveBiped.Bip01_L_Hand
ValveBiped.Bip01_L_Finger2
ValveBiped.Bip01_L_Finger21
ValveBiped.Bip01_L_Finger22
ValveBiped.Bip01_L_Finger1
ValveBiped.Bip01_L_Finger11
ValveBiped.Bip01_L_Finger12
ValveBiped.Bip01_L_Finger0
ValveBiped.Bip01_L_Finger01
ValveBiped.Bip01_L_Finger02
ValveBiped.Bip01_R_Clavicle
ValveBiped.Bip01_R_UpperArm
ValveBiped.Bip01_R_Forearm
ValveBiped.Bip01_R_Hand
ValveBiped.Bip01_R_Finger2
ValveBiped.Bip01_R_Finger21
ValveBiped.Bip01_R_Finger22
ValveBiped.Bip01_R_Finger1
ValveBiped.Bip01_R_Finger11
ValveBiped.Bip01_R_Finger12
ValveBiped.Bip01_R_Finger0
ValveBiped.Bip01_R_Finger01
ValveBiped.Bip01_R_Finger02
ValveBiped.Bip01_R_Wrist
ValveBiped.Bip01_L_Wrist
ValveBiped.Bip01_L_Ulna
ValveBiped.Bip01_R_Ulna
ValveBiped.weapon_bone
ValveBiped.weapon_bone_RHand
ValveBiped.weapon_bone_LHand
ValveBiped.weapon_bone_Clip
ValveBiped.forward

# Attachments for player
forward
grenade0
grenade1
grenade2
grenade3
pistol
primary
defusekit
eholster
lfoot
rfoot
muzzle_flash

# Bones for weapon_m4a1
v_weapon.m4_Parent
v_weapon.cube_Trigger
v_weapon.m4_Eject
v_weapon.m4_Clip
v_weapon.m4_Silencer
v_weapon
v_weapon.Hands_parent
v_weapon.Root34
v_weapon.Left_Arm
v_weapon.eff16
v_weapon.Root16
v_weapon.Left_Hand
v_weapon.eff2
v_weapon.Root17
v_weapon.Left_Thumb01
v_weapon.Left_Thumb_02
v_weapon.Left_Thumb03
v_weapon.Root18
v_weapon.Left_Pinky01
v_weapon.Left_Pinky02
v_weapon.Left_Pinky03
v_weapon.Root19
v_weapon.Left_Ring01
v_weapon.Left_Ring02
v_weapon.Left_Ring03
v_weapon.Root20
v_weapon.Left_Middle01
v_weapon.Left_Middle02
v_weapon.Left_Middle03
v_weapon.Root21
v_weapon.Left_Index01
v_weapon.Left_Index02
v_weapon.Left_Index03
v_weapon.Root99
v_weapon.L_wrist_helper
v_weapon.Root36
v_weapon.Right_Arm
v_weapon.eff18
v_weapon.Root23
v_weapon.Right_Hand
v_weapon.eff9
v_weapon.Root24
v_weapon.Right_Thumb01
v_weapon.Right_Thumb02
v_weapon.Right_Thumb03
v_weapon.Root25
v_weapon.Right_Index01
v_weapon.Right_Index02
v_weapon.Right_Index03
v_weapon.Root26
v_weapon.Right_Middle01
v_weapon.Right_Middle02
v_weapon.Right_Middle03
v_weapon.Root27
v_weapon.Right_Ring01
v_weapon.Right_Ring02
v_weapon.Right_Ring03
v_weapon.Root28
v_weapon.Right_Pinky01
v_weapon.Right_Pinky02
v_weapon.Right_Pinky03
v_weapon.Root98
v_weapon.R_wrist_helper

# Attachments for weapon_m4a1
1
2


Edit:
With GetBoneTransform, you can easily get an absolute position.

Syntax: Select all

#  200  199 CBaseAnimating::GetBoneTransform(int, matrix3x4_t &)
GetBoneTransform = player.pointer.make_virtual_function(
199,
Convention.THISCALL,
[DataType.POINTER, DataType.INT, DataType.POINTER],
DataType.VOID
)

matrix = Matrix3x4()
GetBoneTransform(player, weapon_bone_index, matrix)
weapon_origin = matrix.position
print(weapon_origin)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sat Nov 11, 2017 11:53 pm

Ayuto wrote:I can't seem to find ValveBiped.flash.

That bone is on the weapon's world models:

Syntax: Select all

from studio.cache import model_cache

models = (
'models/weapons/w_rif_ak47.mdl',
'models/weapons/v_rif_ak47.mdl',
'models/player/t_phoenix.mdl'
)

for model in models:
print(model)
header = model_cache.get_model_header(model_cache.find_model(model))
for index in range(header.attachments_count):
attachment = header.get_attachment(index)
bone = header.get_bone(attachment.local_bone)
print('\t-', attachment.name, '->', bone.name, '->', header.get_bone(bone.parent).name)

"""
models/weapons/w_rif_ak47.mdl
- muzzle_flash -> ValveBiped.flash -> ValveBiped.weapon_bone
models/weapons/v_rif_ak47.mdl
- 1 -> v_weapon.AK47_Parent ->
- 2 -> v_weapon.AK47_Parent ->
models/player/t_phoenix.mdl
- forward -> ValveBiped.forward -> ValveBiped.Bip01_Head1
- grenade0 -> ValveBiped.Bip01_Spine -> ValveBiped.Bip01_Pelvis
- grenade1 -> ValveBiped.Bip01_Spine -> ValveBiped.Bip01_Pelvis
- grenade2 -> ValveBiped.Bip01_Spine -> ValveBiped.Bip01_Pelvis
- grenade3 -> ValveBiped.Bip01_Spine -> ValveBiped.Bip01_Pelvis
- pistol -> ValveBiped.Bip01_R_Thigh -> ValveBiped.Bip01_Pelvis
- primary -> ValveBiped.Bip01_Spine2 -> ValveBiped.Bip01_Spine1
- eholster -> ValveBiped.Bip01_L_Thigh -> ValveBiped.Bip01_Pelvis
- c4 -> ValveBiped.Bip01_Spine2 -> ValveBiped.Bip01_Spine1
- lfoot -> ValveBiped.Bip01_L_Foot -> ValveBiped.Bip01_L_Calf
- rfoot -> ValveBiped.Bip01_R_Foot -> ValveBiped.Bip01_R_Calf
- muzzle_flash -> ValveBiped.Bip01_L_Hand -> ValveBiped.Bip01_L_Forearm
"""

The muzzle_flash attachment of the player, being associated to his left hand, makes me assume it is the flashlight position and not the actual position of the muzzle on the rendered weapon. I did some testings just now with a trail and this is correct, parenting to the player's muzzle_flash is at this location:
Image
However, parenting to the '1' attachment of the view model seems accurate:
Image
The following function works fine from my testing:

Syntax: Select all

def get_muzzle_origin(player):
null = Entity.create('info_null')
null.set_parent(player.active_weapon)
null.call_input('SetParentAttachment', '1')
origin = null.origin
null.spawn()
return origin

EDIT: Actually no, it seems to also returns the root origin of the player.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 6:54 am

i can help you, but it depends on what you are trying to do...

a) do you need the 3d world position?
or
b) do you need a 2d translated position? (e.g. viewposition)

and,

when do you need to look it up?
a) while there is an existing attachment?
or
b) while there is no existing attachement? (anytime)

just a note for lincibles confusion:
attachments are not bone positions. attachments use bone positions and then apply additional matrices which results in the attachment position.

so it really depends on what the goal here is. so: if you want an engine-separate function, to access the 3d world position at anytime, it would probably just be 2 matrices after hooking any (!) existing rootpos of the player via studiomodel as lincible suggested.. (which btw is already player-oriented) so im wondering what the big deal is here.. sorry if i am misunderstanding ...
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Get muzzle position

Postby satoon101 » Sun Nov 12, 2017 7:22 am

I'm trying to get the world position at the time a player shoots their weapon (or more precisely, on bullet_impact and OnTakeDamage).

I did find a few SM plugins that use CBaseCombatCharacter::Weapon_ShootPosition(). I tried adding the virtual function to my entity data, but it gives an error (from here):

Code: Select all

Access violation while writing address '1'


I looked up the code in the SDK, and it seems do-able to rewrite it in Python, but I'm not 100% sure what all of the underlying functions do to accomplish it:
https://github.com/alliedmodders/hl2sdk ... 2764-L2781

Here is the code for AngleVectors:
https://github.com/alliedmodders/hl2sdk ... #L921-L961
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sun Nov 12, 2017 7:46 am

satoon101 wrote:I'm trying to get the world position at the time a player shoots their weapon (or more precisely, on bullet_impact and OnTakeDamage).

I did find a few SM plugins that use CBaseCombatCharacter::Weapon_ShootPosition(). I tried adding the virtual function to my entity data, but it gives an error (from here):

Code: Select all

Access violation while writing address '1'


I looked up the code in the SDK, and it seems do-able to rewrite it in Python, but I'm not 100% sure what all of the underlying functions do to accomplish it:
https://github.com/alliedmodders/hl2sdk ... 2764-L2781

Here is the code for AngleVectors:
https://github.com/alliedmodders/hl2sdk ... #L921-L961

I've exported that function as QAngle.get_angle_vectors and reproduced the code:

Syntax: Select all

from mathlib import QAngle, Vector
from players.entity import Player

player = Player(1)

angles = QAngle(*player.get_property_vector('m_angAbsRotation'))
pos = player.get_property_vector('m_HackedGunPos')

forward = Vector()
right = Vector()
up = Vector()
angles.get_angle_vectors(forward, right, up)

origin = player.get_property_vector('m_vecAbsOrigin')
origin += (forward * pos.y)
origin += (right * pos.x)
origin += (up * pos.z)

But this points at the exact same location the code I posted using info_null is retrieving (the front of its feet):
Image
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 8:03 am

@satoon101
are you trying to write the math with "import math" functions? doesnt "import mathlib" support matrix multiplications? i would use those.

what you explain sounds like,
-> adding a player method for "muzzle_position" (just like eye_position with 1 more forward matrix multiplication added)

BUT(!),
in your case i would probably do this: ( you can still add this as a player method )
-> get the player.active_weapon -> get the studio_model of the weapon -> check if the model has "weapon_muzzle" bone (not all active weapons have it) -> use that bone as your desired world position. ( it should carry world coordinates if engine is hooked correctly )
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 8:07 am

@L'In20Cible
what if you test this code:

Syntax: Select all

from mathlib import QAngle, Vector
from players.entity import Player

player = Player(1)

angles = QAngle(*player.get_property_vector('m_angAbsRotation'))
pos = player.get_property_vector('m_HackedGunPos')

forward = Vector()
right = Vector()
up = Vector()
angles.get_angle_vectors(forward, right, up)

origin = player.get_property_vector('m_vecAbsOrigin')
origin += (forward * pos.y)
origin += (right * pos.x)
origin += (up * (pos.z +64))
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sun Nov 12, 2017 8:17 am

Speed0x wrote:@L'In20Cible
what if you test this code:

I didn't test, but can already tells it won't help. Moving the z axis by 64 (or directly using player.view_offset.z) will only move the vector up without taking the player's angle into consideration and will be in front of the player's eyes no matter where the actual weapon is pointing at. The only thing it tells me, is that the Weapon_ShootPosition method is from HL2 and that other games are probably overriding it in their dispatch table; or are simply not using it at all.

EDIT: I just did test:
Image
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 8:32 am

sorry i misinserted the z offset xD
what about this?

EDIT:

Syntax: Select all

from mathlib import QAngle, Vector
from players.entity import Player

player = Player(1)

angles = QAngle(*player.get_property_vector('m_angAbsRotation'))
pos = player.get_property_vector('m_HackedGunPos')

forward = Vector()
right = Vector()
up = Vector()
angles.get_angle_vectors(forward, right, up)

origin = player.get_property_vector('m_vecAbsOrigin')
origin += (forward * pos.y)
origin += (right * pos.x)
origin += 64 + (up * pos.z)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sun Nov 12, 2017 8:51 am

Speed0x wrote:well you dont have to test it, if you dont want to. it just sounded like you tested your code one moment earlier. so why are you saying that your code was pointing towards "(the front of its feet)"? looking at your actual code, i can say it probably just point towards to the worlds root axis (Y).
It does points in front of the player's feet because m_HackedGunPos is a Vector(0.0, 32.0, 0.0) so it moves 32 points into the y azis from his origin and in the direction he is facing. Thus why I mentioned that this is probably some old code left in the engine for HL2 or other games that use a different "root" origin for player/npc entities or something.

Speed0x wrote:its best not to attack someone who is trying to help, and saying that he doesnt help if YOU misphrase and miscommunicate something :P

Well, I didn't attack you. :eek: And I didn't say you are not helping. I said that the proposed solution of adding 64 to the z axis won't help, which is totally different. All ideas are certainly appreciated!
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 8:58 am

if m_HackedGunPos is just a static vector then why use it? thats why i proposed to use the correct value from studiomodel.. for the length of the weapon. well your code might still work though, i have just advised you to use +64z on the player position for the shoulders height. because the arbitrary vector of (0,32,0) is probably just an "average" gun length vector. so in simple words, you are taking the players shoulder position and adding the view vector for the guns endposition to it. this should work, but again, its probably only an "approach" not a perfect solution.

havent tested though :rolleyes: :cool:
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sun Nov 12, 2017 9:09 am

Speed0x wrote:sorry i misinserted the z offset xD
what about this?

EDIT:

Syntax: Select all

from mathlib import QAngle, Vector
from players.entity import Player

player = Player(1)

angles = QAngle(*player.get_property_vector('m_angAbsRotation'))
pos = player.get_property_vector('m_HackedGunPos')

forward = Vector()
right = Vector()
up = Vector()
angles.get_angle_vectors(forward, right, up)

origin = player.get_property_vector('m_vecAbsOrigin')
origin += (forward * pos.y)
origin += (right * pos.x)
origin += 64 + (up * pos.z)

The result of 64 + (up * pos.z) is Vector(64.0, 64.0, 64.0), so it is just randomly moving to the world center.
Speed0x wrote:if m_HackedGunPos is just a static vector then why use it? thats why i proposed to use the correct value from studiomodel.. for the length of the weapon. well your code might still work though, i have just advised you to use +64z on the player position for the shoulders height. because the arbitrary vector of (0,32,0) is probably just an "average" gun length vector. so in simple words, you are taking the players shoulder position and adding the view vector for the guns endposition to it. this should work, but again, its probably only an "approach" not a perfect solution.

havent tested though :rolleyes: :cool:

To achieve that, we would need to add that to the origin before moving in the direction:

Syntax: Select all

origin = player.get_property_vector('m_vecAbsOrigin').copy()
origin += player.view_offset # or origin.z += 64
origin += (forward * pos.y)
origin += (right * pos.x)
origin += (up * pos.z)

But same result; in front of the player's eyes ignoring the x and z axis.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Get muzzle position

Postby Speed0x » Sun Nov 12, 2017 9:24 am

yeah sorry im totally misreading your code xD it looked like so much code, that i never really read it properly xD
with matrices it would really just be 1 or 2 rows in total...

not to add more confusion, but translating your code a bit, wouldn't this code work too?:

Syntax: Select all

mat =[Vector(),Vector(),Vector()]
QAngle(*player.get_property_vector('m_angAbsRotation')).get_angle_vectors(mat[0], mat[1], mat[2])

gunpos = player.get_property_vector('m_HackedGunPos')
origin = player.eye_position+(mat[0] * gunpos.y)+(mat[1] * gunpos.x)+(mat[2] * gunpos.z)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Get muzzle position

Postby L'In20Cible » Sun Nov 12, 2017 9:46 am

Player doesn't have an eye_position attribute, I guess you meant eye_location. However, it returns player.origin + player.view_vector, and your code is the exact same thing, just differently written. ^^

EDIT: Quite crappy... but works!

Syntax: Select all

from engines.precache import Model
from entities.constants import EntityEffects
from entities.constants import SolidType
from entities.entity import Entity
from mathlib import Matrix3x4
from mathlib import Vector
from memory import find_binary
from memory import Convention
from memory import DataType
from players.entity import Player
from studio.cache import model_cache
from stringtables import string_tables


def get_muzzle_position(player):
weapon = player.active_weapon
if weapon is None:
return

model = string_tables[Model.precache_table][weapon.world_model_index]
header = model_cache.get_model_header(model_cache.find_model(model))

for index in range(header.attachments_count):
if header.get_attachment(index).name == 'muzzle_flash':
break
else:
return

header = player.model_header

for index in range(header.bones_count):
if header.get_bone(index).name == 'ValveBiped.Bip01_R_Hand':
break
else:
return

GetBoneTransform = player.make_virtual_function(
199, Convention.THISCALL, [DataType.POINTER, DataType.INT, DataType.POINTER],
DataType.VOID)

matrix = Matrix3x4()
GetBoneTransform(player, index, matrix)

angles = matrix.angles
angles.z += 180

prop = Entity.create('prop_dynamic_override')
prop.model_name = model
prop.effects = EntityEffects.NODRAW
prop.solid_type = SolidType.NONE
prop.origin = matrix.position
prop.angles = Vector(*angles)
prop.spawn()

null = Entity.create('info_null')
null.set_parent(prop)
null.call_input('SetParentAttachment', 'muzzle_flash')

origin = null.get_property_vector('m_vecAbsOrigin')

null.spawn()
prop.remove()

return origin
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Get muzzle position

Postby satoon101 » Sun Nov 12, 2017 4:16 pm

L'In20Cible wrote:EDIT: Quite crappy... but works!

lol. Hey, as long as it works, I'm good with it. Thank you!
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Get muzzle position

Postby Ayuto » Sun Nov 12, 2017 4:48 pm

No need to use a signature for LookupBone:

Syntax: Select all

def find_bone(header, name):
for index in range(header.bones_count):
bone = header.get_bone(index)
if bone.name == name:
return index

return -1

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 29 guests