Author Topic: Level Bracket XP/Gold Rewards  (Read 437 times)

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« on: September 27, 2010, 11:17:24 pm »


               hello

I'm looking to get a bit of help. What i need is a script that gives experience points and gold to players of a certain level bracket. Something like; levels 20-25 recieve 250 XP and 250 gold, levels 26-30 recieve 500 XP and 500 gold and so on...
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #1 on: September 27, 2010, 11:30:29 pm »


               We'll need to know where it'll be used. A DM's Widget, a creatures death event, a conversation with an NPC, every time you pull a lever, etc... . Additionaly, it'd help in some of these cases to know if it is a one shot event. Does the reward just get given to a single PC as well or is it shared by those partied together?
               
               

               
            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #2 on: September 27, 2010, 11:40:55 pm »


               Sorry for the lack of info.



It'll be used in an onplayerdeath script using the function GetLastHostileActor. The rewards should go to a single player.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #3 on: September 27, 2010, 11:42:32 pm »


               This would go in a placeables onused event, I did not finish the script but you can get the gest of it:




void main()
{
 object oPC = GetLastUsedBy();
 int nHD = GetHitDice(oPC);
 int nBase = 100;

 switch(nHD)
 {
  case 1: case 2: case 3: case 4: case 5:
  SetXP(oPC, GetXP(oPC)+nBase); GiveGoldToCreature(oPC, nBase); break;
  case 5: case 7: case 8: case 9: case 10:
  SetXP(oPC, GetXP(oPC)+(nBase*2)); GiveGoldToCreature(oPC, nBase*2); break;
  //............so on and so forth to case 40:
 }
}

               
               

               
            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #4 on: September 28, 2010, 01:03:21 am »


               Thanks.

I added it to what I already have and it works great, but how would i go about modifying the script so i can alter the amounts of XP/Gold given?
               
               

               


                     Modifié par Mooselips, 28 septembre 2010 - 12:08 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #5 on: September 28, 2010, 01:16:14 am »


               In what way would you wish to do so?
The base amount is defined as int nBase = 100.
I kinda figured that would be a jump off point. In the second "bracket" you will see the amount awarded is nBase*2, which translates to 100 multiplied by 2, or 100x2 = 200. You can up the number of the multiplier per "bracket", or say in the next set, which would be the case 11:.......through......case 15: you could bump the award by simply stating nBase*3 would yeild you 300.
               
               

               


                     Modifié par Baragg, 28 septembre 2010 - 12:17 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #6 on: September 28, 2010, 01:18:54 am »


               You may also want to add a.....default:......case in after the case 40. This would be a catch all incase something odd happens. It would look like:



default:

// do stuff here incase they don't fit in the other case statements

break;
               
               

               
            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #7 on: September 28, 2010, 01:24:32 am »


               ok, i understand now.

Thanks for the help

'<img'>
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #8 on: September 28, 2010, 01:28:41 am »


               My pleasure.
               
               

               
            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #9 on: September 28, 2010, 02:35:32 am »


               Sorry, I have one last question.



Can the script you made check to see if the player recieving the reward
is 5 levels or higher than the loser and if so reward nothing?



I haven't play tested this yet, but here's what i have in the onplayerdeath event.





#include "x2_inc_toollib"

#include "sd_score_inc"





// Baragg Script

void XPGReward(object oPlayer)



{



object oPlayer = GetLastHostileActor();

int nHD = GetHitDice(oPlayer);



int nBase = 100;







switch(nHD)



{



case 1: case 2: case 3: case 4: case 5:



SetXP(oPlayer, GetXP(oPlayer)+nBase); GiveGoldToCreature(oPlayer, nBase); break;



case 6: case 7: case 8: case 9: case 10:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*2)); GiveGoldToCreature(oPlayer, nBase*2); break;



case 11: case 12: case 13: case 14: case 15:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*3)); GiveGoldToCreature(oPlayer, nBase*3); break;



case 16: case 17: case 18: case 19: case 20:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*4)); GiveGoldToCreature(oPlayer, nBase*4); break;



case 21: case 22: case 23: case 24: case 25:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*5)); GiveGoldToCreature(oPlayer, nBase*5); break;



case 26: case 27: case 28: case 29: case 30:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*6)); GiveGoldToCreature(oPlayer, nBase*6); break;



case 31: case 32: case 33: case 34: case 35:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*7)); GiveGoldToCreature(oPlayer, nBase*7); break;



case 36: case 37: case 38: case 39: case 40:



SetXP(oPlayer, GetXP(oPlayer)+(nBase*8)); GiveGoldToCreature(oPlayer, nBase*8); break;



}

}



void main()

{

   object oPlayer = GetLastPlayerDied();

   object oVictor = GetLastHostileActor(oPlayer);

   object oArea = GetArea(oPlayer);



   location lPillar = GetLocation(oPlayer);

   string sArea = GetTag(oArea);



   // Standard death code to all areas.

   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect (VFX_COM_CHUNK_RED_LARGE), oPlayer, 3.0);



   DelayCommand(5.0f, ForceRest(oPlayer));





   if (sArea == "Arena")

   {

   XPGReward(oPlayer);

      //FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(3.0f, respawnArena(oPlayer, oVictor));

   }

   else if (sArea == "TeamArena")

   {

      //FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(1.5f, respawnTeamArena(oPlayer, oVictor));

      //respawnTeam(oPlayer, oVictor);

   }

   else if (sArea == "TeamArenaFFA")

   {

   XPGReward(oPlayer);

      //FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(1.5f, respawnTeamArenaFFA(oPlayer, oVictor));

      //respawnTeam(oPlayer, oVictor);

   }

   else if (sArea == "TrainingArena")

   {

      //FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(3.0f, respawnTraining(oPlayer, oVictor));

   }

   else if (sArea == "SummoningChamber")

   {

      TLVFXPillar(VFX_COM_CHUNK_RED_LARGE, lPillar, 10, 0.1, 0.5, 0.75);

      FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(5.0f, respawnPVM(oPlayer));

   }

   else if (sArea == "FCPDPrison")

   {

      FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(5.0f, respawnJail(oPlayer));

   }

   else

   {

      FloatingTextStringOnCreature("** Respawn in 5 seconds **", oPlayer, FALSE);

      DelayCommand(5.0f, respawnDefault(oPlayer));

   }

}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #10 on: September 28, 2010, 02:48:33 am »


               Add something like so?:

void main()

{

   object oPlayer = GetLastPlayerDied();

   object oVictor = GetLastHostileActor(oPlayer);

   object oArea = GetArea(oPlayer);

   int iLvlDifference = GetHitDice(oPlayer) - GetHitDice(oVictor);
   if (iLvlDifference > 5 || iLvlDifference < -5)return;


Pretty sure I got that right. I hope. Hope that helps.

EDIT: Or did you mean just not give the xp reward in that one area if the level difference is too high but still run the rest of the death stuff? If that is the case then you might do something like so:

else if (sArea == "TeamArenaFFA")

   {
   int iLvlDifference = GetHitDice(oPlayer) - GetHitDice(oVictor);
   if ((iLvlDifference <= 5 && iLvlDifference >= 0) ||
        (iLvlDifference >= -5 && iLvlDifference <= 0))
   XPGReward(oPlayer);
               
               

               


                     Modifié par GhostOfGod, 28 septembre 2010 - 02:14 .
                     
                  


            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #11 on: September 28, 2010, 03:12:42 am »


               Yeah, just the two areas where i have XPGReward(oPlayer); set.



I added what you have and got everything to compile, just gotta play test it now.



Thank you
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #12 on: September 28, 2010, 03:16:08 am »


               I edited what I posted above. I didn't eat my wheaties this morning sorry.
               
               

               
            

Legacy_Mooselips

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #13 on: September 28, 2010, 07:01:42 am »


               Me and a buddy play tested it, and for some reason we're not getting the rewards. I've tried modifying the script from top to bottom but i cannot get it working. All the respawns work in each area, it's just not giving the xp/gold.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Level Bracket XP/Gold Rewards
« Reply #14 on: September 28, 2010, 07:28:42 am »


               The person who died isn't supposed to get the xp are they? Should be the person who killed them?
Change:
XPGReward(oPlayer);

To:
XPGReward(oVictor);

And in the "XPGReward" function I would remove the line "object oPlayer = GetLastHostileActor();" since the function requires you to pass a player into it anyway. There is no sense in re-defining oPlayer:

// Baragg Script
void XPGReward(object oPlayer)
{
object oPlayer = GetLastHostileActor(); <---remove this line
int nHD = GetHitDice(oPlayer)
int nBase = 100;

switch(nHD)
        {
        case 1: case 2: case 3: case 4: case 5:

Hope that helps.
               
               

               


                     Modifié par GhostOfGod, 28 septembre 2010 - 06:29 .