Help with custom enemy behavior

Status
Not open for further replies.

Goldenhog

Wandering Protagonist
# Custom Enemy - Cold Sol

Thing 319
MAPTHINGNUM = 123
SPAWNSTATE = 1818
SPAWNHEALTH = 1
SEESTATE = 1820
SEESOUND = 0
REACTIONTIME = 8
ATTACKSOUND = 0
PAINSTATE = 0
PAINCHANCE = 0
PAINSOUND = 0
MELEESTATE = 0
MISSILESTATE = 0
DEATHSTATE = 1641
DEATHSOUND = 119
XDEATHSTATE = 0
SPEED = 393216
RADIUS = 1048576
HEIGHT = 3145728
MASS = 100
DAMAGE = 0
ACTIVESOUND = 0
RAISESTATE = 0
FLAGS = 16779781

# Spawn State - Look for player

FRAME 1818
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1819
ACTION A_Look

FRAME 1819
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1818
ACTION A_Look

# See State - Start Buzz thinker

FRAME 1820
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1821
ACTION A_SpawnObjectRelative
VAR1 = 0
VAR2 = 2097170

FRAME 1821
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 34
NEXT = 1822
ACTION A_PlaySound
VAR1 = 208
VAR2 = 1

FRAME 1822
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1823
ACTION A_SpawnObjectRelative
VAR1 = 0
VAR2 = 2097170

FRAME 1823
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 34
NEXT = 1824
ACTION A_PlaySound
VAR1 = 208
VAR2 = 1

FRAME 1824
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1825
ACTION A_SpawnObjectRelative
VAR1 = 0
VAR2 = 2097170

FRAME 1825
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 34
NEXT = 1826
ACTION A_PlaySound
VAR1 = 208
VAR2 = 1

FRAME 1826
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1827
ACTION A_SpawnObjectRelative
VAR1 = 0
VAR2 = 2097170

FRAME 1827
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 34
NEXT = 1828
ACTION A_PlaySound
VAR1 = 208
VAR2 = 1

FRAME 1828
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1829
ACTION A_BuzzFly
VAR1 = 0
VAR2 = 0

FRAME 1829
SPRITENUMBER = 244
SPRITESUBNUMBER = 1
DURATION = 1
NEXT = 1828
ACTION A_BuzzFly
VAR1 = 0
VAR2 = 0
Here is my custom enemy SOC. It works as it should - Once you pop into this guy's line of vision, he slowly spawns four SOCced spikeballs that rotate around it and it starts pursuing you until he loses track of you or you go underwater.

However, when the player steps out of its line of vision, it returns to SpawnState, which is OK, but that means that when the player is seen again, my custom enemy spawns four more spikeballs instead of just cutting straight to the chase with the 4 it had already spawned.

So, my question is: Is there any way to make it not spawn spikeballs when it sees the player if it has already done so?

(Also, how do I make it so that it can damage the player on contact but the player can't spin into it and destroy it?)
 
Last edited:
You could always have it just spawn the spikeballs immediately upon creation and never mess with them again. I'm not sure it would make much of a difference in gameplay terms. Also, if you don't need to use this enemy underwater, you could have it technically be an MF_FIRE-flag object (like the Torch) instead of an MF_ENEMY to make it damaging but indestructible.
 
You could always have it just spawn the spikeballs immediately upon creation and never mess with them again. I'm not sure it would make much of a difference in gameplay terms.

I did try to make it spawn the spikeballs once the level starts, but it doesn't make a difference because it goes back to SpawnState again once it loses sight of the player. Which means that instead of spawning 4 balls each time it sees a player, it does so each time it loses sight of a player.

Also, if you don't need to use this enemy underwater, you could have it technically be an MF_FIRE-flag object (like the Torch) instead of an MF_ENEMY to make it damaging but indestructible.

Hey, this works pretty nicely! I'll have to keep Elemental Shields and this enemy as far away from each other as possible, but thanks anyway!

And yeah, no water for this guy. That's the reason I'm using A_BuzzFly.
 
I did try to make it spawn the spikeballs once the level starts, but it doesn't make a difference because it goes back to SpawnState again once it loses sight of the player. Which means that instead of spawning 4 balls each time it sees a player, it does so each time it loses sight of a player.

The only thing I can think of, then, is this: Have a seperate invisible object that immediately spawns your enemy whenever it first spawns. Place this object on the map instead of your enemy. After it spawns the enemy, this invisible object should create the four spikeballs itself and then self-destruct, ensuring that for each enemy spawned only one set of spikeballs can be created.
 
The only thing I can think of, then, is this: Have a seperate invisible object that immediately spawns your enemy whenever it first spawns. Place this object on the map instead of your enemy. After it spawns the enemy, this invisible object should create the four spikeballs itself and then self-destruct, ensuring that for each enemy spawned only one set of spikeballs can be created.

Thanks for the suggestion, but I already solved my problem. I cut out the A_SpawnObjectRelative states and just made the spikeballs placeable in a map editor. Then I placed 4 spikeball things around the custom enemy thing, each one facing away from said enemy. The spikeballs are SOCced to look for the nearest of this enemy it can find and orbit around it. So now there are no more extra spikeballs where they don't belong.
 
A_RandomState can be placed on the spawnstate to trigger a switch away from the spikeball spawning states; because actions are not run on spawn unless you add MF_RunSpawnFunc, A_RandomState will only trigger when A_BuzzFly sends it back to the spawnstate.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top