Author Topic: lua scripting attack for specific units  (Read 845 times)

esraacs

  • Swordman
  • *
  • Posts: 14
    • View Profile
lua scripting attack for specific units
« on: 19 June 2015, 00:04:21 »
by using lua scripting how can i give attack command to specific units like defense tower and air ballista ?
I tried this
createUnit('defense_tower', 0, startLocation(0))      
givePositionCommand(lastCreatedUnit(), 'attack',startLocation(0))
createUnit('air_ballista', 0, startLocation(0))      
givePositionCommand(lastCreatedUnit(), 'attack',startLocation(0))

and this
createUnit('defense_tower', 0, startLocation(0))      
givePositionCommand(lastCreatedUnit(), 'attack_on',startLocation(0))
createUnit('air_ballista', 0, startLocation(0))      
givePositionCommand(lastCreatedUnit(), 'attack_on',startLocation(0))

it gives that invalid command in both cases
how can give attack command to these units using lua scripting ?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: lua scripting attack for specific units
« Reply #1 on: 19 June 2015, 04:58:47 »
If you consult the XMLs, you'll find that the defense tower does not have an attack command. It has an attack skill and an attack_stopped command (which is usually referred to as "hold position" for regular units). The major difference is that you cannot pick the target of the defense tower (and other units using this pattern). The reason for this is that attack commands require a move skill and for obvious reasons, it doesn't make sense to have buildings move.

It's been too long since I experimented with that, but IIRC, there's no way to give a  move skill that will not have the building at least rotate, and thus there's no way to give the defense tower a way to choose its target without engine modifications (but again, it's been a long time and maybe someone else has found a way to make that work). All the same, it won't work with the Megapack.

You can tell the defense tower to use its attack stopped command ("attack on") with giveAttackStoppedCommand.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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