Spawn function is not spawning in x and y coordinate I want

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!)
Post Reply
Paladin
Posts: 2
Joined: Tue Mar 12, 2019 6:41 pm

Spawn function is not spawning in x and y coordinate I want

Post by Paladin »

First, sorry that I'm not just noob in this forum, but also in scripting ACS.
I do tried to use the "search" on forum, it appeared lot of pages and going through I have found nothing related to my problem, sorry if I skipped a thread with same subject.

So, I saw the zdoom wiki about the Spawn function and it have this nice feature of spawning health bonus in a circle around the player...
... The problem is, when I used this code, the math does change the 'x' and 'y' value, but the object spawn exactly in the middle of the actor tag. The code is the following:

Code: Select all

// Spawn a circle of Health Bonus in a radius 64 around a teleport spawn:
script 12 (void)
 {
    print(s: "This is not working strangely...");
    int Total = 10;
    for (int n = 0; n < Total; ++n)
    {
       int Angle = FixedDiv(n, Total - 1);
       int x = GetActorX(21) + FixedMul(cos(Angle), 64);
       int y = GetActorY(21) + FixedMul(sin(Angle), 64);
       print(s: "x: ", d: x, s: " y: ", d: y);
       int z = GetActorFloorZ(21);
       Spawn("HealthBonus", x, y, z);
       delay(16);
    }  
 }
I tried different radius, different actor placement, GetActorCeilingZ - 8.0 (don't even spawn), on the tid 0, and nothing worked... :/
---

So well, it does spawn the health bonus, but as I said, only in the exactly point of the tagged actor, yet, when printed, the console shows differences between 'x' and 'y', here is an image:
Spoiler:
---

EDIT:
Sorry the late edit, but well, I have no answer yet, but I wanted to put more info, the port I'm using is the last version of "Zandronum" and I'm making the map with "(ZDoom) Doom in Hexen format".
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Spawn function is not spawning in x and y coordinate I w

Post by Graf Zahl »

Your problem is in the FixedMul calls. 64 is an integer not a fixed point number, to get a fixed point number you must pass 64.0.
Paladin
Posts: 2
Joined: Tue Mar 12, 2019 6:41 pm

Re: Spawn function is not spawning in x and y coordinate I w

Post by Paladin »

It worked, thank you! :)
Such a detail...
Post Reply

Return to “Scripting”