ZScript Discussion

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Do weapons and/or custominventory have their own internal Tick function when being used on the player?

I know for weapons, it's basically overlays in a nutshell that can act just like Tick.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

They have a Tick function but you shouldn't use it.
The correct place to let an item do an effect on the player is the DoEffect method.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Is Vec3Angle a relative version of Vec3Offset? I.e.

Vec3Offset is like A_Warp with WARPF_ABSOLUTEANGLE, and the absolute boolean is equivalent to adding WARPF_ABSOLUTEPOSITION.

Vec3Angle is like A_Warp without those flags (moves the actor relatively forward with x, sideways with y), though the boolean would be like adding WARPF_ABSOLUTEANGLE.

Is this correct?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

No. Vec3Angle calculates a position by adding a directional vector calculated from a given angle and a distance.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

If I have an array of colors like this:

Code: Select all

static const Color PrimaryColor[] =
{
	"Red",
	"AELimeGreen",
	"AEDarkRed",
	"AEGreenYellow",
	"AEPoo",
	"AEPutridGreen",
	"Black",
	"Blue",
	"Brown",
	"DarkGreen",
	"DimGray",
	"Gold",	//11
	"Green",
	"Grey",
	"LightSlateGray",
	"Purple",
	"Seashell2",
	"Snow3",
	"White",
	"Yellow" // 19
};
Do I need to do any sort of casting in order to pass them around from one actor to another?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

The static array contains colors, not strings. The initialization and conversion will occur at compile time.
Just: Where are AELimeGreen etx defined? Are you including a replacement for x11r6rgb.txt?
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Yes. Inside the X11R6RGB file.

Code: Select all

  0 175   0		AELimeGreen
 67   0   0		AEDarkRed
222 254 114		AEGreenYellow
135 087 051		AEPoo
 67 147  55		AEPutridGreen
 
  0  88   0		AELimeGreenD2
 34   0   0		AEDarkRedD2
111 127  57		AEGreenYellowD2
 68  44  26		AEPooD2
 17  74  28		AEPutridGreenD2
  0  50   0		AEDarkGreenD2
 50   0   0		AEDarkRedD2
 53  53  53		AEDimGreyD2
128 108   0 	AEGoldD2
 87 128  24		AEGreenYellowD2
119 115 111		AESeaShell2D2
255 255   0		AEYellowD2
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: ZScript Discussion

Post by Ed the Bat »

Had a quick question that I forgot to ask weeks ago. For the heck of it, I was converting some DECORATE in an old project (not one of mine -- NeoDoom Gold and Final NeoDoom, to be specific) to ZScript as a learning exercise, and an actor used the Teleport thing special. ZScript doesn't like this, as it has its own Teleport function with completely different parameters. Is there a simple way to convert that old DECORATE actor, or it is something that should just be redone from scratch? I always felt using the thing special was kinda hacky, anyway.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Damnit, another one I did not catch. Best wait with this, I'll have to rename the internal function then.

In general, if something clashes with an action special name, report as a bug, that isn't supposed to happen.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: ZScript Discussion

Post by Ed the Bat »

I'll keep that in mind from now on. Thanks. And for the record, leaving it in DECORATE still works, so the official versions of those projects still operate as well as they ever did.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Even weirder. It looks like the DECORATE code resolves the names differently then.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Is Touch() supposed to rely upon PICKUP and SPECIAL flags, along with health > 0? Because that's what it's doing now, and I feel this can only be useful for items.

Code: Select all

//============================================================================
//
// AActor :: Touch
//
// Something just touched this actor. Normally used only for inventory items,
// but some Strife monsters also use it.
//
//============================================================================
But...

Code: Select all

// Check for special pickup
    if ((thing->flags & MF_SPECIAL) && (tm.thing->flags & MF_PICKUP)
        // [RH] The next condition is to compensate for the extra height
        // that gets added by P_CheckPosition() so that you cannot pick
        // up things that are above your true height.
        && thing->Z() < tm.thing->Top() - tm.thing->MaxStepHeight)
    { // Can be picked up by tmthing
        P_TouchSpecialThing(thing, tm.thing);    // can remove thing
    }
Elsewhere...

Code: Select all

void P_TouchSpecialThing (AActor *special, AActor *toucher)
{
    double delta = special->Z() - toucher->Z();

    // The pickup is at or above the toucher's feet OR
    // The pickup is below the toucher.
    if (delta > toucher->Height || delta < MIN(-32., -special->Height))
    { // out of reach
        return;
    }

    // Dead thing touching.
    // Can happen with a sliding player corpse.
    if (toucher->health <= 0)
        return;

    //Added by MC: Finished with this destination.
    if (toucher->player != NULL && toucher->player->Bot != NULL && special == toucher->player->Bot->dest)
    {
        toucher->player->Bot->prev = toucher->player->Bot->dest;
        toucher->player->Bot->dest = NULL;
    }
    special->CallTouch (toucher);
} 
Last edited by Major Cooke on Sun Dec 11, 2016 2:29 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Yes. And this cannot be changed because it'd break the entire system.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Discussion

Post by Major Cooke »

Perhaps a different Touch then, like TouchActor that's called within PIT_CheckThing? But I suppose that too might not be doable when coming to performance.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

No, that was precisely what I was trying to avoid with CanCollideWith.

Return to “Scripting”