Change initial actor movement direction

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!)
User avatar
JUSSOMONE
Posts: 35
Joined: Fri Oct 07, 2022 8:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia (Modern GZDoom)

Change initial actor movement direction

Post by JUSSOMONE »

Greetings everyone, I've noted a thing from the engine that has been bugging me...when you summon monsters from the console command they seem to always face and move to one specific direction (until purposely changing it), most of the time to the right from the automap perspective.

So...

The problem is...whatever I want to spawn an actor with A_SpawnItemEx and set a random angle (0 - 359) his initial direction angle changes but right afterwards, he returns his original spawn direction movement...moving to (again) one specific direction...it's very frustating, since I've made a "hacky" system in spawning invisible dummy actors from other actors with extreme speed to wander about the map and finally spawning another one. It was meant to be dynamic and random, but it's complicated when they have a tendency to go to one specific direction in their initial spawn state.

Here are the images

Image
The arrow indicates their initial tendency to go

Image
Image

You can see by the last two images what really happens...

and finally the code to the dummy actors

Code: Select all


//This one i've put in the PostBeginPlay of the five visible actors on the screen

A_SpawnItemEX("Dummy_SentrySpawner", 0.0, 0.0, 0.0, 0, 0, 0, random(0, 359.9), SXF_NOCHECKPOSITION);

/////////////////////////

//THIS IS THE INVISIBLE DUMMY SPAWNER

Class Dummy_SentrySpawner : Actor
{
    int Wander_Timer;
    
	Default
	{
	      // PROPERTY
	          Health                  999999;
		  Radius                  12;
		  Height                  50;
		  Speed                   50; //999
		  
		  MaxDropOffHeight        48; //x2.0
                  MaxStepHeight           48; //x2.0
		  
             // FLAGS
		  //MONSTER;
		  -SOLID;
		  +ISMONSTER;
		  +THRUACTORS;
		  -COUNTKILL;
		  -SHOOTABLE;
		  -CANUSEWALLS;
		  -CANPUSHWALLS;
		  -ACTIVATEMCROSS;
		  +NOTELEPORT;
	}
	States
	{
	Spawn:
		  TNT1 A 1 A_Wander; 
		  TNT1 A 0 A_SentryCanSpawn();
		  TNT1 A 0
		  {
		        Wander_Timer++; 
				
				if(Wander_Timer == 35) // 1 secs overall in "frozen" time
				{
				      Destroy(); //Removes if he doesn't met conditions until then.
				}
		  }
		  Loop;
	SpawnSentry:
		  TNT1 A 0 A_SpawnItemEx("WehrmachtSentryGunBase", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
		  Stop;
	}
	Void A_SentryCanSpawn()
	{		  
		  if(!CheckProximity("Dummy_SentrySpawner", 1024, 1, CPXF_ANCESTOR|CPXF_CHECKSIGHT) && !CheckProximity("WehrmachtSentryGunBase", 1024, 1, CPXF_ANCESTOR|CPXF_CHECKSIGHT) && GetZAt(256, 0) == floorz && 
                  GetZAt(-256, 0) == floorz && GetZAt(0, 256) == floorz && GetZAt(0, -256) == floorz)
		  {
			SetStateLabel("SpawnSentry");
		  }
		  else
		  {
		        return;
		  }
	}
	override void PostBeginPlay()
	{
		super.PostBeginPlay();
		
		// Set Wander timer to 0 so it can count the steps until enough
		int Wander_Timer = 0;
    }
}

I ask if anyone out there can help me with this...it's a mod I've been working on about a year for now and it's finally reaching it's final alpha stages...I would be very grateful in advance for it.

Return to “Scripting”