Jump to content
  • 0

A couple of quick ZScript questions


Rifleman

Question

Hi guys,

 

I need some advice. Tried to search, tried using AI, but no dice. I'm sure some genius here will know right away...:)

First, I see code like this a lot, where a random number is generated using the name of the class and I don't get how it works, what numbers are 'being used' to pick. A piece of Heresiarch's code as an example:
 

void A_StopBalls()
    {
        int chance = random[Heresiarch]();
        args[3] = SORC_STOPPING;                // stopping mode
        args[1] = 0;                            // Reset rotation counter

        if ((args[0] <= 0) && (chance < 200))
        {
            StopBall = "SorcBall2";    // Blue
        }
        else if((health < (SpawnHealth() >> 1)) && (chance < 200))
        {
            StopBall = "SorcBall3";    // Green
        }
        else
        {
            StopBall = "SorcBall1";    // Yellow
        }
    }

 

And second, again using Heresiarch's code - is there a way to use this function, but set the z offset to spawn the projectile higher?

 

mo = parent.SpawnMissileAngle(cls, ang1, 4.);

 

I know there is SpawnMissileAngleZ function, but there is no description on the wiki and I am not sure it's supposed to do what I think. No matter what I set the first argument of it to, I see no projectiles in game.

 

Thanks in advance for any help!

Share this post


Link to post

1 answer to this question

Recommended Posts

  • 0

 

34 minutes ago, Rifleman said:

First, I see code like this a lot, where a random number is generated using the name of the class and I don't get how it works, what numbers are 'being used' to pick.

 

random() without parameters should return an integer between 0 and 255.

The [Heresiarch] identifier just make the RNG call independent on other RNG calls (that have different identifier or no identifier).

 

 

35 minutes ago, Rifleman said:

And second, again using Heresiarch's code - is there a way to use this function, but set the z offset to spawn the projectile higher?

 

You can simply use A_SpawnProjectile, which is customizable and well documented on wiki. (use CMF_AIMDIRECTION flag to make it behave more like SpawnMissileAngle).

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...