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!)
I saw that, but it was several months ago so I thought mayb they were here
And also plz, somebody , can one register eventhandlers from ZScript rather than MAPINFO
EDIT 2: Why can't I return null for a String function? How would I do that? EDIT 3: Also, when I try replacing \n in a string, if \n is inside a const array it won't work
i.e
Seems like backslash expressions lose their meaning in a constant array. Should I file a bug report or is there something I'm missing?[/s] I'm really tired right now
Weird that there were no errors from having no commas in the array, though.
EDIT 4: Is there a way to evaluate a string as a math expression, i.e: "100/3+4"
Zscript is still documented not enough.
1. What is the difference between MonsterMove() and TryWalk()?
2. MonsterMove() and TryWalk() works like A_Chase with CHF_DONTTURN flag. If monster changes angle, it continues to move in the original direction. How to set this direction?
How work with DoEffect?
I want item that take every half of second one plasma cell and give at whole seond one point of health, to maximum health. How make it?
Uberkreatur wrote:Zscript is still documented not enough.
1. What is the difference between MonsterMove() and TryWalk()?
2. MonsterMove() and TryWalk() works like A_Chase with CHF_DONTTURN flag. If monster changes angle, it continues to move in the original direction. How to set this direction?
I'm not an expert on this, but I believe that MonsterMove() just tries to move an actor in its current direction (movedir). It returns true if the actor is able to move, and false it it's blocked. If you look in gzdoom.pk3, you'll see that TryWalk is defined as
bool TryWalk ()
{
if (!MonsterMove ())
{
return false;
}
movecount = random[TryWalk]() & 15; // Sets movecount to a random number less than 16
return true;
}
movecount is a countdown used by A_Chase. When it reaches 0, the actor either attacks, or if it can't, it randomly changes direction.
Here's roughly what A_Chase did in the original Doom source code (translated into ZScript):
Does somebody know how to clear a midtexture from a linedef with ZScript?
I have some midtexture lights on several linedefs. Now switching the lights on works as follows:
TextureId textlight = TexMan.CheckForTexture ("ZLIGHTLM", TexMan.Type_Any);
int linenum = 0;
int LightLineTag = 666;
LineIdIterator lit = LineIdIterator.Create(LightLineTag);
while ((linenum = lit.Next()) >= 0)
{
level.lines[linenum].sidedef[1].SetTexture(1, textlight); // sidedef[1] = back
}
But I don't know how to switch them off.
[EDIT] Found it: (just similar to the hack commonly used in ACS SetLineTexture with "-"):
assigning the TextureId like this before using the SetTexture:
Does zscript have pointers for children? And if have, how they named?
I make imp that after some damage split to 7-13 its shadow_part, which count as his children, who after death kill all it sibling and warp instead of oneself it master.
I want add to that imp ability warp to one randomly pick shadow_image child. How make it?
Direct pointers to children don't exist, rather each child has a pointer to its master. The "canon" way to do get all children (used by internal functions like A_GiveToChildren) is to use a ThinkerIterator and check if the "master" pointer is equal to something.
The ZScript syntax is a bit different than the C++ example above, so here's a quick example on how to do this (from Eriguns, copy+pasted from here, with new comments):
action void X_DetonateBolts()
{
// Eriguns's Irebolt weapon fires sticky bolts that can be remotely detonated with
// Altfire. When each bolt is fired, its "master" pointer is set to the player that
// fired it. This function handles finding all the child bolts and detonating 'em.
// Firstly, since we know that all children will be of class "IreboltShot", we can
// explicitly tell our iterator that we're only looking for actors of this class
// for a bit of a performance boost.
ThinkerIterator boltIterator = ThinkerIterator.Create("IreboltShot");
IreboltShot bolt;
// Do the iteration. boltIterator.Next() returns an Actor, so we want to cast it to
// IreboltShot in order to call a custom function on it.
while(bolt = IreboltShot(boltIterator.Next() ) ) {
// Here, I'm checking that the bolt's "master" is the player; since I'm calling
// the function from the weapon, "self" is the player. Most likely, you'll
// be adding this function to your custom imp class, so "self" will be the imp
// itself too, meaning this is probably the check you're looking for.
if(bolt.master == self) {
// Do your special logic here.
bolt.X_BoltDetonate();
}
}
}
I'm trying to fetch the distance to the wall an actor is facing towards, so far I've looked at AimLineAttack and BlockLinesIterator but I'm not sure how to use either to fetch the desirable wall and the distance.
Anyone got ideas or suggestions for the most optimal way for this?
And how randomly pick up one child from thinkeriterator list?
If I correct, after activating thinker(Le Penseur)iterator it run all over the map with notebook and pencil and ask every single object "is you actor class "shadow_split"?"
If he receive "true" it write it in notebook and continue, else just continue.
After it check all map it start execute custom action.
If I adapt it code as is