// GAME.CON v1.11 for NAPALM
// (c) Heikki & Tuomo Korva 1998
  
include DEFAULT1.CON
include DEFAULT2.CON

define AITA 3831
define ILMAMIINA 58
define PIINA 172
define BLUEMAINFLAG 1819
define REDMAINFLAG 1818
define DEADVC 2045
define BEASTFLAG 1880
define FIREVASE 1390
define SNAKEYE 1391
define PIKKUSAVU 2328
define SHARK 1549
define ENSPA 1921
define DEMOMAN 1739
define RADIOMAN 1679
define MEDIC 1726
define GRUNT 2149
define CLAYMORE 3644
define CLAYMORE2 3645
define SIRPALE 1553
define LIEKITYS 1889
define MORTAR10 2700
define MORTAR11 2701
define MORTAR12 2702
define MORTAR13 2703
define MORTAR14 2704
define MORTAR15 2705
define MORTAR16 2706
define NUOLI 1919
define VALEDOD 2725
define GI 1305
define F105 2675
define AMMUS 3796
define WORDZ 606
define OHJUS3 2680
define CO1 3690
define CO2 3692
define SMOKE 1551
define HUPROB 3633
define DEADTANK 2730
define HUEYDOWN 3675

action AITA1 0 1 1 1 1
useractor notenemy AITA TOUGH AITA1
cstat 17
enda



action KOPTERI 0 2 5 1 8
action CHOPSPIN 0 5 1 1 10

move ALASP2 100 750
ai AICHOPDOWN CHOPSPIN ALASP2 spin 

useractor notenemy HUEYDOWN 0 KOPTERI 
        sizeat 48 48

        ifaction KOPTERI
        {
        soundonce HELICOP_IDLE
        ifpdistl 26000 { globalsound HK1 ai AICHOPDOWN }
        }

        ifai AICHOPDOWN
        {
        ifrnd 196 spawn SMALLSMOKE

        iffloordistl 5
                {
                stopsound HK1
                stopsound HELICOP_IDLE
                spawn EXPLOSION2
                spawn BURNING2
                spawn SIRPALE spawn SIRPALE spawn SIRPALE
                debris SCRAP1 25
                debris SCRAP6 25
                debris SCRAP2 25
                globalsound LASERTRIP_EXPLODE
                globalsound LASERTRIP_EXPLODE
                killit
                }
        }

enda



move apers9 0 -400
action BOUNDAPERS 0 1 1 1 1
useractor notenemy ILMAMIINA 0 BOUNDAPERS apers9 faceplayer  
sizeat 40 40 
ifaction BOUNDAPERS
        {
        ifcount 8 
                { 
                sound INTRUDER_ALERT 
                spawn EXPLOSION2
                debris SCRAP6 9
                debris SCRAP2 9
                hitradius 4500 20 30 50 90
                killit
                } 
        }
enda


action HI 0 1 1 1 1
useractor notenemy HUPROB 0 HI
{
ifaction HI { 
              sizeat 48 48 
              ifspritepal 4 {
                                cstat 17
                                soundonce HELICOP_IDLE
                                ifpdistl 3000 { spritepal 5 stopsound HELICOP_IDLE }
                            }

              ifspritepal 5 {
                               
                               soundonce GENAMB6
                               ifrnd 5 { stopsound GENAMB6 sound SOMETHINGFROZE resetcount spritepal 6 }
                            }

              ifspritepal 6 { ifcount 1500 { sound ALIEN_TALK1 cstat 0 spritepal 7 resetcount } }

              ifspritepal 7 { ifcount 70 soundonce HELICOP_IDLE }
            }
}
enda

action TANKKIPALAA 0 7 1 1 14
useractor notenemy DEADTANK 0 TANKKIPALAA
ifaction TANKKIPALAA { cstat 1 sizeat 38 38 soundonce FIRE_CRACKLE }
enda

action CO11 0 1 1 1 1
action CO12 0 2 1 1 15
action CO13 0 1 1 1 1
action CO14 0 2 1 1 15
action CO15 0 2 1 1 15
useractor notenemy CO1 0 CO11

ifaction CO11
{
cstat 1
sizeat 42 42
ifpdistl 2048
                {
                ifspritepal 10 { sound M1 action CO12 }
                ifspritepal 11 { sound M4 action CO14 }
                ifspritepal 12 { sound M6 action CO12 }
                ifspritepal 13 { ifcount 100 { sound M27 action CO15 } }
                }

}

ifaction CO15 { ifactioncount 47 action CO13 }
ifaction CO12 { ifactioncount 70 action CO13 }
ifaction CO14 { ifactioncount 100 action CO13 }

ifaction CO13
{
ifpdistl 1024
        { ifhitspace
                { 
                   ifspritepal 10 { sound M1 action CO12 }
                   ifspritepal 11 { sound M4 action CO14 }
                   ifspritepal 12 { sound M6 action CO12 }
                   ifspritepal 13 { sound M27 action CO15 }
                }
        }
}
enda

action CO21 0 1 1 1 1
action CO22 0 2 1 1 15
action CO23 0 1 1 1 1
action CO24 0 2 1 1 15
action CO25 0 2 1 1 15
action CO26 0 2 1 1 15
useractor notenemy CO2 0 CO21

ifaction CO21
{
cstat 1
sizeat 42 42
ifpdistl 2048
                {
                ifspritepal 10 { ifcount 50 { sound M2 action CO22 } }
                ifspritepal 11 { sound M7 action CO24 }
                ifspritepal 12 { sound M22 action CO25 }
                ifspritepal 13 { sound M25 action CO24 }
                ifspritepal 14 { sound M26 action CO24 }
                ifspritepal 15 { sound M28 action CO26 }
                }

}

ifaction CO22 { ifactioncount 37 action CO23 }
ifaction CO24 { ifactioncount 43 action CO23 }
ifaction CO25 { ifactioncount 49 action CO23 }
ifaction CO26 { ifactioncount 66 action CO23 }

ifaction CO23
{
ifpdistl 1024
        { ifhitspace
                { 
                   ifspritepal 10 { sound M2 action CO22 }
                   ifspritepal 11 { sound M7 action CO24 }
                   ifspritepal 12 { sound M22 action CO25 }
                   ifspritepal 13 { sound M25 action CO24 }
                   ifspritepal 14 { sound M26 action CO24 }
                   ifspritepal 15 { sound M28 action CO26 }
                }
        }
}
enda



action SANA
action SANA2
useractor notenemy WORDZ 0 SANA
ifaction SANA
{
cstat 32768
ifp palive {
ifcansee
{
ifpdistl 800
        {
        ifspritepal 10 { quote 151 action SANA2 }
        ifspritepal 11 { ifhitspace { quote 4 action SANA2 } }
        }
} } }

ifaction SANA2
{ ifpdistg 800 action SANA }
enda


action PII 0 1 1 1 1
useractor notenemy PIINA 0 PII
{
ifaction PII
              {
               cstat 32768
               
               ifspritepal 10 {
                               ifpdistl 500 { ifp palive { addphealth -200 } }
                              }

               ifspritepal 11
                        { ifpdistl 700 { ifcount 20 { addphealth -1 palfrom 16 16 ifrnd 50 sound DUKE_LONGTERM_PAIN2 resetcount } } }  

              }
}
enda



action COMM1 0 1 1 1 1
action COMM2 3 1 1 1 1 
action COMM3 4 1 1 1 1

action AG 6 1 1 1 1
action MG 7 1 1 1 1
action SN 8 1 1 1 1
action GR 9 1 1 1 1
action PM 10 1 1 1 1
action ME 11 1 1 1 1
action SQL 12 1 1 1 1
action RM 13 1 1 1 1

useractor notenemy NUOLI 0 0
        ifaction 0 { sizeat 39 39 cstat 0 action COMM1 }

        ifaction COMM1
        {
        ifpinventory GET_SCUBA 60 { } else { spritepal 1 ifcount 1 killit }
        ifpinventory GET_SCUBA 70 { } else { spritepal 0 ifcount 1 killit }
        ifpinventory GET_SCUBA 10 { } else { spritepal 8 ifcount 1 killit } 

        ifpinventory GET_SCUBA 65 { } else { action COMM2 spritepal 1 }
        ifpinventory GET_SCUBA 75 { } else { action COMM2 spritepal 0 }
        
        ifpinventory GET_SCUBA 64 { } else { action COMM3 spritepal 1 }
        ifpinventory GET_SCUBA 74 { } else { action COMM3 spritepal 0 }

        ifpinventory GET_SCUBA 80 { } else { action AG }
        ifpinventory GET_SCUBA 81 { } else { action MG }
        ifpinventory GET_SCUBA 82 { } else { action SN }
        ifpinventory GET_SCUBA 83 { } else { action GR }
        ifpinventory GET_SCUBA 84 { } else { action PM }
        ifpinventory GET_SCUBA 85 { } else { action ME }
        ifpinventory GET_SCUBA 86 { } else { action SQL }
        ifpinventory GET_SCUBA 87 { } else { action RM }
        ifcount 1 killit
        }
        
        ifaction COMM2 
        { ifcount 1 killit }
        
        ifaction COMM3
        { ifcount 1 killit }

        ifaction AG
        { ifcount 1 killit }

        ifaction MG
        { ifcount 1 killit }
        
        ifaction SN
        { ifcount 1 killit }

        ifaction GR
        { ifcount 1 killit }

        ifaction PM
        { ifcount 1 killit }

        ifaction ME
        { ifcount 1 killit }

        ifaction SQL
        { ifcount 1 killit }

        ifaction RM
        { ifcount 1 killit }

        enda





state krhsound
    ifrnd 85 sound MORTAR1 
    else ifrnd 85 sound INC12   
    else sound INC13 
ends

state krhx
   ifonwater { spawn WATERSPLASH2 killit break }
   else
    {
    spawn EXPLOSION2
    sound BOMB2
    debris SCRAP4 20 debris SCRAP3 15
    hitradius 4500 25 50 100 200
    stopsound MORTAR1 stopsound INC12 stopsound INC13
    ifrnd 128 spawn BURNING2
    killit
    }
ends

state krhx2
    spawn EXPLOSION2
    sound BOMB2
    debris SCRAP4 20 debris SCRAP3 15
    hitradius 4500 25 50 100 200
    killit
ends

move m1 150 -700
move m2 150 0
move m3
move m4 150 700

action KH1 0 1 1 1 2

ai AIKRH1 KH1 m1 geth getv
ai AIKRH2 KH1 m2 geth getv
ai AIKRH3 KH1 m3 geth getv
ai AIKRH4 KH1 m4 geth getv

useractor notenemy MORTAR10 0 0 geth getv
ifaction 0 { sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { cstat 264 ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 70 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR11 0 0 geth getv
ifaction 0 { sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { cstat 264 ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 115 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR12 0 0 geth getv
ifaction 0 { cstat 264 sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else {  state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 160 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR13 0 0 geth getv
ifaction 0 { cstat 264 sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 205 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR14 0 0 geth getv
ifaction 0 { cstat 264 sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 250 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR15 0 0 geth getv
ifaction 0 { cstat 264 sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 295 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda

useractor notenemy MORTAR16 0 0 geth getv
ifaction 0 { cstat 264 sizeat 48 48 ai AIKRH1 }
ifai AIKRH1 { ifceilingdistl 20 { ifoutside { cstat 32768 ai AIKRH2 } else { state krhx2 } } }
ifai AIKRH2 { ifnotmoving killit else ifactioncount 340 { state krhsound ai AIKRH3 } }
ifai AIKRH3 { ifactioncount 8 { cstat 256 ai AIKRH4 } }
ifai AIKRH4 { iffloordistl 20 state krhx }
enda


move liekkinop 400 20
action LIEKITYS1 2 10 1 1 5
useractor notenemy LIEKITYS 0 LIEKITYS1 liekkinop geth getv
ifaction LIEKITYS1
{ 
cstat 384
sizeat 10 10
ifactioncount 1 sizeat 11 11
ifactioncount 2 sizeat 12 12
ifactioncount 3 sizeat 13 13
ifactioncount 4 sizeat 14 14
ifactioncount 5 sizeat 15 15
ifactioncount 6 sizeat 16 16
ifactioncount 7 sizeat 17 17
ifactioncount 8 sizeat 18 18
ifactioncount 9 sizeat 19 19


ifactioncount 10 killit
ifnotmoving { ifrnd 128 { spawn BURNING }
              spawn SHRINKEREXPLOSION hitradius 1024 10 20 40 60 killit
            }
}
enda


state cs
spawn CLAYMORE2 spawn CLAYMORE2 spawn CLAYMORE2 spawn CLAYMORE2
ends

move eiliiku
move claymoremv 800 0
                      
useractor notenemy CLAYMORE 0 0 eiliiku
{ state cs state cs state cs state cs state cs killit }
enda

action TYHJA 0 1 1 1 1

move SADE 100 0
move SADE2 150 0
move SADE3 500 0

ai CM1 TYHJA SADE randomangle
ai CM2 TYHJA SADE2 randomangle
ai CM3 TYHJA SADE3 randomangle

state cls
spawn EXPLOSION2 hitradius 3072 10 20 40 70
ends

useractor notenemy CLAYMORE2 0 0 claymoremv getv geth

ifaction 0
{
  ifcount 1 { ifrnd 30 { ai CM1 } }
  else ifcount 2 { ifrnd 60 { ai CM2 } }
  else ifcount 3 { ai CM3 } 
}

ifai CM1
{
ifrnd 128 { spawn SIRPALE }
state cls killit
}

ifai CM2
{
  ifcount 1 { ifrnd 128 { spawn SIRPALE state cls killit } }
  else ifcount 2 { state cls killit }
}

ifai CM3
{
  ifcount 1 { ifrnd 128 { spawn SIRPALE state cls killit } }
  else ifcount 2 { state cls killit }
}

enda



action FB 0 4 1 1 1
action FB2 4 4 1 1 1

move LEN0 1 -42
move LEN1 300 -320
move LEN2 300 -240
move LEN3 300 -160
move LEN4 300 -80
move LEN5 300 0
move LEN6 300 80
move LEN7 300 160
move LEN8 300 240
move LEN9 300 320
move LEN10 20
move LEN11

ai AICRANU0 FB2 LEN0 randomangle
ai AICRANU1 FB2 LEN1 randomangle
ai AICRANU2 FB2 LEN2 randomangle
ai AICRANU3 FB2 LEN3 randomangle
ai AICRANU4 FB2 LEN4 randomangle
ai AICRANU5 FB2 LEN5 randomangle
ai AICRANU6 FB LEN6 randomangle
ai AICRANU7 FB LEN7 randomangle
ai AICRANU8 FB LEN8 randomangle
ai AICRANU9 FB LEN9 randomangle
ai AICRANU10 FB LEN10 randomangle
ai AICRANU11 FB LEN11 randomangle

state cranu0
{ ifcansee ai AICRANU1 else killit }
ends

state cranu1
{
        move LEN1 geth getv
        ifactioncount 4 ai AICRANU2
}
ends

state cranu2
{
        move LEN2 geth getv
        iffloordistl 8 ai AICRANU11
        else ifactioncount 4 ai AICRANU3
}
ends

state cranu3
{
   move LEN3 geth getv
   iffloordistl 8 {  ifonwater ai AICRANU10
                     else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU4
}
ends

state cranu4
{
        move LEN4 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU5
}
ends

state cranu5
{
        move LEN5 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU6
}
ends

state cranu6
{
        move LEN6 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU7
}
ends

state cranu7
{
        move LEN7 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU8
}
ends

state cranu8
{
        move LEN8 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11 }
        else ifactioncount 4 ai AICRANU9
}
ends

state cranu9
{
        move LEN9 geth getv
        iffloordistl 8 {  ifonwater ai AICRANU10
                          else ai AICRANU11
                       }
        else ai AICRANU9
}
ends

state cranu10
{ spawn WATERSPLASH2 killit } 
ends

state cranu11
{
      ifrnd 64 spawn BURNING
      killit
}
ends

useractor notenemy SIRPALE 0 0
{
ifaction 0 { sizeat 48 48 ai AICRANU0 }
else { 
          ifai AICRANU0 state cranu0
          else ifai AICRANU1 state cranu1
          else ifai AICRANU2 state cranu2
          else ifai AICRANU3 state cranu3
          else ifai AICRANU4 state cranu4
          else ifai AICRANU5 state cranu5
          else ifai AICRANU6 state cranu6
          else ifai AICRANU7 state cranu7
          else ifai AICRANU8 state cranu8
          else ifai AICRANU9 state cranu9
          else ifai AICRANU10 state cranu10
          else ifai AICRANU11 state cranu11
     }
}
enda

state genericshrunkcode
ends
        
state sharkspawner
       spawn SHARK spawn SHARK spawn SHARK spawn SHARK 
       spawn SHARK spawn SHARK spawn SHARK spawn SHARK 
       spawn SHARK spawn SHARK spawn SHARK spawn SHARK
       ifrnd 128 { spawn SHARK spawn SHARK spawn SHARK }
       ifrnd 64 { spawn SHARK spawn SHARK spawn SHARK }
ends

state smokespawner
       spawn SMOKE spawn SMOKE spawn SMOKE spawn SMOKE
       spawn SMOKE spawn SMOKE spawn SMOKE spawn SMOKE
       spawn SMOKE spawn SMOKE spawn SMOKE spawn SMOKE
ends

action VALO0 0 1 1 1 1
action VALOJUOVA 2247 1 7 1 1
move VALO1 2 -42
move VALO3 2 -70
move VALO2 511

ai AIVALO VALO0 VALO1 faceplayer
ai AIVALO3 VALO0 VALO3 faceplayer
ai AIVALO2 VALOJUOVA VALO2 faceplayer

state valostate3
iffloordistl 35 { } else { ifcansee ai AIVALO2 else killit }
ends

state valostate
     iffloordistl 22 { } else { ifcansee ai AIVALO2 else killit }
ends

state valostate2
    cstat 0
    move VALO2 geth getv
    ifnotmoving { killit } 
    else ifpdistl 1500 { killit }
    else ifcount 100 { killit }
ends

action ASHARK0 0 1 1 1 1
action ASHARK1 0 1 1 1 1
action ASHARK2 0 1 1 1 1
action ACD 0 1 1 1 1
action ACD2 2 1 1 1 1

move YLESPAIN 0 -25
move POISPAIN  -150 -50
move SHARKVEL1 0  -27
move SHARKVEL2 240  0
move SHARKVEL3 200  0
move SHARKVEL4 0  100
move SHARKVEL5 650  0
move SHARKVEL6 0  -200
move SHARKVEL7 0  1350
move SHARKVEL8 400  0

ai AIRAJ1 ASHARK2 SHARKVEL3 randomangle
ai AISUUNTAUS ASHARK2 YLESPAIN faceplayer
ai AISUUNTAUS2 ASHARK2 POISPAIN faceplayer
ai AISHARK1 ASHARK1 SHARKVEL1 faceplayer
ai AISHARK2 ASHARK2 SHARKVEL2 randomangle
ai AISHARK3 ASHARK2 SHARKVEL2 randomangle
ai AICD ACD SHARKVEL2 randomangle

state suuntaustate
{
 iffloordistl 22 { ifnotmoving killit
                   else ifcount 50 killit }

              else   {
                       ifnotmoving killit
                       else ai AISUUNTAUS2
                     }
}
ends

state suuntaustate2
{
move POISPAIN geth getv

ifceilingdistl 120 { 
                    ifoutside { spawn TRANSPORTERBEAM killit } 
                    else killit
                   }
else { ifnotmoving { ifoutside { spawn TRANSPORTERBEAM killit } 
                      else killit
                   }
     }
}
ends

state sharkstate1
{ ifceilingdistl 100 { ai AISHARK2 resetcount } }
ends

state sharkstate2
{ ifrnd 3 
        { spawn CEILINGSTEAM killit } 
  else 
        { ifcount 220 { spawn CEILINGSTEAM killit } }
}
ends

state sharkstate3
{ ifrnd 1 { ifrnd 32 { spawn CEILINGSTEAM killit } } }
ends




state rajstate1
ifcount 10 { ifrnd 128 { spawn EXPLOSION2 hitradius 1024 8 16 32 64 killit } }
else ifcount 20 { spawn EXPLOSION2 hitradius 1024 8 16 32 64 killit }
ends

state cdstate
ifcount 5 { ifrnd 51 { spawn EXPLOSION2 hitradius 3500 20 40 70 100 killit } }
else ifcount 15 { ifrnd 51 { spawn EXPLOSION2 hitradius 3500 20 40 70 100 killit } }
else ifcount 25 { ifrnd 51 { spawn EXPLOSION2 hitradius 3500 20 40 70 100 killit } }
else ifcount 35 { spawn EXPLOSION2 hitradius 3500 20 40 70 100 killit } 
ends

useractor notenemy SHARK 0 ASHARK0
ifaction ASHARK0 
{ 
ifspawnedby RUBBERCAN { cstat 32768 ai AICD } 
else ifspawnedby TRANSPORTERBEAM { ai AISHARK1 }
else ifspawnedby SPACESHUTTLE { cstat 32768 ai AISHARK3 }
else ifspawnedby LIZTROOPDUCKING { sizeat 43 43 cstat 0 ai AIVALO }
else ifspawnedby LIZMAN { sizeat 43 43 cstat 0 ai AIVALO3 }
else ifspawnedby EXPLOSION2 { cstat 32768 ai AIRAJ1 }
else ifspawnedby RADIOMAN { cstat 0 ai AISUUNTAUS }
else killit
}
else 
        {
          ifai AISHARK1 state sharkstate1
          else ifai AIRAJ1 state rajstate1
          else ifai AISUUNTAUS state suuntaustate
          else ifai AISUUNTAUS2 state suuntaustate2
          else ifai AIVALO state valostate
          else ifai AIVALO2 state valostate2
          else ifai AIVALO3 state valostate3
          else ifai AISHARK2 state sharkstate2
          else ifai AISHARK3 state sharkstate3
          else ifai AICD state cdstate
        }
enda

action ASMOKE0

ai AISMOKEYLOS ASMOKE0 YLESPAIN faceplayer
ai AISMOKEHAJO ASMOKE0 SHARKVEL2 randomangle
ai AISMOKEALAS ASMOKE0 SHARKVEL7 faceplayer

useractor notenemy SMOKE 0 0
ifaction 0 { ifspawnedby SMOKE ai AISMOKEALAS else ai AISMOKEYLOS }

ifai AISMOKEYLOS
{ ifceilingdistl 100 { ai AISMOKEHAJO resetcount } }

ifai AISMOKEHAJO
{
  ifrnd 4 { spawn SMOKE killit } 
  else { ifcount 220 { spawn SMOKE killit } }
}

ifai AISMOKEALAS
{ iffloordistl 10 { ifonwater killit else { sound LADY_SCREAM spawn SHRINKEREXPLOSION killit } } }
enda


move RESPAWN_ACTOR_FLAG

state headhitstate
// wackplayer
ends

action EXPBARRELFRAME         0   2   1   1   15
actor EXPLODINGBARREL 26
    fall
    ifaction EXPBARRELFRAME
    {
        ifactioncount 2
        {
            hitradius 1024 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
            spawn EXPLOSION2
            debris SCRAP2 2
            sound PIPEBOMB_EXPLODE
            killit
        }
        break
    }
    ifsquished
    {
        debris SCRAP1 5
        killit
        break
    }
    ifhitweapon
        action EXPBARRELFRAME
enda

action BURNING_FLAME    0   12   1   1   2
action BURNING_FLAME5   0   13   1   1   13

move BURNING_VELS 

state burningstate

    ifspawnedby FEM3
            {
                spritepal 8
                ifactioncount 2 { ifpdistl 3500 { addphealth -1 palfrom 32 32 ifrnd 32 sound DUKE_LONGTERM_PAIN2 resetactioncount } }
                else ifcount 412 killit 
            }

    ifrnd 60 spawn SMALLSMOKE 
    ifgapzl 16 break
    ifpdistg 10240 break
    ifcount 128
    {
        ifspawnedby TIRE
        {
            ifactioncount 512
            {
                sizeto 16 16
                killit
            }
            ifrnd 16 sizeto 64 48
        }
        else
        {
            sizeto 8 8 sizeto 8 8
            ifactioncount 192 killit
        }
    }
    else
    {
        ifmove 0 move BURNING_VELS

        ifspawnedby BOX
            { sizeto 32 32 ifcount 32 { spawn SMALLSMOKE killit } }
        else ifspawnedby TREE1 sizeto 96 96
        else ifspawnedby TREE2 sizeto 96 96
        else ifspawnedby APLAYER { sizeto 40 40 sizeto 40 40 }
        else sizeto 52 52
        ifactor BURNING { ifp palive ifpdistl 844 ifrnd 32 ifcansee { soundonce DUKE_LONGTERM_PAIN addphealth -1 palfrom 24 16 } }
    }
ends

actor BURNING WEAK BURNING_FLAME
    cstat 128
    state burningstate
enda

actor BURNING2 WEAK BURNING_FLAME5
    state burningstate cstat 130 
enda

actor TOILETWATER 
ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget 
{ quote 155 addinventory GET_BOOTS 100 killit }  
enda

actor RUBBERCAN

fall
ifspawnedby APLAYER { } else { 
        ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget         
                          { 
                        ifpinventory GET_BOOTS 62 { } else { quote 149 addinventory GET_BOOTS 64 killit }                                               
                        ifpinventory GET_BOOTS 64 { } else { quote 149 addinventory GET_BOOTS 66 killit }
                        ifpinventory GET_BOOTS 66 { } else { break }
                        addinventory GET_BOOTS 62 quote 149 killit 
                          }
                            }                 
ifcount 100 {
              state sharkspawner
              sound PIPEBOMB_EXPLODE debris SCRAP6 8 debris SCRAP2 8
              spawn EXPLOSION2
              killit }


enda

actor STEAM  
cstat 32768
ifpdistl 20000 {
        
          ifspritepal 10 {
                          ifcount 1000 {
                          ifrnd 51 sound WAR_AMBIENCE1
                          else ifrnd 51 sound GENERIC_AMBIENCE1
                          else ifrnd 51 sound KILLME
                          else ifrnd 51 sound TURR_PAIN
                          else ifrnd 51 sound TURR_DYING
                          else ifrnd 51 sound BOS1_WALK
                          resetcount
                                        }
                         }

           else ifcount 700 {
                resetcount
                ifrnd 18 sound WAR_AMBIENCE1
                else ifrnd 18 sound WAR_AMBIENCE2
                else ifrnd 18 sound WAR_AMBIENCE3
                else ifrnd 18 sound WAR_AMBIENCE4
                else ifrnd 18 sound WAR_AMBIENCE10
                else ifrnd 18 sound WARAMB1
                else ifrnd 18 sound WARAMB2
                else ifrnd 18 sound AAVE
                else ifrnd 18 sound WARAMB3
                else ifrnd 18 sound GENERIC_AMBIENCE13
                else ifrnd 18 sound GENERIC_AMBIENCE16
                else ifrnd 18 sound GENERIC_AMBIENCE17
                else ifrnd 18 sound SPACE_DOOR1
                else ifrnd 18 sound SPACE_DOOR2
                             } 
     }
enda

action RUBCAN5 1 2 1 1 3
move LENTO5 512
actor HORSEONSIDE 100 0 LENTO5 randomangle 
        ifaction 0 { cstat 32 sound AAVE action RUBCAN5 }
        ifaction RUBCAN5 
        {
        ifpdistl 7092 { ifcount 8 { sound VIHELLYS spawn COLA resetcount } }
        ifnotmoving killit
        }
enda

state minexplo
sound INTRUDER_ALERT debris SCRAP6 12 debris SCRAP2 12 spawn EXPLOSION2 hitradius 2048 30 50 80 120 killit break
ends

state minexplo2
sound SWITCH_ON spawn ILMAMIINA killit
ends

state minedead
sound LASERTRIP_ONWALL quote 102 killit break
ends


action APERS1 0 1 1 1 1
action APERS2 1 1 1 1 1
action APERZ  1 1 1 1 1
useractor notenemy FEM7 WEAK  
{
    sizeat 48 48 fall cstat 256

    ifhitweapon { ifwasweapon RADIUSEXPLOSION { state minexplo } }
    ifaction 0 action APERS1
     
    ifaction APERS1 
    { 
    ifpdistl 800 { sound SWITCH_ON action APERS2 }
    else ifpdistl 2800
        {
        ifpinventory GET_BOOTS 100 { } else { soundonce TURR_RECOG }
        ifpinventory GET_SCUBA 84 { } else { soundonce TURR_RECOG }
        }
        
    }

    ifaction APERS2 
    { 
            
      ifpdistg 800 { state minexplo2 }  
      else
      {
      ifpinventory GET_BOOTS 100 { } else { soundonce TURR_RECOG }
      ifpinventory GET_SCUBA 84 { } else { soundonce TURR_RECOG }
      }
      
      ifhitspace
      {
        ifpinventory GET_SCUBA 80 { } else { ifrnd 51 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 81 { } else { ifrnd 51 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 82 { } else { ifrnd 154 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 83 { } else { ifrnd 51 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 84 { } else { ifrnd 230 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 85 { } else { ifrnd 51 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 86 { } else { ifrnd 51 state minedead else state minexplo2 }
        ifpinventory GET_SCUBA 87 { } else { ifrnd 154 state minedead else state minexplo2 }

        ifrnd 128 { sound LASERTRIP_ONWALL quote 102 killit }
        else { state minexplo2 }
      }
    } 

}
enda

action PUTOA3 0 1 1 1 1
action PUTOA4 0 1 1 1 1

actor CEILINGSTEAM 

ifaction 0
{ cstat 32768 action PUTOA3 }

ifaction PUTOA3
{
ifrnd 2
        { 
        ifrnd 70 
                { 
                ifrnd 128 sound INC10 else sound INC11
                action PUTOA4   
                }
        }
else action PUTOA3
}


ifaction PUTOA4
{
fall
iffloordistl 4
    {
       ifonwater { spawn WATERSPLASH2 killit break }
       else { 
            ifspawnedby SHARK { } else spawn NUKEBARREL
            spawn EXPLOSION2
            debris SCRAP4 25 debris SCRAP3 20
            hitradius 4500 25 50 100 200 
            ifrnd 128 sound EXP10 else sound EXP11
            ifrnd 128 spawn BURNING2 
            killit 
            }       
    }
}
enda



actor WATERBUBBLEMAKER 0 0 randomangle
    ifpdistl 3084 ifrnd 24 spawn WATERBUBBLE
enda

action BUBBLE
action CRACKEDBUBBLE    1
move BUBMOVE           -10 -36
move BUBMOVEFAST           -10 -52

actor WATERBUBBLE 0 BUBBLE BUBMOVE getv geth randomangle

    ifaction CRACKEDBUBBLE
    {
        ifinwater ifrnd 192 killit
        ifactioncount 7 killit
    }
    else
    {
        ifcount 4
        {
            ifrnd 192 move BUBMOVE getv geth randomangle
            else move BUBMOVEFAST getv geth randomangle
            resetcount
        }

        ifonwater
        {
            iffloordistl 8 action CRACKEDBUBBLE
        }
        else ifactioncount 40 action CRACKEDBUBBLE
    }
enda


move ENGINE_SMOKE 64 -64
move SMOKESHOOTOUT -192
move SMOKEVEL2 10 -18
move SMOKEVEL3 10 9

action SMOKEFRAMES 1317 8 1 1 18

actor SMALLSMOKE 0 SMOKEFRAMES
    ifmove 0
    {
        ifspawnedby RECON
            move SMOKESHOOTOUT geth
        else ifspawnedby SECTOREFFECTOR
            move ENGINE_SMOKE geth getv
        else ifspawnedby SHOTSPARK1 { spawn PIKKUSAVU killit }
        else ifspawnedby KNEE { spawn PIKKUSAVU killit }
        else ifspawnedby BURNING2 move SMOKEVEL2 geth getv randomangle
        else ifspawnedby BURNING move SMOKEVEL2 geth getv randomangle
        else ifspawnedby TRANSPORTERSTAR move SMOKEVEL2 geth getv randomangle
        else ifspawnedby OHJUS3 move SMOKEVEL3 geth getv randomangle
        else ifspawnedby CRYSTALAMMO move SMOKEVEL3 geth getv randomangle
        else move SMOKEVEL2 geth getv randomangle

    }
    ifpdistl 500 ifspawnedby RPG killit
    cstat 2
    ifactioncount 8 killit
enda

action SMOKEFRAMES2 1 4 1 1 6
useractor notenemy PIKKUSAVU 0 SMOKEFRAMES2
sizeat 20 20 cstat 130
ifactioncount 4 killit
enda

action BARREL_DENTING  2 2 1 1 6
action BARREL_DENTED   1
action BARREL_DENTED2  2

move SPAWNED_BLOOD

action PUTOA 0 1 1 1 1
action PUTOA2 109 1 1 1 1

actor NUKEBARRELDENTED 
ifaction 0 { cstat 32768 action PUTOA }
ifaction PUTOA
{

ifrnd 2 
        { 
        ifrnd 70 
                { 
                cstat 0 state krhsound action PUTOA2 
                }
        }

else action PUTOA
}
ifaction PUTOA2
{
fall
iffloordistl 4
    {
       ifonwater { spawn WATERSPLASH2 killit break }
       else { spawn EXPLOSION2 sound BOMB2 debris SCRAP4 20 debris SCRAP3 15 hitradius 3200 25 50 100 200 ifrnd 128 spawn BURNING2 spawn NUKEBARREL killit } 
     }
}
enda

action HEKO  3575 2 5 1 3
action HEKO2 3575 2 5 1 3
move HEKONOP 175
actor ATOMICHEALTH 100 0 HEKONOP randomangle
        ifaction 0 { action HEKO }
        ifaction HEKO 
        { 
          soundonce HELICOP_IDLE
          ifpdistl 8000
                { ifphealthl MAXPLAYERHEALTH 
                        {
                        ifrnd 96 { resetcount sound HK1 spawn FIRSTAID action HEKO2 }
                        else { resetcount sound HK2 spawn SIXPAK action HEKO2 }
                        } 
                  else 
                        {
                        ifrnd 128 { resetcount sound HK1 spawn FIRSTGUNSPRITE action HEKO2 }
                        else ifrnd 96 { resetcount sound HK2 spawn SHRINKERSPRITE action HEKO2 }
                        else ifrnd 32 { resetcount sound HK2 spawn RPGSPRITE action HEKO2 }
                        else action HEKO2
                        }
                }
          ifnotmoving { stopsound HELICOP_IDLE killit }
        }

        ifaction HEKO2
        { 
          soundonce HELICOP_IDLE
          ifnotmoving { stopsound HELICOP_IDLE killit }
          ifcount 256 action HEKO
        }
enda

action CR 2361 1 1 1 1

useractor notenemy NUKEBARREL 
    fall
    ifaction 0 { sizeat 48 48 cstat 162 action CR }
enda

state burningbarrelcode
    fall
    ifcount 32
    {
        resetcount
        ifp palive ifpdistl 1480 ifp phigher
        {
            addphealth -1
            palfrom 16 16
            ifrnd 96 sound DUKE_LONGTERM_PAIN
        }
    }
    ifhitweapon
    {
        sound VENT_BUST
        debris SCRAP1 10
        spawn BURNING
        killit
    }
ends

actor FIREBARREL state burningbarrelcode enda

state ohjus2
spawn EXPLOSION2
sound BOMB2
ifspawnedby F105 { } else { debris SCRAP4 30 debris SCRAP3 20 }
hitradius 4096 25 50 100 200
ends

action OHJUS 1215 1 7 1 1 
move OHJUSNOP 800 700

actor FIREVASE 100 0 OHJUSNOP randomangle
        ifaction 0
        { sound OHJUSLENTO action OHJUS }

        ifaction OHJUS
        {
        ifcount 1 { spawn SMALLSMOKE resetcount }
        ifnotmoving { state ohjus2 killit }
        iffloordistl 8 
                {
                    {
                    ifonwater { spawn WATERSPLASH2 killit break }
                    else { state ohjus2 ifrnd 128 spawn BURNING2 spawn NUKEBARREL killit } 
                    }
                }
        }
enda

action OHJUSS 1214 1 7 1 1 
move OHJUSNOP2 800 1000

useractor notenemy SNAKEYE 100 0 OHJUSNOP2 randomangle
        ifaction 0
        { sizeat 48 48 sound OHJUSLENTO action OHJUSS }

        ifaction OHJUSS
        {
        ifcount 1 { spawn SMALLSMOKE resetcount }
        ifnotmoving { state ohjus2 killit }
        iffloordistl 8 
                {
                    {
                    ifonwater { spawn WATERSPLASH2 killit break }
                    else { state ohjus2 ifrnd 128 spawn BURNING2 killit } 
                    }
                }
        }
enda

action OHJUSX 1 1 1 1 1 
move OHJUSNOP3 0 -250

useractor notenemy OHJUS3 100 0 OHJUSNOP3 faceplayer
        ifaction 0
        { sizeat 48 48 sound AAVE action OHJUSX }

        ifaction OHJUSX
        {
        ifcount 1 { spawn SMALLSMOKE resetcount }
        ifnotmoving killit
        ifceilingdistl 50 killit
        }
enda




action SHRINKERFRAMES 235 19 1 1 4
action FLAMER2 235 19 1 1 3
action SMOKE1 2134 6 1 1 85
action ILMO15 2133 10 1 -1 50

action SMOKEHAIHTUU 2124 10 1 1 50
action SHRINKERFRAMES2 0 1 1 1 1

actor SHRINKEREXPLOSION 1
    ifaction 0
    {
      ifspawnedby LIEKITYS action FLAMER2
      else ifspawnedby SMOKE
                {
                 sizeto 4096 4096
                 ifrnd 64 { cstat 14 } else ifrnd 64 { cstat 10 }
                 else ifrnd 64 { cstat 6 } else { cstat 2 }
                 action ILMO15
                }
      else ifspawnedby APLAYER action SHRINKERFRAMES
      else action SHRINKERFRAMES2
    }

    ifaction SHRINKERFRAMES2
    { debris SCRAP6 8 debris SCRAP2 8 hitradius 3300 22 44 88 150 action SHRINKERFRAMES }

    ifaction SHRINKERFRAMES 
    { ifactioncount 19 killit }

    ifaction FLAMER2
    { ifactioncount 19 killit }

    ifaction SMOKE1
    { ifactioncount 54 action SMOKEHAIHTUU }
                
    ifaction ILMO15
    { ifactioncount 10 action SMOKE1 }
           
    ifaction SMOKEHAIHTUU
    { ifactioncount 10 killit }

enda

action EXPLOSION 0 20 1 1 4
action NALLI 1725 6 1 1 3 
action EXPLOD1 742 16 1 1 4
action EXPLOD2 760 22 1 1 4


actor EXPLOSION2 1

ifaction 0
{
ifspawnedby APLAYER action NALLI
else ifspawnedby COLA { spawn SIRPALE spawn SHARK action EXPLOSION }
else ifspawnedby LIZMANJUMP { spawn SHARK spawn SHARK spawn SHARK action EXPLOSION }
else ifspawnedby HUEYDOWN { spawn SHARK spawn SHARK spawn SHARK spawn SHARK spawn SHARK action EXPLOSION }
else ifspawnedby NAPALM { spawn SIRPALE spawn SHARK action EXPLOSION }
else ifspawnedby TRIPBOMB { spawn CLAYMORE killit }
else ifspawnedby HEAVYHBOMB { spawn SIRPALE hitradius 3800 20 30 60 100 action EXPLOSION } 
else ifspawnedby SHARK
        {
          cstat 0
          ifrnd 85 action EXPLOD1
          else ifrnd 85 action EXPLOD2
          else action EXPLOSION  
        }
else ifspawnedby CLAYMORE2
        {
          ifrnd 85 action EXPLOD1
          else ifrnd 85 action EXPLOD2
          else action EXPLOSION  
        }
else ifspawnedby CEILINGSTEAM
{ spawn SIRPALE spawn SIRPALE spawn SHARK spawn SHARK action EXPLOSION }
else action EXPLOSION
}


ifaction EXPLOSION
    {
    ifspawnedby COLA sizeto 4096 4096
    ifspawnedby NAPALM sizeto 4096 4096
    ifspawnedby SHARK sizeto 4096 4096
    ifspawnedby FIREVASE sizeto 4096 4096
    ifspawnedby CRYSTALAMMO cstat 32768
    ifspawnedby SHRINKEREXPLOSION cstat 32768
    ifspawnedby TRANSPORTERSTAR cstat 32768 
    ifactioncount 20 killit
    }
ifaction NALLI
    { cstat 2 spritepal 2 ifactioncount 6 killit }

ifaction EXPLOD1 { ifactioncount 16 killit }

ifaction EXPLOD2 { ifactioncount 22 killit }

enda

actor EXPLOSION2BOT 1 EXPLOSION
    ifspawnedby FIREVASE sizeto 4096 4096
    ifspawnedby CRYSTALAMMO cstat 32768
    ifspawnedby SHRINKEREXPLOSION cstat 32768
    ifspawnedby TRANSPORTERSTAR cstat 32768 
    ifactioncount 20 killit
enda


move flaredown 0 5
action TRAN 1985 6 1 1 300
action TRANS1 0 1 1 1 1
actor TRANSPORTERSTAR 0 0 flaredown randomangle

ifaction 0 action TRANS1

ifaction TRANS1
{
  ifspawnedby FREEZEBLAST { spawn LIEKITYS killit }
  else ifspawnedby CRYSTALAMMO action TRAN
  else ifspawnedby APLAYER action TRAN
  else { killit break }
}

ifaction EXPLOD1
{ ifactioncount 16 killit }

ifaction EXPLOD2
{ ifactioncount 22 killit }

ifaction TRAN
{
ifrnd 83 spawn EXPLOSION2
ifcount 1 { spawn SMALLSMOKE resetcount }
iffloordistl 50 killit
ifactioncount 6 killit
}         
enda

actor TRANSPORTERBEAM
ifspawnedby SHARK { spawn SHARK killit }
else ifcount 1 killit
enda

state getcode    
    sound DUKE_GET
    palfrom 16 0 32
    ifrespawn
    {
        move RESPAWN_ACTOR_FLAG
        spawn RESPAWNMARKERRED
        cstat 32768
    }
    else killit
ends


state getweaponcode
    palfrom 32 0 32
    ifgotweaponce 1 break
    ifrespawn
    {
        move RESPAWN_ACTOR_FLAG
        spawn RESPAWNMARKERRED
        cstat 32768
    }
    else killit
ends


state respawnit
    ifcount RESPAWNITEMTIME { spawn TRANSPORTERSTAR move 0 cstat 0 sound TELEPORTER }
ends

state quikget
    sound DUKE_GET
    palfrom 16 0 32
    killit
ends

state quikweaponget
    palfrom 32 0 32
    ifgotweaponce 1 break
    killit
ends

actor STEROIDS
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE
        ifpinventory GET_STEROIDS STEROID_AMOUNT ifcanseetarget
    {
        addweapon DEVISTATOR_WEAPON 0
        addinventory GET_STEROIDS STEROID_AMOUNT 
        quote 37 state getcode
        ifspawnedby STEROIDS state getcode
        else state quikget
    }
enda

actor HEATSENSOR
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_HEATS HEAT_AMOUNT
        ifcanseetarget
    {
        addinventory GET_HEATS HEAT_AMOUNT quote 101 state getcode
        ifspawnedby HEATSENSOR state getcode
        else state quikget
    }
enda

actor BOOTS
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_BOOTS BOOT_AMOUNT
        ifcanseetarget
    {
        addinventory GET_BOOTS 30 quote 148
        ifspawnedby BOOTS state getcode
        else state quikget
    }
enda

actor SHIELD
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_SHIELD SHIELD_AMOUNT
        ifcanseetarget
    {
        addinventory GET_SHIELD SHIELD_AMOUNT quote 38
        ifspawnedby SHIELD state getcode
        else state quikget
    }
enda

action AMM0 0 1 1 1 1
action M2HB 1 1 1 1 1
action M2HBONCE 1 1 1 1 1
action M60ONCE 0 1 1 1 1
action VCBOX 4 1 1 1 1
action KRHAMMO 5 1 1 1 1

useractor notenemy FEM4 
    fall
    sizeat 48 48 
    ifaction 0
    { ifspritepal 11 action M2HBONCE
      else ifspritepal 10 action M2HB
      else ifspritepal 14 { cstat 32768 action M60ONCE }
      else ifspritepal 12 action VCBOX
      else ifspritepal 9 action KRHAMMO
      else action AMM0 }

    ifaction KRHAMMO
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    { quote 181 addinventory GET_BOOTS 127 }
    }

    ifaction M60ONCE
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    { sound DUKE_GET addinventory GET_BOOTS 126 killit }
    }
    
    ifaction M2HB
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    { quote 157 addinventory GET_BOOTS 120 }
    }

    ifaction M2HBONCE
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    { quote 157 sound DUKE_GET addinventory GET_BOOTS 120 killit }
    }
    
    ifaction AMM0
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {      
     ifrnd 96 { sound DUKE_GET addweapon PISTOL_WEAPON 80 quote 65 killit }
     else ifrnd 96 { sound DUKE_GET addammo PISTOL_WEAPON 180 quote 65 killit } 
     else ifrnd 96 { sound DUKE_GET addammo SHOTGUN_WEAPON 50 quote 69 killit }
     else ifrnd 96 { sound DUKE_GET addammo CHAINGUN_WEAPON 150 quote 63 killit }
     else { sound DUKE_GET quote 77 killit }
    }
    }

    ifaction VCBOX
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {      
     ifrnd 96 { ifphealthl MAXPLAYERHEALTH { sound DUKE_GET addphealth 100 quote 176 killit } else { sound DUKE_GET quote 77 killit } }
     else ifrnd 128 { ifrnd 128 { sound DUKE_GET sound DUKE_HIT_STRIPPER2 quote 177 killit } else { sound DUKE_GET sound DUKE_HIT_STRIPPER2 quote 178 killit } }
     else ifrnd 64 { sound DUKE_GET spawn NUKEBARRELLEAKED sound LASERTRIP_ARMING quote 154 killit }
     else ifrnd 96 { sound DUKE_GET addweapon HANDBOMB_WEAPON 4 quote 55 killit }
     else { sound DUKE_GET quote 77 killit }
    }
    }

enda

action ODOTUS 0 1 1 1 1
action LUUPPI 0 1 1 1 1

useractor notenemy SATELLITE 0 LUUPPI
    cstat 32768
      
ifaction LUUPPI
{
// fireteam

    ifspritepal 9
    {
    ifp palive ifpdistl 400 ifcanseetarget
    { addammo PISTOL_WEAPON -48 addinventory GET_SHIELD -50 action ODOTUS }
    else ifcount 8 killit 
    }

// a-gunner
    else ifspritepal 10 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 160
    addinventory GET_SCUBA 80
    addinventory GET_BOOTS 140

    addweapon HANDBOMB_WEAPON 2
    addinventory GET_SHIELD 100
    addammo PISTOL_WEAPON 50
    action ODOTUS
    } }

// machine gunner
    else ifspritepal 11 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 161
    addinventory GET_SCUBA 81
    addinventory GET_BOOTS 141

    addweapon HANDBOMB_WEAPON 1
    addinventory GET_SHIELD 100
    addweapon CHAINGUN_WEAPON 450
    action ODOTUS
    } } 

// sniper
    else ifspritepal 12 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 162
    addinventory GET_SCUBA 82
    addinventory GET_BOOTS 142

    addinventory GET_HEATS HEAT_AMOUNT
    addweapon GROW_WEAPON 20  
    addweapon HANDBOMB_WEAPON 1
    addinventory GET_SHIELD 25
    action ODOTUS
    } } 

// grenadier
    else ifspritepal 13 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 163
    addinventory GET_SCUBA 83
    addinventory GET_BOOTS 143

    addweapon HANDBOMB_WEAPON 2
    addweapon TRIPBOMB_WEAPON 2
    addweapon SHRINKER_WEAPON 6
    addinventory GET_SHIELD 50
    action ODOTUS
    } } 

// point man
    else ifspritepal 14 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 164
    addinventory GET_SCUBA 84
    addinventory GET_BOOTS 144

    addweapon HANDBOMB_WEAPON 2
    addinventory GET_SHIELD 100
    addweapon SHOTGUN_WEAPON 40
    action ODOTUS
    } }

// medic
    else ifspritepal 15 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 165
    addinventory GET_SCUBA 85
    addinventory GET_BOOTS 145

    addweapon TRIPBOMB_WEAPON 1
    addinventory GET_FIRSTAID FIRSTAID_AMOUNT
    addinventory GET_SHIELD 100
    addammo PISTOL_WEAPON 80
    action ODOTUS
    } }

// squad leader
    else ifspritepal 16 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 166
    addinventory GET_SCUBA 86
    addinventory GET_BOOTS 146

    addinventory GET_HEATS HEAT_AMOUNT
    addweapon HANDBOMB_WEAPON 2
    addinventory GET_SHIELD 75
    addammo PISTOL_WEAPON 180

    action ODOTUS
    } }

// rifleman
    else ifspritepal 17 
    {
    ifp palive ifpdistl 1024 ifcanseetarget
    {
    quote 189
    addinventory GET_SCUBA 87
    addinventory GET_BOOTS 152

    addinventory GET_SHIELD 100
    addammo PISTOL_WEAPON 180
    action ODOTUS
    } }          

    
    else ifspritepal 0
    {            
    ifpinventory GET_SCUBA 60 { } else
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl 1300 
    {
        quote 141 addinventory GET_SCUBA 70 
    } }

    ifpinventory GET_SCUBA 0 { } else
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl 1300 
    {
        quote 141 addinventory GET_SCUBA 70 
    } } }
}

ifaction ODOTUS
{ ifpdistg 2048 action LUUPPI }

enda


action HOLODUKE_FRAMES 0 4 1 1 8
actor HOLODUKE 0 HOLODUKE_FRAMES
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifpinventory GET_HOLODUKE HOLODUKE_AMOUNT
        ifcanseetarget
    {
        addinventory GET_HOLODUKE HOLODUKE_AMOUNT quote 51 state getcode
        ifspawnedby HOLODUKE state getcode
        else state quikget
    }
enda

actor JETPACK
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifpinventory GET_JETPACK JETPACK_AMOUNT ifcanseetarget
    {
        addweapon DEVISTATOR_WEAPON 0
        addinventory GET_JETPACK JETPACK_AMOUNT quote 41 state getcode
        ifspawnedby JETPACK state getcode
        else state quikget
    }
enda

actor AMMO
    fall
    ifspawnedby APLAYER { ifp palive ifcount 72 ifpdistl RETRIEVEDISTANCE ifcanseetarget { addammo PISTOL_WEAPON 180 quote 65 sound DUKE_GET killit } }
    else ifmove RESPAWN_ACTOR_FLAG state respawnit    
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addammo PISTOL_WEAPON PISTOLAMMOAMOUNT quote 65
        ifspawnedby AMMO state getcode
        else state quikget
    }
enda

action MINE_TRIGGERED 1 1 1 1 1
action MINE_FRAME 0 1 1 1 1

useractor notenemy MINE WEAK
{
fall sizeat 48 48 cstat 256
    ifhitweapon { ifwasweapon RADIUSEXPLOSION { spawn EXPLOSION2 debris SCRAP6 12 debris SCRAP2 12 sound INTRUDER_ALERT killit } }

    ifaction 0 { ifspawnedby APLAYER { ifcount 100 action MINE_FRAME } else { action MINE_FRAME } }
    
    ifaction MINE_FRAME 
    {
    ifpdistl 800 { sound SWITCH_ON action MINE_TRIGGERED }
    else ifpdistl 2800
        {
        ifpinventory GET_BOOTS 100 { } else { soundonce TURR_RECOG }
        ifpinventory GET_SCUBA 84 { } else { soundonce TURR_RECOG }
        }
    }

ifaction MINE_TRIGGERED 
{
    ifpinventory GET_BOOTS 100 { } else { soundonce TURR_RECOG }
    ifpinventory GET_SCUBA 84 { } else { soundonce TURR_RECOG }
    ifpdistg 800 { state minexplo }  
    
    ifhitspace
      {
        ifpinventory GET_SCUBA 80 { } else { ifrnd 51 state minedead else state minexplo }
        ifpinventory GET_SCUBA 81 { } else { ifrnd 51 state minedead else state minexplo }
        ifpinventory GET_SCUBA 82 { } else { ifrnd 154 state minedead else state minexplo }
        ifpinventory GET_SCUBA 83 { } else { ifrnd 51 state minedead else state minexplo }
        ifpinventory GET_SCUBA 84 { } else { ifrnd 230 state minedead else state minexplo }
        ifpinventory GET_SCUBA 85 { } else { ifrnd 51 state minedead else state minexplo }
        ifpinventory GET_SCUBA 86 { } else { ifrnd 51 state minedead else state minexplo }
        ifpinventory GET_SCUBA 87 { } else { ifrnd 154 state minedead else state minexplo }
        ifrnd 128 { sound LASERTRIP_ONWALL quote 102 killit }
        else { sound INTRUDER_ALERT debris SCRAP6 12 debris SCRAP2 12 spawn EXPLOSION2 hitradius 2048 30 50 80 120 killit }
      }
  }

}
enda

actor SHOTGUNAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addammo SHOTGUN_WEAPON SHOTGUNAMMOAMOUNT quote 69
        ifspawnedby SHOTGUNAMMO state getcode
        else state quikget
    }
enda

actor AMMOLOTS
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifcount 6 ifpdistl RETRIEVEDISTANCE ifcanseetarget
    {
        addinventory GET_BOOTS 50 quote 147
        ifspawnedby AMMOLOTS state getcode
        else state quikget
    }
enda

move flareup 0 -175
action FLAREYLOS 0 1 1 1 1
actor CRYSTALAMMO 0 0 flareup randomangle
ifaction 0 { action FLAREYLOS }
ifaction FLAREYLOS
        {
        ifrnd 70 { spawn EXPLOSION2 }
        ifcount 1 { spawn SMALLSMOKE resetcount }
        ifceilingdistl 70 { spawn TRANSPORTERSTAR killit } 
        }
enda

actor BATTERYAMMO
    fall   
    ifspawnedby APLAYER { ifp palive ifcount 72 ifpdistl RETRIEVEDISTANCE ifcanseetarget { addammo CHAINGUN_WEAPON CHAINGUNAMMOAMOUNT quote 63 sound DUKE_GET killit } }
    else ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        addammo CHAINGUN_WEAPON CHAINGUNAMMOAMOUNT quote 63
        ifspawnedby BATTERYAMMO state getcode
        else state quikget
    }
enda

action RUBCAN 211 2 1 1 3 
move LENTO 512
actor DEVISTATORAMMO 100 0 LENTO randomangle
        ifaction 0 { cstat 32 sound AAVE action RUBCAN }
        ifaction RUBCAN 
        {
        ifrnd 22 { spawn NAPALM } 
        ifnotmoving killit
        }
enda

action AMMUS0 0 1 7 1 1
move LENTO3 2000 2000
useractor notenemy AMMUS 100 0 LENTO3 randomangle
        sizeat 48 48
        ifaction 0 { action AMMUS0 }
        ifaction AMMUS0
        {
        iffloordistl 20 { spawn SHOTSPARK1 killit }
        ifnotmoving { spawn SHOTSPARK1 killit }
        }
enda
             
action THUD1 1 2 1 1 3
action THUD2 3 2 1 1 3
move LENTO2 400
useractor notenemy F105 100 0 LENTO2 randomangle
        ifaction 0 { sizeat 46 46 cstat 32 sound SPACE_DOOR4 action THUD1 }

        ifaction THUD1 
        {
        ifrnd 8 { action THUD2 } 
        ifrnd 2 { spawn SNAKEYE }
        ifnotmoving killit
        }

        ifaction THUD2 
        {
        ifcount 3 { sound SPACE_DOOR5 spawn AMMUS resetcount }
        ifactioncount 40 action THUD1
        ifnotmoving killit
        }
enda


actor HBOMBAMMO
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break // ( Multiplayer (mode 3) only )

        addweapon HANDBOMB_WEAPON 1 quote 55
        addammo HANDBOMB_WEAPON HANDBOMBBOX

        ifspawnedby HBOMBAMMO state getweaponcode
        else state quikweaponget
    }
enda

actor RPGSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break // ( Multiplayer (mode 3) only )

        addweapon RPG_WEAPON RPGAMMOBOX quote 56
        ifspawnedby RPGSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor SHOTGUNSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        {
          ifgotweaponce 0 break // Multiplayer only
          addweapon SHOTGUN_WEAPON SHOTGUNAMMOAMOUNT quote 57
        }
        ifspawnedby SHOTGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda



actor SIXPAK
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifphealthl MAXPLAYERHEALTH ifcanseetarget
    {
        addphealth 30 quote 62
        ifspawnedby SIXPAK state getcode
        else state quikget
    }
enda

action POMMINPUDOTUS 0 1 1 1 1

actor COLA 100 0 POMMINPUDOTUS randomangle
        fall
        iffloordistl 2 
        {
        ifonwater { spawn WATERSPLASH2 killit break }
        else
                {
                spawn EXPLOSION2
                debris SCRAP6 15 debris SCRAP2 15
                sound BOMB2
                hitradius 3750 25 50 90 170
                ifrnd 32 spawn BURNING2
                killit break
                }
        }
enda

state btdead
quote 168 killit break
ends
    
action BT1 0 1 1 1 1
action BT2 0 1 1 1 1

useractor notenemy NUKEBARRELLEAKED
ifaction 0 { ifspawnedby FEM4 { cstat 32768 action BT2 } else { cstat 32768 action BT1 } }
ifaction BT1
{ ifpdistl 1024 
        { ifrnd 2 
                { ifrnd 120 
                    {
                        ifpinventory GET_SCUBA 80 { } else { ifrnd 51 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 81 { } else { ifrnd 51 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 82 { } else { ifrnd 154 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 83 { } else { ifrnd 51 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 84 { } else { ifrnd 230 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 85 { } else { ifrnd 51 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 86 { } else { ifrnd 51 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifpinventory GET_SCUBA 87 { } else { ifrnd 154 state btdead else { sound LASERTRIP_ARMING quote 154 action BT2 } }
                        ifrnd 102 { quote 168 killit break } else { sound LASERTRIP_ARMING quote 154 action BT2 }
                    }
                } 
        } 
}

ifaction BT2
{ ifcount 25 { spawn EXPLOSION2 sound PIPEBOMB_EXPLODE hitradius 4000 25 50 100 200 debris SCRAP6 8 debris SCRAP2 8 killit } } 

enda

actor FIRSTAID
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6
        ifpinventory GET_FIRSTAID FIRSTAID_AMOUNT ifcanseetarget
    {
        addinventory GET_FIRSTAID FIRSTAID_AMOUNT quote 3

        ifspawnedby FIRSTAID state getcode
        else state quikget
    }
enda

actor FIRSTGUNSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break

        addweapon PISTOL_WEAPON 40 
        quote 28
        ifspawnedby FIRSTGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor GROWSPARK GROWSPARK_WEAPON_STRENGTH
sound SNIPER killit
enda

actor GROWSPRITEICON
fall
ifmove RESPAWN_ACTOR_FLAG state respawnit
else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
{
 ifgotweaponce 0 break
 addweapon GROW_WEAPON GROWCRYSTALAMMOAMOUNT quote 179
 ifspawnedby GROWSPRITEICON state getweaponcode
 else state quikweaponget
}
enda


actor TRIPBOMBSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break

        addweapon TRIPBOMB_WEAPON 1
        quote 58
        ifspawnedby TRIPBOMBSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor CHAINGUNSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break

        addweapon CHAINGUN_WEAPON 150 quote 54
        ifspawnedby CHAINGUNSPRITE state getweaponcode
        else state quikweaponget
    }
enda

action NOLLA
action OHJUSPAWNER 0 2 1 1 200
action AMMO8 0 1 1 1 1 
action NOAMMO 0 1 1 1 1
action SLAP 0 1 1 1 1
action M2HB2 1 1 1 1 1
action KKTESTAUS 0 1 1 1 1
action KUUSKYT 4 1 1 1 1
action SIXTY 0 1 1 1 1
action KKTESTAUS2 0 1 1 1 1
action ARTY 0 1 1 1 1
action KRH 2228 1 5 1 
action KRHTESTAUS 0 1 1 1 1

useractor notenemy SPACESHUTTLE
    fall
    cstat 32768
    ifaction 0
    { ifspritepal 11 { cstat 0 action M2HB2 }
      else ifspritepal 10 action SLAP
      else ifspritepal 12 action KUUSKYT
      else ifspritepal 9 action SIXTY
      else ifspritepal 7 action ARTY
      else ifspritepal 6 { cstat 0 spritepal 0 sizeat 37 37 action KRH }
      else ifspritepal 5 action OHJUSPAWNER
      else action AMMO8 }

    ifaction OHJUSPAWNER
    { 
      ifactioncount 6 { ifrnd 128 spawn OHJUS3 resetactioncount }
      ifcount 2048 action NOLLA
    }

    ifaction KRH
    {
      cstat 0
      ifp palive {
                 ifpdistl 380 {
                     ifpinventory GET_BOOTS 127 { quote 14 } else {
                         quote 180 cstat 32768 addinventory GET_BOOTS 128 action KRHTESTAUS
                                                          }
                              }
                  }
    }

    ifaction KRHTESTAUS
    {
    ifp palive {
                ifpdistg 380 { addinventory GET_BOOTS 200 action KRH }                 
               }
    else action KRH
    }

    ifaction ARTY
    {
    ifcount 100
        { resetcount ifrnd 128 spawn SHARK }
    }

    ifaction M2HB2
    {
    cstat 16
    ifp palive 
        { ifpdistl 1500
                {
                ifpinventory GET_BOOTS 122 { } else { cstat 32768 }
                ifpinventory GET_BOOTS 123 { } else { cstat 32768 }
                }
        }
    }

    ifaction KUUSKYT
    {
    cstat 16
    ifp palive 
        { ifpdistl 1500
                {
                ifpinventory GET_BOOTS 124 { } else { cstat 32768 }
                ifpinventory GET_BOOTS 125 { } else { cstat 32768 }
                }
        }
    }
    
    ifaction AMMO8
    {
    ifp palive { ifpdistl 380 { quote 66 addweapon DEVISTATOR_WEAPON DEVISTATORAMMOAMOUNT } }
    ifcount 250 { action NOAMMO resetcount }
    }

    ifaction NOAMMO
    { 
    ifp palive { ifpdistl 380 { quote 61 } }
    ifcount 400 { action AMMO8 resetcount }
    }

    ifaction SLAP
    {
      ifp palive {
                 ifpdistl 380 {
                     ifpinventory GET_BOOTS 120 { quote 14 } else {
                         quote 158 addinventory GET_BOOTS 122 action KKTESTAUS 
                                                          }
                              } 
                  } 
    }

    ifaction KKTESTAUS
    {
    ifp palive {
                 ifpdistg 380 { addinventory GET_BOOTS 200 action SLAP }
               }
    else action SLAP
    }


    ifaction SIXTY
    {
      ifp palive {
                 ifpdistl 380 {
                     ifpinventory GET_BOOTS 126 { quote 14 } else {
                         quote 169 addinventory GET_BOOTS 124 action KKTESTAUS2 
                                                          }
                              }
                  } 
    }

    ifaction KKTESTAUS2
    {
    ifp palive {
                 ifpdistg 380 { addinventory GET_BOOTS 200 action SIXTY }
               }
    else action SIXTY
    }
enda

actor SHRINKERSPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break

        addweapon SHRINKER_WEAPON CRYSTALAMMOAMOUNT quote 60
        ifspawnedby SHRINKERSPRITE state getweaponcode
        else state quikweaponget
    }
enda

actor FREEZESPRITE
    fall
    ifmove RESPAWN_ACTOR_FLAG state respawnit
    else ifp pshrunk { } else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget
    {
        ifgotweaponce 0 break

        addweapon FREEZE_WEAPON FREEZEAMMOAMOUNT quote 59
        ifspawnedby FREEZESPRITE state getweaponcode
        else state quikweaponget
    }
enda


action POMMIKONE 1222 2 1 1 3
move PK 285

actor DEVISTATORSPRITE 100 0 PK randomangle    
ifaction 0 { cstat 32 action POMMIKONE } 
ifaction POMMIKONE 
        {
        soundonce INVADER
        cstat 32 action POMMIKONE
        ifcount 4
                {
                resetcount
                ifrnd 64 { sound VIHELLYS spawn COLA } 
                }
        else ifnotmoving { stopsound INVADER killit }
       }
enda


state firestate

    ifgapzl 16 break
    ifinwater killit

    ifactor FIRE { ifp palive ifpdistl 844 ifrnd 32 ifcansee { soundonce DUKE_LONGTERM_PAIN addphealth -1 palfrom 32 32 } }

    ifactor FIRE ifspawnedby FIRE break
    else ifactor FIRE2 ifspawnedby FIRE2 break

    iffloordistl 128
    {
        ifcount 32 sizeto 8 8
        ifcount 64 killit
    }
    else killit

ends

action FIRE_FRAMES     -1 14 1 1 1
action FIRE_FRAMES5    -1 14 1 1 13
move FIREVELS
actor FIRE WEAK FIRE_FRAMES FIREVELS
cstat 128 state firestate enda

actor FIRE2 WEAK FIRE_FRAMES5 FIREVELS
cstat 130 state firestate enda

action FFLAME 0 1 1 1 1
 
actor TRIPFLARE
    fall
    ifcount 150
    ifaction 0 action FFLAME
    
    ifaction FFLAME
    { 
        {  ifpdistl 1100 { sound GENERIC_AMBIENCE22 spawn BURNING2 spawn CRYSTALAMMO killit } }
           else action FFLAME
    }

enda

actor FLOORFLAME
        cstat 32768
        ifcount 600
        { 
          ifrnd 50 { ifrnd 128 spawn DEVISTATORAMMO }
          else ifrnd 50 { ifrnd 128 spawn DEVISTATORSPRITE }
          else ifrnd 50 { ifrnd 128 spawn ATOMICHEALTH }
          ifcount 600 resetcount
          
        }
enda

actor NAPALM 
    cstat 256
    fall
    iffloordistl 2
    { 
    ifonwater killit
    else
    {
        sound BURN1
        spawn EXPLOSION2
        hitradius 3000 25 50 100 200
        spawn BURNING
        killit
    }
    }
enda

state drop_ammo ifrnd SPAWNAMMOODDS spawn AMMO ends
state drop_battery ifrnd SPAWNAMMOODDS spawn BATTERYAMMO ends
state drop_sgshells ifrnd SPAWNAMMOODDS spawn SHOTGUNAMMO ends
state drop_shotgun ifrnd SPAWNAMMOODDS spawn SHOTGUNSPRITE ends
state drop_chaingun ifrnd SPAWNAMMOODDS spawn BATTERYAMMO ends

state jib_sounds
    ifrnd SWEARFREQUENCY
    {
        ifrnd 16 sound JIBBED_ACTOR1
        else ifrnd 16 sound JIBBED_ACTOR2
        else ifrnd 16 sound JIBBED_ACTOR3
        else ifrnd 16 sound JIBBED_ACTOR5
        else ifrnd 16 sound JIBBED_ACTOR6
        else ifrnd 16 sound JIBBED_ACTOR10
        else ifrnd 16 sound JIBBED_ACTOR7
        else ifrnd 16 sound JIBBED_ACTOR4
        else ifrnd 16 sound JIBBED_ACTOR8
        else ifrnd 16 sound JIBBED_ACTOR13
        else ifrnd 16 sound JIBBED_ACTOR9
        else ifrnd 16 sound JIBBED_ACTOR11
        else ifrnd 16 sound JIBBED_ACTOR12
    }
ends

//  TNT (tnt@mbnet.fi) 

state standard_jibs
    guts JIBS2 1
    guts JIBS3 2
    guts JIBS4 3
    guts JIBS5 2
    guts JIBS6 3
    ifrnd 4 { guts JIBS1 1 spawn BLOODPOOL }               // spine
    state jib_sounds
ends

action VALE 0 1 1 1 1
useractor enemy VALEDOD 55 0

ifaction 0 { sizeat 45 45 action VALE }

ifaction VALE { ifcansee { ifpdistl 3000 { spawn PIGCOP killit }
                               else ifpdistl 7000 {
                                 ifangdiffl 900 { } else { spawn PIGCOP killit }
                                                  }
                           }
                  ifhitweapon { ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs killit }
                                else spawn PIGCOP killit }

              }
enda




action HEI1 2362 2 5 1 3
useractor notenemy FEM1 0 HEI1
        sizeat 48 48 
        ifspritepal 10 fall
        soundonce HELICOP_IDLE
enda

useractor notenemy PIIKKI TOUGH 
   fall
   sizeat 36 36 
   cstat 17
   ifpdistl 512 
   { ifcount 20 { addphealth -1 palfrom 16 16 ifrnd 50 sound DUKE_LONGTERM_PAIN2 resetcount } }   

enda

action MINE2_FRAME 0 1 1 1 1
action MINE2_TRIG 0 1 1 1 1

useractor notenemy FEM3 WEAK
{
    fall
    sizeat 48 48 
    cstat 256
    ifaction 0 action MINE2_FRAME
    
    ifaction MINE2_FRAME 
    { 
    ifpdistl 800 { ifrnd 60 { quote 39 sound SWITCH_ON spawn BURNING2 killit } } 

    ifpinventory GET_BOOTS 100 { } else { ifpdistl 2800 { soundonce TURR_RECOG } }
    ifpinventory GET_SCUBA 84 { } else { ifpdistl 2800 { soundonce TURR_RECOG } }
    
    ifhitweapon { ifwasweapon RADIUSEXPLOSION { ifrnd 128 { spawn BURNING2 killit } } }
    }
}
enda


action AANTA 0 1 1 1 1
action HILJAA 0 1 1 1 1
useractor notenemy FEM6 
sizeat 48 48
cstat 32768
ifaction 0 action AANTA

ifaction AANTA
ifpdistl 1000
{ 
ifrnd 80 soundonce BUSH1
else ifrnd 100 soundonce BUSH3
else action HILJAA         
}

ifaction HILJAA
{ 
ifp pjumping soundonce BUSH3
else ifpdistg 1000 action AANTA 
}
enda


actor WOODENHORSE
    cstat 32768

    ifpinventory GET_SCUBA 0 { } else
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl 1300 
    {
    quote 140 addinventory GET_SCUBA 60 
    } }

    ifpinventory GET_SCUBA 70 { } else
    {
    ifp pshrunk { } else ifp palive ifcount 6 ifpdistl 1300 
    {
    quote 140 addinventory GET_SCUBA 60 
    } }

enda

useractor notenemy FEM8 
    fall
    sizeat 48 48 
    ifcount 16
    {
        resetcount
        ifp palive ifpdistl 1024 ifp phigher
        {
            addphealth -5
            palfrom 16 16
            ifrnd 64 sound DUKE_LONGTERM_PAIN2
        }
     } 
enda

// blue_standard 
action BLUEWINS 0 1 1 1 1
action BLUELOSE 1666 12 1 1 2
action BLUEWAIT 0 1 1 1 1

useractor notenemy NAKED1

ifaction 0 action BLUEWAIT
ifaction BLUEWAIT
{
ifpinventory GET_SCUBA 65 { } else { 
                          ifpdistl 2048 { quote 145 action BLUEWINS }
                                   }  

ifpinventory GET_SCUBA 74 { } else { 
                          ifpdistl 3048 { cstat 128 action BLUELOSE }
                                   }  

}

ifaction BLUEWINS 
{ ifpdistl 2048 { 
                ifpinventory GET_SCUBA 60 { } else { addinventory GET_SCUBA 64 }
                ifpinventory GET_SCUBA 65 { } else { addinventory GET_SCUBA 64 }
               
                }
   ifcount 200 { sound WIERDSHOT_FLY resetcount }
}

ifaction BLUELOSE
{
  
}
enda


// red_standard
action REDWINS 0 1 1 1 1
action REDLOSE 975 12 1 1 2
action REDWAIT 0 1 1 1 1 
useractor notenemy PODFEM1 
ifaction 0 action REDWAIT

ifaction REDWAIT 
{
ifpinventory GET_SCUBA 75 { } else {
                                ifpdistl 2048 { quote 146 action REDWINS } 
                                   }

ifpinventory GET_SCUBA 64 { } else {
                                ifpdistl 3048 { cstat 128 action REDLOSE } 
                                   }
}

ifaction REDWINS
{ ifpdistl 2048 {
        ifpinventory GET_SCUBA 70 { } else { addinventory GET_SCUBA 74 }
        ifpinventory GET_SCUBA 75 { } else { addinventory GET_SCUBA 74 } 
      
                }
 ifcount 200 { sound TURR_ROAM resetcount }
}

ifaction REDLOSE 
{
 
}
enda

actor STATUE
cstat 32768
ifp palive { ifpdistl 3072 { endofgame 52 } }
enda

actor MIKE
    ifpdistl 1024 
        { ifpinventory GET_SCUBA 10 
                { } 
          else  
                { quote 144 addinventory GET_SCUBA 5 } 
        }
enda

state troop_body_jibs
ifrnd 64 spawn BLOODPOOL
ends

state liz_body_jibs
ifrnd 64 spawn BLOODPOOL
ends

state vehiclehit

        ifwasweapon RPG { sound METALLI debris SCRAP1 20 }
        
        ifwasweapon RADIUSEXPLOSION
        { sound METALLI }
        
        ifwasweapon FIRELASER 
        { sound METALLI debris SCRAP1 10 }

        ifwasweapon SHOTSPARK1 { sound PISTOL_RICOCHET addstrength 20 }

        ifwasweapon SHRINKSPARK { sound METALLI debris SCRAP1 10 }

        ifwasweapon GROWSPARK { sound PISTOL_RICOCHET addstrength 80 }
ends

state vehiclehit2

        ifwasweapon RPG
        {
            sound METALLI debris SCRAP1 20 
            ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
            break
        }
        
        ifwasweapon RADIUSEXPLOSION
        {
            sound METALLI debris SCRAP1 20 
            ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
            break
        }
        
        ifwasweapon FIRELASER 
        {
             sound METALLI
             ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
        }

        ifwasweapon SHOTSPARK1 
        {
             sound PISTOL_RICOCHET
             addphealth 15
             ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
        }

        ifwasweapon CHAINGUN 
        {
             sound PISTOL_RICOCHET
             addphealth 18
             ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
        } 
        
        ifwasweapon SHOTGUN 
        {
             sound PISTOL_RICOCHET
             addphealth 18
             ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
        } 

        ifwasweapon SHRINKSPARK
        { 
              sound METALLI debris SCRAP1 20
              addphealth 18
              ifdead { debris SCRAP1 40 sound RPG_EXPLODE }
        }
ends


state delete_enemy killit ends

action BLOODFRAMES 0 4 1 1 15
actor BLOOD 0 BLOODFRAMES
    sizeto 72 72 sizeto 72 72 sizeto 72 72
    ifpdistg 3144 killit
    ifactioncount 4 killit
enda

actor KNEE KNEE_WEAPON_STRENGTH enda
actor SPIT SPIT_WEAPON_STRENGTH enda
actor CHAINGUN CHAINGUN_WEAPON_STRENGTH enda
actor SHOTGUN SHOTGUN_WEAPON_STRENGTH enda
actor FIRELASER FIRELASER_WEAPON_STRENGTH enda
actor HEAVYHBOMB HANDBOMB_WEAPON_STRENGTH enda
actor BOUNCEMINE BOUNCEMINE_WEAPON_STRENGTH enda
actor MORTER MORTER_WEAPON_STRENGTH enda
actor SHRINKSPARK SHRINKER_WEAPON_STRENGTH enda
actor RPG RPG_WEAPON_STRENGTH enda
actor FREEZEBLAST FREEZETHROWER_WEAPON_STRENGTH enda
actor DEVISTATORBLAST FREEZETHROWER_WEAPON_STRENGTH enda
actor COOLEXPLOSION1 COOL_EXPLOSION_STRENGTH enda
actor TRIPBOMB TRIPBOMB_STRENGTH enda

action WEAP2FRAMES 0  4  1  1  6
actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH WEAP2FRAMES
    ifdead killit
    ifactioncount 4 killit
    else
    {
        ifactioncount 3 { ifinwater spawn WATERBUBBLE }
        else ifcount 2 { } else ifonwater spawn WATERSPLASH2
    }
enda

state standard_pjibs
    guts JIBS1 1
    guts JIBS3 2
    guts JIBS4 1
    guts JIBS5 1
    guts JIBS6 2
    guts DUKETORSO 1
    guts DUKELEG 2
    guts DUKEGUN 1
    ifrnd 16 money 1
ends

move DUKENOTMOVING
state handle_dead_dukes
    fall
    ifmove 0     // 1st time initializiation...
    {
        ifrnd 128 cstat 4
        else cstat 0
        move DUKENOTMOVING
    }

    ifsquished
    {
        sound SQUISHED
        spawn OOZ
        killit
    }
    else ifcount 1024 ifpdistg 4096 killit
    else
    {
        strength 0
        ifhitweapon ifwasweapon RADIUSEXPLOSION
        {
            state standard_jibs
            killit
        }
    }
ends

action GI0 2498 1 5 1
action GIKK_F 2498 2 5 1 5
action GIKK 2498 1 5 1

useractor notenemy GI 100 GI0
fall
sizeat 38 38
ifaction GI0 {
                ifspritepal 10 { ifcount 250 action GIKK_F }
                ifspritepal 11 { ifcount 450 action GIKK_F }
             }

ifaction GIKK_F
{
ifcount 3 { sound POOLBALLHIT resetcount }
ifactioncount 75 action GIKK
}

enda

action PLYINGFRAMES 0 1 0 1 1
actor DUKELYINGDEAD 0 PLYINGFRAMES
    state handle_dead_dukes
enda

action PSTAND       0   1   5   1    1
action PEXPLODE     106   5   1   1   10
action PEXPLODEAD   113   1   1    
action KK           2398 1   5   1
action KK2          2403 1   5   1 
action KK6          2413 1   5   1
action KK7          2418 1   5   1    
action KRHDUKE      1315 1   5   1 
action TANKKI       2221 1   5   1
action HELIKO       2270 2   5   1   6
action PJPHOUVER    2270 2   5   1
action PWALK        20   4   5   1   16
action PRUN         20   4   5   1   10
action PWALKBACK    45   4   5  -1   16
action PRUNBACK     45   4   5  -1   10
action PJUMPING     50   4   5   1   30
action PFALLING     65   1   5
action PDUCKING     86   1   5
action PCRAWLING    86   3   5   1   20
action PAKICKING    40   2   5   1   25
action PFLINTCHING  106  1   1   1   10
action PTHROWNBACK  106  5   1   1   18
action PFROZEN       20  1   5
action PLYINGDEAD   113  1   1
action EYES         2035  7  1   1   15
action INVI          -1  1  1   1   1 
action PSWIMMINGGO   375   1   5   1   10
action PSWIMMING     375   4   5   1   13
action PSWIMMINGWAIT 395   1   5   1   13
action PTREDWATER    395   2   5   1   17

move PSTOPED
move PSHRINKING // used as a var only

state check_dead_thrown_back
    ifdead
    {
        strength 0
        action PTHROWNBACK
    }
ends

state check_pstandard
    ifp pwalking action PWALK
    else ifp pkicking action PAKICKING
    else ifp pwalkingback action PWALKBACK
    else ifp prunning action PRUN
    else ifp prunningback action PRUNBACK
    else ifp pjumping
        action PJUMPING
    else ifp pducking action PDUCKING
ends

state random_wall_jibs
    ifrnd 96 shoot BLOODSPLAT1
    ifrnd 96 shoot BLOODSPLAT2
    ifrnd 96 shoot BLOODSPLAT3
    ifrnd 96 shoot BLOODSPLAT4
    ifrnd 96 shoot BLOODSPLAT1
ends


move nopeu1 100
actor APLAYER 100 PSTAND 0 0 nopeu1

     ifphealthl 15 { ifrnd 1 { ifrnd 40 { ifp palive { action PFLINTCHING spawn BLOOD addphealth -1 quote 159 ifphealthl 1 action PTHROWNBACK } } } }
             

     ifpinventory GET_SCUBA 2 { } else {
     ifp pjumping action INVI
     ifp pfalling action INVI
     ifp pstanding action INVI
     ifp prunning action EYES
     ifp pwalkingback action INVI
     ifp prunningback action INVI
     ifp pducking action INVI
     ifdead { addinventory GET_SCUBA 1 }                     
                                        }

     ifpinventory GET_BOOTS 128 { } else
     {
     action KRHDUKE
     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 129 quote 183 resetcount }
                }
         }

     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 129 quote 183 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR10 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 129 { } else
     {
     action KRHDUKE 
     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 130 quote 184 resetcount }
                }
         }     
     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 130 quote 184 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR11 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 130 { } else
     {
     action KRHDUKE

     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 131 quote 185 resetcount }
                }
         }
     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 131 quote 185 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR12 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 131 { } else
     {
     action KRHDUKE

     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 132 quote 186 resetcount }
                }
         }
     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 132 quote 186 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR13 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 132 { } else
     {
     action KRHDUKE

     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 133 quote 187 resetcount }
                }
         }
     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 133 quote 187 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR14 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 133 { } else
     {
     action KRHDUKE

     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 134 quote 188 resetcount }
                }
         }
     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 134 quote 188 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR15 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 134 { } else
     {
     action KRHDUKE

     ifcount 15
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 128 quote 182 resetcount }
                }
         }


     ifcount 40
        { ifhitspace
                { ifp pducking
                        { addinventory GET_BOOTS 128 quote 182 resetcount }
                  else
                        { sound SPACE_DOOR3 spawn MORTAR16 resetcount }
                }
        }
     ifdead { addinventory GET_BOOTS 0 }
     }


     ifpinventory GET_BOOTS 122 { } else
     {
     action KK
     ifcount 3 { ifhitspace { addinventory GET_BOOTS 123 resetcount } }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 123 { } else
     {
     action KK2 shoot SHOTSPARK1 sound POOLBALLHIT
     addinventory GET_BOOTS 122 resetcount
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 124 { } else
     {
     action KK6
     ifcount 4 { ifhitspace { addinventory GET_BOOTS 125 resetcount } }
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 125 { } else
     {
     action KK7 shoot CHAINGUN sound OCTA_ROAM
     addinventory GET_BOOTS 124 resetcount
     ifdead { addinventory GET_BOOTS 0 }
     }

     ifpinventory GET_BOOTS 200 { } else
     {
     action PSTAND
     ifdead { addinventory GET_BOOTS 0 }
     ifcount 1 { addinventory GET_BOOTS 0 } 
     }

     ifpinventory GET_STEROIDS 2 { } else
     {
     action PSTAND
     ifdead { addinventory GET_STEROIDS 0 }
     ifcount 1 { addinventory GET_STEROIDS 0 } 
     }

ifp prunning
    {
     ifp ponsteroids { }
     else ifonwater { }
     else ifp pjetpack { }
     else ifp pjumping { }
     else soundonce RUN2
     }

ifpinventory GET_SCUBA 10 { } else { ifcount 1 { spawn NUOLI } }

ifpinventory GET_SCUBA 60 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 70 { } else { ifcount 1 { spawn NUOLI } }
   
ifpinventory GET_SCUBA 65 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 75 { } else { ifcount 1 { spawn NUOLI } }
   
ifpinventory GET_SCUBA 64 { } else { cstat 0 ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 74 { } else { cstat 0 ifcount 1 { spawn NUOLI } }


ifpinventory GET_SCUBA 80 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 81 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 82 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 83 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 84 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 85 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 86 { } else { ifcount 1 { spawn NUOLI } }
ifpinventory GET_SCUBA 87 { } else { ifcount 1 { spawn NUOLI } }

ifaction 0 action PSTAND
    ifdead
    
    {
        ifsquished palfrom 32 63 63 63
        else fall

        ifactioncount 7 { move 0 } else ifactioncount 6
        {
            ifmultiplayer { }
            else
            {
                ifrnd 32 sound DUKE_KILLED5
                else ifrnd 32 sound DUKE_KILLED3
                else ifrnd 32 sound DUKE_KILLED1
                else ifrnd 32 sound DUKE_KILLED2
            }
        }

        ifaction PLYINGDEAD
        {
            ifactioncount 3 move PSTOPED
            ifpinventory GET_SCUBA 80 { } else { quote 167 break }
            ifpinventory GET_SCUBA 81 { } else { quote 167 break }
            ifpinventory GET_SCUBA 82 { } else { quote 167 break }
            ifpinventory GET_SCUBA 83 { } else { quote 167 break }
            ifpinventory GET_SCUBA 84 { } else { quote 167 break }
            ifpinventory GET_SCUBA 85 { } else { quote 167 break }
            ifpinventory GET_SCUBA 86 { } else { quote 167 break }
            ifpinventory GET_SCUBA 87 { } else { quote 167 break }
            quote 13
            ifhitspace
            {
                action PSTAND
                ifpinventory GET_SCUBA 5 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 1 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 10 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 65 { } else { spawn REDMAINFLAG }
                ifpinventory GET_SCUBA 75 { } else { spawn BLUEMAINFLAG }
                spawn DUKELYINGDEAD
                resetplayer
            }
            break
        }
        else ifaction PTHROWNBACK
        {
            ifactioncount 5
            {
                spawn BLOODPOOL
                action PLYINGDEAD
            }
            else ifactioncount 1 move 0
            break
        }
        else ifaction PFROZEN
        {
            cstat 257

            palfrom 16 0 0 24

            ifhitweapon
            {
                ifrnd 84 spawn BLOODPOOL

                getlastpal
                cstat 32768
                action PLYINGDEAD
                break
            }

            ifactioncount THAWTIME { getlastpal strength 1 move 0 action PSTAND }
            else ifactioncount FROZENDRIPTIME { ifrnd 32 spawn WATERDRIP }

            ifp pfacing   // assumes some other player
                ifpdistl FROZENQUICKKICKDIST pkick

            break
        }
        else ifaction PEXPLODEAD
        {
            ifpinventory GET_SCUBA 80 { } else { quote 167 break }
            ifpinventory GET_SCUBA 81 { } else { quote 167 break }
            ifpinventory GET_SCUBA 82 { } else { quote 167 break }
            ifpinventory GET_SCUBA 83 { } else { quote 167 break }
            ifpinventory GET_SCUBA 84 { } else { quote 167 break }
            ifpinventory GET_SCUBA 85 { } else { quote 167 break }
            ifpinventory GET_SCUBA 86 { } else { quote 167 break }
            ifpinventory GET_SCUBA 87 { } else { quote 167 break }
            quote 13
            ifhitspace
            {
                action PSTAND
                ifpinventory GET_SCUBA 5 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 1 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 10 { } else { ifrnd 235 spawn BEASTFLAG }
                ifpinventory GET_SCUBA 65 { } else { spawn REDMAINFLAG }
                ifpinventory GET_SCUBA 75 { } else { spawn BLUEMAINFLAG }
                resetplayer
            }
            break
        }
        else ifaction PEXPLODE
        {
            ifactioncount 5
            {
                action PEXPLODEAD
                spawn BLOODPOOL
            }
            break
        }

        else ifp pshrunk
        {
            state standard_pjibs
            spawn BLOODPOOL

            sound SQUISHED
            sound DUKE_DEAD

            cstat 32768                 // Hide the sprite

            action PLYINGDEAD
        }

        else
        {
            ifinwater
            {
                action PLYINGDEAD
                spawn WATERBUBBLE
                spawn WATERBUBBLE
            }
            else
            {
                action PEXPLODE
                state standard_pjibs
                cstat 32768
                sound SQUISHED
                sound DUKE_DEAD
            }
        }
        break
    }

    ifsquished
    {
        strength -1
        sound SQUISHED
        spawn OOZ
        break
    }

    ifp ponsteroids
    {
      action TANKKI
      ifhitweapon state vehiclehit2 
      ifp pjetpack { quote 78 ifrnd 7 { addphealth -200 sound RPG_EXPLODE debris SCRAP1 40 action PEXPLODE } }
      ifpdistg 512 { ifpdistl 1024 { shoot FIRELASER } }
      addweapon DEVISTATOR_WEAPON DEVISTATORAMMOAMOUNT
      ifaction PJUMPING { action TANKKI }
      ifpinventory GET_STEROIDS 2 { } else { addinventory GET_STEROIDS 0 }
      }

    ifp pjetpack
    {
      ifcount 600 { quote 79 ifhitspace { spawn TRANSPORTERSTAR ifrnd 128 sound HK1 else sound HK2 resetcount } }
      action HELIKO
      ifhitweapon state vehiclehit2
      addweapon DEVISTATOR_WEAPON DEVISTATORAMMOAMOUNT          
    }
     
    
    ifmove PSHRINKING
    {
        ifcount 32
        {
            ifcount SHRUNKDONECOUNT move 0
            else ifcount SHRUNKCOUNT
            {
                sizeto 42 36
                ifgapzl 24
                {
                    strength 0
                    sound SQUISHED
                    palfrom 48 64
                    break
                }
            }
            else ifp ponsteroids count SHRUNKCOUNT
        }
        else
        {
            ifp ponsteroids count SHRUNKCOUNT
            else { sizeto 8 9 spawn FRAMEEFFECT1 }
        }
    }

    else ifhitweapon
    {
        ifdead { ifmultiplayer sound DUKE_KILLED4 }
        else
        {
            ifmultiplayer
            {
                ifpinventory GET_SCUBA 2 { } else { ifrnd 128 sound PREDAPAIN1 else sound PREDAPAIN2 }
                ifphealthl YELLHURTSOUNDSTRENGTHMP
                {
                    ifrnd 64 sound DUKE_LONGTERM_PAIN2
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN3
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN4
                    else sound DUKE_DEAD
                }
                else
                {
                    ifrnd 64 sound DUKE_LONGTERM_PAIN5
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN6
                    else ifrnd 64 sound DUKE_LONGTERM_PAIN7
                    else sound DUKE_LONGTERM_PAIN8
                }
            }
            else
            {
                ifpinventory GET_SCUBA 2 { } else { ifrnd 128 sound PREDAPAIN1 else sound PREDAPAIN2 }     
                ifphealthl YELLHURTSOUNDSTRENGTH
                {
                    ifrnd 74 sound DUKE_LONGTERM_PAIN2
                    else ifrnd 8 sound DUKE_LONGTERM_PAIN3
                    else sound DUKE_LONGTERM_PAIN4
                }
                ifrnd 128 sound DUKE_LONGTERM_PAIN
            }
        }
        
        ifstrength TOUGH
        {
            state headhitstate
            sound DUKE_GRUNT
            ifp pstanding action PFLINTCHING
        }

        ifwasweapon RPG
        {
            addphealth -30
            ifrnd 32 spawn BLOOD
            ifdead state standard_pjibs
            palfrom 48 52
            break
        }

        ifwasweapon SPIT
        { addphealth 30 break }

        ifwasweapon RADIUSEXPLOSION
        {
            ifrnd 32 spawn BLOOD
            ifdead state standard_pjibs
            palfrom 48 52
            break
        }
        
        ifwasweapon FIREEXT
        {
            ifrnd 32 spawn BLOOD
            ifdead state standard_pjibs
            palfrom 48 52
            break
        }
        
        ifwasweapon FIRELASER 
        {
             palfrom 24 16
             sound SQUISHED
             ifrnd 32 spawn BLOOD
             ifdead state standard_pjibs
             break
        }

        ifwasweapon SHOTSPARK1 palfrom 24 48
        else ifwasweapon SHRINKSPARK
        {
            ifrnd 128 spawn BLOOD
            palfrom 48 52
            ifp pdead action PTHROWNBACK 
            break
        }
        else ifwasweapon COOLEXPLOSION1 palfrom 48 48 0 48
        else ifwasweapon KNEE palfrom 16 32
        state check_dead_thrown_back
        state random_wall_jibs

        break
    }

    ifaction INVI
    {
    cstat 33025
    ifcount 40 { quote 138 soundonce PREDALOAD }
    ifcount 200 
                { stopsound PREDALOAD quote 139 
                  ifhitweapon { 
                                resetcount  
                                ifrnd 128 soundonce PREDAPAIN1 else soundonce PREDAPAIN2
                              }
                   ifhitspace 
                        { palfrom 48 52 spawn EXPLOSION2 sound LASER2 shoot FIRELASER resetcount } 
                } 
   
    ifrnd 1 { 
                { ifrnd 128 
                        { cstat 259 action EYES }
                }
             }
    else ifrnd 1 { 
                   ifrnd 128 soundonce PREDSFX1      
                   else soundonce PREDSFX2
                 }
    }
    
    
    ifaction EYES
    { 
    cstat 259
    soundonce PREDEYES 
    ifactioncount 7 { cstat 33025 action INVI } 
    }
    
    ifaction PFLINTCHING
    {
        ifactioncount 2 action PSTAND
        break
    }

    ifinwater
    {
       ifaction PTREDWATER
        {
            ifp pwalking prunning action PSWIMMINGGO
        }
        else ifp pstanding pwalkingback prunningback action PTREDWATER
        else
        {
            ifaction PSWIMMING
            {
                ifrnd 4 spawn WATERBUBBLE
                ifactioncount 4
                    action PSWIMMINGWAIT
            }
            else ifaction PSWIMMINGWAIT
            {
                ifactioncount 2
                    action PSWIMMINGGO
            }
            else ifaction PSWIMMINGGO
            {
                ifactioncount 2
                    action PSWIMMING
            }
            else action PTREDWATER
        }
        ifrnd 4 spawn WATERBUBBLE // For effect

        break
    }
    else
    {
        ifaction PTREDWATER action PSTAND
        ifaction PSWIMMING action PSTAND
        ifaction PSWIMMINGWAIT action PSTAND
        ifaction PSWIMMINGGO action PSTAND
        ifaction PJPHOUVER action PFALLING
    }

    ifaction PFALLING
    {
        ifp ponground
            action PSTAND
        else
        {
            ifp pfalling break
            else state check_pstandard
        }
    }

    ifaction PDUCKING
    {
        ifgapzl 48
        {
            ifp pwalking pwalkingback prunning prunningback action PCRAWLING
        }
        else ifp pducking
        {
            ifp pwalking pwalkingback prunning prunningback action PCRAWLING
        }
        else
        {
            ifp pstanding action PSTAND
            else state check_pstandard
        }
    }

    else ifaction PCRAWLING
    {
        ifgapzl 48
        {
            ifp pstanding action PCRAWLING
        }
        else ifp pducking
        {
            ifp pstanding action PDUCKING
        }
        else
        {
            ifp pstanding action PSTAND
            else state check_pstandard
        }
    }
    else ifgapzl 48 action PDUCKING

    else ifaction PJUMPING
    {
        ifp ponground action PSTAND
        else ifactioncount 4 ifp pfalling action PFALLING
    }

    ifp pfalling action PFALLING
    else ifaction PSTAND state check_pstandard
    else ifaction PAKICKING
    {
        ifactioncount 2 action PSTAND
        break
    }
    else ifaction PWALK
    {
        ifp pfalling action PFALLING
        else ifp pstanding action PSTAND
        else ifp prunning action PRUN
        else ifp pwalkingback action PWALKBACK
        else ifp prunningback action PRUNBACK
        else ifp pjumping
            action PJUMPING
        else ifp pducking action PDUCKING
    }

    else ifaction PRUN
    {
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp pwalkingback action PWALKBACK
        else ifp prunningback action PRUNBACK
        else ifp pjumping
            action PJUMPING
        else ifp pducking action PDUCKING
    }

    else ifaction PWALKBACK
    {
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp prunning action PRUN
        else ifp prunningback action PRUNBACK
        else ifp pjumping
            action PJUMPING
        else ifp pducking action PDUCKING
    }

    else ifaction PRUNBACK
    {
        ifp pstanding action PSTAND
        else ifp pwalking action PWALK
        else ifp prunning action PRUN
        else ifp pwalkingback action PWALKBACK
        else ifp pjumping
            action PJUMPING
        else ifp pducking action PDUCKING
    }

    ifaction PCRAWLING { ifhitspace { ifactioncount 5 { 
        ifpinventory GET_SCUBA 5 { } else { 
    ifpinventory GET_JETPACK JETPACK_AMOUNT { addinventory GET_JETPACK 0 }
    ifpinventory GET_STEROIDS STEROID_AMOUNT { addinventory GET_STEROIDS 0 }
    ifpinventory GET_BOOTS BOOT_AMOUNT { addinventory GET_BOOTS 0 }
    addinventory GET_SCUBA 2 cstat 33025 action INVI                                      
                                          }   
                     
        ifpinventory GET_BOOTS 22 { } else { spawn TRIPFLARE quote 108 addinventory GET_BOOTS 0 resetactioncount }
        ifpinventory GET_BOOTS 24 { } else { spawn TRIPFLARE quote 108 addinventory GET_BOOTS 22 resetactioncount }
        ifpinventory GET_BOOTS 26 { } else { spawn TRIPFLARE quote 108 addinventory GET_BOOTS 24 resetactioncount } 
        ifpinventory GET_BOOTS 28 { } else { spawn TRIPFLARE quote 108 addinventory GET_BOOTS 26 resetactioncount }  
        ifpinventory GET_BOOTS 30 { } else { spawn TRIPFLARE quote 108 addinventory GET_BOOTS 28 resetactioncount } 
       
        ifpinventory GET_BOOTS 42 { } else { spawn MINE quote 42 addinventory GET_BOOTS 0 resetactioncount } 
        ifpinventory GET_BOOTS 44 { } else { spawn MINE quote 42 addinventory GET_BOOTS 42 resetactioncount } 
        ifpinventory GET_BOOTS 46 { } else { spawn MINE quote 42 addinventory GET_BOOTS 44 resetactioncount } 
        ifpinventory GET_BOOTS 48 { } else { spawn MINE quote 42 addinventory GET_BOOTS 46 resetactioncount }
        ifpinventory GET_BOOTS 50 { } else { spawn MINE quote 42 addinventory GET_BOOTS 48 resetactioncount }                                               
        
        ifpinventory GET_BOOTS 62 { } else { spawn RUBBERCAN quote 150 addinventory GET_BOOTS 0 resetactioncount }                                               
        ifpinventory GET_BOOTS 64 { } else { spawn RUBBERCAN quote 150 addinventory GET_BOOTS 62 resetactioncount }                                               
        ifpinventory GET_BOOTS 66 { } else { spawn RUBBERCAN quote 150 addinventory GET_BOOTS 64 resetactioncount }                                               
                        
// special
        ifpinventory GET_BOOTS 140 { } else { spawn BATTERYAMMO spawn BATTERYAMMO spawn BATTERYAMMO addinventory GET_BOOTS 147 quote 170 resetactioncount }
        ifpinventory GET_BOOTS 141 { } else { spawn BATTERYAMMO addinventory GET_BOOTS 149 quote 170 resetactioncount }
        ifpinventory GET_BOOTS 145 { } else { shoot SPIT quote 173 resetactioncount }
        ifpinventory GET_BOOTS 146 { } else { spawn RADIOMAN addinventory GET_BOOTS 148 quote 174 resetactioncount }
        ifpinventory GET_BOOTS 142 { } else { addammo GROW_WEAPON 20 addinventory GET_BOOTS 150 quote 175 resetactioncount }
        ifpinventory GET_BOOTS 150 { } else { addammo GROW_WEAPON 20 addinventory GET_BOOTS 151 quote 175 resetactioncount }

        ifpinventory GET_BOOTS 110 { } else { spawn RUBBERCAN addinventory GET_BOOTS 112 quote 171 resetactioncount }
        ifpinventory GET_BOOTS 111 { } else { spawn RUBBERCAN addinventory GET_BOOTS 110 quote 171 resetactioncount }
        ifpinventory GET_BOOTS 143 { } else { spawn RUBBERCAN addinventory GET_BOOTS 111 quote 171 resetactioncount }

        ifpinventory GET_BOOTS 152 { } else { spawn AMMO addinventory GET_BOOTS 153 quote 170 resetactioncount }


// flare4pm   ifpinventory GET_BOOTS 144 { } else { sound GENERIC_AMBIENCE22 spawn CRYSTALAMMO quote 172 resetactioncount }

        resetactioncount                                        
                }
        }
}
enda


state rf
    ifrnd 128 cstat 4
    else cstat 0
ends

action ATROOPSTAND       0    1    5    1    1
action ATROOPSTAYSTAND  -2    1    5    1    1
action ATROOPWALKING     0    4    5    1   12
action ATROOPWALKINGBACK 15   4    5   -1   12
action ATROOPRUNNING     0    4    5    1    8
action ATROOPSHOOT      35    1    5    1   30
action ATROOPJETPACK    40    1    5    1    1
action ATROOPJETPACKILL 40    2    5    1   50
action ATROOPFLINTCH    50    1    1    1    6
action ATROOPDYING      50    5    1    1   16
action ATROOPDEAD       54    1    1    1   15
action ATROOPPLAYDEAD   20    1    1    1   25
action ATROOPSUFFERDEAD 58    2    1   -4   24
action ATROOPSUFFERING  59    2    1    1   21
action ATROOPDUCK       64    1    5    1    3
action ATROOPDUCKSHOOT  64    2    5    1   25


move TROOPWALKVELS 130
move TROOPWALKVELSBACK -72
move TROOPRUNVELS 150
move TROOPSTOPPED
move DONTGETUP
move SHRUNKVELS 32

ai AITROOPSEEKPLAYER ATROOPWALKING   TROOPWALKVELS seekplayer
ai AITROOPHAEPELAAJA ATROOPRUNNING TROOPRUNVELS seekplayer
ai AITROOPKAMIKAZE   ATROOPPLAYDEAD TROOPSTOPPED faceplayer
ai AITROOPTUSKA      ATROOPDEAD   TROOPSTOPPED faceplayer


state troophaepelaaja
ifai AITROOPKAMIKAZE
{
ifcansee
   {
    ifpdistl 1024
     {
     ifcanshoottarget 
     ifcount 5 { sound PIG_RECOG }
     ifcount 6
      {
      resetcount
      spawn EXPLOSION2 sound RPG_EXPLODE hitradius 2048 25 50 80 120
      state standard_jibs state delete_enemy
      }
      }
      else
      ai AITROOPHAEPELAAJA
      }
      else ai AITROOPHAEPELAAJA
      break
      }
ifcansee
{
ifpdistl 1024
ifcanshoottarget
 ai AITROOPKAMIKAZE
}
ends

state trooptuska
ifdead { sound RPG_EXPLODE state standard_jibs spawn EXPLOSION2 hitradius 2048 25 50 80 120 killit }
else { sound PIG_PAIN }
ifactioncount 2 ai AITROOPHAEPELAAJA

ends

state troophidestate
ends


state troopgunnashoot
ends

state troopseekstate
ends

state troopduckstate
ends

state troopshootstate
ends

state troopfleestate
ends

state troopdying
    iffloordistl 32 { ifactioncount 5 { cstat 0 iffloordistl 8 sound THUD ifrnd 64 spawn BLOODPOOL state rf strength 0 move TROOPSTOPPED action ATROOPDEAD } break }
    else { state rf move 0 action ATROOPDYING }
ends

state checktroophit
    ifaction ATROOPSUFFERING { stopsound LIZARD_BEG sound PRED_DYING cstat 0 strength 0 action ATROOPSUFFERDEAD break }
    ifdead
    {
        ifwasweapon SHRINKSPARK { }

        state drop_ammo
        state random_wall_jibs
        addkills 1

        ifwasweapon RPG { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
        else ifwasweapon RADIUSEXPLOSION { sound SQUISHED state troop_body_jibs state standard_jibs state delete_enemy }
        else { sound PRED_DYING ifrnd 32 iffloordistl 32 { sound LIZARD_BEG spawn BLOODPOOL strength 0 move 0 action ATROOPSUFFERING break } action ATROOPDYING break }
    }
    else
    {
        state random_wall_jibs
        sound PRED_PAIN
    }
ends

state troopjetpackstate
ends

state checksquished
    ifsquished { addkills 1 sound SQUISHED state standard_jibs spawn OOZ state delete_enemy }
ends

state troopsufferingstate
ends

state troopshrunkstate
ends

state troopcode 
ends

actor LIZTROOP TROOPSTRENGTH ATROOPSTAND faceplayer  
fall
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } }
ifaction ATROOPSTAND
ai AITROOPHAEPELAAJA
ifai AITROOPTUSKA 
        { state trooptuska break }
ifhitweapon { ifrnd 70 { addstrength -56 }
              ai AITROOPTUSKA break
            }
ifai AITROOPHAEPELAAJA state troophaepelaaja
ifai AITROOPKAMIKAZE state troophaepelaaja
enda



action SOLIC1 1811   4   5   1   17
action SOLIC2 1811   1   5   1   1
action SOLIC3 1811   1   5   1   1
action SOLDIE 1831   5   1   1   18
action SOLPAIN 1831  1   1   1   10
action SOLDED 1836 1 1 
action SOLCEE 1837 1 1 1 10
action SOLMINE 1838 1 1 1 10

move solspeed 93
move soltopspeed 108
move solstop 0 
move soljumpspeed 120 -95

ai AISOLIC SOLIC1 solspeed seekplayer 
ai AISOLICHEAL SOLIC2 solstop faceplayer
ai AISOLSNIPE1 SOLIC2 solstop faceplayer
ai AISOLDYING SOLDIE solstop faceplayer
ai AISOLPAIN SOLPAIN solstop faceplayer 
ai AISOLBULLET SOLIC1 soltopspeed dodgebullet
ai AISOLSTAY SOLIC2 solstop faceplayer
ai AISOLJUMP SOLIC1 soljumpspeed faceplayer
ai AISOLPAIN2 SOLPAIN solstop faceplayer
ai AISOLDEMO SOLCEE solstop faceplayer
ai AISOLMINE SOLMINE solstop faceplayer

ai AISOLFOLLOW SOLIC1 solspeed faceplayer
ai AISOLFOLLOWSTOP SOLIC2 solstop faceplayer

state mil
{
ifcansee { ifpdistl 1700 { ai AISOLICHEAL } } 
else { }
}
ends

state milheal
{ 
ifpdistl 1000 { ifcount 20 { ifhitspace { quote 128 sound BOS2_RECOG ai AISOLFOLLOW } } }
else ifpdistg 1700 { ai AISOLIC }
}
ends

state mildying  
{ 
ifactioncount 5 action SOLDED 
}
ends

state milpain
{
        ifdead {
                ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_pjibs killit break }
                else ifwasweapon RPG { sound SQUISHED state standard_pjibs killit break }
                else ai AISOLDYING
                }  
         
        else { sound BOS2_PAIN ai AISOLPAIN2 }
}
ends

state milpain2
        {
        ifactioncount 2 { ifrnd 128 ai AISOLBULLET else ai AISOLIC } 
        }
ends

state milbullet
        {
        ifactioncount 55 ai AISOLIC
        }
ends

state milfollow
        { 
        ifpdistl 1700 { ifcansee { ai AISOLFOLLOWSTOP } }
        else ifcount 40 { ifp phigher { ifpdistl 5000 { ai AISOLJUMP } } }
        else ifcansee { } else { ifcount 325 { ai AISOLIC } }
        else ifpdistg 7192 { ai AISOLIC }
        }
ends

state miljump
        {
        ifactioncount 4 ai AISOLFOLLOW
        }
ends

state milfollowstop
{
ifpdistl 1000 { ifcount 32 { ifhitspace { ifp pducking { sound BOS2_ROAM quote 130 ai AISOLMINE }
                                               else { quote 129 sound BOS1_ROAM ai AISOLSTAY } 
                                             } 
                                }           
                    }
else ifpdistg 1700 ai AISOLFOLLOW 
}
ends

state milstay
{ 
ifpdistl 1000 { ifcount 32 { ifhitspace { ifp pducking { sound BOS2_ROAM quote 131 ai AISOLDEMO }
                                               else { quote 128 sound BOS2_ATTACK ai AISOLFOLLOW } 
                                             } 
                                }           
                    }
}
ends

state milmine
ifcount 110 { spawn MINE ai AISOLFOLLOW }
ends

state mildemo
ifcount 65 { sound BOS2_DYING spawn RUBBERCAN ai AISOLBULLET }
ends

useractor notenemy DEMOMAN 80 SOLIC3 fall
sizeat 38 38 cstat 257
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs killit } }
ifaction SOLIC3 ai AISOLIC
else ifaction SOLDED
       {
        cstat 256 move 0 strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy } break
       }

else
       {
          ifai AISOLIC state mil
          else ifai AISOLICHEAL state milheal
          else ifai AISOLDYING state mildying
          else ifai AISOLBULLET state milbullet
          else ifai AISOLSTAY state milstay
          else ifai AISOLJUMP state miljump
          else ifai AISOLPAIN2 state milpain2
          else ifai AISOLFOLLOW state milfollow
          else ifai AISOLFOLLOWSTOP state milfollowstop
          else ifai AISOLDEMO state mildemo
          else ifai AISOLMINE state milmine
          ifbulletnear state milbullet
          ifinwater { ifrnd 4 { strength 0 state mildying } }
          ifhitweapon state milpain
       }
enda

action ATROOPAIMING2 0 1 5 1 1
action ATROOPSNIPE2 0 2 5 1 5
action ATROOPLIIKKUU2 0 1 5 1 1
action ASNIPEDYING2 1834 5 1 1 15
action ASNIPEDEAD2 301 1 1 1 1
action JUOVIA 0 2 5 1 5

move snipe2

actor LIZTROOPDUCKING TROOPSTRENGTH ATROOPAIMING2 faceplayersmart

fall
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } }
 
    ifaction 0
    {
        action ATROOPAIMING2
        move snipe2 faceplayersmart
    }
    else ifaction ATROOPLIIKKUU2
    {    
        { action ATROOPSNIPE2 move snipe2 faceplayersmart  }
        
    }
    else ifaction ATROOPSNIPE2
    {
        ifcount 4 { sound HMG shoot SHOTSPARK1 shoot SHOTSPARK1
                    ifspritepal 10 { ifrnd 50 action JUOVIA }
                    resetcount
                  }
        else ifcansee { } else { action ATROOPAIMING2 }
        else action ATROOPSNIPE2 
    }                                                                                                    

    else ifaction JUOVIA
    {
       ifcount 4 { sound HMG spawn SHARK
                   shoot SHOTSPARK1 shoot SHOTSPARK1
                   ifrnd 30 action ATROOPSNIPE2
                   resetcount
                 }

       else ifcansee { } else { action ATROOPAIMING2 }
       else action JUOVIA
    }

    else ifaction ATROOPAIMING2
    { 
    ifcount 5 { ifp palive { ifcansee { action ATROOPLIIKKUU2 } } } 
    else action ATROOPAIMING2
    }
    
    ifhitweapon 
    {
    ifrnd 50 { addstrength -56 }
    ifdead
         { 
            ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break } 
            else ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy break }            
            else { sound PIG_DYING action ASNIPEDYING2 }
         }    
           else { sound PIG_PAIN spawn BLOOD action ATROOPAIMING2 move 0 }
         }

    else ifaction ASNIPEDYING2
    { ifactioncount 5 { ifrnd 64 spawn BLOODPOOL state rf iffloordistl 8 sound THUD action ASNIPEDEAD2 } }

    else ifaction ASNIPEDEAD2
    { strength 0 
      ifhitweapon { ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break } }
      break 
    }


enda

action ATROOPAIMING 0 1 5 1 1 
action ATROOPLIIKKUU 0 1 5 1 1
action ATROOPSNIPE 5 1 5 1 10
action ASNIPEDYING 465 5 1 1 15
action ASNIPEDEAD 470 1 1 1 1

move snipe

actor LIZTROOPSHOOT TROOPSTRENGTH ATROOPAIMING faceplayersmart
fall
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } }
 
    ifaction 0
    {
        action ATROOPAIMING
        move snipe faceplayersmart
    }
    else ifaction ATROOPLIIKKUU
    {    
        { action ATROOPSNIPE move snipe faceplayersmart  }
        
    }
    else ifaction ATROOPSNIPE
    {
        ifcount 4 { sound SNIPER shoot SHOTSPARK1 shoot SHOTSPARK1 shoot SHOTSPARK1 shoot SHOTSPARK1 shoot SHOTSPARK1 action ATROOPAIMING }   
        else ifcount 15 { ifpdistg 3000 { ifrnd 128 action ATROOPAIMING } }
        else ifcount 60 resetcount 
        else action ATROOPSNIPE
    }                                                                                                    
    else ifaction ATROOPAIMING
    { 
    ifcount 80 { ifrnd 20 { ifp palive { ifcansee { action ATROOPLIIKKUU } } } }
    else ifcount 20 { ifp palive { ifcansee { ifpdistl 3000 action ATROOPLIIKKUU } } }
    else action ATROOPAIMING
    }
    
    ifhitweapon 
    {
    ifrnd 70 { addstrength -56 }
    ifdead
         { 
            ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break } 
            else ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy break }
            else { sound PIG_DYING action ASNIPEDYING }
         }    
           else { sound PIG_PAIN spawn BLOOD action ATROOPAIMING move 0 }
         }

    else ifaction ASNIPEDYING
    { ifactioncount 5 { ifrnd 64 spawn BLOODPOOL state rf iffloordistl 8 sound THUD action ASNIPEDEAD } }

    else ifaction ASNIPEDEAD
    { strength 0 
      ifhitweapon { ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break } }
      break 
    }

enda

actor LIZTROOPSTAYPUT TROOPSTRENGTH ATROOPSTAYSTAND ai AITROOPSEEKPLAYER cactor LIZTROOP enda


action RADIC1 1801   4   5   1   17
action RADIC2 1801   1   5   1   1
action RADIC3 1801   1   5   1   1
action RADDIE 1821   5   1   1   18
action RADPAIN 1821  1   1   1   10
action RADDED 1826 1 1 
action RADIC4 1827 1 1 1 10

move radspeed 93
move radtopspeed 108
move radstop 0 
move radjumpspeed 120 -95

ai AIRADART RADIC4 radstop faceplayer
ai AIRADART2 RADIC4 radstop faceplayer
ai AIRADART3 RADIC4 radstop faceplayer
ai AIRADIC RADIC1 radspeed seekplayer 
ai AIRADICHEAL RADIC2 radstop faceplayer
ai AIRADDYING RADDIE radstop faceplayer
ai AIRADPAIN RADPAIN radstop faceplayer 
ai AIRADBULLET RADIC1 radtopspeed dodgebullet
ai AIRADSTAY RADIC2 radstop faceplayer
ai AIRADJUMP RADIC1 radjumpspeed faceplayer
ai AIRADPAIN2 RADPAIN radstop faceplayer

ai AIRADFOLLOW RADIC1 radspeed faceplayer
ai AIRADFOLLOWSTOP RADIC2 radstop faceplayer

state rac
{
ifcansee { ifpdistl 1700 { ai AIRADICHEAL } } 
else { }
}
ends

state racheal
{ 
ifpdistl 1000 { ifcount 20 { ifhitspace { quote 99 sound SLIM_DYING ai AIRADFOLLOW } } }
else ifpdistg 1700 { ai AIRADIC }
}
ends

state racdying  
{ 
ifactioncount 5 action RADDED 
}
ends

state racpain  
{
        stopsound SLIM_HATCH
        ifdead {
                ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_pjibs killit break }
                else ifwasweapon RPG { sound SQUISHED state standard_pjibs killit break }
                else ai AIRADDYING
                }  
        else { sound SLIM_RECOG ai AIRADPAIN2 }
}
ends

state racpain2
        {
        ifactioncount 2 { ifrnd 128 ai AIRADBULLET else ai AIRADIC } 
        }
ends

state racbullet
        {
        ifactioncount 55 ai AIRADIC
        }
ends

state racfollow
        { 
        ifpdistl 1700 { ifcansee { ai AIRADFOLLOWSTOP } }
        else ifcount 40 { ifp phigher { ifpdistl 5000 { ai AIRADJUMP } } }
        else ifcansee { } else { ifcount 325 { ai AIRADIC } }
        else ifpdistg 7192 { ai AIRADIC }
        }
ends

state racjump
        {
        ifactioncount 4 ai AIRADFOLLOW
        }
ends

state racart
{
ifcount 240 { 
              state sharkspawner
              ai AIRADFOLLOW
             }

}
ends

state racart3
{ ifcount 240 { state smokespawner ai AIRADFOLLOW } }
ends

state racart2
ifcount 160 ai AIRADFOLLOW
ends

state racfollowstop
{
ifpdistl 1000
        { ifcount 8
                { ifhitspace
                        { ifp pducking
                                { ifoutside { quote 156 sound SLIM_HATCH ai AIRADART3 } else { sound SLIM_ROAM quote 125 ai AIRADART2 } }
                          else
                                { quote 135 sound SLIM_DYING ai AIRADSTAY }
                        } 
                }           
        }
else ifpdistg 1700 ai AIRADFOLLOW 
}
ends

state racstay
{ 
ifpdistl 1000 
        { ifcount 8 
                { ifhitspace 
                        { ifp pducking 
                                { ifrnd 192 { quote 64 sound SLIM_HATCH ai AIRADART } else { sound SLIM_ROAM quote 125 ai AIRADART2 } }
                          else 
                                { quote 99 sound SLIM_ATTACK ai AIRADFOLLOW }
                        } 
                } 
        }

}
ends

useractor notenemy RADIOMAN 80 RADIC3 fall
sizeat 38 38 cstat 257
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs killit } }
ifaction RADIC3 { ifspawnedby APLAYER { state sharkspawner killit } else ai AIRADIC }
else ifaction RADDED
       {
        cstat 256 move 0 strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy } break
       }


else
        {
          ifai AIRADIC state rac
          else ifai AIRADICHEAL state racheal
          else ifai AIRADDYING state racdying
          else ifai AIRADBULLET state racbullet
          else ifai AIRADSTAY state racstay
          else ifai AIRADJUMP state racjump
          else ifai AIRADART state racart
          else ifai AIRADART2 state racart2
          else ifai AIRADART3 state racart3
          else ifai AIRADPAIN2 state racpain2
          else ifai AIRADFOLLOW state racfollow
          else ifai AIRADFOLLOWSTOP state racfollowstop
          ifbulletnear state racbullet
          ifinwater { ifrnd 4 { strength 0 state racdying } }
          ifhitweapon state racpain
        }
enda



action MEDIC1 1724   4   5   1   17
action MEDIC2 1724   1   5   1   1
action MEDIC3 1724   1   5   1   1
action MEDDIE 1744   5   1   1   18
action MEDPAIN 1744  1   1   1   10
action MEDDED 1749 1 1 

move medspeed 93
move medtopspeed 108
move medstop 0 
move medjumpspeed 120 -95

ai AIMEDIC MEDIC1 medspeed seekplayer 
ai AIMEDICHEAL MEDIC2 medstop faceplayer
ai AIMEDDYING MEDDIE medstop faceplayer
ai AIMEDPAIN MEDPAIN medstop faceplayer 
ai AIMEDBULLET MEDIC1 medtopspeed dodgebullet
ai AIMEDSTAY MEDIC2 medstop faceplayer
ai AIMEDJUMP MEDIC1 medjumpspeed faceplayer
ai AIMEDPAIN2 MEDPAIN medstop faceplayer

ai AIMEDFOLLOW MEDIC1 medspeed faceplayer
ai AIMEDFOLLOWSTOP MEDIC2 medstop faceplayer

state doc
{
ifcansee { ifpdistl 1700 { ai AIMEDICHEAL } } 
else { ai AIMEDIC }
}
ends

state docheal
{ 
ifphealthl 100 { ifpdistl 1024 { ifcount 15 { addphealth 5 ifrnd 20 { ifrnd 128 soundonce MEDIC33 else soundonce SOLIC22 } resetcount } } }
else ifpdistl 1000 { ifcount 20 { ifhitspace { quote 126 sound MEDIC11 ai AIMEDFOLLOW } } }
else ifpdistg 1700 { ai AIMEDIC }
}
ends

state docdying  
{ 
ifactioncount 5 { action MEDDED 
                  ifrnd 128 { spawn SIXPAK }
                }
}
ends

state docpain  
{
        ifdead {
                ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_pjibs killit break }
                else ifwasweapon RPG { sound SQUISHED state standard_pjibs killit break }
                else ai AIMEDDYING
                }  
         
        else { sound SOLIC11 ai AIMEDPAIN2 }
}
ends

state docpain2
        {
        ifactioncount 2 { ifrnd 128 ai AIMEDBULLET else ai AIMEDIC } 
        }
ends

state docbullet
        {
        ifactioncount 55 ai AIMEDIC
        }
ends

state docfollow
        { 
        ifpdistl 1700 { ifcansee { ai AIMEDFOLLOWSTOP } }
        else ifcount 40 { ifp phigher { ifpdistl 5000 { ai AIMEDJUMP } } }
        else ifcansee { } else { ifcount 325 { ai AIMEDIC } }
        else ifpdistg 7192 { ai AIMEDIC }
        }
ends

state docjump
        {
        ifactioncount 4 ai AIMEDFOLLOW
        }
ends

state docfollowstop
{
ifphealthl 100 { ifpdistl 1024 { ifcount 15 { addphealth 5 ifrnd 20 { ifrnd 128 soundonce MEDIC33 else soundonce SOLIC22 } resetcount } } }
else ifpdistl 1000 { ifcount 32 { ifhitspace { quote 127 sound MEDIC22 ai AIMEDSTAY } } }
else ifpdistg 1700 ai AIMEDFOLLOW 
}
ends

state docstay
{ 
ifphealthl 100 { ifpdistl 1000 { ifcount 15 { addphealth 5 ifrnd 20 { ifrnd 128 soundonce MEDIC33 else soundonce SOLIC22 } resetcount } } }
else ifpdistl 1000 { ifcount 32 { ifhitspace { quote 126 sound BOS1_RECOG ai AIMEDFOLLOW } } }
}
ends

useractor notenemy MEDIC 80 MEDIC3 fall
sizeat 38 38 cstat 257
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs killit } }
ifaction MEDIC3 ai AIMEDIC
else ifaction MEDDED
       {
        cstat 256 move 0 strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy } break
       }


else
        {
          ifai AIMEDIC state doc
          else ifai AIMEDICHEAL state docheal
          else ifai AIMEDDYING state docdying
          else ifai AIMEDBULLET state docbullet
          else ifai AIMEDSTAY state docstay
          else ifai AIMEDJUMP state docjump
          else ifai AIMEDPAIN2 state docpain2
          else ifai AIMEDFOLLOW state docfollow
          else ifai AIMEDFOLLOWSTOP state docfollowstop
          ifbulletnear state docbullet
          ifinwater { ifrnd 4 { strength 0 state docdying } }
          ifhitweapon state docpain
        }
enda

action ALIZWALKING       0     4    5    1    15
action ALIZRUNNING       0     4    5    1    11
action ALIZTHINK         70    1    5    1    30
action ALIZSCREAM        70    1    5    1    30
action ALIZJUMP          70    1    5    1    30
action ALIZFALL          70
action ALIZSHOOTING      70    2    5    1    7
action ALIZDYING         60    6    1    1    15
action ALIZLYINGDEAD     65    1
action ALIZFROZEN         0    1    5

move LIZWALKVEL 36
move LIZRUNVEL 96
move LIZJUMPVEL 0
move LIZSTOP

ai AILIZGETENEMY ALIZWALKING LIZWALKVEL seekplayer
ai AILIZDODGE ALIZTHINK LIZSTOP faceplayerslow
ai AILIZCHARGEENEMY ALIZRUNNING LIZRUNVEL seekplayer
ai AILIZFLEENEMY ALIZSHOOTING LIZSTOP faceplayer
ai AILIZSHOOTENEMY ALIZSHOOTING LIZSTOP faceplayer
ai AILIZJUMPENEMY ALIZJUMP LIZJUMPVEL jumptoplayer
ai AILIZSHRUNK ALIZWALKING SHRUNKVELS fleeenemy
ai AILIZSPIT ALIZSCREAM LIZSTOP faceplayerslow
ai AILIZDYING ALIZDYING LIZSTOP faceplayer

state lizseekstate

    ifactornotstayput
    {
        ifcansee ifp palive ifpdistl 15360 ifcount 16 { ai AILIZSHOOTENEMY break }
        ifai AILIZCHARGEENEMY
        {
            ifcount 72 ifcansee { ai AILIZSHOOTENEMY break }
        }
        else ifpdistl 15360 { ifrnd 92 { ifcount 48 ifcansee ai AILIZSHOOTENEMY } else ifcount 24 { ai AILIZCHARGEENEMY break } }

        ifrnd 4 ifnotmoving operate
        else ifrnd 1 ifbulletnear
        {
            ifgapzl 128 ai AILIZGETENEMY
            else ifactornotstayput ai AILIZGETENEMY 
        }
    }
    else
    {
        ifactioncount 16 { ifp palive ifrnd 32 ifcansee ai AILIZSHOOTENEMY }
        ifcount 16 ifrnd 32 move LIZWALKVEL randomangle geth
    }

ends

state lizshrunkstate
ends

state lizfleestate
    ifactioncount 2
    {
        ifcansee
        { sound CAPT_ATTACK shoot SHOTSPARK1 resetactioncount }
        else ai AILIZDODGE
    }
ends

state lizdodgestate
    ifp palive { ifcansee ai AILIZFLEENEMY } 
    else ai AILIZDODGE
ends

state lizthinkstate
    ifcount 128 { ifp palive ifcansee ai AILIZSHOOTENEMY }
ends

state lizshootstate
    ifactioncount 2
    {
        ifcansee
        {
        sound CAPT_ATTACK shoot SHOTSPARK1
        ifspritepal 12 { ifrnd 128 spawn SHARK }
        resetactioncount
        }
        else ai AILIZGETENEMY
    }
ends

state checklizhit
    spawn BLOOD
    ifai AILIZSHRUNK
        { addkills 1 sound SQUISHED state standard_jibs state delete_enemy }
    ifdead
    {
        ifwasweapon SHRINKSPARK { }
        addkills 1

        ifwasweapon RPG { sound SQUISHED state liz_body_jibs state standard_jibs state delete_enemy }
        else ifwasweapon RADIUSEXPLOSION { sound SQUISHED state liz_body_jibs state standard_jibs state delete_enemy }
        else { state rf ai AILIZDYING ifrnd 64 spawn BLOODPOOL }
        sound CAPT_DYING
    }
    else
    {
        sound CAPT_PAIN
        state random_wall_jibs
        ifp palive ifcansee { ai AILIZSHOOTENEMY break }
    }
ends

state lizjumpstate
    ifcount 128 { ifp palive ifcansee ai AILIZSHOOTENEMY }     
ends

state lizdyingstate
    ifaction ALIZLYINGDEAD
    {
        strength 0
        ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
        ifcount RESPAWNACTORTIME ifrespawn
        {
            spawn TRANSPORTERSTAR cstat 257 strength LIZSTRENGTH ai AILIZGETENEMY
        }
    }
    else ifai AILIZDYING ifactioncount 6 { iffloordistl 8 sound THUD move LIZSTOP action ALIZLYINGDEAD }
ends

actor LIZMANSTAYPUT LIZSTRENGTH ai AILIZFLEENEMY cactor LIZMAN enda


action KOLIC1  1361   4   5   1   17
action KOLIC2  1361   1   5   1   1
action KOLIC3  1361   1   5   1   1
action KOLDIE  1381   5   1   1   18
action KOLPAIN 1381   1   1   1   10
action KOLDED  1386   1   1 
action KOLAMB  1387   1   5   1   1
action KOLAMB2 1392   1   5   1   1

move kolspeed 93
move koltopspeed 108
move kolstop 0 
move koljumpspeed 120 -95

ai AIKOLIC KOLIC1 kolspeed seekplayer 
ai AIKOLICHEAL KOLIC2 kolstop faceplayer
ai AIKOLSNIPE1 KOLIC2 kolstop faceplayer
ai AIKOLDYING KOLDIE kolstop faceplayer
ai AIKOLPAIN KOLPAIN kolstop faceplayer 
ai AIKOLSTAY KOLIC2 kolstop faceplayer
ai AIKOLJUMP KOLIC1 koljumpspeed faceplayer
ai AIKOLMINE KOLAMB2 kolstop faceplayer


ai AIKOLAMB1 KOLAMB kolstop faceplayersmart
ai AIKOLAMB2 KOLAMB kolstop faceplayersmart
ai AIKOLAMB3 KOLAMB kolstop faceplayersmart


ai AIKOLSHOOT KOLAMB kolstop faceplayersmart

ai AIKOLSHOOT2 KOLAMB2 kolstop faceplayer
ai AIKOLFLEE KOLIC1 koltopspeed dodgebullet

ai AIKOLFOLLOW KOLIC1 kolspeed faceplayer
ai AIKOLFOLLOWSTOP KOLIC2 kolstop faceplayer

state kil
{
ifcansee { ifpdistl 1700 { ai AIKOLICHEAL } } 
else { }
}
ends

state kilheal
{ 
ifpdistl 1000 { ifcount 20 { ifhitspace { quote 132 sound BOS1_ATTACK2 ai AIKOLFOLLOW } } }
else ifpdistg 1700 { ai AIKOLIC }
}
ends

state kils
sound PISTOL_FIRE shoot CHAINGUN shoot CHAINGUN
ends

state kildying  
{ 
ifactioncount 5 { action KOLDED 
                  ifrnd 128 { spawn AMMO }
                  ifrnd 32 { spawn RPGSPRITE }
                }
}
ends

state kilpain  
{
        ifdead {
                ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_pjibs killit break }
                else ifwasweapon RPG { sound SQUISHED state standard_pjibs killit break }
                else ai AIKOLDYING
                }  
         else { sound BOS1_DYING } 
}
ends

state kilbullet
        {
        ifactioncount 55 ai AIKOLIC
        }
ends

state kilfollow
        { 
        ifpdistl 1700 { ifcansee { ai AIKOLFOLLOWSTOP } }
        else ifcount 40 { ifp phigher { ifpdistl 5000 { ai AIKOLJUMP } } }
        else ifcansee { } else { ifcount 325 { ai AIKOLIC } }
        else ifpdistg 7192 { ai AIKOLIC }
        }
ends

state kiljump
        {
        ifactioncount 4 ai AIKOLFOLLOW
        }
ends

state kilfollowstop
{
ifpdistl 1000
        { ifcount 32
                { ifhitspace
                        { ifp pducking
                                {
                                sound OCTA_ATTACK1 quote 137
                                ai AIKOLMINE
                                }

                          else { quote 133 ifrnd 128 sound BOS1_PAIN else sound BOS1_ATTACK2 ai AIKOLSTAY }
                        } 
                }
         }
else ifpdistg 1700 ai AIKOLFOLLOW 
}
ends

state kilstay
{ 
ifpdistl 1000 { ifcount 32 { ifhitspace { ifp pducking
                                {       
                                sound LASER1 quote 134
                                ai AIKOLAMB2
                                }
else  { quote 132 ifrnd 128 sound OCTA_ATTACK2 else sound LASER1 ai AIKOLFOLLOW }
} } } }
ends

state kilmine
ifcount 256 { ifp palive { ifcansee { ifpdistl 15000 { ai AIKOLSHOOT2 } } } }
ends 

state kilamb1
ifcount 256 { ifp palive { ifcansee { ifpdistl 8000 { ai AIKOLSHOOT } } } }
ends

state kilamb2
ifcount 256 { ifp palive { ifcansee { ifpdistl 17000 { ai AIKOLSHOOT } } } }
ends

state kilamb3
ifp palive { ifcansee { ai AIKOLSHOOT } } 
ends

state kilshoot
ifcount 6 
        { ifp palive 
                { ifcansee 
                        { state kils resetcount } 
                  else ai AIKOLAMB3
                } 
        }
ends

state kilshoot2
ifcount 16
        { ifp palive 
                { ifcansee                        
                        { sound RPG_SHOOT shoot RPG ai AIKOLFLEE }                     
                }
        }
ends

state kilflee
ifactioncount 70 ai AIKOLIC
ends

useractor notenemy GRUNT 85 KOLIC3 fall
sizeat 38 38 cstat 257
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs killit } }
ifaction KOLIC3 ai AIKOLIC
else ifaction KOLDED
       {
        cstat 256 move 0 strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy } break
       }

else
        {
          ifai AIKOLIC state kil
          else ifai AIKOLICHEAL state kilheal
          else ifai AIKOLDYING state kildying
          else ifai AIKOLSTAY state kilstay
          else ifai AIKOLJUMP state kiljump
          else ifai AIKOLFOLLOW state kilfollow
          else ifai AIKOLFOLLOWSTOP state kilfollowstop
          else ifai AIKOLMINE state kilmine
          else ifai AIKOLAMB1 state kilamb1
          else ifai AIKOLAMB2 state kilamb2
          else ifai AIKOLAMB3 state kilamb3
          else ifai AIKOLSHOOT state kilshoot
          else ifai AIKOLSHOOT2 state kilshoot2
          else ifai AIKOLFLEE state kilflee
          ifinwater { ifrnd 4 { strength 0 state kildying } }
          ifhitweapon state kilpain
        }
enda

move vctankspeed 110
move vcattackspeed 170
move vctankstop 0

action VCTANK 0 1 5 1 1
action VCTANKSHOOT 5 1 5 1 1
action VCODOTUS 0 1 5 1 1

ai AITANKSEEK VCTANK vctankspeed seekplayer
ai AITANKAIM VCTANK vctankstop faceplayer
ai AITANKSHOOT VCTANKSHOOT vctankstop faceplayer
ai AITANKJYRAA VCTANK vcattackspeed faceplayer
ai AITANKHURT VCTANK vctankstop faceplayer
ai AITANKINSTASHOOT VCTANKSHOOT vctankstop faceplayer

state taseek
{
      ifcansee { ifp palive { ifpdistl 5000 ai AITANKJYRAA
                              else { ai AITANKINSTASHOOT resetcount } 
               }            }
}
ends


state tainsta
shoot RPG sound RECOILLESS resetcount ai AITANKAIM
ends

state taaim
{         ifcount 50 {   ifpdistl 5000 ai AITANKJYRAA
                        else ifcansee ai AITANKSHOOT
                        else ai AITANKSEEK }
}
ends

state tashoot
shoot RPG sound RECOILLESS resetcount ai AITANKAIM
ends

state tajyraa
{
ifp palive ifpdistl 1024 { shoot FIRELASER }
else ifpdistg 5000 ai AITANKSEEK
}
ends

state tdead
spawn SIRPALE spawn SIRPALE spawn SIRPALE spawn SIRPALE spawn SIRPALE
spawn EXPLOSION2
stopsound DUKE_HARTBEAT spawn DEADTANK debris SCRAP1 30 killit
ends


state tahurt
{
move 0
ifwasweapon RPG { state tdead }
ifdead { state tdead }
else { ifcansee { ifrnd 45 ai AITANKINSTASHOOT else ai AITANKAIM } else ai AITANKSEEK }
}
ends


actor LIZMANJUMP 800 VCODOTUS 100 fall
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs killit } }
ifaction VCODOTUS ai AITANKSEEK
else {    ifai AITANKSEEK state taseek
          else ifai AITANKAIM state taaim
          else ifai AITANKSHOOT state tashoot
          else ifai AITANKJYRAA state tajyraa
          else ifai AITANKHURT state tahurt
          else ifai AITANKINSTASHOOT state tainsta
          ifhitweapon { move 0 ai AITANKHURT state vehiclehit }
          soundonce DUKE_HARTBEAT
      }
enda

actor LIZMAN LIZSTRENGTH fall
    state checksquished
    ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } } 
    ifai 0 ai AILIZGETENEMY
    else ifaction ALIZLYINGDEAD { fall state lizdyingstate break }
    else ifai AILIZJUMPENEMY state lizjumpstate
    else
    {
        fall
        ifai AILIZGETENEMY state lizseekstate
        else ifai AILIZCHARGEENEMY state lizseekstate
        else ifai AILIZDODGE state lizdodgestate
        else ifai AILIZSHOOTENEMY state lizshootstate
        else ifai AILIZFLEENEMY state lizfleestate
        else ifai AILIZSHRUNK state lizshrunkstate
        else ifai AILIZDYING state lizdyingstate
        else ifai AILIZSPIT
            { ifcount 26 ai AILIZGETENEMY else ifcount 18 { } }
    }

    ifai AILIZSHRUNK break
    ifhitweapon { ifrnd 70 { addstrength -56 }
                   state checklizhit
                }
enda


// blue_main_flag
action BLUEFLAG 61 4 1 1 10
useractor notenemy BLUEMAINFLAG 0 BLUEFLAG
    {
    sizeat 65 65 
    spritepal 1
    fall
    cstat 256
    ifpinventory GET_SCUBA 70 { } else { ifp palive ifcount 6 ifpdistl 1300
        {
        quote 142
        addinventory GET_SCUBA 75
        killit
        }                               }

                                            


    ifpinventory GET_SCUBA 64 { } else { ifp palive ifcount 6 ifpdistl 20000
        { killit }                     }
}
enda


// red_main_flag
action REDFLAG 62 4 1 1 10
useractor notenemy REDMAINFLAG 0 REDFLAG
    {
    sizeat 65 65 
    fall
    cstat 256
    ifpinventory GET_SCUBA 60 { } else { ifp palive ifcount 6 ifpdistl 1300
     {
        quote 142
        addinventory GET_SCUBA 65
        killit 
        }                               }
                                        

    ifpinventory GET_SCUBA 74 { } else { ifp palive ifcount 6 ifpdistl 20000
        { killit }                     }

     }
enda

action APIGWALK         0  4 5 1 20
action APIGRUN          0  4 5 1 11
action APIGSHOOT        30 2 5 1 35
action APIGCOCK         30 2 5 1 35
action APIGSTAND        30 1 5 1 1
action APIGDIVE         20 1 5 1 1
action APIGDIVESHOOT    20 2 5 1 35
action APIGDYING        55 5 1 1 15
action APIGHIT          55 1 1 1 10
action APIGDEAD         60 1 1 1 1
action APIGFROZEN        0 1 5

move PIGWALKVELS 72
move PIGRUNVELS 108
move PIGSTOPPED

ai AIPIGSEEKENEMY APIGWALK PIGWALKVELS seekplayer
ai AIPIGSHOOTENEMY APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGFLEEENEMY APIGWALK PIGWALKVELS fleeenemy
ai AIPIGSHOOT APIGSHOOT PIGSTOPPED faceplayer
ai AIPIGDODGE APIGRUN PIGRUNVELS dodgebullet
ai AIPIGCHARGE APIGRUN PIGRUNVELS seekplayer
ai AIPIGDIVING APIGDIVE PIGSTOPPED faceplayer
ai AIPIGDYING APIGDYING PIGSTOPPED faceplayer
ai AIPIGSHRINK APIGWALK SHRUNKVELS fleeenemy
ai AIPIGHIT APIGHIT PIGSTOPPED faceplayer

state pigseekenemystate

    ifai AIPIGCHARGE
    {
        ifcansee ifpdistl 10000
        {
            ifnotmoving ai AIPIGSEEKENEMY
            else ai AIPIGDIVING
        }
        break
    }
    else iffloordistl 32
    {
        ifpdistg 10000 { ifactornotstayput ai AIPIGCHARGE }
        ifrnd 8 { ifbulletnear ai AIPIGDODGE }
    }

    ifrnd 128 ifcansee
    {
        ifai AIPIGDODGE { ifcount 32 ai AIPIGCHARGE break }
        iffloordistl 32
        {
            ifp palive ifcanshoottarget
                { ai AIPIGSHOOTENEMY break }
            ifcount 24 { ifp palive ifcanshoottarget { ai AIPIGSHOOTENEMY else ai AIPIGDIVING break } }
        }
    }
ends


state pigshootenemystate
    {
        ifspritepal 11 { ifpdistg 4096 { ifpdistl 8192 { ifrnd 1 { spawn SHARK } } } }

        ifcount 12 { } else ifcount 11
        {
            ifcanshoottarget { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
            else ai AIPIGSEEKENEMY
        }
        ifcount 25 { } else ifcount 24 { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
        ifcount 48 { } else ifcount 47
        {
            ifcanshoottarget { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
            else ai AIPIGSEEKENEMY
        }
        ifcount 60 { } else ifcount 59 { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
        ifcount 72
        {
            ifrnd 64 resetcount
            else
            {
                ifpdistl 768 ai AIPIGFLEEENEMY
                else ai AIPIGSEEKENEMY
            }
        }
        ifaction APIGCOCK ifactioncount 2 action APIGSHOOT
    }
    else ai AIPIGSEEKENEMY
ends

state pigfleeenemystate
    ifactioncount 8 ai AIPIGSEEKENEMY
    else ifnotmoving ai AIPIGSEEKENEMY
ends

state pigdivestate
    ifaction APIGDIVESHOOT
    {
        ifcansee
        {
            ifcount 12 { } else ifcount 11
            {
                ifcanshoottarget { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
                else ai AIPIGSEEKENEMY
            }
            ifcount 25 { } else ifcount 24 { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
            ifcount 48 { } else ifcount 47
            {
                ifcanshoottarget { ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK shoot SHOTSPARK1 }
                else ai AIPIGSEEKENEMY
            }
            ifcount 60 { } else ifcount 59
            {
                ifrnd 85 sound AK47 else ifrnd 85 sound LIZARD_BEG else sound PRED_ATTACK
                ifgapzl 32 ai AIPIGDIVING
                else
                {
                    ifpdistl 4096 ai AIPIGFLEEENEMY
                    else ai AIPIGSEEKENEMY
                }
            }
        }
        else ifgapzl 32 ai AIPIGDIVING else ai AIPIGSEEKENEMY
    }
    else ifactioncount 2 ifp palive { resetcount action APIGDIVESHOOT }
ends

state checkpighitstate
    spawn BLOOD
    ifdead
    {
        ifspritepal 10 { endofgame 52 state standard_jibs killit break }
        state random_wall_jibs
        ifwasweapon SHRINKSPARK { }

        addkills 1
        ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy }
        else ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy }
        ai AIPIGDYING sound PIG_DYING
    }
    else
    {
        sound PIG_PAIN
        state random_wall_jibs
    }
ends

state pigshrinkstate
ends

state pigdyingstate
    ifactioncount 5 { ifrnd 64 spawn BLOODPOOL state rf iffloordistl 8 sound THUD action APIGDEAD move PIGSTOPPED ifspritepal 10 { endofgame 52 } break }
ends

useractor notenemy DEADVC
sizeat 48 48 
state handle_dead_dukes
enda

actor PIGCOPSTAYPUT PIGCOPSTRENGTH ai AIPIGSEEKENEMY cactor PIGCOP enda
actor PIGCOP PIGCOPSTRENGTH APIGSTAND fall
    fall
    state checksquished
    ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } }
    ifaction APIGSTAND ai AIPIGSEEKENEMY
    else ifaction APIGDEAD
    {
    strength 0 ifhitweapon ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break }
    }

    else ifai AIPIGDYING state pigdyingstate
    else ifai AIPIGHIT { ifactioncount 3 ai AIPIGSEEKENEMY }
    else
    {
        ifai AIPIGSEEKENEMY state pigseekenemystate
        else ifai AIPIGDODGE state pigseekenemystate
        else ifai AIPIGSHOOTENEMY state pigshootenemystate
        else ifai AIPIGFLEEENEMY state pigfleeenemystate
        else ifai AIPIGDIVING state pigdivestate
        else ifai AIPIGCHARGE state pigseekenemystate
        ifhitweapon { ifrnd 70 { addstrength -56 }
                      state checkpighitstate
                    }
        ifrnd 1
                { ifrnd 96
                        {
                        ifrnd 43 soundonce PIG_ROAM
                        else ifrnd 43 soundonce VCAMB1
                        else ifrnd 43 soundonce VCAMB2
                        else ifrnd 43 soundonce PIG_ROAM2
                        else ifrnd 43 soundonce RECOG33
                        else soundonce PIG_ROAM3
                        } 
                }
    }
enda

useractor notenemy ENSPA   
{         
        cstat 32768
        ifcount 650
        { 
          ifrnd 17 { ifrnd 80 spawn PIGCOP }
          else ifrnd 17 { ifrnd 80 spawn LIZMAN }
          else ifrnd 17 { ifrnd 80 spawn LIZTROOP }
          else ifrnd 17 { ifrnd 80 spawn PIGCOP spawn PIGCOP } 
          else ifrnd 17 { ifrnd 80 spawn PIGCOP spawn LIZMAN }
          ifcount 650 resetcount        
        }
}
enda

action DRONE2 0 4 1 1 10

useractor notenemy BEASTFLAG 0 DRONE2
{
    sizeat 48 48 
    spritepal 8
    fall

    ifpinventory GET_SCUBA 70 { } else 
    { 
    ifp palive ifcount 6 ifpdistl 1300  
        {
        quote 143
        addinventory GET_SCUBA 10
        killit
        }
    }
    
    ifpinventory GET_SCUBA 60 { } else 
    { 
    ifp palive ifcount 6 ifpdistl 1300  
        {
        quote 143
        addinventory GET_SCUBA 10
        killit
        }
    }

    ifpinventory GET_SCUBA 0 { } else 
    { 
    ifp palive ifcount 6 ifpdistl 1300  
        {
        quote 143
        addinventory GET_SCUBA 10
        killit
        }
    }
}

enda


action ASATSPIN   60 3 5 1 40
action ASATSHOOTING -10 3 5 1 40
action ASATWAIT 0 1 5 1 1
move turrvel

actor ROTATEGUN ROTTURRETSTRENGTH ASATWAIT faceplayersmart
{
fall
ifp ponsteroids { ifpdistl 1024 { state standard_pjibs sound SQUISHED state delete_enemy } }
 
    ifaction 0
    {
        action ASATWAIT
        move turrvel faceplayersmart
    }
    else ifaction ASATSPIN
    {    
        { action ASATSHOOTING move turrvel faceplayersmart  }
        
    }
    else ifaction ASATSHOOTING
    {
        ifcount 4 { sound RECOILLESS shoot RPG action ASATWAIT }   
        else ifcount 15 { ifpdistg 3000 { ifrnd 128 action ASATWAIT } }
        else ifcount 60 resetcount 
        else action ASATSHOOTING
    }                                                                                                    
    else ifaction ASATWAIT
    { 
    ifcount 65 { ifrnd 20 { ifp palive { ifcansee { action ASATSPIN } } } }
    else ifcount 20 { ifp palive { ifcansee { ifpdistl 3000 action ASATSPIN } } }
    else action ASATWAIT
    }
    
    ifhitweapon 
    { ifdead 
         { 
            ifwasweapon RADIUSEXPLOSION { sound SQUISHED state standard_jibs state delete_enemy break } 
            else ifwasweapon RPG { sound SQUISHED state standard_jibs state delete_enemy break }            
            else { sound PIG_DYING debris SCRAP6 14 debris SCRAP2 14 state standard_jibs spawn EXPLOSION2 state delete_enemy break }
         }    
           else { sound PIG_PAIN spawn BLOOD action ASATWAIT move 0 }
    }

}
enda

useractor notenemy FEM9    
        cstat 32768
        sizeat 48 48 
        ifcount 750
        { 
          ifrnd 45 { ifrnd 128 spawn GRUNT }
          else ifrnd 45 { ifrnd 128 spawn MEDIC }
          else ifrnd 45 { ifrnd 128 spawn DEMOMAN }
          else ifrnd 45 { ifrnd 128 spawn RADIOMAN }
          ifcount 750 resetcount
          
        }
enda


