A_ItemSpawn() Problem

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Zajo
Posts: 88
Joined: Sun Apr 23, 2006 7:00 am

A_ItemSpawn() Problem

Post by Zajo »

Why does this not spawn an imp in front of the warlock?

Code: Select all

actor Warlock : Archvile 30001
{
	speed 12
	painchance 40
	
	states
	{
		Missile:
			VILE G 0 bright A_VileStart
			VILE G 10 bright A_FaceTarget
			VILE H 8 bright A_SpawnItem("DoomImp", 0, 0, 1, 0)
			VILE IJKLMN 8 bright A_FaceTarget
			VILE O 8 bright
			VILE P 20 bright
			goto See
	}
}
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: A_ItemSpawn() Problem

Post by bagheadspidey »

I'm not sure about this, but maybe try spawning it a little farther away?
User avatar
Zajo
Posts: 88
Joined: Sun Apr 23, 2006 7:00 am

Re: A_ItemSpawn() Problem

Post by Zajo »

That helps a bit, but the documentation says that 0 means to spawn the thing the closest possible to the calling actor. Also, I need just that to happen, because I plan the warlock to spawn several types of monster, not just imp, and I would have to set the distance manually for every type. Is the function corrupt?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: A_ItemSpawn() Problem

Post by Matt »

A_SpawnItem only spawns if there's enough space for the object. Problem is, the check is a bit finicky and tends to err in favour of not spawning.
[wiki]A_SpawnItemEx[/wiki] lets you skip the space check, among other things. Don't be surprised if you get monsters stuck in walls or other solid actors, though...
User avatar
Zajo
Posts: 88
Joined: Sun Apr 23, 2006 7:00 am

Re: A_ItemSpawn() Problem

Post by Zajo »

That's why I'd never use such a function, or better said, the option to skip the check.
User avatar
Unknown_Assassin
Posts: 2468
Joined: Wed Apr 12, 2006 5:17 pm
Location: Where dead carcasses lie
Contact:

Re: A_ItemSpawn() Problem

Post by Unknown_Assassin »

The best way I can think of this is to make the Archvile make a projectile and uses A_CustomMissile. That projectile can then spawn a monster.

If you want an example, check the Imp Warlord in the Monster Resource Wad

MRW
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: A_ItemSpawn() Problem

Post by Matt »

The projectile stores its owner as a hate target, so the spawned monster will either attack the warlock or (if it can't target the warlock) stand there until it sees a player.
User avatar
Unknown_Assassin
Posts: 2468
Joined: Wed Apr 12, 2006 5:17 pm
Location: Where dead carcasses lie
Contact:

Re: A_ItemSpawn() Problem

Post by Unknown_Assassin »

Vaecrius wrote:The projectile stores its owner as a hate target, so the spawned monster will either attack the warlock or (if it can't target the warlock) stand there until it sees a player.
I just test it. The Bat Familiar and Dragon Familiar that were spawned didn't hurt the Imp Warlord.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: A_ItemSpawn() Problem

Post by Matt »

Unknown_Assassin wrote:I just test it. The Bat Familiar and Dragon Familiar that were spawned didn't hurt the Imp Warlord.
It custommissiles a dummy actor that then custommissiles the familiar. Try it with the monster targeting another monster, or move so that the familiar doesn't spawn facing you - that's the problem I'm thinking about.

As well, the custommissile always spawns the actor (i.e., it never does the A_SpawnItem check); the spawned actor just dies instantly if it's stuck.
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Re: A_ItemSpawn() Problem

Post by TheDarkArchon »

Vaecrius wrote:
Unknown_Assassin wrote:I just test it. The Bat Familiar and Dragon Familiar that were spawned didn't hurt the Imp Warlord.
It custommissiles a dummy actor that then custommissiles the familiar. Try it with the monster targeting another monster, or move so that the familiar doesn't spawn facing you - that's the problem I'm thinking about.

As well, the custommissile always spawns the actor (i.e., it never does the A_SpawnItem check); the spawned actor just dies instantly if it's stuck.
A note on this: If you do decide to do this, then you need to have the first death state have A_Die to handle failed spawns properly.
User avatar
Unknown_Assassin
Posts: 2468
Joined: Wed Apr 12, 2006 5:17 pm
Location: Where dead carcasses lie
Contact:

Re: A_ItemSpawn() Problem

Post by Unknown_Assassin »

Vaecrius wrote:Try it with the monster targeting another monster, or move so that the familiar doesn't spawn facing you - that's the problem I'm thinking about.
Whoops. The Imp Warlord was a bad example. I was actually thinking of the DESentinel. It uses A_CustomMissile.
Locked

Return to “Editing (Archive)”