Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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