Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Maths and angles question #5580
07/13/01 07:07
07/13/01 07:07
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
This is quite basic, I think, but for some reason I just can't get my head around it:

I have a fighter who can block, but of course he shouldn't be able to block when another fighter comes up behind him. So basically all I want to do is have it so that if the attacker is within the range -40 degrees to +40 degrees in front of the player (ie player's blocking range) and player's blockmode is on, he blocks, otherwise he gets hurt. I tried subtracting you.pan from my.pan and vice versa (you is set to the other player) and trying a number of conditions (eg. if(you.pan-my.pan>260)&&(you.pan-my.pan<100)...argh), but I'm missing something...

Thanks,
Keith


Re: Maths and angles question #5581
07/13/01 21:05
07/13/01 21:05

A
Anonymous
Unregistered
Anonymous
Unregistered
A



ok, there may be other solutions, but i'd tale this one:

vec_set(dirVec, fighter2.pos);
vec_sub(dirVec, fighter1.pos); // vector to fighter2

to_angle(dirAng,dirVec); // recieve the angles

if (abs(ang(dirAng.pan - fighter1.pan)) < maxPan) { call BlockHim; }
/* if the absolute (degree) difference of the looking direction and the enemy's direction is smaller than the maximal difference, you may block him */

// not tested


Re: Maths and angles question #5582
07/13/01 22:23
07/13/01 22:23
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
Thank you! That works brilliantly.

Cheers,
Keith



Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1