ZScript Help: NienerWiener Template Spawning Modification [RESOLVED]

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.

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!)
Psychojack88
Posts: 54
Joined: Sat May 07, 2022 10:12 pm
Graphics Processor: nVidia (Modern GZDoom)

ZScript Help: NienerWiener Template Spawning Modification [RESOLVED]

Post by Psychojack88 »

Working on a companion mod and am trying to improve the spawning of a companion. At the moment the companion spawns exactly onto the same position of the player position. I just want to offset it to the back of the player or to the side.

This is the spawning handler code from a sample of one of NienerWiener's template code for which I based the companion on.

Code: Select all

Class FriendDoomGuySpawnHandler : EventHandler
{
	Override Void PlayerEntered(PlayerEvent e)
	{
		Let pl = players[e.PlayerNumber].mo;
		
		let dke = pl.Spawn("NNR_FriendEY",pl.pos,ALLOW_REPLACE);
		If(dke)
		{
			dke.Master = pl;
			dke.Translation = pl.Translation;
			dke.A_FaceMaster();
		}
	}
}
Currently this spawns the companion exactly onto the exact same position of the player, but can easily get in the way as soon as you play the more hectic maps.

Anyone know how to make the spawning position offset a little away from the player position? This is to prevent the player screen from being needlessly obscured, which can be annoying and intrusive for players on more hectic maps or wads where immediate reactions are necessary. Any help would be greatly appreciated. Thanks in advance!
Psychojack88
Posts: 54
Joined: Sat May 07, 2022 10:12 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: ZScript Help: NienerWiener Template Spawning Modification [RESOLVED]

Post by Psychojack88 »

Never mind, I just went to the spawner and added a little (x,y,z) to the player position. Solved the problem right there. 😅

Return to “Scripting”