Page 1 of 1

[SOLVED] Antiblocking ACS problem...

Posted: Sun Jun 08, 2014 9:57 pm
by Vincent(PDP)
I've tried to make an antiblocking script for when a solid object is spawned on my map.
When the object is spawned it checks all players' coordinates and teleports them if they're blocked by the object.
For some reason the players aren't teleported when blocked by it.

-= ACS Code =-

Code: Select all

Script 18 (Int x, Int y, Int z)
{
    For(Int P=0; P <3 2; P++)
    {
    Int TeleportMe = False;
        If(GetActorX(PLAYER_TID+P) < (x + 60.0) && GetActorX(PLAYER_TID+P) > (x + 62.0))
        {
            TeleportMe = True;
        }
        Else If(GetActorX(PLAYER_TID+P) > (x - 60.0) && GetActorX(PLAYER_TID+P) < (x - 62.0))
        {
            TeleportMe = True;
        }
        
        If(GetActorY(PLAYER_TID+P) < (y + 60.0) && GetActorY(PLAYER_TID+P) > (y + 62.0))
        {
            TeleportMe = True;
        }
        Else If(GetActorY(PLAYER_TID+P) > (y - 60.0) && GetActorY(PLAYER_TID+P) < (y - 62.0))
        {
            TeleportMe = True;
        }
        
        If(TeleportMe == True)
        {
            TeleportOther(PLAYER_TID+P, 800+P, Yes);
            TeleportMe = False;
        }
    }
}
-= DECORATE Code =-

Code: Select all

Actor BrokenTree1 30303
{
//$Category Visual Vincent's Stuff
  height 97
  radius 65
  +SOLID
  +FORCEYBILLBOARD
  states
  {
  Spawn:
  TRBR A 1
  TRBR A 1 ACS_ExecuteAlways(18, 0, x, y, z)
  TRBR A -1
  Stop
  }
}
I've tried with a print message, the script is executed.

Anybody have any suggestions?

RE: Antiblocking ACS problem...

Posted: Sun Jun 08, 2014 11:01 pm
by Konda
I don't really understand the logic behind your ACS code, especially this part:

Code: Select all

If(GetActorX(PLAYER_TID+P) < (x + 60.0) && GetActorX(PLAYER_TID+P) > (x + 62.0))
So, if x = 0, the if statement is checking if the player's x coordinate is smaller than 60 and bigger than 62? At the same time? wat?

If you want to determine the distance between 2 points/actors based on x and y coordinates, this is how you do it:

Code: Select all

int distance = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
That code calculates the distane between points A(x1,y1) and B(x2, y2), based on x and y coordinates of the points. sqrt is the square root function. Zandronum doesn't have the sqrt ACS function yet, but you can still make it in ACS. The implementation can be found here: http://zdoom.org/wiki/Sqrt

If you want to calculate the distance between 2 actors considering all 3 coordinates (x, y, and z), do this:

Code: Select all

int distance = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1));

RE: Antiblocking ACS problem...

Posted: Sun Jun 08, 2014 11:44 pm
by Vincent(PDP)
(facepalm) I'm so stupid... It was meant to check if the player's x coordinates were smaller than x + 60 and bigger than x - 62. Not x + 62.
No wonder why it didn't work.

Well I wanted the script to see if you're inside the objects' "hitbox?".
The biggest radius of the objects is 90, but I added a little more. So I tried to make it calculate if you were inside it's box. (For example: x = 0, It checks if the player's x coordinate is more than -62 and less than 60. x is the object's x coordinate)

I'll try more tomorrow and see if I can get it working. You distance script can be useful though. Thanks for the reply. ;)

RE: Antiblocking ACS problem...

Posted: Mon Jun 09, 2014 3:29 pm
by Vincent(PDP)
Ok I got it working 25%...
Now, it only teleports you if both x and y coordinates are less than 0.

Code: Select all

Script 18 (Int x, Int y, Int z)
{
    PrintBold(d:(x + 60));
    For(Int P=0; P<1; P++)
    {
    Int x2 = GetActorX(PLAYER_TID+P);
    Int y2 = GetActorY(PLAYER_TID+P);
    Int x3 = x * 65536;
    Int y3 = y * 65536;

    Int TeleportMe = False;
    
        If(x2 < 0.0 && y2 < 0.0)
        {
            If(x2 <= (x3 + 7864320) && x2 >= (x3 - 7864320) && y2 <= (y3 + 7864320) && y2 >= (y3 - 7864320))
            {
                TeleportMe = True;
            }
        }
        Else If(x2 >= 0.0 && y2 >= 0.0)
        {
            If(x2 >= (x3 + 7864320) && x2 <= (x3 - 7864320) && y2 >= (y3 + 7864320) && y2 <= (y3 - 7864320))
            {
                TeleportMe = True;
            }
        }
        Else If(x2 >= 0.0 && y2 < 0.0)
        {
            If(x2 >= (x3 + 7864320) && x2 <= (x3 - 7864320) && y2 <= (y3 + 7864320) && y2 >= (y3 - 7864320))
            {
                TeleportMe = True;
            }
        }
        Else If(x2 < 0.0 && y2 >= 0.0)
        {
            If(x2 <= (x3 + 7864320) && x2 >= (x3 - 7864320) && y2 >= (y3 + 7864320) && y2 <= (y3 - 7864320))
            {
                TeleportMe = True;
            }
        }
        
        If(TeleportMe == True)
        {
            TeleportOther(PLAYER_TID+P, 800+P, Yes);
            TeleportMe = False;
        }
    }
}

RE: Antiblocking ACS problem...

Posted: Mon Jun 09, 2014 6:43 pm
by Vincent(PDP)
Nobody can help? :(

bump

EDIT:

Fixed it! Finally!