//Created by Genisys 5/23/08
//This script rewards the PC targeted by the DM with a Random Reward
//Note this is a tag based item script which fires OnActivateItem Unique Power
#include "x2_inc_switches"
#include "setxp_inc"

void main()
{

    //Declare Major Variables
    object oPC;
    object oItem;
    object oTarget;
    string aItem;
    int bInt;
    int dInt;
    int gInt;
    int nInt;
    int nLvl;
    int gGold;
    int nGold;

    //Major Variables Defined...
    oPC = GetItemActivator();
    oTarget = GetItemActivatedTarget();
    bInt = Random(100);
    //This is the amount of gold given X Level (adjust below)
    dInt = 3000;
    nLvl = GetHitDice(oTarget);
    //Give them an amount of Gold X PC Level (See dInt above)
    gGold = nLvl * dInt;
    nGold = GetGold(oTarget);


if(!GetIsPC(oTarget))
{
SendMessageToPC(oPC, "You must target a PC!");
}

FloatingTextStringOnCreature("You have recieved a random reward!", oTarget, TRUE);

 //Lets make sure they aren't pretty rich..
 if(nGold < 500000)
 {
  GiveGoldToCreature(oPC, gGold);
 }

//Whopping 1% chance of the best item the DM can give a player!!
 if(bInt == 50)
{
 //Don't forget to create this item and give it the resref name "dmitem7"
 CreateItemOnObject("dmitem7", oPC, 1);
}
 //Award a Level 40% chance..
 else if(bInt <= 39)
 {
  Give1Level(oPC);
 }

//Award a special item 20% chance.. (1 of 6 different rare items!)
 else if(bInt >=80)
 {
 //You will want to create 6 items resref named below "dmitem"
 //don't forget the item # !
  nInt = d6(1);

 switch (nInt)
 {
  case 1:
  {
  CreateItemOnObject("dmitem1", oPC, 1);
  break;
  }
  case 2:
  {
  CreateItemOnObject("dmitem2", oPC, 1);
  break;
  }
  case 3:
  {
  CreateItemOnObject("dmitem3", oPC, 1);
  break;
  }
  case 4:
  {
  CreateItemOnObject("dmitem4", oPC, 1);
  break;
  }
  case 5:
  {
  CreateItemOnObject("dmitem5", oPC, 1);
  break;
  }
  case 6:
  {
  CreateItemOnObject("dmitem6", oPC, 1);
  break;
  }
 }

}

 //Otherwise give a random reward (something decent..)
 else
 {
 GiveXPToCreature(oTarget, 1000);
 GiveGoldToCreature(oTarget, 5000);
 //Note I created these items! (you can create your own!) :)
 CreateItemOnObject("grtrestorepots", oTarget, 10);
 CreateItemOnObject("bagofholding", oTarget, 10);
 }

//End Script
}