RPTools.net

Discussion and Support

Skip to content

It is currently Fri Nov 24, 2017 1:32 pm 






Reply to topic  [ 4 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Mon Oct 23, 2017 7:56 am
Posts: 9
 Post subject: How to get target facing data?
PostPosted: Wed Oct 25, 2017 7:59 pm 
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:
[Attacker] fires an arrow and hits [TargetName] at a [Angle] degree angle.
[Attacker] successfully bypasses [Targetname]'s shield. 


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3775
Location: MD
 Post subject: Re: How to get target facing data?
PostPosted: Wed Oct 25, 2017 10:02 pm 
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:
[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."


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon Oct 23, 2017 7:56 am
Posts: 9
 Post subject: Re: How to get target facing data?
PostPosted: Wed Nov 08, 2017 8:59 pm 
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:
[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!


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon Oct 23, 2017 7:56 am
Posts: 9
 Post subject: Re: How to get target facing data?
PostPosted: Sun Nov 19, 2017 4:54 pm 
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:
<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>




Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 4 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman