Author Topic: xp and gold penalty on enter script help?  (Read 453 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
xp and gold penalty on enter script help?
« on: April 02, 2015, 07:37:05 am »


               Hello,


I am a novice scripter who has managed to write down a respawn script. Which bases on the pc's alignment if the character goes to hell or hell (then finding out that there was a ready to go script for it all along....)


Aaaanyway I seem to be unable to get the death penalty right on either script and even looked at the campaign script to help me but no luck.


So here is what I am looking for and hopi someone can help me write the script(or give one to me if possible):


I am looking for an on enter script that will take xp and gold from the pc when it enters the dead zone. (Based on the original campaign respawn script: 10% being taken but cannot lose level)


I am not very good with the variables yet so hence why I ask for some help here. Since not reallyy sure how to start with this.


Also in an addition wanted to add the deadzone thing to it, meaning that the character would be unable to use his/her items and spells for the duration that the character is in that area.


Hope someone could help me with a script for this.

thanks in advance!
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
xp and gold penalty on enter script help?
« Reply #1 on: April 02, 2015, 07:54:15 pm »


               

Concerning your respawn code, a few things to mention: A respawn script usually does not only apply gold and xp penalties, it also removes bad effects, restores hit points etc... This is not performed in the OnEnter script of an area, but in the respawn script of the module.


 


That being said, I will still assume you need the code in the OnEnter script of an area:


 


void ApplyPenalty(object oPC)

{

    int nXP = GetXP(oPC);

    int nLv = GetHitDice(oPC);

    int nPenalty = 100 * nLv; // set xp penalty formula here

    

    // * You can not lose a level with this respawning

    int nMin = ((nLv * (nLv - 1)) / 2) * 1000;

 

    int nNewXP = nXP - nPenalty;

    if(nNewXP < nMin) nNewXP = nMin;

    SetXP(oPC, nNewXP);

    int nGoldToTake = FloatToInt(0.10 * GetGold(oPC)); // set gold penalty formula here

 

    // * a cap of 10 000gp taken from you

    if(nGoldToTake > 10000) nGoldToTake = 10000; // modify cap here

    AssignCommand(oPC, TakeGoldFromCreature(nGoldToTake, oPC, TRUE));

}

 


void main()


{


    object oPC = GetEnteringObject();


    if(GetIsDM(oPC) || GetIsDMPossessed(oPC) || !GetIsPC(oPC)) return;    


    ApplyPenalty(oPC);


}


 


 


Kato



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
xp and gold penalty on enter script help?
« Reply #2 on: April 02, 2015, 08:21:24 pm »


               Yes I am aware of that and I did managed to do that just I cannot seem to combine similar script with with my respawn script so this was my alternative option sothank you so much for helping me out!


Been trying it out myself since i posted this but with no luck.


So thank you for being my knight in scripted armor '<img'>