header general

Fly

  • Blue Shadow
  • Blue Shadow's Avatar
  • Administrator
  • Administrator
More
6 years 6 months ago #11 by Blue Shadow
Replied by Blue Shadow on topic Fly
  • I suggest some code cleanup now that the fly isn't interactive (the commented-out lines can be removed):
    Warning: Spoiler!
  • 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
  • doomedarchviledemon's Avatar Topic Author
  • Pain Elemental
  • Pain Elemental
More
6 years 6 months ago #12 by doomedarchviledemon
Replied by doomedarchviledemon on topic Fly
Implemented the requested changes. Now the fly will chase the player only when in a certain range. I also made it so that the fly will occasionally change how fast it flies around. It can still be a bit slow at its lowest speed but now it can also be fairly quick as well as speedy. I think it makes it more lively that way.

Please Log in or Create an account to join the conversation.

  • Blue Shadow
  • Blue Shadow's Avatar
  • Administrator
  • Administrator
More
6 years 5 months ago #13 by Blue Shadow
Replied by Blue Shadow on topic Fly
  • 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
  • doomedarchviledemon's Avatar Topic Author
  • Pain Elemental
  • Pain Elemental
More
6 years 5 months ago #14 by doomedarchviledemon
Replied by doomedarchviledemon on topic Fly
Alright, I implemented your code and it seems to be working fine, but now it does not do the A_JumpIfCloser part. I'm not sure why it's not activating though because it seems to be in the correct order and makes sense to me. I have it set right after the A_Wander and just before your code. I even made it so that it would force to play a sound if it jumps to the Follow state to make sure I know it triggers, but it just doesn't trigger no matter how close I get to the fly.

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
  • Blue Shadow's Avatar
  • Administrator
  • Administrator
More
6 years 5 months ago #15 by Blue Shadow
Replied by Blue Shadow on topic Fly

doomedarchviledemon wrote: Alright, I implemented your code and it seems to be working fine, but now it does not do the A_JumpIfCloser part.

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.

Does 'Active' only refer to when an enemy is chasing a player/enemy?

Yes, more specifically, A_Chase is what plays the active sound.

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
  • doomedarchviledemon's Avatar Topic Author
  • Pain Elemental
  • Pain Elemental
More
6 years 5 months ago #16 by doomedarchviledemon
Replied by doomedarchviledemon on topic Fly
Ah, my bad then. Forgot to put that back in. Download like has been updated.

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
  • Blue Shadow's Avatar
  • Administrator
  • Administrator
More
6 years 5 months ago #17 by Blue Shadow
Replied by Blue Shadow on topic Fly
There's one problem still. The fly will only look for a target for the first few tics after spawning. If it doesn't find one, it'll enter the See state sequence without one, and it'll be stuck in that state sequence forever without the ability to acquire a target again. To resolve this, the Spawn state sequence needs adjustment:
Code:
Spawn: FLYA AAABBB 1 A_Wander TNT1 A 0 { A_Look; if (Random(0, 255) < 50) { A_SetSpeed(RandomPick(1, 3, 5)); } } Loop


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:
Code:
Spawn: FLYA AAABBB 1 { A_Wander; if (Random(0, 255) < 3) // 3/256 chance of playing the active sound, similar to A_Chase. { PlayActiveSound(); } } TNT1 A 0 { A_Look; if (Random(0, 255) < 50) { A_SetSpeed(RandomPick(1, 3, 5)); } } Loop
Of course, if you decided to do that, you also need to edit the See state sequence as well, since A_Wander is being called there too.

Please Log in or Create an account to join the conversation.

  • doomedarchviledemon
  • doomedarchviledemon's Avatar Topic Author
  • Pain Elemental
  • Pain Elemental
More
6 years 5 months ago #18 by doomedarchviledemon
Replied by doomedarchviledemon on topic Fly
I have updated the Fly to address the issue. I also decided to keep the sound only being active when it enters its Follow state because I do think having the flies constantly buzzing would be rather annoying.

Please Log in or Create an account to join the conversation.

  • Blue Shadow
  • Blue Shadow's Avatar
  • Administrator
  • Administrator
More
6 years 5 months ago #19 by Blue Shadow
Replied by Blue Shadow on topic Fly
Why was the code made a part of the See state sequence instead of the Spawn one?

Please Log in or Create an account to join the conversation.

  • doomedarchviledemon
  • doomedarchviledemon's Avatar Topic Author
  • Pain Elemental
  • Pain Elemental
More
6 years 5 months ago #20 by doomedarchviledemon
Replied by doomedarchviledemon on topic Fly
...because I am not the brightest person doing codes lol. Again, my lack of understanding on how to code these things properly is apparent. I thought it was working fine to just include it in the See state since it is in a loop state at that point. Even if it goes into the follow state it goes back to the See state, thus going through the whole code again and doing the A_Look in that sequence.

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.