[ACS] Difficulty with GetActorProperty (APROP_Speed)

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Loki
Posts: 17
Joined: Wed Jul 06, 2005 6:20 pm
Location: Sigil, the City of Doors

[ACS] Difficulty with GetActorProperty (APROP_Speed)

Post by Loki »

Well, this would be my second post (I'm new here, though not to the ZDoom engine), and I'm having a great deal of difficulty getting what I thought would be a very simple script and trap to work. Essentially, it's an attempt at creating a trap which shoot plasma (or any projectiles) at the doomguy if he moves too fast. I'm not entirely sure what the speed (defined as "velocity") should be set at, but this is simply a test run, and I'm more concerned about getting it to work at all. It may be an error with the GetActorProperty() function (because I'm using it to tag the player), but I really have no idea. The script itself works simply as a combination of two linedefs running script 1 and 2, and a map spot (or three) to shoot.
Anyway, here's the code:

Code: Select all

/*
This is an attempt at making a sector that shoots plasma at the player if he is moving too fast.
This script will only work if the player's TID is set to 740.
*/

#library "BHE.acs"
#include "zcommon.acs"

int toggle;
int velocity;

script 1 (void)
{
	velocity = GetActorProperty(740, APROP_Speed);
	print(s:"your speed is ", d:velocity);	//I put this in so I could debug the script by checking my velocity int.
	toggle = 1;
	if(velocity > 32)
	{
		Thing_ProjectileIntercept(741, T_PLASMABOLT, 256, 740, 742);	
		delay(14);
		restart;
	}
	else
	{
		delay(7);
		restart;
	}
}

script 2 (void)
{
	if(toggle == 1)
	{
		ACS_Terminate(1,1);
		toggle = 0;
	}
	else
	{
		ACS_Execute(1,1,0,0,0);	
	}
}
If anyone could help me with this little dilemma, that'd be great, as I'm supposed to be coding traps and other such crap for Deathsong's Strife: BHE mod. Thanks.
User avatar
Deathsong12
Posts: 1083
Joined: Sat May 07, 2005 1:29 pm
Location: On the hunt

Post by Deathsong12 »

Remain strong, and give me my goddam lava pit!
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Post by DoomRater »

Do you have an ENTER script setting the Marine's TID to the number you need?
User avatar
Loki
Posts: 17
Joined: Wed Jul 06, 2005 6:20 pm
Location: Sigil, the City of Doors

Post by Loki »

Ummm... I wasn't entirely sure that was necessary, although it did seem to work to an extent... However, the difficulty is getting that damn GetActorProperty() function to respond when the doomguy is selected. That, and I also had a problem when I set the TID within the Thing_ChangeTID() to 0, which had it selecting the projectiles as targets, exponentially increasing the number of plasmabolts in the room. Let's just say it wasn't any fun trying to exit ZDoom. I'll see if that works, though.
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Post by DoomRater »

If you want to read the Doomguy's properties, the PLayer must have a TID, and that's set when he enters the script. By the way, it's lost at death so you also have to reset it on respawn as well.
User avatar
Deathsong12
Posts: 1083
Joined: Sat May 07, 2005 1:29 pm
Location: On the hunt

Post by Deathsong12 »

Ah. All you have to do is put the tid setting function in an OPEN script. That would circumvent the whole "exponental plasma" thing. cool. I'm not sure about the whole problem of insane velocity. Did you remove those two zombiemen from that room? Their bulletpuffs were probably setting off your linedef.
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Post by DoomRater »

IT has to be an ENTER script that sets the MArine's TID, because ENTER has an owner.
User avatar
Grubber
Posts: 1031
Joined: Wed Oct 15, 2003 12:19 am
Location: Czech Republic
Contact:

Post by Grubber »

You can't get actual movement speed of player by GetActorProperty. You have to do it via GetActorX/Y/Z.

Code: Select all

script 999 ENTER
{
    int oldX, oldY, oldZ, dX, dY, dZ, speed;

    // Change player TID to 256
    Thing_ChangeTID (0, 256);

    while (1)
    {
        // Get player's coordinates
        oldX = GetActorX (256);
        oldY = GetActorY (256);
        oldZ = GetActorZ (256);

        Delay (1);

        // Compute speed
        dX = GetActorX (256) - oldX;
        dY = GetActorY (256) - oldY;
        dZ = GetActorZ (256) - oldZ;
        speed = sqrt (dX*dX + dY*dY + dZ*dZ);

        // Do whatever you want with the speed
    }
}
You can find sqrt function here.

BTW the speed is fixed point value, e.g. speed 8 units per tic = 8.0 (not the same as 8 without .0).

(I hope it will work, it's untested)
Locked

Return to “Editing (Archive)”