OK, been away for a few days because a storm took down my electricity and my Internet.
This is what I have by way of a couple of test actors. All actor names, and everything else too, are subject to change. Could someone who understands ZScript a bit better take a look and see where it can be improved?
The intention is to be able to place an actor that spawns a flock of boids which then stay centred on the spawning actor. i.e. it creates a decorative flock of boids.
At present it seems to work, but it's probably clumsily coded and error-filled.
Code: Select all
Class NJBoider : Actor
POSS A 0;
POSS A 0 A_JumpIf(args == 0, "BoidsIsNull");
POSS A 1 Bright A_SetArg(4, args);
POSS A 0 Bright A_JumpIf(args == 0, "NoMoreBoids");
POSS A 0 Bright A_SpawnItemEx("NJBoid",20,0,40,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION);
POSS A 0 Bright A_SetArg(4, args - 1);
POSS A 1 A_SetArg(0, 8);
SPOS A -1;
The NJBoider actor above is the one that spawns the flock. Obviously, the final version will not be visible. I *think* I have set it up so that it reads arg0 and then spawns a number of boids equal to that arg's value. If the arg is 0, it sets itself to a default of 8. This was adapted from some old DECORATE code and I could well have made some mistakes here but, like I said, it does seem to work.
Code: Select all
Class NJBoid : HXA_Boid
Override Void Tick()
BoidFlight(MaxVelocity: 12, CloseToMaster: TRUE, DistanceFromMaster: 200);
The NJBoid actor is the boid that I want to spawn in flocks. I know that I've gone over the top with the flags - I can address that. It's the other stuff I need to check to make sure it is OK. The boids aren't flying quite how I want them to (a bit to erratic in the Z axis, a bit fast and wander a bit too far from the spawning actor), but I'm guessing I can tweak this with some more parameter changes.
I don't want these boids to die, despawn, whatever (i.e. they are a permanent decoration) but once I have things figured out, I will probably change the spawning actor so that it can be deactivated and call A_RemoveChildren. That way the flock could be despawned/respawned via ACS if need be.
The line HXA_Boid.BoidActor "NJBoider";
seems to be necessary. If I don't have that, separate flocks from different "NJBoider" actors seem to not stay separate. Is that correct? Have I used the line correctly?
So, can it be improved?