Fly
- Blue Shadow
- Administrator
- Posts: 1129
- I suggest some code cleanup now that the fly isn't interactive (the commented-out lines can be removed):
Warning: Spoiler!Code:ACTOR Fly 9662 { //Health 1 Radius 3 Height 3 Speed 1 Mass 10 Scale 0.25 //PainChance 255 //MONSTER ActiveSound "Flying/Fly" //-COUNTKILL //-CANUSEWALLS //-SOLID +BOUNCEONWALLS +FLOAT +NOGRAVITY //-SHOOTABLE States { Spawn: FLYA A 10 A_Look Loop See: TNT1 A 0 A_Chase FLYA AAABBB 1 A_Wander Loop //Death: //TNT1 A 0 A_PlaySound("FlyHit/Hit",0,1) //FLYD A -1 //Stop } } - The fly should be buzzing around from the start, instead upon spotting the player.
- It could do with a speed increase. I find it a little too slow at the moment.
- Instead of unconditionally chasing the player all the time, maybe have it do so only if the player is in certain range? Like if the player is out of its range, it would just wander about.
Please Log in or Create an account to join the conversation.
- doomedarchviledemon
- Topic Author
- Pain Elemental
- Posts: 251
Please Log in or Create an account to join the conversation.
- Blue Shadow
- Administrator
- Posts: 1129
- The fly still attempts to chase its target if it's out of range. My idea was that it should do that if, and only if, the target is within range. If it's out of range, the fly should just wander.
- As long as it doesn't have a target, it will never change its speed, which is kind of odd. If there is no target A_Chase jumps back to Spawn, meaning the See state sequence is not fully gone through, and the speed changing happens after that.
- The speed changing code could be made cleaner. Instead of using A_Jump and having different states to jump to for various speed settings, you could do this:
Code:TNT1 A 0 { if (Random(0, 255) < 50) { A_SetSpeed(RandomPick(1, 3, 5)); } }
Please Log in or Create an account to join the conversation.
- doomedarchviledemon
- Topic Author
- Pain Elemental
- Posts: 251
Also, am I wrong in thinking that the Active Sound should automatically play when an enemy is in its See state? Doesn't seem to be the case. Does 'Active' only refer to when an enemy is chasing a player/enemy?
States
{
Spawn:
FLYA AAABBB 1
Goto See
See:
FLYA AAABBB 1 A_Wander
TNT1 A 0 A_JumpIfCloser(156,"Follow")
TNT1 A 0
{
if (Random(0, 255) < 50)
{
A_SetSpeed(RandomPick(1, 3, 5));
}
}
loop
Follow:
FLYA AAABBBAAABBB 1 A_Chase
TNT1 A 0 A_JumpIfCloser(156,"Follow")
Goto See
}
}
Please Log in or Create an account to join the conversation.
- Blue Shadow
- Administrator
- Posts: 1129
Since you seem to have removed A_Look, the fly can no longer acquire a target. A_JumpIfCloser relies on the presence of a target to perform the jump. The fly needs to look for a target while wandering.doomedarchviledemon wrote: Alright, I implemented your code and it seems to be working fine, but now it does not do the A_JumpIfCloser part.
Yes, more specifically, A_Chase is what plays the active sound.Does 'Active' only refer to when an enemy is chasing a player/enemy?
I'll try and help fix the code a bit later, considering it's my suggestions that have created this mess you're dealing with now.
Please Log in or Create an account to join the conversation.
- doomedarchviledemon
- Topic Author
- Pain Elemental
- Posts: 251
I just placed A_Look back in and it seems to be working as intended now. The fly changes speeds on its own at random while wandering, and it will chase the player if it is in range and will continue to follow the player if they remain in range. Otherwise they will go back to wandering. Additionally, the fly will only make the buzzing sounds if they are chasing the player. Not sure if it is possible to continue having it play while only wandering without having to make another A_Jump with a small chance to play a sound or something, similar to how I did with the Blind Pinky, but I actually think it's fine with only playing sounds while chasing. That way if an area is filled with flies the buzzing is not always constant and it lets the player know that they are being chased by an annoyance... like real flies. Never know until they are right in your ear!
Also, no worries. Your suggestions are always very helpful and I appreciate your feedback. It's my implementation and lack of understanding code in general that are the flaws. I'm sure there is a much better way of doing the things I want to have done but I am not experienced enough sometimes. But I try my hardest and keep doing my best!
Please Log in or Create an account to join the conversation.
- Blue Shadow
- Administrator
- Posts: 1129
Regarding the active sound, I'm fine either way, so it's up to you if you want it to play the sound while wandering or not. Building upon the code above, here's how it could be implemented:
Please Log in or Create an account to join the conversation.
- doomedarchviledemon
- Topic Author
- Pain Elemental
- Posts: 251
Please Log in or Create an account to join the conversation.
- Blue Shadow
- Administrator
- Posts: 1129
Please Log in or Create an account to join the conversation.
- doomedarchviledemon
- Topic Author
- Pain Elemental
- Posts: 251
I guess I am confused as to if what I did was a bad thing that messed with the behavior or if it was a case of a simple unnecessary extra state that wasn't needed. To my understanding, a monster, or other actor that moves and interacts with the world, needs a Spawn and See state at minimum. Spawn meaning just to spawn the actor and See being used for everything else. Though now I see that is not necessarily the case in certain circumstances, in this case an actor that doesn't have any sort of attacks or other forms of interaction.
Either way, the See state has been removed and the code now only includes the Spawn and Follow state. From what I am seeing it is working properly.
Please Log in or Create an account to join the conversation.