Author Topic: function WhereShot(Shoter, Victim: Byte; r: single): string;  (Read 1690 times)

0 Members and 1 Guest are viewing this topic.

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
function WhereShot(Shoter, Victim: Byte; r: single): string;
« on: February 22, 2014, 10:07:55 am »
I created a function that returns the direction of the shot. I would like to ask you to test it because I wrote it on my smartphone and I can not test it.

function WhereShot(Shoter, Victim: Byte; r: single): string;
Shoter - ID shoter
Victim - ID victim
R - Radius ( I do not have a computer for testing to determine exactly so I put it, the picture below should explain what's going on. Please determine the optimal radius.)
 

What function returns:
UP, DOWN, RIGHT, LEFT
RIGHTUC - Right upper corner
RIGHTBC - Right bottom corner
LEFTUC - Left upper corner
LEFTBC - Left bottom corner

What I see application? I think the most interesting are BloodHUD (DrawText + my function). But I DID it that are needed to test the position of the text (characters: / | _).

Code: [Select]
function WhereShot(Shoter, Victim: Byte; r: single): string;
begin
//Gora - Up
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')>GetPlayerStat(Victim,'y')) then Result := 'UP';
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')>GetPlayerStat(Victim,'y')) then Result := 'UP';
//Dol - Down
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')<GetPlayerStat(Victim,'y')) then Result := 'DOWN';
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')<GetPlayerStat(Victim,'y')) then Result := 'DOWN';
//Prawa - Right
if (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')+r)) and (GetPlayerStat(Shoter,'x')>GetPlayerStat(Victim,'x')) then Result := 'RIGHT';
if (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')-r)) and (GetPlayerStat(Shoter,'x')>GetPlayerStat(Victim,'x')) then Result := 'RIGHT';
//Lewa - Left
if (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')+r)) and (GetPlayerStat(Shoter,'x')<GetPlayerStat(Victim,'x')) then Result := 'LEFT';
if (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')-r)) and (GetPlayerStat(Shoter,'x')<GetPlayerStat(Victim,'x')) then Result := 'LEFT';
//Prawy gorny rog - Right upper corner
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')+r)) then Result := 'RIGHTUC';
//Prawy dolny rog - Right bottom corner
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')-r)) then Result := 'RIGHTBC';
//Lewy dolny rog - Left bottom corner
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')-r)) then Result := 'LEFTBC';
//Lewy gorny rog - Left upper corner
if (GetPlayerStat(Shoter, 'x')<=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')+r)) then Result := 'LEFTUC';
end;
« Last Edit: February 22, 2014, 05:51:16 pm by dominikkk26 »

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #1 on: February 22, 2014, 04:27:30 pm »
comma (',')

EDIT:

Code: [Select]

function WhereShot(Shoter, Victim: Byte; r: single): string;
begin

//Gora - Up
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')>GetPlayerStat(Victim,'y')) then Result := 'UP';
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')>GetPlayerStat(Victim,'y')) then Result := 'UP';

//Dol - Down
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')<GetPlayerStat(Victim,'y')) then Result := 'DOWN';
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')<GetPlayerStat(Victim,'y')) then Result := 'DOWN';

//Prawa - Right
if (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')+r)) and (GetPlayerStat(Shoter,'x')>GetPlayerStat(Victim,'x')) then Result := 'RIGHT';
if (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')-r)) and (GetPlayerStat(Shoter,'x')>GetPlayerStat(Victim,'x')) then Result := 'RIGHT';

//Lewa - Left
if (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')+r)) and (GetPlayerStat(Shoter,'x')<GetPlayerStat(Victim,'x')) then Result := 'LEFT';
if (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')-r)) and (GetPlayerStat(Shoter,'x')<GetPlayerStat(Victim,'x')) then Result := 'LEFT';

//Prawy gorny rog - Right upper corner
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')+r)) then Result := 'RIGHTUC';

//Prawy dolny rog - Right bottom corner
if (GetPlayerStat(Shoter,'x')>=(GetPlayerStat(Victim,'x')+r)) and (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')-r)) then Result := 'RIGHTBC';

//Lewy dolny rog - Left bottom corner
if (GetPlayerStat(Shoter,'x')<=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')<=(GetPlayerStat(Victim,'y')-r)) then Result := 'LEFTBC';

//Lewy gorny rog - Left upper corner
if (GetPlayerStat(Shoter, 'x')<=(GetPlayerStat(Victim,'x')-r)) and (GetPlayerStat(Shoter,'y')>=(GetPlayerStat(Victim,'y')+r)) then Result := 'LEFTUC';
end;


DarkCrusade

  • Guest
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #2 on: February 22, 2014, 06:56:55 pm »
May I ask in which function this would be called?

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #3 on: February 23, 2014, 03:35:31 am »
There are no plans to change its name, but if you want (For my weak English, the name does not agree with) Suggest different.

I would like to ask you to determine the appropriate radius, I do not have the possibility for such tests.

DarkCrusade

  • Guest
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #4 on: February 23, 2014, 04:31:57 am »
Alright, let's do this nice and slow:

1) Do you want this to be a new function which would be implemented to Soldat or............
2) .. do you want to call this in an existing function, as I already asked in my first comment.

Offline Akinaro

  • Flagrunner
  • ****
  • Posts: 749
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #5 on: February 23, 2014, 05:53:29 am »
looking at this:
Quote
What I see application? I think the most interesting are BloodHUD (DrawText + my function). But I DID it that are needed to test the position of the text (characters: / | _).


Its seems that he just post it as an "Idea" that could be used with other scripts.
Something like add-on with info from what direction someone shoot at you.

Idea is nice, it could be good in Realistic Mode with show you info where shooter is.
« Last Edit: February 23, 2014, 08:26:43 am by Akinaro »

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: function WhereShot(Shoter, Victim: Byte; r: single): string;
« Reply #6 on: February 23, 2014, 07:14:38 am »
Exactly as it says akinaro