//THE DIFFRENT STATES
//0: Opened book at first page 
//1: 2 page 
//2: 3 page 
//3: 4 + 5 page 
//4: back to 1 page again 
//5: unopened book at first page 
//6: Closed and finished book

//THE DIFFRENT CONTENTS
//0: No ingredients
//1: 2 ingredients in place
//2: 3 ingredients in place
//3: Last ingredient in place
//6: Summoning finished, dont check for ingredients anymore


//-------------------------------------------------------------------------------------- 
//Read and open the book 
IfSpawned 
  tmpargument = 5 
  SetState 

//See if all ingredients are in place
IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsAPlayer
    tmpargument = 0
    IfContentIs
      IfTimeOut
        tmpargument = [GREE]  //Greenleaf
        CostTargetItemID
          tmpargument = 5
          SendMessageNear
          tmpargument = 1
          SetContent
          tmpargument = 100
          SetTime
          tmpargument = 20
          tmpdistance = EXPSECRET
          GiveExperienceToTarget
    tmpargument = 1
    IfContentIs
      IfTimeOut
        tmpargument = [DRAG]  //dragon blood
        CostTargetItemID
          tmpargument = 6
          SendMessageNear
          tmpargument = 2
          SetContent
          tmpargument = 100
          SetTime
          tmpargument = 20
          tmpdistance = EXPSECRET
          GiveExperienceToTarget
    tmpargument = 2
    IfContentIs
      IfTimeOut
        tmpargument = [REDS]  //bloodgem
        CostTargetItemID
          tmpargument = 7
          SendMessageNear
          tmpargument = 3
          SetContent
          tmpargument = 100
          SetTime
          tmpargument = 20
          tmpdistance = EXPSECRET
          GiveExperienceToTarget
    tmpargument = 3	   //Finish the summoning!
    IfContentIs
      IfTimeOut            //Disable text looping
        tmpargument = 8
        SendMessageNear
        tmpargument = 6
        SetContent
        SetState
        tmpargument = 100
        SetTime
        tmpargument = 78           //Slot number 78
        tmpx = selfx               // X position of the new character
        tmpy = selfy + 240               // Y position of the new character
        tmpdistance = selfz + 15  // Altitude of the new character
        tmpturn = targetturnto         // facing of the new character
        SpawnExactCharacterXYZ      //Summon the HELL ROVER!! mohaha

        tmpargument = 0       //part0.txt
        tmpx = selfx            // x
        tmpy = selfy            // y
        tmpdistance = selfz     // z
        tmpturn = rand & 1000   // These are all spell effects
        SpawnExactParticle      // creating lighting bolts
        tmpturn = rand 1 & 2000  
        SpawnExactParticle
        tmpturn = rand 1 & 2000  
        SpawnExactParticle
        tmpturn = rand 1 & 5000  
        SpawnExactParticle
        tmpturn = rand 1 & 6000  
        SpawnExactParticle
        tmpturn = rand 1 & 7000  
        SpawnExactParticle
        tmpargument = 0      //Thunder sound
        PlaySound

        //Award some experience
        tmpargument = 50
        tmpdistance = EXPQUEST
        GiveExperienceToTarget

IfBumped 			//PlayerBumpsBookStand 
  IfTimeOut 
    SetTargetToWhoeverBumped 	//Targets the Bumper 
    IfTargetIsAPlayer 		//Is the Bumper a player? 
      tmpargument = 3 
      IfStateIs 		//PAGE 4 + 5 
        tmpargument = 3 
        SendMessageNear 
        tmpargument = 4 
        SendMessageNear 
        SetState 
        tmpargument = 100 
        SetTime
        tmpargument = 1
        PlaySound		//Page turning sound

      tmpargument = 2 
      IfStateIs //PAGE 3  //UNUSED YET!!!!
        tmpargument = 2 
        SendMessageNear 
        tmpargument = 3 
        SetState 
        tmpargument = 100 
        SetTime 
        tmpargument = 1
        PlaySound		//Page turning sound

      tmpargument = 1 		
      IfStateIs //PAGE 2 
        tmpargument = 1 
        SendMessageNear 
        tmpargument = 3 
        SetState 
        tmpargument = 100 
        SetTime 
        tmpargument = 1
        PlaySound		//Page turning sound

      tmpargument = 0 
      IfStateIs //PAGE 1 
        tmpargument = 0 
        SendMessageNear 
        tmpargument = 1 
        SetState 
        tmpargument = 100 
        SetTime 
        tmpargument = 1
        PlaySound		//Page turning sound

      tmpargument = 4 
      IfStateIs 
        tmpargument = 0 
        SetState

      tmpargument = 5 
      IfStateIs //UNOPENED 
        tmpargument = ACTIONDB 
        DoAction 
        KeepAction 
        tmpargument = 0 
        SendMessageNear 
        tmpargument = 1 
        SetState 
        tmpargument = 100 
        SetTime 

      tmpargument = 6 
      IfStateIs //UNOPENED -finished
        UnkeepAction 
        tmpargument = 9 
        SendMessageNear 
        tmpargument = 10 
        SendMessageNear
        tmpargument = 100 
        SetTime 


//------------------------------------------------------------------------------------------ 


End

