<tower maxlevel="4"  template="ini/units/towers/template.xml"
       level="2"
       unittype="tower"
       name="cannon"
       radius="320"
       allowtargets="earth,sea"
       damagebysector="yes"
       sectorangle="360"
       maxtargets="1"

       bullet="ini/units/towers/cannon_bullet.xml"
       bullet_params0="0,0,-28x50|45,0,-15x70|90,0,-10x88|135,0,15x70|180,0,30x50|225,0,18x50|270,0,-10x45|315,0,-18x50|"
       bullet_params1="0,0,-48x50|45,0,-35x70|90,0,+10x88|135,0,35x70|180,0,50x50|225,0,48x50|270,0,+10x45|315,0,-38x50|"
       >

  <mover>
    <params>
      <allowangles value="0,45,90,135,180,225,270,315"/>
      <thresold value="24"/>
    </params>
  </mover>

  <effects>
    <positive damage="60"/>
  </effects>

  <machine_unit>
    <transitions>
      <sleep seetarget="readyfire"/>
      <readyfire notarget="waittarget"/>
      <readyfire charge="charging"/>
      <charging ready="readyfire"/>
      <waittarget seetarget="readyfire"/>
      <waittarget relax="waittarget"/>

    </transitions>
    <params>
      <state_readyfire charge_volume="2" delay="0"/>
      <state_waittarget duration="1"/>
      <state_charging duration="3"/>
    </params>
  </machine_unit>

  <machine_move>
    <transitions>
      <move stop="stop"/>
      <stop move="move"/>
    </transitions>
  </machine_move>

  <children>
    <node type="sprite" name="skin" image="catapult2::catapult2_dr.001.png" center="0.5x0.25" />
    <node type="sprite" name="shoot" center="0.5x0.0" scale="0.9x0.9" pos="0x48"/>
    <node type="sprite" name="level" image="images::gamescene/level2.png" center="0.5x0.5" z="3" pos="0x-15" scale="0.75x-0.75"  color="ffae00"/>
  </children>

  <actions>
    <action name="animate0"   value="Animate[1,[folder:catapult2::catapult2_r., indexes:.png,006:012,001:006]]"/>
    <action name="animate45"  value="Animate[1,[folder:catapult2::catapult2_dr.,indexes:.png,006:012,001:006]]"/>
    <action name="animate90"  value="Animate[1,[folder:catapult2::catapult2_d., indexes:.png,006:012,001:006]]"/>
    <action name="animate135" value="Animate[1,[folder:catapult2::catapult2_dl.,indexes:.png,006:012,001:006]]"/>
    <action name="animate180" value="Animate[1,[folder:catapult2::catapult2_l., indexes:.png,006:012,001:006]]"/>
    <action name="animate225" value="Animate[1,[folder:catapult2::catapult2_ul.,indexes:.png,006:012,001:006]]"/>
    <action name="animate270" value="Animate[1,[folder:catapult2::catapult2_u., indexes:.png,006:012,001:006]]"/>
    <action name="animate315" value="Animate[1,[folder:catapult2::catapult2_ur.,indexes:.png,006:012,001:006]]"/>

    <action name="shoot1" value="Sequence[DelayTime[0.3],Show[],Animate[0.3,[folder:cannon_shoot::,indexes:.png,1:5]],Hide[]]"/>
  </actions>

  <events>
    <eventlist name="on_shoot0_byangle0">
      <runaction action="animate0" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle90">
      <runaction action="animate90" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle180">
      <runaction action="animate180" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle270">
      <runaction action="animate270" target="skin"/>
    </eventlist>

    <eventlist name="on_shoot0_byangle45">
      <runaction action="animate45" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle135">
      <runaction action="animate135" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle225">
      <runaction action="animate225" target="skin"/>
    </eventlist>
    <eventlist name="on_shoot0_byangle315">
      <runaction action="animate315" target="skin"/>
    </eventlist>

    <eventlist name="on_shoot0">
      <playsound sound="##cannon_shoot##"/>
    </eventlist>
  </events>

</tower>
