#  ![](https://www.realm667.com/media/kunena/topic_icons/realm667_repo/user/rep_approved.png) Fly

##

- **Blue Shadow**
- ![Blue Shadow's Avatar](https://www.realm667.com/media/kunena/core/svg/person.svg)
- Administrator
- ![Administrator](https://www.realm667.com/media/kunena/ranks/rank_20_barrel.png)

 Less More- Posts: 1131
-
-
-

   8 years 1 month ago [\#7051](#7051) by Blue Shadow  Replied by *Blue Shadow* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7051 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

- 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 } }

    Considering the fly can't be killed, the death sound and sprite can also be removed.
- 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **doomedarchviledemon**
- ![doomedarchviledemon's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar209.png) Topic Author
- Pain Elemental
- ![Pain Elemental](https://www.realm667.com/media/kunena/ranks/rank_9_pain.png)

 Less More- Posts: 258
-
-
-

   8 years 1 month ago [\#7053](#7053) by doomedarchviledemon  Replied by *doomedarchviledemon* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7053 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **Blue Shadow**
- ![Blue Shadow's Avatar](https://www.realm667.com/media/kunena/core/svg/person.svg)
- Administrator
- ![Administrator](https://www.realm667.com/media/kunena/ranks/rank_20_barrel.png)

 Less More- Posts: 1131
-
-
-

   8 years 1 month ago [\#7082](#7082) by Blue Shadow  Replied by *Blue Shadow* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7082 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

- 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) &lt; 50) { A_SetSpeed(RandomPick(1, 3, 5)); } }

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **doomedarchviledemon**
- ![doomedarchviledemon's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar209.png) Topic Author
- Pain Elemental
- ![Pain Elemental](https://www.realm667.com/media/kunena/ranks/rank_9_pain.png)

 Less More- Posts: 258
-
-
-

   8 years 1 month ago [\#7083](#7083) by doomedarchviledemon  Replied by *doomedarchviledemon* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7083 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 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) &lt; 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **Blue Shadow**
- ![Blue Shadow's Avatar](https://www.realm667.com/media/kunena/core/svg/person.svg)
- Administrator
- ![Administrator](https://www.realm667.com/media/kunena/ranks/rank_20_barrel.png)

 Less More- Posts: 1131
-
-
-

   8 years 1 month ago [\#7085](#7085) by Blue Shadow  Replied by *Blue Shadow* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7085 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

> 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **doomedarchviledemon**
- ![doomedarchviledemon's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar209.png) Topic Author
- Pain Elemental
- ![Pain Elemental](https://www.realm667.com/media/kunena/ranks/rank_9_pain.png)

 Less More- Posts: 258
-
-
-

   8 years 1 month ago [\#7086](#7086) by doomedarchviledemon  Replied by *doomedarchviledemon* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7086 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **Blue Shadow**
- ![Blue Shadow's Avatar](https://www.realm667.com/media/kunena/core/svg/person.svg)
- Administrator
- ![Administrator](https://www.realm667.com/media/kunena/ranks/rank_20_barrel.png)

 Less More- Posts: 1131
-
-
-

   8 years 1 month ago [\#7088](#7088) by Blue Shadow  Replied by *Blue Shadow* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7088 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 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) &lt; 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) &lt; 3) // 3/256 chance of playing the active sound, similar to A_Chase. { PlayActiveSound(); } } TNT1 A 0 { A_Look; if (Random(0, 255) &lt; 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **doomedarchviledemon**
- ![doomedarchviledemon's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar209.png) Topic Author
- Pain Elemental
- ![Pain Elemental](https://www.realm667.com/media/kunena/ranks/rank_9_pain.png)

 Less More- Posts: 258
-
-
-

   8 years 3 weeks ago [\#7098](#7098) by doomedarchviledemon  Replied by *doomedarchviledemon* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7098 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **Blue Shadow**
- ![Blue Shadow's Avatar](https://www.realm667.com/media/kunena/core/svg/person.svg)
- Administrator
- ![Administrator](https://www.realm667.com/media/kunena/ranks/rank_20_barrel.png)

 Less More- Posts: 1131
-
-
-

   8 years 3 weeks ago [\#7099](#7099) by Blue Shadow  Replied by *Blue Shadow* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7099 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 Why was the code made a part of the See state sequence instead of the Spawn one?

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **doomedarchviledemon**
- ![doomedarchviledemon's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar209.png) Topic Author
- Pain Elemental
- ![Pain Elemental](https://www.realm667.com/media/kunena/ranks/rank_9_pain.png)

 Less More- Posts: 258
-
-
-

   8 years 3 weeks ago [\#7100](#7100) by doomedarchviledemon  Replied by *doomedarchviledemon* on topic *[Fly](https://www.realm667.com/forum/closed-submissions/1059-fly?start=10#7100 "Name: Fly

Connection: None
Palette: PNG
Summon: Fly
Destroyable: No
Special Effects: None

Decorate: Doomedarchviledemon
Sprites: Blood
Sounds: FreeSounds
Sprite Edits: Doomedarchviledemon
Idea Base: Population animal

Description: Buzz buzz buzz! Annoying little buggers.")*

 ...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](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL2Nsb3NlZC1zdWJtaXNzaW9ucy8xMDU5LWZseT9zdGFydD0xMA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

[Powered by](https://www.realm667.com/forum/credits) [Kunena Forum](https://www.kunena.org)
