Aller au contenu

Photo

Level Bracket XP/Gold Rewards


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
Mooselips

Mooselips
  • Members
  • 8 messages
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...

#2
kalbaern

kalbaern
  • Members
  • 824 messages
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?

#3
Mooselips

Mooselips
  • Members
  • 8 messages
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.

#4
Baragg

Baragg
  • Members
  • 271 messages
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:
 }
}


#5
Mooselips

Mooselips
  • Members
  • 8 messages
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 .


#6
Baragg

Baragg
  • Members
  • 271 messages
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 .


#7
Baragg

Baragg
  • Members
  • 271 messages
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;

#8
Mooselips

Mooselips
  • Members
  • 8 messages
ok, i understand now.

Thanks for the help

:)

#9
Baragg

Baragg
  • Members
  • 271 messages
My pleasure.

#10
Mooselips

Mooselips
  • Members
  • 8 messages
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));

   }

}

#11
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#12
Mooselips

Mooselips
  • Members
  • 8 messages
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

#13
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I edited what I posted above. I didn't eat my wheaties this morning sorry.

#14
Mooselips

Mooselips
  • Members
  • 8 messages
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.

#15
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#16
Mooselips

Mooselips
  • Members
  • 8 messages
Works now. Thanks