How to get target facing data?

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
imB_YipMan
Kobold
Posts: 15
Joined: Mon Oct 23, 2017 8:56 am

How to get target facing data?

Post by imB_YipMan »

Is it possible to return the facing of a token in a targeting script?
I haven't seen any script that does.

In example i would like to see something like this:

Code: Select all

[Attacker] fires an arrow and hits [TargetName] at a [Angle] degree angle.
[Attacker] successfully bypasses [Targetname]'s shield.  

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: How to get target facing data?

Post by Full Bleed »

imB_YipMan wrote:Is it possible to return the facing of a token in a targeting script?
I haven't seen any script that does.

In example i would like to see something like this:

Code: Select all

[Attacker] fires an arrow and hits [TargetName] at a [Angle] degree angle.
[Attacker] successfully bypasses [Targetname]'s shield.  
You should be able to work this out by grabbing the token locations, facing, and then working out the math.

Wiki: getTokenFacing()
Wiki: getTokenX()
Wiki: getTokenY()
Category:Mathematical_Function

That said, this would be a luxury feature... most certainly with a degree of precision you don't get on a table. Do you need that sort of precision to resolve this sort of thing? How do you do this when playing on a table?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

imB_YipMan
Kobold
Posts: 15
Joined: Mon Oct 23, 2017 8:56 am

Re: How to get target facing data?

Post by imB_YipMan »

Full Bleed wrote:
imB_YipMan wrote:Is it possible to return the facing of a token in a targeting script?
I haven't seen any script that does.

In example i would like to see something like this:

Code: Select all

[Attacker] fires an arrow and hits [TargetName] at a [Angle] degree angle.
[Attacker] successfully bypasses [Targetname]'s shield.  
You should be able to work this out by grabbing the token locations, facing, and then working out the math.

Wiki: getTokenFacing()
Wiki: getTokenX()
Wiki: getTokenY()
Category:Mathematical_Function

That said, this would be a luxury feature... most certainly with a degree of precision you don't get on a table. Do you need that sort of precision to resolve this sort of thing? How do you do this when playing on a table?
I am making a turn based version of Mount and blade bannerlord - partially copying the combat system there, with some modifications to make it work in turn based game play.
Once the combat system is done I will add RPG elements mainly from D&D.

The angles are calculated in so far 4 situations:
a) Ambushes
b) When a target is "pinned" by an aggressive opponent
c) When a target is targeting another unit
d) The target is routed or fleeing

The steeper the angle - the lower the chance of the target being able to spot or defend the incoming attack.

If you could help me out on this one I would be extremely thankful!

imB_YipMan
Kobold
Posts: 15
Joined: Mon Oct 23, 2017 8:56 am

Re: How to get target facing data?

Post by imB_YipMan »

For those interested in calculating offset between an Attacker and a Defender, you can use this code (Probably better ways to do it, but there is no similar code available as I know)!

Code: Select all

<TARGETTING DATA>


<Get player ID and Facing >
[h:PlayerID = currentToken()]
[h:PlayerFacing = getTokenFacing(PlayerID)]


<Get attacker ID & Relative Offset>
[h: EnemyFacing = getTokenFacing(SelectedTargetID)]

[h,if(EnemyFacing > 0), CODE: {
[h:RelativeAngle = (180-abs(EnemyFacing))*(-1)] 
};{
[h:RelativeAngle = (180-abs(EnemyFacing))] 
}]





[h,if(abs(PlayerFacing - RelativeAngle) < 180), CODE: {  
[EnemyAttackAngle = PlayerFacing - RelativeAngle]
};{

[h,if(abs(PlayerFacing-RelativeAngle) > 0), CODE: {
[EnemyAttackAngle =(180+ (180- abs (PlayerFacing - RelativeAngle)))* (-1) ]
};{
[EnemyAttackAngle = 180- abs (PlayerFacing - RelativeAngle)]
}]

}]
[h:EnemyAttackAngle = abs(EnemyAttackAngle)] 

<hr>
Player facing: [PlayerFacing] <br>
Enemy facing: [EnemyFacing]<br>
Relative angle: [RelativeAngle]<br>
The resulting angle is: [EnemyAttackAngle]<br>



Post Reply

Return to “Requests for HELLLLP!”