Battlebot

From whuckaba
Jump to: navigation, search
alias lolistriker {

  if ( $1 == !loliname ) {
    /lolinamer $2-
    halt
  }

  if ( $1 == !strike ) { 
    if ( $chan != #silviedebug ) { 
      lolinotice $nick Currently reworking.
      halt 
    }
    if ( $nick != keine ) { halt }
    ;advancedstrikesetup $2 $3 $4 $5 $6 $7 $8
    halt
  }
  if ( $1 == !commands ) {
    givefightcommands $2 $3 $4 $5 $6 $7
    halt
  }
  if ( $1 == !mystatus ) {
    /lolifightstatus $nick 2
    halt
  }
  if ( $1 == !deploytrap ) {
    /lolideploytrap $nick $2
    halt
  }
  if ( $1 == !flee ) {
    /loliflee $nick
    halt
  }
  if ( $1 == !bishaura ) {
    /lolibishaura $nick $2
    halt
  }

  if ( $1 == !attack ) {
    /loliattack $nick $2
    halt
  }
  if ( $1 == !antiloli ) {
    /describe $chan takes a loli back from $nick
    /loligamedata $nick loli -1 * * DIFF
  }



}




alias advancedstrikesetup {
  if ( $1 == $null ) {
    lolinotice $nick Format: !strike [person]
    lolinotice $nick Alt:  !strike the bank 
    lolinotice $nick Remind Keine to add the help file stuff
    halt
  }

  var %myfights = $loligamedata($nick,fights).get
  var %myfighting = $loligamedata($nick,fighting).get

  if (( %myfights < 1 ) || ( %myfights == $null)) {
    lolinotice $nick You currently have no fights available.
    halt
  }
  if (( %myfighting != no.one ) && ( %myfighting != $null)) {
    lolinotice $nick You are already engaged in war.
    halt
  }

  var %lolidatanick = $1
  var %loliname = $1
  var %lolispec = $null
  var %lolinet = $network
  var %theirfights = $loligamedata(%lolidatanick,fights,%lolispec,%lolinet).get
  var %theirfighting = $loligamedata(%lolidatanick,fighting,%lolispec,%lolinet).get
  if ( $2 == bank ) {
    %lolidatanick = $null
    %lolispec = bank
    %loliname = $network $+ 's bank
    %lolinet = $network
    %theirfights = 1
    %theirfighting = $null
  }
  var %valueloli = $loligamedata(%lolidatanick,loli,%lolispec,%lolinet).get

  if ( $1 == $me ) {
    %lolidatanick = $null
    %lolispec = silvie
    %loliname = Silvie and the Wanko Loli Collection Force
    %lolinet = $network
    %theirfights = 1
    %theirfighting = $null
    %valueloli = %loligamedata($nick,loli).get
  }
  if ( ( %valueloli == $null ) && ( $1 != $me ) ) {
    lolinotice $nick I don't think they have played my game (or they are on a different network)
    halt
  }
  if (( %theirfights < 1 ) || ( %theirfights == $null)) {
    lolinotice $nick %loliname currently has a protected state.
    halt
  }
  if (( %theirfighting != no.one ) && ( %theirfighting != $null)) {
    lolinotice $nick %loliname is already engaged in war.
    halt
  }

  while ( %i == %i ) {
    var %unid = WAR $+ $rand(1,10000)
    var %check = $readini(c:\script\silviewar.ini,master,%unid)
    if ( %check == $null ) {
      /break
    }
  } 

  msg $nick UNIQUE BATTLE ID: %unid
  msg $nick You have challenged %loliname to a battle. If %loliname doesn't respond within the 5 minute period, they will be played by $me $+ .
  msg $nick If you fail to respond to your turns, your battle will be forfeited.
  msg $nick List of available commands at: �!commands�
  if ( %lolidatanick != $null ) { 
    msg %lolidatanick UNIQUE BATTLE ID: %unid 
    msg %lolidatanick $nick has challenged you to a battle. If you do not respond within the 5 minute period, you will be played by $me $+ .
    msg %lolidatanick List of available commands at: �!commands� 
  }


  var %cond = GOOD. 
  ;whatever else blah go here

  /writeini c:\script\silviewar.ini master %unid IN PROGRESS
  /writeini c:\script\silviewar.ini %unid network $network
  /writeini c:\script\silviewar.ini %unid 1 $nick
  /writeini c:\script\silviewar.ini %unid $+ . $+ $nick name $nick

  /loligamedata $nick fighting %unid
  /loligamedata $nick fights $calc(%myfights -1)


  if ( $1 == $me ) {
    /writeini c:\script\silviewar.ini %unid 2 the.silvie
    /writeini c:\script\silviewar.ini %unid $+ .the.silvie NPC TRUE
    /writeini c:\script\silviewar.ini %unid $+ .the.silvie name %loliname
  }
  elseif ( $2 == bank ) {
    /writeini c:\script\silviewar.ini %unid 2 the.bank
    /writeini c:\script\silviewar.ini %unid $+ .the.bank NPC TRUE
    /writeini c:\script\silviewar.ini %unid $+ .the.bank name %loliname
  }
  else {
    /writeini c:\script\silviewar.ini %unid 2 %lolidatanick
    /writeini c:\script\silviewar.ini %unid $+ . $+ %lolidatanick name %loliname

    /loligamedata %lolidatanick fighting %unid
    /loligamedata %lolidatanick fights $calc(%theirfights -1)   

  }


  var %topone = $loligamedata(,UNITS).get

  var %quick = 0
  var %iio = 0
  while ( %iio <= %topone ) {
    var %stocks = $LOLICOMD(%iio)
    if ( %iio = 0 ) {   var %stocks = loli }

    var %tempa = $loligamedata($nick,%stocks).get
    if ( %tempa == $null ) { %tempa = 0 }
    /writeini c:\script\silviewar.ini %unid $+ . $+ $nick %stocks $+ .start %tempa
    /writeini c:\script\silviewar.ini %unid $+ . $+ $nick %stocks $+ .hp $calc(%tempa * $hget(loligamehash,fight. $+ %stocks $+ .hp))

    if ( $1 == $me ) {
      var %tempa = $int($calc($loligamedata($nick,%stocks).get * 1.3))
      if ( %tempa == $null ) { %tempa = 0 }
      /writeini c:\script\silviewar.ini %unid $+ .the.silvie %stocks $+ .start %tempa 
      /writeini c:\script\silviewar.ini %unid $+ .the.silvie %stocks $+ .hp $calc(%tempa * $hget(loligamehash,fight. $+ %stocks $+ .hp))
      %quick = 1
    }
    elseif ( $2 == bank ) {
      var %tempa = $loligamedata(%lolidatanick,%stocks,%lolispec,%lolinet).get
      if ( %tempa == $null ) { %tempa = 0 }
      /writeini c:\script\silviewar.ini %unid $+ .the.bank %stocks $+ .start %tempa
      /writeini c:\script\silviewar.ini %unid $+ .the.bank %stocks $+ .hp $calc(%tempa * $hget(loligamehash,fight. $+ %stocks $+ .hp))
      %quick = 2
    }
    else {
      var %tempa = $loligamedata(%lolidatanick,%stocks,%lolispec,%lolinet).get
      if ( %tempa == $null ) { %tempa = 0 }
      /writeini c:\script\silviewar.ini %unid $+ . $+ %lolidatanick %stocks $+ .start %tempa
      /writeini c:\script\silviewar.ini %unid $+ . $+ %lolidatanick %stocks $+ .hp $calc(%tempa * $hget(loligamehash,fight. $+ %stocks $+ .hp))

    }
    inc %iio
  }



  if ( $chan != $null ) {
    msg $chan $nick has engaged in combat with %loliname
  } 



  msg $nick Currently additional phases of this fighting have not been written.. currently only in theater setup

  /lolifightstatus $nick 2
  if ( %quick == 0 ) { 
    /lolifightstatus %lolidatanick 2 
    /lolifightstatus %lolidatanick 3 $nick
    /lolifightstatus $nick 3 %lolidatanick
  }
  if ( %quick == 1 ) { 
    /lolifightstatus the.silvie 0 
    /lolifightstatus $nick 3 the.silvie
  }
  if ( %quick == 2 ) { 
    /lolifightstatus the.bank 0 
    /lolifightstatus $nick 3 the.bank
  }

  /writeini c:\script\silviewar.ini %unid status prematch

  /writeini c:\script\silviewar.ini %unid time $ctime
  /writeini c:\script\silviewar.ini %unid starttime $ctime
  if ( $chan != $null ) {   /writeini c:\script\silviewar.ini %unid chan $chan }




  ;/timer $+ %unid 1 10 /lolifightminder %unid
  /lolifightminder %unid
}



alias lolifightstatus {
  if ( $5 == $null ) { var %unid = $lolifightchecker }
  if ( $5 != $null ) { var %unid = $5 }

  ; $2 = 99 - just run calcs
  ; $2 = 98 - kill $6 HP

  var %forwho = $1
  if ( $1 == $null )  { %forwho = $nick }

  if ( $2 == 100 ) {

    var %hpmax = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,HPMAX)
    var %hpnow = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,HPNOW)
    return $int($calc((%hpnow / %hpmax)*100) )
  }

  if ( $2 == 3 ) {
    var %hpmax = $readini(c:\script\silviewar.ini,%unid $+ . $+ $3,HPMAX)
    var %hpnow = $readini(c:\script\silviewar.ini,%unid $+ . $+ $3,HPNOW)

    var %tattack = $readini(c:\script\silviewar.ini,%unid $+ . $+ $3,ATTACK)
    var %mdefense = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,DEFENSE)
    var %mhp = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,HPNOW)

    var %whatif = $calc( %tattack - ( %mdefense + %mhp ) )
    if ( %whatif > 1 ) { var %extra = Warning, they could critically strike you. }   

    /echo -s the item is %unid $+ . $+ $3,HPNOW

    var %goname = $readini(c:\script\silviewar.ini,%unid $+ . $+ $3,name)
    msg %forwho %goname $+ 's forces are currently at $int($calc((%hpnow / %hpmax)*100) ) percent. %extra

  }

  if ( $2 == 98 ) {
    var %outout = $null
    var %killed = 0
  }

  ; ################# ACTUAL FIGURING


  var %iio = 0
  var %topone = $loligamedata(,UNITS).get
  while ( %iio <= %topone ) {
    var %stocks = $LOLICOMD(%iio)
    if ( %iio = 0 ) {   var %stocks = loli }

    var %tempa  = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,%stocks $+ .start)
    var %hpstart = $calc(%tempa * $hget(loligamehash,fight. $+ %stocks $+ .hp))
    var %hpnow = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,%stocks $+ .hp)
    var %uniteff = $calc(%hpnow / $hget(loligamehash,fight. $+ %stocks $+ .hp))

    if (%stocks == TRAP ) {

      var %bishaura = $readini(c:\script\silviewar.ini,%unid $+ . $+ %forwho,BISH.AURA)
      if (%bishaura == $null ) {
        %bishaura = 0
        /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho BISH.AURA 0
      }
      var %bishauratwo = $calc((100 - %bishaura) / 100 )
      var %bishaura = $calc(%bishaura / 100 )
      var %offense = $calc((%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .attack)) * %bishauratwo )
      var %defense = $calc((%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .defense)) * %bishauratwo )
      var %offenset = $calc((%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .attack)) * %bishaura * -22)
      var %defenset = $calc((%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .defense)) * %bishaura * 10)
      var %offense = $int($calc(%offense + %offenset))
      var %defense = $int($calc(%defense + %defenset))
    }
    else {




      var %offense = $int($calc(%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .attack)))
      ;above must be corrected for spells/effects
      var %defense = $int($calc(%uniteff * $hget(loligamehash,fight. $+ %stocks $+ .defense)))
    }

    var %totalhpmax = $calc(%totalhpmax + %hpstart)
    var %totalhp = $calc(%totalhp + %hpnow)
    var %totaloff = $calc(%totaloff + %offense)
    var %totaldef = $calc(%totaldef + %defense)
    if ( $2 == 1 ) {
      msg %forwho %stocks $+ : HP: $chr(91) $+ %hpnow $+ / $+ %hpstart $+ $chr(93)  Offensive Power: %offense   Defensive Power: %defense
    }


    if ( $2 == 98 ) {
      var %partake = $calc(%defense / $7)
      var %inflict = $int($calc(($6 * %partake) + 1 + %killed ))
      %killed = 0
      ;if ( %hpnow == 0 ) { %inflict = 0 }
      var %difhp = $calc(%hpnow - %inflict)
      if ( %difhp < 0 ) {
        var %killed = $calc( 0 - %difhp )
        var %difhp = 0
        if ( %hpnow > 0 ) {
          if ( %outout == $null ) {
            %outout = You have killed all of their: 
          }
          var %outout = %outout $LOLICOMDNAME(%stocks) 
          %outout = %outout $+ ,
        }
      }              
      /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho %stocks $+ .hp %difhp


      ;       %killed = 0


      ;msg #silviedebug %stocks to Partken = %partake , inflict %inflict ,  HP %hpnow , end %difhp , carry over %killed

    }



    inc %iio
  } 

  if ( $2 == 2 ) {
    msg %forwho Current Status: HP $chr(91) $+ %totalhp $+ / $+ %totalhpmax $+ $chr(93)  Offensive Power: %totaloff   Defensive Power: %totaldef
  }

  if ( $2 == 98 ) {
    return %outout
  }

  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho HPMAX %totalhpmax
  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho HPNOW %totalhp
  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho ATTACK %totaloff
  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho DEFENSE %totaldef





}





alias lolifightchecker {
  ;     /loligamedata %lolidatanick fighting %unid
  var %who = $nick
  if ( %who == $null ) { %who = $1 }

  var %unid = $loligamedata(%who,fighting).get
  if ( ( %unid == no.one ) || ( %unid == $null ) ) {
    msg $nick You do not appear to be in a fight at the moment.
    halt
  }
  return %unid
}


alias loliattack {
  if ( $2 == TTT ) { %unid = $3 }
  if ( $2 != TTT ) {
    if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { %unid = $lolifightchecker }
    if ( ( $1 == the.silvie ) || ( $1 == the.bank ) ) { %unid = $3 }
  }

  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %activep = $readini(c:\script\silviewar.ini,%unid,activep)
  }
  var %pass = 0
  if ( %activep == $1 ) { %pass = 1 }

  if ( %pass == 0 ) {
    msg $1 Sorry, you can't do that right now. Try when it is your turn.
    halt
  }

  var %pone = $1
  var %ptwo = $readini(c:\script\silviewar.ini,%unid,2)
  if ( %ptwo == %pone ) {
    var %ptwo = $readini(c:\script\silviewar.ini,%unid,1)
  }

  /lolifightstatus %pone 99 * * %unid
  /lolifightstatus %ptwo 99 * * %unid



  ;  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho HPMAX %totalhpmax
  ;  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho HPNOW %totalhp
  ;  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho ATTACK %totaloff
  ;  /writeini c:\script\silviewar.ini %unid $+ . $+ %forwho DEFENSE %totaldef

  var %ponehp = $readini(c:\script\silviewar.ini,%unid $+ . $+ %pone,hpnow)
  var %ptwohp = $readini(c:\script\silviewar.ini,%unid $+ . $+ %ptwo,hpnow)
  var %poneattk = $readini(c:\script\silviewar.ini,%unid $+ . $+ %pone,ATTACK)
  var %ptwodefn = $readini(c:\script\silviewar.ini,%unid $+ . $+ %ptwo,DEFENSE)

  var %attkvar = $rand($int($calc(%poneattk * 0.8)),$int($calc(%poneattk * 1.4)))
  var %forcer = $int($calc((%attkvar / %poneattk) * 100)) percent

  ;  msg $nick DEBUG %pone HP = %ponehp , %ptwo HP = %ptwohp , attack = %poneattk , defense = %ptwodefn , mod = %attkvar

  var %outline = You attack with %forcer of your power.



  var %damage = $calc( %attkvar - %ptwodefn )


  if ( %damage < 1 ) {
    %damage = 0
    var %outline = %outline You don't even scratch $readini(c:\script\silviewar.ini,%unid $+ . $+ %ptwo,name) $+ .

    if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) {
      msg $1 %outline
    }
    lolifightchangesides %unid
  }

  ;msg #silviedebug Damage = %damage





  var %what = $lolifightstatus(%ptwo,98,,,%unid,%damage,%ptwodefn)

  var %outline = %outline %what
  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { 
    msg $1 %outline
  }

  lolifightchangesides %unid

}

















alias lolideploytrap {
  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { %unid = $lolifightchecker }
  if ( ( $1 == the.silvie ) || ( $1 == the.bank ) ) { %unid = $3 }

  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %activep = $readini(c:\script\silviewar.ini,%unid,activep)
  }
  var %pass = 0
  if ( %status == prematch ) { %pass = 1 }
  if ( %activep == $1 ) { %pass = 1 }

  if ( %pass == 0 ) {
    msg $1 Sorry, you can't do that right now. Try when it is your turn.
    halt
  }

  if ( $2 == $null ) {
    msg $1 You must tell me how many traps to deploy into the feild.
    halt
  }

  var %hptrap = $readini(c:\script\silviewar.ini,%unid $+ . $+ $1,TRAP.HP)
  var %maxtrap = $int($calc(%hptrap / $hget(loligamehash,fight.trap.hp)))

  var %todeploy = $2
  if ( %todeploy > %maxtrap ) {
    msg $1 You only have %maxtrap traps that can be deployed.
    %todeploy = %maxtrap
  }

  %hptrap = $calc(%hptrap - (%todeploy * $hget(loligamehash,fight.trap.hp)))
  /writeini c:\script\silviewar.ini %unid $+ . $+ $1 TRAP.HP %hptrap

  var %jj = $readini(c:\script\silviewar.ini,%unid,1)
  if ( %jj == $1 ) { 
    %jj = $readini(c:\script\silviewar.ini,%unid,2) 
  }

  var %existingtrap = $readini(c:\script\silviewar.ini,%unid $+ . $+ %jj,EXITTRAP)
  if ( %existingtrap == $null ) { %existingtrap = 0 }
  /writeini c:\script\silviewar.ini %unid $+ . $+ %jj EXITTRAP $calc(%existingtrap + %todeploy)

  if ( %jj = the.bank ) { %jj = $network $+ 's bank }
  if ( %jj = the.silvie ) { %jj = silvie }

  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) {
    msg $1 %jj was surrounded with %existingtrap traps gaurding the exit routes, now %jj is now surrounded by $calc(%existingtrap + %todeploy) traps. 
  }

  halt




}


alias lolibishaura {

  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { %unid = $lolifightchecker }
  if ( ( $1 == the.silvie ) || ( $1 == the.bank ) ) { %unid = $3 }

  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %activep = $readini(c:\script\silviewar.ini,%unid,activep)
  }
  var %pass = 0
  if ( %status == prematch ) { %pass = 1 }
  if ( %activep == $1 ) { %pass = 1 }

  if ( %pass == 0 ) {
    msg $1 Sorry, you can't do that right now. Try when it is your turn.
    halt
  }

  if ( $2 == $null ) {
    msg $1 You must tell me what percent of your BISH you want to become self-obsessed.
    halt
  }


  var %plays = $int($2)
  if ( $2 < 0 ) {
    msg $1 You must have 0% or more of your BISH involved in self-appreciation.
    halt
  }
  if ( $2 > 100 ) {
    msg $1 You must have 100% or less of your BISH involved in self-appreciation.
    halt
  } 

  var %jj = $readini(c:\script\silviewar.ini,%unid,1)
  if ( %jj == $1 ) { 
    %jj = $readini(c:\script\silviewar.ini,%unid,2) 
  }

  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { 
    msg $1 Now %plays percent of your BISH are involved in appreaciating their beauty.
  }
  if ( ( %jj != the.silvie ) &&  ( %jj != the.bank ) ) { 
    if ( %plays < 5 ) {
      msg %jj $1 $+ 's battle field loses its Bishie glow.
    }
    if ( ( %plays > 5 ) && ( %plays < 95 ) ) {
      msg %jj $1 $+ 's battle feild begins to have an aura of Bishie to it.
    }
    if ( %plays > 95 ) {
      msg %jj It almost feels like the view of $1 $+ 's battle feild in your binoculars is bordered by roses and vines. It's very distracting.

    }
  }
  /writeini c:\script\silviewar.ini %unid $+ . $+ $1 BISH.AURA %plays




  halt
}











alias loliflee {
  if ( ( $1 != the.silvie ) && ( $1 != the.bank ) ) { %unid = $lolifightchecker($1) }
  if ( ( $1 == the.silvie ) || ( $1 == the.bank ) ) { %unid = $2 }

  ;msg #silviedebug person is $1 and result is %unid

  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %activep = $readini(c:\script\silviewar.ini,%unid,activep)
  }
  var %pass = 0
  if ( %status == prematch ) { %pass = 1 }
  if ( %activep == $1 ) { %pass = 1 }

  if ( %pass = 0 ) {
    msg $nick Sorry, you can't do that right now. Try when it is your turn.
    halt
  }


  var %existingtrap = $readini(c:\script\silviewar.ini,%unid $+ . $+ $1,EXITTRAP)

  if (%existingtrap == $null ) { %existingtrap = 0 }

  var %top = $calc(1 + %existingtrap)
  var %bottom = $calc( 2 + %existingtrap)
  var %chance = $calc(%top / %bottom )
  var %prob = $calc($rand(1,10000) / 10000)

  var %escape = 0
  var %jj = $readini(c:\script\silviewar.ini,%unid,1)
  if ( %jj == $1 ) { 
    %jj = $readini(c:\script\silviewar.ini,%unid,2) 
  }


  if ( %prob > %chance ) { 
    if ( ( $1 != the.bank ) || ( $1 != the.silvie ) ) { msg $1 You have successfully fled. }
    if ( ( %jj != the.bank ) || ( %jj != the.silvie ) ) { msg %jj $1 $+ 's force has fled the feild of battle.  }
    /fightend %unid %jj fled
    halt
  }


  if ( %existingtrap = 0 ) { 
    if ( ( $1 != the.bank ) || ( $1 != the.silvie ) ) { 
      msg $1 Your pride keeps you from leaving. 
      if ( ( %jj != the.bank ) || ( %jj != the.silvie ) ) { msg %jj $1 started to flee, but $1 $+ 's pride kept them from leaving. }
    }
  }    

  if ( %existingtrap > 1 ) {
    if ( ( $1 != the.bank ) || ( $1 != the.silvie ) ) { msg $1 You begin to leave, but you come across a cute girl.. er.. wait.. its ... A TRAP! ...   }


    var %ii = 1

    while ( %ii < 10 ) {

      var %topone = $loligamedata(,UNITS).get

      var %iio = $rand(0,%topone)
      var %stocks = $LOLICOMD(%iio)
      if ( %iio = 0 ) { %stocks = LOLI }
      var %hpstock = $readini(c:\script\silviewar.ini,%unid $+ . $+ $1,%stocks $+ .HP)
      var %maxstock = $int($calc(%hpstock / $hget(loligamehash,fight. $+ %stocks $+ .hp)))
      if ( %hpstock > 0 ) {
        %maxstock = $int($calc(%maxstock / 2 ))
        if ( %maxstock == 0 ) { %maxstock = 1 }
        var %loss = $rand(1,%maxstock)
        if ( ( %stocks == STKR ) && ( %loss > 1 ) ) { %loss = 1 }
        if ( %loss = 0 ) {
          msg $1 The trap detonates an explosive device, but luckily your force was safe.
          if ( ( %jj != the.bank ) || ( %jj != the.silvie ) ) { msg %jj One of your deployed Traps exploded, but caused no damage. }          
          /break
        }
        if ( %stocks == STKR ) {
          msg $1 One of your Strikers ventures too close to the TRAP just as it detonates, mortally wounding your Striker.
          if ( ( %jj != the.bank ) || ( %jj != the.silvie ) ) { msg %jj Even from across the battlefeild it is clear that $1 $+ 's Striker was trying to retreat... but was killed by a Trap you deployed! }          
        } 
        else {
          msg $1 The trap explodes, taking %loss of your %stocks with it.
          if ( ( %jj != the.bank ) || ( %jj != the.silvie ) ) { msg %jj $1 tried to retreat, but one of your Deployed Traps detonated killing some of their force! }          
        } 
        %loss = $calc(%loss * $hget(loligamehash,fight. $+ %stocks $+ .hp) )
        %hpstock = $calc( %hpstock - %loss)
        if ( %hpstock < 0 ) { %hpstock = 0 }
        /writeini c:\script\silviewar.ini %unid $+ . $+ $1 %stocks $+ .HP %hpstock
        /break
      }
      ;otherwise have to find another stock out there
      inc %ii
    }
  }


  if ( %existingtrap > 0 ) {
    %existingtrap = $calc(%existingtrap - 1)
    /writeini c:\script\silviewar.ini %unid $+ . $+ $1 EXITTRAP %existingtrap
  }


  if ( %status != prematch ) {
    lolifightchangesides %unid 
    halt
  }


  halt
}


















alias lolifightminder {
  var %unid = $1
  if ( %unid == $null ) { halt }
  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  var %stime = $readini(c:\script\silviewar.ini,%unid,time)
  var %ptime = $calc($ctime - %stime)
  var %pone = $readini(c:\script\silviewar.ini,%unid,1)
  var %ptwo = $readini(c:\script\silviewar.ini,%unid,2)
  var %ochan = $readini(c:\script\silviewar.ini,%unid,chan)

  if ( %status == prematch ) {
    ;globaldebug $scriptline Time %ptime okay? pone: %pone ptwo: %ptwo

    if ( %ptime < 260 ) {
      if ( %ptime < 5 ) { var %outline =  About 5 minutes remain in the pre-match period. }
      if ( ( %ptime > 55 ) && ( %ptime < 65 )) { var %outline = About 4 minutes remain in the pre-match period. }
      if ( ( %ptime > 115 ) && ( %ptime < 125 )) { var %outline = About 3 minutes remain in the pre-match period. }
      if ( ( %ptime > 175 ) && ( %ptime < 185 )) { var %outline = About 2 minutes remain in the pre-match period. }
      if ( ( %ptime > 235 ) && ( %ptime < 245 )) { var %outline = About 1 minute remains in the pre-match period. }
      if ( %outline != $null ) {
        msg %pone %outline
        if ( . !isin %ptwo ) { msg %ptwo %outline }
      }
      /timer $+ %unid 1 30 /lolifightminder %unid  
      halt
    }
    if ( ( %ptime > 259 ) && ( %ptime < 300 ) ) {


      if ( ( %ptime > 268 ) && ( %ptime < 272 )) { var %outline = About 30 seconds remain in the pre-match period. }
      if ( ( %ptime > 278 ) && ( %ptime < 282 )) { var %outline = About 20 seconds remain in the pre-match period. }
      if ( ( %ptime > 288 ) && ( %ptime < 292 )) { var %outline = About 10 seconds remain in the pre-match period. }
      if ( ( %ptime > 293 ) && ( %ptime < 297 )) { var %outline = About 5 seconds remain in the pre-match period. }
      if ( %outline != $null ) {
        msg %pone %outline
        if ( . !isin %ptwo ) { msg %ptwo %outline }
      }
      /timer $+ %unid 1 5 /lolifightminder %unid  
      halt
    }



    globaldebug $scriptline well we hit the end of that. Do NPC and forfeit checking here.





    /lolifightstatus %pone 2 * * %unid
    var %outline = %pone $+ 's forces at $lolifightstatus(%pone,100,,,%unid) percent.
    if (( %ptwo != the.bank ) && ( %ptwo != the.silvie ) ) { 
      /lolifightstatus %ptwo 2 * * %unid
      /lolifightstatus %ptwo 3 %pone * %unid
      /lolifightstatus %pone 3 %ptwo * %unid
      var %outline = %outline %ptwo $+ 's forces at $lolifightstatus(%ptwo,100,,,%unid) percent.
    }
    if ( %ptwo == the.silvie ) { 
      /lolifightstatus the.silvie 0 * * %unid
      /lolifightstatus %pone 3 the.silvie * %unid
      var %outline = %outline Silvie's forces at $lolifightstatus(the.silvie,100,,,%unid) percent.
    }
    if ( %ptwo == the.bank ) { 
      /lolifightstatus the.bank 0 * * %unid
      /lolifightstatus %pone 3 the.bank * %unid
      var %outline = %outline $network bank's forces at $lolifightstatus(the.bank,100,,,%unid) percent.
    }


    if ( %ochan != $null ) { msg %ochan Battle Report, 5 minutes: %outline }

    var %outline = Now entering aggressive rounds. %pone starts first.
    msg %pone %outline
    if ( . !isin %ptwo ) { msg %ptwo %outline }



    /writeini c:\script\silviewar.ini %unid status p1
    /writeini c:\script\silviewar.ini %unid activep %pone
    /writeini c:\script\silviewar.ini %unid time $ctime
    /writeini c:\script\silviewar.ini %unid artime 5
    /timer $+ %unid 1 15 /lolifightminder %unid  



    halt
  }


  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %whoitis = $readini(c:\script\silviewar.ini,%unid,activep)
    var %whoitis = $readini(c:\script\silviewar.ini,%unid $+ . $+ %whoitis,name)

    if ( %ptime < 49 ) {
      if ( ( %ptime > 10 ) && ( %ptime < 20 )) { var %outline = About 45 seconds left in %whoitis $+ 's turn. }
      if ( ( %ptime > 25 ) && ( %ptime < 35 )) { var %outline = About 30 seconds left in %whoitis $+ 's turn. }
      if ( ( %ptime > 40 ) && ( %ptime < 50 )) { var %outline = About 15 seconds left in %whoitis $+ 's turn. }
      if ( %outline != $null ) {
        msg %pone %outline
        if ( . !isin %ptwo ) { msg %ptwo %outline }
      }
      /timer $+ %unid 1 15 /lolifightminder %unid  
      halt
    }
    if ( %ptime < 60 ) {
      /timer $+ %unid 1 15 /lolifightminder %unid  
      halt
    }        
    lolifightchangesides %unid
    halt
  }
  if ( %status == cleanup ) {
    /lolicleanupservice %unid
  }

  ;  /writeini c:\script\silviewar.ini %unid status prematch
  ;  /writeini c:\script\silviewar.ini %unid time $ctime


}


alias lolicleanupservice {
  var %war = $1
  var %pone = $readini(c:\script\silviewar.ini,$1,1)
  var %ptwo = $readini(c:\script\silviewar.ini,$1,2)
  var %pnet = $readini(c:\script\silviewar.ini,$1,network)

  /remini c:\script\silviewar.ini MASTER $1
  /remini c:\script\silviewar.ini $1
  /remini c:\script\silviewar.ini $1 $+ . $+ %pone
  /remini c:\script\silviewar.ini $1 $+ . $+ %ptwo

  globaldebug $scriptline  Remember to change cleanup when this is all over.
  if ( ( %pone != the.bank ) && ( %pone != the.silvie ) ) {
    /loligamedata %pone fighting no.one * %pnet
    msg %pone Battle ID %war is over. Cleanup complete. 
    ;next temp
    /loligamedata %pone fights 1 * %pnet
  }
  if ( ( %ptwo != the.bank ) && ( %ptwo != the.silvie ) ) {
    /loligamedata %ptwo fighting no.one * %pnet
    msg %ptwo Battle ID %war is over. Cleanup complete.
    /loligamedata %ptwo fights 1 * %pnet
  }

}

alias lolifightsettings {

  /hadd -s LOLIGAMEHASH FIGHT.LOLI.HP 5
  /hadd -s LOLIGAMEHASH FIGHT.LOLI.ATTACK 1
  /hadd -s LOLIGAMEHASH FIGHT.LOLI.DEFENSE 1
  /hadd -s LOLIGAMEHASH FIGHT.SHTA.HP 10
  /hadd -s LOLIGAMEHASH FIGHT.SHTA.ATTACK 2
  /hadd -s LOLIGAMEHASH FIGHT.SHTA.DEFENSE 2
  /hadd -s LOLIGAMEHASH FIGHT.TRAP.HP 15
  /hadd -s LOLIGAMEHASH FIGHT.TRAP.ATTACK 1
  /hadd -s LOLIGAMEHASH FIGHT.TRAP.DEFENSE 10
  /hadd -s LOLIGAMEHASH FIGHT.BISH.HP 15
  /hadd -s LOLIGAMEHASH FIGHT.BISH.ATTACK 10
  /hadd -s LOLIGAMEHASH FIGHT.BISH.DEFENSE 3
  /hadd -s LOLIGAMEHASH FIGHT.TSUN.HP 10
  /hadd -s LOLIGAMEHASH FIGHT.TSUN.ATTACK 8
  /hadd -s LOLIGAMEHASH FIGHT.TSUN.DEFENSE 8
  /hadd -s LOLIGAMEHASH FIGHT.YNDR.HP 15
  /hadd -s LOLIGAMEHASH FIGHT.YNDR.ATTACK 20
  /hadd -s LOLIGAMEHASH FIGHT.YNDR.DEFENSE 8
  /hadd -s LOLIGAMEHASH FIGHT.MGNK.HP 10
  /hadd -s LOLIGAMEHASH FIGHT.MGNK.ATTACK 2
  /hadd -s LOLIGAMEHASH FIGHT.MGNK.DEFENSE 20
  /hadd -s LOLIGAMEHASH FIGHT.STKR.HP 500
  /hadd -s LOLIGAMEHASH FIGHT.STKR.ATTACK 30
  /hadd -s LOLIGAMEHASH FIGHT.STKR.DEFENSE 20
  /hadd -s LOLIGAMEHASH FIGHT.MHSJ.HP 500
  /hadd -s LOLIGAMEHASH FIGHT.MHSJ.ATTACK 25
  /hadd -s LOLIGAMEHASH FIGHT.MHSJ.DEFENSE 25






}






alias givefightcommands {
  %unid = $lolifightchecker
  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  if (( %status == p1 ) || ( %status == p2 ) ) {
    var %activep = $readini(c:\script\silviewar.ini,%unid,activep)
  }


  if ( $1 == $null) {

    if ( %status == prematch ) {
      msg $nick The following commands are available during the pre-match period.
      msg $nick !commands !mystatus !deploytrap !bishaura !flee
      msg $nick Use �!commands [command] � to learn more about a command.
      halt
    }
    if ( %activep == $nick ) {
      msg $nick The following commands are available during your turn.
      msg $nick !commands !mystatus !deploytrap !bishaura !flee
      msg $nick Use �!commands [command] � to learn more about a command.
      halt
    }      

    if ( %activep != $nick ) {
      msg $nick The following commands are available when it is not your turn.
      msg $nick !commands !mystatus
      msg $nick Use �!commands [command] � to learn more about a command.
      halt
    }      


  } 
  if ( $1 == !commands ) {
    msg $nick Um, didn't you figure that already? This command is available through the whole match.
  }
  if ( $1 == !mystatus ) {
    msg $nick This will show your current HP, Offensive Power, and Defensive Power. This command is available through the whole match.
  }  
  if ( $1 == !deploytrap ) {
    msg $nick !deploytrap [no. of traps to deploy]
    msg $nick Available during Pre-match period and during your turn.
    msg $nick Decreases the chance that your opponent can !flee and also reduces certain types of attacks. A deployed Trap is no longer available to fight or defend, and so your HP will be reduced accordingly.
  }  
  if ( $1 == !bishaura ) {
    msg $nick !bishaura [PERCENTAGE]
    msg $nick Available during Pre-match period and during your turn.
    msg $nick Bishie like thinking about themselves, gaining that mystrical glow around them. It's hard to not be distracted by it.
    msg $nick This increases your defense and reduces some incoming attacks.
    msg $nick However, your own forces are attracted to this aura.
  }  
  if ( $1 == !flee ) {
    msg $nick Available during Pre-match period and during your turn.
    msg $nick Try to leave the fight. But be warned, its not so easy all the time.
  }  

}

alias fightend {
  ;    /fightend %unid $1 fled
  var %unid = $1
  var %pone = $2 
  var %ponen = $readini(c:\script\silviewar.ini,%unid $+ . $+ %pone,name)

  ; actor that won
  var %ochan = $readini(c:\script\silviewar.ini,%unid,chan)
  var %ptwo = $readini(c:\script\silviewar.ini,%unid,2)
  if ( %ptwo == %pone ) { 
    %ptwo = $readini(c:\script\silviewar.ini,%unid,1) 
  }
  var %ptwon = $readini(c:\script\silviewar.ini,%unid $+ . $+ %ptwo,name)

  ;/writeini c:\script\silviewar.ini %unid starttime $ctime

  var %starttime = $readini(c:\script\silviewar.ini,%unid,starttime)
  var %tti = $calc($ctime - %starttime)


  var %outline = %ponen wins battle with %ptwon in a battle lasting $duration(%tti) $+ ! 

  if ( $3 == fled ) {
    var %outline = %outline %ptwon fled the battle feild.
  }

  if ( $3 == won ) {
    var %outline = %outline %ponen won in normal combat.
  }

  if ( $3 == collateral ) {
    %outline = %outline %ptwon killed themselves in collateral damage.
  }


  if ( %ochan != $null ) { msg %ochan %outline } 



  /writeini c:\script\silviewar.ini %unid status cleanup

  /timer $+ %unid 1 5 /lolifightminder %unid  
  halt
}

alias lolifightchangesides {
  var %unid = $1
  if ( %unid == $null ) { halt }
  var %status = $readini(c:\script\silviewar.ini,%unid,status)
  var %pone = $readini(c:\script\silviewar.ini,%unid,1)
  var %ptwo = $readini(c:\script\silviewar.ini,%unid,2)

  ;  globaldebug $scriptline change them sides!

  /lolifightstatus %pone 2 * * %unid
  var %outline = %pone $+ 's forces at $lolifightstatus(%pone,100,,,%unid) percent.
  if (( %ptwo != the.bank ) && ( %ptwo != the.silvie ) ) { 
    /lolifightstatus %ptwo 2 * * %unid
    /lolifightstatus %ptwo 3 %pone * %unid
    /lolifightstatus %pone 3 %ptwo * %unid
    var %outline = %outline %ptwo $+ 's forces at $lolifightstatus(%ptwo,100,,,%unid) percent.
  }
  if ( %ptwo == the.silvie ) { 
    /lolifightstatus the.silvie 0 * * %unid
    /lolifightstatus %pone 3 the.silvie * %unid
    var %outline = %outline Silvie's forces at $lolifightstatus(the.silvie,100,,,%unid) percent.
  }
  if ( %ptwo == the.bank ) { 
    /lolifightstatus the.bank 0 * * %unid
    /lolifightstatus %pone 3 the.bank * %unid
    var %outline = %outline $network bank's forces at $lolifightstatus(the.bank,100,,,%unid) percent.
  }


  var %ponehp = $readini(c:\script\silviewar.ini,%unid $+ . $+ %pone,hpnow)
  var %ptwohp = $readini(c:\script\silviewar.ini,%unid $+ . $+ %ptwo,hpnow)



  if ( %status = p1 ) {
    /writeini c:\script\silviewar.ini %unid status p2
    /writeini c:\script\silviewar.ini %unid activep %ptwo
    /writeini c:\script\silviewar.ini %unid time $ctime
    /timer $+ %unid 1 15 /lolifightminder %unid  


    var %whoitis = $readini(c:\script\silviewar.ini,%unid,activep)
    var %whoitis = $readini(c:\script\silviewar.ini,%unid $+ . $+ %whoitis,name)



    if ( %ptwohp < 1 ) {
      /fightend %unid %pone won
    }
    if ( %ponehp < 1 ) {
      /fightend %unid %ptwo collateral
    }

    var %outline = It is now %whoitis $+ 's turn!

    if ( %outline != $null ) {
      msg %pone %outline
      if ( . !isin %ptwo ) { msg %ptwo %outline }
    }


    halt

  }
  ;below assumes going back to p1 from p2


  if ( %ponehp < 1 ) {
    /fightend %unid %ptwo won
  }

  if ( %ptwohp < 1 ) {
    /fightend %unid %pone collateral
  }




  var %ochan = $readini(c:\script\silviewar.ini,%unid,chan)
  var %minele = $readini(c:\script\silviewar.ini,%unid,artime)
  %minele = $calc(%minele + 2)
  /writeini c:\script\silviewar.ini %unid artime %minele


  var %first = $calc( (%minele) / 5)
  var %second = $calc( $int(%first) * 5 )
  if ( %second == %minele ) {
    if ( %ochan != $null ) { msg %ochan Battle Report, round %minele $+ : %outline }
  }



  /writeini c:\script\silviewar.ini %unid status p1
  /writeini c:\script\silviewar.ini %unid activep %pone
  /writeini c:\script\silviewar.ini %unid time $ctime
  /timer $+ %unid 1 15 /lolifightminder %unid  

  var %ptwon = $readini(c:\script\silviewar.ini,%unid $+ . $+ %pone,name)
  var %outline = It is now %pone $+ 's turn!
  if ( %outline != $null ) {
    msg %pone %outline
    if ( . !isin %ptwo ) { msg %ptwo %outline }
  }




  halt
}