// Mods and code by SAW

gamevar initx 0 2
gamevar inity 0 2

// Sound Effects

define WATERFALLSFX 406
definesound WATERFALLSFX falls_a.VOC 0 0 253 2 0

define POTBREAKSFX 407
definesound POTBREAKSFX potbreak.VOC 0 0 120 2 0

define BARRELBREAKSFX 408
definesound BARRELBREAKSFX barrelbr.VOC 0 120 0 2 0

define ARROWTRAPSFX 409
definesound ARROWTRAPSFX arrowtrp.VOC 0 0 120 2 0

define CANNONSHOOTSFX 410
definesound CANNONSHOOTSFX cannonsh.VOC 0 120 0 2 0

define CANNONBOOMSFX 411
definesound CANNONBOOMSFX cannonbm.VOC 0 120 0 2 0

define GETCOINSFX 412
definesound GETCOINSFX get_coin.VOC 0 0 254 0 0

define DRIPSFX 413
definesound DRIPSFX drip.VOC 0 0 120 2 0

define AQUACRITSFX 414
definesound AQUACRITSFX aquacrit.VOC 0 0 120 2 0

// Contained defs.

define WALLBARREL 438
define BED 466
define FIREPLACE 472
define IRONSTOVE 473
define STREETPOST 474
define TABLE2 494
define CHAIR2 495
define EPICSPLASH 500
define DRIPSPAWN 544
define NEWDRIP 545
define GRASSB1 324
define GRASSB2 325
define GRASST1 335

define FISHI1 3650

eventloadactor BIGSMOKEMAKER
 cstat 32768
enda

eventloadactor SMALLSMOKEMAKER
 cstat 32768
enda

eventloadactor FALLSMAKER
 getactor[THISACTOR].x initx
 getactor[THISACTOR].y inity
 cstat 32768
enda

eventloadactor SPRITZMAKER
 getactor[THISACTOR].x initx
 getactor[THISACTOR].y inity
 cstat 32768
enda

eventloadactor DRIPSPAWN
 cstat 32768
enda

eventloadactor 3430 cstat 32768 enda

// --------------------------------- Set Shadows...
spritenopal 2520

//general noshade
spritenoshade 132
spritenoshade 133
spritenoshade 184 spritenopal 184
spritenoshade 185 spritenopal 185
spritenoshade 186 spritenopal 186
spritenoshade 187 spritenopal 187
spritenoshade 189 spritenopal 189
spritenoshade 190 spritenopal 190
spritenoshade 192 spritenopal 192
spritenoshade 193 spritenopal 193
spritenoshade 231 spritenopal 231
spritenoshade 236 spritenopal 236
spritenoshade 244 spritenopal 244
spritenoshade 245 spritenopal 245
spritenoshade 246 spritenopal 246
spritenoshade 247 spritenopal 247
spritenoshade 256
spritenoshade 259 spritenopal 259
spritenoshade 262 spritenopal 262
spritenoshade 276
spritenoshade 291
spritenoshade 292
spritenoshade 294
spritenoshade 295
spritenoshade 316
spritenoshade 317
spritenoshade 318
spritenoshade 319
spritenoshade 320
spritenoshade 322 spritenopal 322
spritenoshade 323 spritenopal 323
spritenoshade 340 spritenopal 340
spritenoshade 359 spritenopal 359
spritenoshade 356 spritenopal 356
spritenoshade 357 spritenopal 357
spritenoshade 364 spritenopal 364
spritenoshade 365 spritenopal 365
spritenoshade 381 spritenopal 381
spritenoshade 385 spritenopal 385
spritenoshade 398
spritenoshade 399
spritenoshade 400
spritenoshade 401
spritenoshade 416 spritenopal 416
spritenoshade 417 spritenopal 417
spritenoshade 418 spritenopal 418
spritenoshade 419 spritenopal 419
spritenoshade 420 spritenopal 420
spritenoshade 422 spritenopal 422
spritenoshade 423 spritenopal 423
spritenoshade 436
spritenoshade 444
spritenoshade 445
spritenoshade 446
spritenoshade 455
spritenoshade 456
spritenoshade 498 spritenopal 498

//for rocks
spriteshadow GENROCK1 
  spritenopal GENROCK1 
    spritenoshade GENROCK1 
spriteshadow GENROCK2
  spritenopal GENROCK2
    spritenoshade GENROCK2 
spriteshadow GENROCK3
  spritenopal GENROCK3
    spritenoshade GENROCK3 
spriteshadow GENROCK4
  spritenopal GENROCK4
    spritenoshade GENROCK4 
spriteshadow GENROCK5
  spritenopal GENROCK5
    spritenoshade GENROCK5 
spriteshadow GENROCK6 
  spritenopal GENROCK6 
    spritenoshade GENROCK6 

//the rest
spriteshadow CANNON
spriteshadow CANNONBALL
spriteshadow 1818
spriteshadow JIBS1
spriteshadow JIBS2
spriteshadow JIBS3
spriteshadow JIBS4
spriteshadow JIBS5
spriteshadow JIBS6
spriteshadow MONEY
spriteshadow PAPER
spriteshadow SPIT
spriteshadow GLASSPIECES
spriteshadow SCRAP1
spriteshadow SCRAP2
spriteshadow SCRAP3
spriteshadow SCRAP4
spriteshadow SCRAP6


spriteshadow FORMLESS
// spriteshadow GRASSB1
  spritenoshade GRASSB1
    spritenopal GRASSB1
// spriteshadow GRASSB2
  spritenoshade GRASSB2
    spritenopal GRASSB2
// spriteshadow GRASST1
  spritenoshade GRASST1
    spritenopal GRASST1
spriteshadow GOLD00
  spritenopal GOLD00
    spritenoshade GOLD00

spriteshadow POT
  spritenopal POT
    spritenoshade POT
spriteshadow BARREL
  spritenopal BARREL
    spritenoshade BARREL
spriteshadow BUCKET
  spritenopal BUCKET
    spritenoshade BUCKET
spriteshadow CHAIR1
  spritenopal CHAIR1
    spritenoshade CHAIR1
spriteshadow TABLE1
  spritenopal TABLE1
    spritenoshade TABLE1
spriteshadow TABLE2
  spritenopal TABLE2
    spritenoshade TABLE2
spriteshadow CHAIR2
  spritenopal CHAIR2
    spritenoshade CHAIR2
spriteshadow COLUMN1CHUNK
    spritenoshade COLUMN1CHUNK
spriteshadow WOODSIGN1
  spritenopal WOODSIGN1
    spritenoshade WOODSIGN1
spriteshadow WOODSIGN2
  spritenopal WOODSIGN2
    spritenoshade WOODSIGN2
spriteshadow PLANT1
  spritenopal PLANT1
    spritenoshade PLANT1
spriteshadow PLANT2
  spritenopal PLANT2
    spritenoshade PLANT2
spriteshadow IRONSTOVE
  spritenopal IRONSTOVE
    spritenoshade IRONSTOVE
spriteshadow BED
  spritenopal BED
    spritenoshade BED
spritenoshade SMALLSMOKE  
  spritenopal SMALLSMOKE

spritenoshade TREEPINE1
spritenoshade TREEPINE2
spritenoshade TREEPINE3
spritenoshade TREEPINE4
spritenoshade TREEPINE5
spritenoshade TREEPINE6
spritenoshade TREEPINE7
spritenoshade TREEPINE8
spritenoshade TREEPINE9

spritenopal WALLBARREL
  spritenoshade WALLBARREL
spritenopal WINE
  spritenoshade WINE
spritenopal DOOR1
  spritenoshade DOOR1
spritenopal FIREPLACE
  spritenoshade FIREPLACE
spritenopal BOOKCASE1
  spritenoshade BOOKCASE1
spritenopal BOOKCASE2
  spritenoshade BOOKCASE2
spritenopal BANNER1
  spritenoshade BANNER1
spritenopal BANNER2
  spritenoshade BANNER2
spritenopal 310 // window out
  spritenoshade 310
spritenopal 482 // window in
  spritenoshade 482
// -------------------------------- Effects


action AEPICSPLASH 1380 4 1 1 16

actor EPICSPLASH 0 0
  ifaction 0
  {
    sizeat 72 128
    cstat 0
    soundonce ITEM_SPLASH
    action AEPICSPLASH
  }
  ifactioncount 4 killit
enda

action AFISHCRUISE 0 2 1 1 16
action AFISHFLEE 0 2 1 1 8

move FISHCRUISE 32 0
move FISHFLEE 128 0

actor FISHI1 10 AFISHCRUISE FISHCRUISE randomangle geth
cstat 256

  ifaction AFISHCRUISE
  {
    ifcount 8 ifrnd 32 spawn WATERBUBBLE
    ifpdistl 1024
    {
      move FISHFLEE fleeenemy geth
      sound AQUACRITSFX 
      spawn WATERBUBBLE
      action AFISHFLEE
      break
    }
    move FISHCRUISE geth

    ifnotmoving
      move FISHCRUISE randomangle geth
  }

  ifaction AFISHFLEE
  {
    ifcount 4 ifrnd 64 spawn WATERBUBBLE
    ifpdistg 2048 
      action AFISHCRUISE
    else
      move FISHFLEE fleeenemy geth
  }

  ifhitweapon
    ifdead
    {
      spritepal 7
      guts JIBS6 5
      killit
    }
enda

action ADRIPSPAWN 0 1 1 1 16

actor DRIPSPAWN 0 ADRIPSPAWN
  ifcount 32
    ifrnd 16
    {
      spawn NEWDRIP
      resetcount
    }
enda

action ADRIPFALL 0 1 1 1 1
action ADRIPSPLASH 7 4 1 1 8

actor NEWDRIP 0
  ifinwater killit
  ifaction 0
  {
    ifspawnedby WALLBARREL spritepal 10
    sizeat 24 24
    action ADRIPFALL
    fall
  }
    ifaction ADRIPSPLASH
    {
      
      ifactioncount 4
        killit
    }
    ifaction ADRIPFALL 
    {
      iffloordistl 1
      {
        ifonwater killit
        ifrnd 64 soundonce DRIPSFX 
        action ADRIPSPLASH
      }
      else
        fall
    }
enda



move SMOKEVEL 8 -16
move SMOKEVEL2 8 -16
move SMOKEVEL3 16 -4
move SMOKEVEL4 32 -24
move SMOKEVEL5 8 -16
move SMOKEVEL6 24 -4

move ENGINE_SMOKE 64 -64
move SMOKESHOOTOUT -192

move SMOKEBOOM1 96 -16 
move SMOKEBOOM2 64 -24 
move SMOKEBOOM3 32 -32 
move SMOKEBOOM4 16 -64 

action SMOKEFRAMESBOOM1 1101 11 1 1 4
action SMOKEFRAMESBOOM2 1101 11 1 1 6
action SMOKEFRAMESBOOM3 1101 11 1 1 8
action SMOKEFRAMESBOOM4 1101 11 1 1 10


action SMOKEFRAMESPUNCH 1101 11 1 1 4
action SMOKEFRAMESFALLS	1103 8 1 1 16
action SMOKEFRAMES 1101 11 1 1 16
action BIGSMOKEFRAMES 1101 11 1 1 32

actor SMALLSMOKE 0 SMOKEFRAMESPUNCH
  ifspawnedby FALLSMAKER { sizeto 256 256 }
  else ifspawnedby DIRTBOOM { sizeto 160 160 } 
  else ifspawnedby CANNON  { sizeto 160 160 } 
  else ifspawnedby BIGSMOKEMAKER { sizeto 384 384 }
  ifmove 0
  {
    sizeat 64 64
    cstator 2

    ifspawnedby SMALLSMOKEMAKER 
    {
      action SMOKEFRAMES
      move SMOKEVEL2 randomangle getv
    }
    else
    ifspawnedby BIGSMOKEMAKER 
    {
      action SMOKEFRAMES
      move SMOKEVEL4 randomangle getv
    }
    else
    ifspawnedby FALLSMAKER 
    {
      cstator 512
      sizeat 72 72
      action SMOKEFRAMESFALLS
      move SMOKEVEL6 randomangle getv geth

	getactor[THISACTOR].owner temp
	getactor[temp].pal tempb
	setactor[THISACTOR].pal tempb
    }
    else
    ifspawnedby TRAPARROW
	move SMOKEBOOM1 geth getv
    else
    ifspawnedby CANNON
	move SMOKEBOOM1 geth getv
    else
    ifspawnedby DIRTBOOM
    {
      ifrnd 128 
      {
	action SMOKEFRAMESBOOM1
	move SMOKEBOOM1 randomangle geth
      }
      else ifrnd 64 
      { 
	action SMOKEFRAMESBOOM2
	move SMOKEBOOM2 randomangle geth
      }
      else ifrnd 32 
      { 
	action SMOKEFRAMESBOOM3
        move SMOKEBOOM3 randomangle geth
      }
      else 
      {
	action SMOKEFRAMESBOOM4
	move SMOKEBOOM4 randomangle geth
      }
    }
    else
      move SMOKEVEL geth getv faceplayer
  }

  ifspawnedby DIRTBOOM 
  {
    ifaction SMOKEFRAMESBOOM1
    {
	move SMOKEBOOM1 geth 

	    ifactioncount 0 setactor[THISACTOR].shade 32
	    ifactioncount 1 setactor[THISACTOR].shade 28
	    ifactioncount 2 setactor[THISACTOR].shade 24
	    ifactioncount 3 setactor[THISACTOR].shade 20
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 12
	    ifactioncount 6 setactor[THISACTOR].shade 8
	    ifactioncount 7 setactor[THISACTOR].shade 4
	    ifactioncount 8 setactor[THISACTOR].shade 0
    }
    ifaction SMOKEFRAMESBOOM2 
    {
	move SMOKEBOOM2 geth

	    ifactioncount 0 setactor[THISACTOR].pal 92
	    ifactioncount 1 setactor[THISACTOR].shade 4
	    ifactioncount 2 setactor[THISACTOR].pal 51
	    ifactioncount 3 setactor[THISACTOR].shade 8
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 24
	    ifactioncount 6 
            {
              setactor[THISACTOR].shade 32
              setactor[THISACTOR].pal 0
            }
	    ifactioncount 7 setactor[THISACTOR].shade 16
	    ifactioncount 8 setactor[THISACTOR].shade 8
    }
    ifaction SMOKEFRAMESBOOM3 
    {
	move SMOKEBOOM3 geth

	    ifactioncount 0 setactor[THISACTOR].pal 110
	    ifactioncount 1 setactor[THISACTOR].shade 4
	    ifactioncount 2 setactor[THISACTOR].pal 10
	    ifactioncount 3 setactor[THISACTOR].shade 8
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 24
	    ifactioncount 6 
            {
              setactor[THISACTOR].shade 32
              setactor[THISACTOR].pal 0
            }
	    ifactioncount 7 setactor[THISACTOR].shade 16
	    ifactioncount 8 setactor[THISACTOR].shade 8
    }
    ifaction SMOKEFRAMESBOOM4
    {
	move SMOKEBOOM4 geth

	    ifactioncount 0 setactor[THISACTOR].pal 99
	    ifactioncount 1 setactor[THISACTOR].shade 4
	    ifactioncount 2 setactor[THISACTOR].pal 58
	    ifactioncount 3 setactor[THISACTOR].shade 8
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 24
	    ifactioncount 6 
            {
              setactor[THISACTOR].shade 32
              setactor[THISACTOR].pal 0
            }
	    ifactioncount 7 setactor[THISACTOR].shade 16
	    ifactioncount 8 setactor[THISACTOR].shade 8
    }
  }
  else  
  ifspawnedby CANNON
  {
	move SMOKEBOOM1 geth 

	    ifactioncount 0 setactor[THISACTOR].shade 32
	    ifactioncount 1 setactor[THISACTOR].shade 28
	    ifactioncount 2 setactor[THISACTOR].shade 24
	    ifactioncount 3 setactor[THISACTOR].shade 20
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 12
	    ifactioncount 6 setactor[THISACTOR].shade 8
	    ifactioncount 7 setactor[THISACTOR].shade 4
	    ifactioncount 8 setactor[THISACTOR].shade 0
  }
  else
  ifspawnedby SMALLSMOKEMAKER
  {
    ifceilingdistl 8 { move SMOKEVEL3 geth }
    else ifmove SMOKEVEL3 { move SMOKEVEL2 getv }

	    ifactioncount 0 setactor[THISACTOR].shade 32
	    ifactioncount 1 setactor[THISACTOR].shade 28
	    ifactioncount 2 setactor[THISACTOR].shade 24
	    ifactioncount 3 setactor[THISACTOR].shade 20
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 12
	    ifactioncount 6 setactor[THISACTOR].shade 8
	    ifactioncount 7 setactor[THISACTOR].shade 4
	    ifactioncount 8 setactor[THISACTOR].shade 0
  }
  else
  ifspawnedby BIGSMOKEMAKER
  {
    ifceilingdistl 8 { move SMOKEVEL3 geth }
    else ifmove SMOKEVEL3 { move SMOKEVEL4 getv }

	    ifactioncount 0 setactor[THISACTOR].shade 32
	    ifactioncount 1 setactor[THISACTOR].shade 28
	    ifactioncount 2 setactor[THISACTOR].shade 24
	    ifactioncount 3 setactor[THISACTOR].shade 20
	    ifactioncount 4 setactor[THISACTOR].shade 16
	    ifactioncount 5 setactor[THISACTOR].shade 12
	    ifactioncount 6 setactor[THISACTOR].shade 8
	    ifactioncount 7 setactor[THISACTOR].shade 4
	    ifactioncount 8 setactor[THISACTOR].shade 0
  }

  ifspawnedby FALLSMAKER
  {
    ifactioncount 3
    {  ifawayfromwall nullop else killit  }

    ifactioncount 6
      move SMOKEVEL5 getv geth
    ifactioncount 8
      killit
    ifmove SMOKEVEL5
    {  ifawayfromwall nullop else killit  }
  }
  else
  {
    ifactioncount 11
        killit
    ifspawnedby CANNON nullop
    else
      ifspawnedby TRAPARROW nullop
        else
        ifawayfromwall nullop else killit
  }
enda

actor SMALLSMOKEMAKER 0 0

 ifcount 6
 {	
  ifrnd 64 { spawn SMALLSMOKE resetcount }
 }
enda

actor BIGSMOKEMAKER 0 0
 ifcount 6
 {	 
  ifrnd 32 { spawn SMALLSMOKE resetcount }
 }
enda


actor FALLSMAKER 0
 soundonce WATERFALLSFX
 setactor[THISACTOR].x initx
 setactor[THISACTOR].y inity
 ifpdistl 16000
 {
   ifrnd 64 guts SCRAP5 5
   ifrnd 96 spawn SMALLSMOKE
 }
enda

actor SPRITZMAKER 0 0
 setactor[THISACTOR].x initx
 setactor[THISACTOR].y inity
 ifpdistl 16000
  ifcount 2
  {
    guts SCRAP5 5
    resetcount
  }

enda

actor DIRTBOOM 0 
  ifcount 2
  {
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
iffloordistl 16
{
  ifonwater 
  {
    guts SCRAP5 10
    debris SCRAP5 10
  }
  else
  {
    spritepal 43
      debris SCRAP5 10
    spritepal 28
      debris SCRAP1 3
  }
}


  }
  ifcount 8
  {
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE

iffloordistl 16
{
  ifonwater 
  {
    guts SCRAP5 10
    debris SCRAP5 10
  }
  else
  {
    spritepal 43
      debris SCRAP5 10
    spritepal 28
      debris SCRAP1 3
  }
}

  }
  ifcount 16
  {
    spawn SMALLSMOKE
    spawn SMALLSMOKE
    spawn SMALLSMOKE

iffloordistl 16
{
  ifonwater 
  {
    guts SCRAP5 10
    debris SCRAP5 10
  }
  else
  {
    spritepal 43
      debris SCRAP5 10
    spritepal 28
      debris SCRAP1 3
  }
}
    killit
  }

enda

// --------------------------------- Breakables
actor POT 1
  ifhitweapon
  {
     debris SCRAP1 16
     ifspritepal 0
     {
       ifrnd 64 spawn COLA
       else ifrnd 64 spawn GOLD00
       else ifrnd 48 spawn AMMO
       else ifrnd 48 spawn GOLD05
       else ifrnd 32 spawn GOLD10
       else ifrnd 16 spawn GOLD25
     }
     else ifspritepal 10
     {       
       spawn DIRTBOOM
       hitradius 2048 WEAK MEDIUMSTRENGTH TOUGH REALLYTOUGH 
       sound CANNONBOOMSFX
     }
//     else ifspritepal 2
//     {
//     }
     sound POTBREAKSFX
     killit
  }
enda

actor BARREL 1
  ifhitweapon
  {
    ifspritepal 47
    {
      debris SCRAP2 24
      spawn DIRTBOOM
      hitradius 2048 MEDIUMSTRENGTH TOUGH REALLYTOUGH ROBOTMOUSESTRENGTH
      sound CANNONBOOMSFX
      killit
    }
    else
    {
     ifrnd 64
     {
       spawn BLOODPOOL
       spritepal 10
       debris SCRAP5 12
     }
     else ifrnd 64 spawn COLA
     else ifrnd 32 spawn SIXPAK
     else ifrnd 16 spawn GOLD05
     else ifrnd 8 spawn GOLD10
     debris SCRAP2 24
     sound BARRELBREAKSFX
     killit
    }
  }
enda

actor BUCKET 1
  ifhitweapon
  {
     debris SCRAP2 16
     ifrnd 32 spawn GOLD00
     sound BARRELBREAKSFX
     killit
  }
enda

actor BOOKCASE1 15
  ifdead 
    ifhitweapon
    {
     debris SCRAP2 48
     paper 32
     sound BARRELBREAKSFX 
     killit
    }
enda

actor BOOKCASE2 15 ifhitweapon ifdead { debris SCRAP2 48 sound BARRELBREAKSFX  killit } enda

actor WOODSIGN1 30 ifhitweapon ifdead { debris SCRAP2 48 sound BARRELBREAKSFX  killit } enda

actor WOODSIGN2 30 ifhitweapon ifdead { debris SCRAP2 48 sound BARRELBREAKSFX  killit } enda

actor TABLE1 60 ifhitweapon ifdead { ifspritepal 0 spritepal 1 sound POTBREAKSFX  debris SCRAP1 24 killit } enda

actor CHAIR1 30 ifhitweapon ifdead { ifspritepal 0 spritepal 1 sound POTBREAKSFX  debris SCRAP1 16 killit } enda

actor CHAIR2 20 ifhitweapon ifdead { debris SCRAP2 24 sound BARRELBREAKSFX  killit } enda

actor TABLE2 45 ifhitweapon ifdead { debris SCRAP2 48 sound BARRELBREAKSFX  killit } enda

actor PLANT1 1 cstat 256 ifhitweapon { money 16 killit } enda

actor PLANT2 1 cstat 256 ifhitweapon { money 16 killit } enda

gamevar flatface 0 2

move FACEDUKE
action GRASSDONE 0 1 1 1 0

actor GRASSB1 30  // not used yet...
cstat 256 ifhitweapon { money 4 ifdead { money 16 killit } }
enda


actor GRASSB2 1 0
  ifpdistl 12000 
    cstat 256 
  else
    cstat 32768

  ifaction 0
  {
    getactor[THISACTOR].yrepeat tempb
    setvarvar temp tempb
    setactor[THISACTOR].extra temp
    action GRASSDONE
  }
  ifhitweapon 
  { 
    money 4 
    ifstrength 10 
      nullop
    else
    {
      getactor[THISACTOR].extra tempb
      setvarvar temp tempb
      setactor[THISACTOR].yrepeat temp
    }

    ifdead 
    { 
      ifrnd 1 spawn GOLD00
      money 16 
      killit 
    } 
  }
enda

actor GRASST1 1 0
  ifaction 0
  {
    cstat 256 
    getactor[THISACTOR].extra temp
    getactor[THISACTOR].yrepeat tempb
    setvarvar temp tempb
    setactor[THISACTOR].extra temp
    action GRASSDONE
  }
  ifhitweapon 
  { 
    money 4 
    ifstrength 10 
      nullop
    else
    {
      getactor[THISACTOR].yrepeat temp
      subvar temp 4
      setactor[THISACTOR].yrepeat temp
    }

    ifdead 
    { 
      ifrnd 1 spawn GOLD00
      money 16 
      killit 
    } 
  }
enda



actor WINE 1
  ifhitweapon
  {
     spawn BLOODPOOL
     lotsofglass 16
     spritepal 10
     debris SCRAP5 12
     sound GLASS_BREAKING
     killit
  }
enda

actor TREEPINE1 90
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 60
      debris SCRAP2 48
      killit
    }
  }
enda

actor TREEPINE2 60
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 60
      debris SCRAP2 48
      killit
    }
  }
enda

actor TREEPINE3 60
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 60
      debris SCRAP2 48
      killit
    }
  }
enda

actor TREEPINE4 140
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 60
      debris SCRAP2 48
      killit
    }
  }
enda

actor TREEPINE5 200
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 80
      debris SCRAP2 64
      killit
    }
  }
enda

actor TREEPINE6 500
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 80
      debris SCRAP2 64
      killit
    }
  }
enda

actor TREEPINE7 500
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 80
      debris SCRAP2 64
      killit
    }
  }
enda

actor TREEPINE8 500
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 80
      debris SCRAP2 64
      killit
    }
  }
enda

actor TREEPINE9 500
  ifhitweapon
  {
    money 20
    ifdead
    {
      money 80
      debris SCRAP2 64
      killit
    }
  }
enda

actor PINEBACK 0
  ifhitweapon
  {
    money 20
  }
enda

action ABANNER1RIP 232 1 1 1 0

actor BANNER1 1
  ifaction 0
    ifhitweapon
      ifdead
        action ABANNER1RIP
enda

action ABANNER2RIP 119 1 1 1 0

actor BANNER2 1
  ifaction 0 
    ifhitweapon
      ifdead
        action ABANNER2RIP
enda

action AWALLBARRELBROKE 55 1 1 1 0

actor WALLBARREL 1
  ifaction 0
    ifhitweapon
      ifdead
      {
        debris SCRAP2 12
        spritepal 10
        debris SCRAP5 12
        spawn BLOODPOOL
        spritepal 0
        sound BARRELBREAKSFX 
        action AWALLBARRELBROKE
      }
  ifaction AWALLBARRELBROKE
    ifcount 16
      ifrnd 8
      {
        spritepal 10
        spawn NEWDRIP
        spritepal 0
      }
enda

// ---------------------------------------- Special

action ADOORCLOSED1 0 1 1 1 0 
action ADOORCLOSIN1 7 7 1 -1 4
action ADOOROPENIN1 0 7 1 1 4

actor DOOR1 1 ADOORCLOSED1
{
  ifp pfacing
    ifpdistl 1280
      ifhitspace
        ifaction ADOORCLOSED1
        {
          action ADOOROPENIN1
        }
  ifaction ADOOROPENIN1
    ifactioncount 7
    {
      action ADOORCLOSIN1
    }
  ifaction ADOORCLOSIN1
    ifactioncount 7
    {
      action ADOORCLOSED1
    }
}
enda

actor GOLD05
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  killit
enda

actor GOLD10
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  killit
enda

actor GOLD25
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  killit
enda

actor GOLD50
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00  spawn GOLD00
  killit
enda

action AGOLDSPAWN 0 1 1 1 15
action AGOLDSET 0 1 1 1 15

move GOLDPOP 32 -96
move GOLDROLL 64 16

actor GOLD00 1
  fall
  sizeat 32 32
  ifaction 0
  {
    move GOLDPOP randomangle getv
    action AGOLDSPAWN
  }
  else
  ifaction AGOLDSPAWN
  {
    ifactioncount 0
      move GOLDPOP getv
    ifactioncount 1
    {
      fall
      move GOLDROLL geth
    }
    ifactioncount 4
    {
      move STOPPED
      action AGOLDSET
      resetcount
    }
  }
  else
  ifaction AGOLDSET
    ifp palive
      ifpdistl RETRIEVEDISTANCE
        ifcanseetarget
        {
          addvar pgold 1
          quote 102
          sound GETCOINSFX
          killit
        }

  ifcount 2 setactorangle 0
  ifcount 4 setactorangle 128
  ifcount 6 setactorangle 256
  ifcount 8 setactorangle 384
  ifcount 10 setactorangle 512
  ifcount 12 setactorangle 640
  ifcount 14 setactorangle 768
  ifcount 16 setactorangle 896
  ifcount 18 setactorangle 1024
  ifcount 20 setactorangle 1152
  ifcount 22 setactorangle 1280
  ifcount 24 setactorangle 1408
  ifcount 26 setactorangle 1536
  ifcount 28 setactorangle 1664
  ifcount 30 { setactorangle 1792 resetcount }

enda

action ATRAPARROWWAIT 0 1 1 1 32
action ATRAPARROWFIRE 1 1 1 1 16

actor TRAPARROW 1 ATRAPARROWWAIT
  ifcount 16
    ifaction ATRAPARROWFIRE
    {
	action ATRAPARROWWAIT
	shoot ARROWFIXED
        spawn SMALLSMOKE
        sound ARROWTRAPSFX
        resetcount
    }
  ifcount 32
    ifcansee
	ifpdistl 10000
        {
	action ATRAPARROWFIRE
 	resetcount
        }
enda

move CANNONBALL1 576 0
move CANNONBALL2 544 32
move CANNONBALL3 512 64
move CANNONBALL4 480 128
move CANNONBALL5 448 256

useractor notenemy CANNONBALL 1

  ifaction 0
  {
    sizeat 32 32
    cstat 257         // Force actor to block
    action ANULLACTION
  }

    ifactioncount 24
    {
      ifactioncount 47 nullop
      else
      {
        move CANNONBALL5 geth getv
      }
    }
    else
      ifactioncount 32
    {
      ifactioncount 45 nullop
      else
        move CANNONBALL4 geth getv
    }
    else
      ifactioncount 16
    {
      ifactioncount 41 nullop
      else
        move CANNONBALL3 geth getv
    }
    else
      ifactioncount 8
    {
      ifactioncount 33 nullop
      else
        move CANNONBALL2 geth getv
    }
    else
      ifactioncount 4
    {
      ifactioncount 17 nullop
      else move CANNONBALL1 geth getv
    }

  ifmove CANNONBALL5
    iffloordistl 8 fall

  ifonwater
  {
    spawn DIRTBOOM
    killit
  }

  ifnotmoving
  {
    spawn DIRTBOOM
    hitradius 4096 TOUGH REALLYTOUGH ROBOTMOUSESTRENGTH GOTTASMART
    sound CANNONBOOMSFX
    killit
  }

enda

define CANNONBALLS 1818
define CANNONBALLSSTRENGTH 10
move CANNONBALLSVEL

useractor notenemy CANNONBALLS CANNONBALLSSTRENGTH
  ifaction 0
  {
    cstator 257
    action ANULLACTION
  }
  ifhitweapon
  {
    ifdead
    {
      spawn DIRTBOOM
      spawn DIRTBOOM
      hitradius 6400 TOUGH REALLYTOUGH ROBOTMOUSESTRENGTH GOTTASMART
      sound CANNONBOOMSFX
      killit
    }
    else
      debris SCRAP1 3
  }
enda


action ACANNONWAIT 0 1 1 1 1
action ACANNONSHOOTING 0 1 1 1 8
//move CANNONSTOP

//useractor enemy CANNON 
actor CANNON 1 0
  ifaction 0
  {
    sizeat 72 72
    action ACANNONWAIT
  }
  else
  ifaction ACANNONSHOOTING
  {
    ifactioncount 0 
    {
      ifcount 0 spawn SMALLSMOKE
      ifcount 2 spawn SMALLSMOKE
      ifcount 4 spawn SMALLSMOKE
      ifcount 6 spawn SMALLSMOKE
      ifcount 8 spawn SMALLSMOKE
    }
    ifactioncount 1
    {
      spawn CANNONBALL
      resetactioncount
      action ACANNONWAIT
    }
  }
  else
  ifaction ACANNONWAIT
  {
    ifpdistl 16000
    ifactioncount 64
    {
      ifrnd 128
      {
        action ACANNONSHOOTING
      }
      else
        resetactioncount
    }
  }
enda


// Static decor
actor GENROCK1 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

actor GENROCK2 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

actor GENROCK3 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

actor GENROCK4 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

actor GENROCK5 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

actor GENROCK6 0
  ifpdistl 16000
    cstat 256 
  else
    cstat 32768
enda

