[SOLVED] Antiblocking ACS problem...

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

[SOLVED] Antiblocking ACS problem...

#1

Post by Vincent(PDP) » Sun Jun 08, 2014 9:57 pm

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?
Last edited by Vincent(PDP) on Mon Jun 09, 2014 6:51 pm, edited 1 time in total.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Konda
Forum Regular
Posts: 487
Joined: Thu Jun 07, 2012 5:22 pm

RE: Antiblocking ACS problem...

#2

Post by Konda » Sun Jun 08, 2014 11:01 pm

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));
Last edited by Konda on Sun Jun 08, 2014 11:10 pm, edited 1 time in total.

Code: Select all

<Synert> fuck
<Synert> plugged in my memory stick and got a bsod

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: Antiblocking ACS problem...

#3

Post by Vincent(PDP) » Sun Jun 08, 2014 11:44 pm

(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. ;)
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: Antiblocking ACS problem...

#4

Post by Vincent(PDP) » Mon Jun 09, 2014 3:29 pm

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;
        }
    }
}
Last edited by Vincent(PDP) on Mon Jun 09, 2014 3:30 pm, edited 1 time in total.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: Antiblocking ACS problem...

#5

Post by Vincent(PDP) » Mon Jun 09, 2014 6:43 pm

Nobody can help? :(

bump

EDIT:

Fixed it! Finally!
Last edited by Vincent(PDP) on Mon Jun 09, 2014 6:51 pm, edited 1 time in total.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Post Reply