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

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

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

Postby Paladin » Tue Mar 12, 2019 8:12 pm

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 allExpand view
// 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".
Paladin
 
Joined: 12 Mar 2019

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

Postby Graf Zahl » Wed Mar 13, 2019 2:25 am

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.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Paladin » Sat Mar 16, 2019 6:37 am

It worked, thank you! :)
Such a detail...
Paladin
 
Joined: 12 Mar 2019


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest