Get the name of the last bone that collided

Topics regarding Scripting with Reality Factory
Post Reply
Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Get the name of the last bone that collided

Post by Veleran » Mon Mar 22, 2010 4:56 am

If a pawn attacks with a melee weapon that has some bones and you want to get the name of the bone that collided the target pawn,
and then use DamageAtBone to inflict damage according the weapon bone that collided, Is there any appropriate command for this?

The reason is that a sword with "damage area" bones,one at middle one next and one at the tip would do more damage towards the tip.


I am not sure i have checked all commands in the manual, from what i remember theres a getlastbonehit command for knowing which place a projectile hit a pawn,which is not what i describe.

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Get the name of the last bone that collided

Post by Veleran » Tue Mar 23, 2010 10:28 am

I checked again,and the getlastbonehit is the only that could be used.
I hope the "hit" means it will work for melee weapons collision,but i am not that good in scripting to do a test.

string GetLastBoneHit();
Returns the name of the bone last hit.

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Get the name of the last bone that collided

Post by QuestOfDreams » Tue Mar 23, 2010 11:56 am

Weapon actors do not perform any collision detection.
GetLastBoneHit() just returns the last bone of the pawn's actor that was hit by a projectile.

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Get the name of the last bone that collided

Post by Veleran » Tue Mar 23, 2010 12:29 pm

Its the master pawn bones that collide the target pawn,the weapon bones are just for moving the weapon ,and has the same skeleton in order to function.
So,now what,maybe ask for a new command?

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Get the name of the last bone that collided

Post by Allanon » Tue Mar 23, 2010 8:53 pm

You might be able to use the GetBoneToBone command to figure out which weapon bone gets the damage when the weapon hit the target pawn. Use the bone returned from the GetLastBoneHit command along with the GetBoneToBone command and compare the distance to each bone in the weapon. The closest weapon bone gets the damage.

NOTE: I've never written a script for RF but I am a programmer.

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Get the name of the last bone that collided

Post by Veleran » Wed Mar 24, 2010 1:23 am

I had already thought it but i want simpler and shorter (and cleaner scripts)
Since there is a get last bone hit command why not having another command
that works for bone to bone collision so we know which of the Pawn bones has hit the target bones.

If this new command can be created easily,
then next and i would not mind to also to know which of the target bones was collided,(head,arm,torso,leg etc).

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Get the name of the last bone that collided

Post by QuestOfDreams » Thu Mar 25, 2010 12:41 pm

I should have made this clearer in my first post: the only actors that currently perform collision detection at the bone bounding box level are projectiles. So it won't be as simple as just adding a new script command...

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Get the name of the last bone that collided

Post by Veleran » Thu Mar 25, 2010 4:52 pm

Ok,thanks- i will better simplify it,and use damageatbone using only one bone at a time from the skeleton that is located near the sword tip,(somewhat before the tip,so it seems like you need to thrust it deep enough to hit stab or cut the target).
This way with damageatbone the damage will be done to the overall target bounding box,and if a tall ogre swings a spiked ball in chain to your face, you can crouch and the ball's bone will pass above you.

About the GetBoneToBone,i thought it can be used to check if the bones of an attached tail.
I hope that around 20 attack animation frames are enough time to use damageatbone (for general damage) and GetBoneToBone -to know if the tail bone has been hit.


I assume i should have a different script for dealing each opponent,otherwise all the attacks will check if the tail bone has hit even when you fight a human wizard.

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: Get the name of the last bone that collided

Post by darksmaster923 » Fri Mar 26, 2010 5:47 am

Kind of ugly, but you can always check the distance to the player, and if the enemy is within a certain radius, the attack does more damage, or less damage and such.
Herp derp.

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Get the name of the last bone that collided

Post by Veleran » Fri Mar 26, 2010 9:45 am

I would like to check if the sword bone gets near the shieild bones first,so i can do damage to the shield accessory and not the enemy itself,
but i am not sure if it can be done,maybe the cpu can test many distances between bones during an attack that lasts 20 frames.

If i manage to check when the sword gets to the sheild first,i would also like to place an actor explosion so it seems like the shield explodes to pieces on the floor.

Post Reply