Author Topic: Annoying issue: Castle deactivates attack after building unit  (Read 1374 times)

Bloodwurm

  • Guest
I feel I've seen something on this but can't find it anymore.

It's really annoying to set to Castle to Attack On, then ask it to build units, to see that, when done, it goes back to Attack Off.

Can I make it so the attack is always on? (don't want it to be set to off)

I would like the building to actually build AND attack at the same time, is that possible?

Is there something that can be done to "dictate" idle behavior? (Could then "force" it to go to Attack On command)

Thx

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Annoying issue: Castle deactivates attack after building unit
« Reply #1 on: 21 December 2011, 17:28:25 »
I believe that hold position Is a stop command. After a skill finishes units will default to a stop command. This may be a code issue.

If you want you could try deleating the attack stop command (not skill). Other than that idk.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Annoying issue: Castle deactivates attack after building unit
« Reply #2 on: 22 December 2011, 02:29:56 »
I'm trying to figure out how this would change the building's actual behavior. The "attack on" command is an attack_stopped command, which means the unit is stopped, but will attack (without moving) when foes are in range. For a unit that has no move skill, attack stopped only serves the purpose of allowing them to attack without rotation (since a regular attack command requires a move skill. Attack stopped only rotates the unit if there is a move skill, and will attack without rotation if the move skill is absent). However, as long as no other commands are active (eg, not producing a worker), the castle should still be able to attack foes that come in range when the stop command is active. You could think of stop commands as being very low priority.

If a unit has an attack_stopped or attack command, when stopped, it will switch to one of these when a foe comes in the unit's sights. Once the foe(s) is/are dead, the unit will switch back to the stop command (which is the default command if there are currently no other commands). If a unit has no attack_stopped or attack command, but has a move skill, it will switch to that move skill and attempt to flee the foe, switching back to stop when it can no longer see the foe. So if you NEVER issue the attack_stopped command to your castle, even though you didn't manually enter it, the castle will still automatically switch to the attack_stopped if a foe appears (and thus attacking the foe). It's difficult to manually tell a unit not to attack. Fortunately, GAE 0.4 (the git-master and betas) have a button which disables or enables this auto-attacking function (and autofleeing).

Code: (Excerpt from castle.xml) [Select]
<command>
<type value="stop"/>
<name value="attack_off"/>
<image path="images/defense_tower_attack_off.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
</command>

<command>
<type value="attack_stopped"/>
<name value="attack_on"/>
<image path="images/defense_tower_attack_on.bmp"/>
<unit-requirements/>
<upgrade-requirements/>
<attack-skill value="attack_skill"/>
<stop-skill value="stop_skill"/>
</command>

With that being said, there is currently no way to have a unit produce and attack at the same time, as they are separate commands, and currently, it's impossible to have a unit do more than one command at a time. While some nifty coding could fix that, I imagine it would require quite a change. Generally, one should avoid giving produce or upgrade commands to defensive structures because the building would be unable to attack while producing/upgrading. Shibboleth is just a testing faction for GAE, and (I think) is not distributed with official releases, only from downloading the data from the git repository. You'll note, though, that the summoner is not able to attack and produce (summon) a unit at the same time (which one could say is intended, to make them vulnerable when producing). Canceling the produce command(s) would allow the summoner to attack again.

As for dictating idle behavior, there's no way to do so, no. If it doesn't have an active command, or its active command has just finished, the unit will always be in the stop command. Units must have a command at all times. Going back to an attack_stopped command after executing another command inbetween seems unnecessary, since units will automatically switch to attack/attack_stopped commands. However, in instances like the summoner, she could possibly break a pretty formation by going back to a stop command instead of attack_stopped after producing a unit (or canceling producing a unit).

For that reasons, although I wouldn't consider it necessarily a bug, units should remember if they were using the stop or the attack_stopped command before they started a different command (eg, produce). When that different command ends, they should go back to either stop OR attack_stopped, depending on whichever command they were using before. MegaGlest had a discussion about this a long while back, but I'm unable to find the topic and cannot remember the outcome.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert