HD/gold check and then give player "x" amount xp/gold script

now this one i cant either wrap my head around or get the result i am looking for, i am attempting to make a script ( during a conversation ) that will first;

check HD of player;
if level 15 or lower, increase xp to be level 16
or if 16 or higher, then nothing happens

then when it comes to gold;
if player has;

more than 100 000, give them nothing
less than 100 000, set gold to 100 000

i’ve tried looking through the lexicon and lilac scripting tools, and they dont have the function of “if something is this make it this” to the way i want it to be,
and when it comes to the conversation script wizard i can’t set xp or gold with a “if char has “x” trait, make it this” my only option basically is; give character set xp or gold

here is a rough-n-ready version modified from a script I use. Call in module on enter. The PC will then need to go through and handle each level up.

void main()
{
object oPC = GetEnteringObject();
object oMe = OBJECT_SELF;
object oMod = GetModule();
int nGold = GetGold(oPC);
if(nGold<=99999)  GiveGoldToCreature(oPC, 100000-nGold);
int nStartLevel = 16;//GetLocalInt(oMod, "STARTING_LEVEL");
if(nStartLevel<=1) return;//System off
int nLevel = GetHitDice(oPC);//This should get total level
if(nLevel>=nStartLevel) return;//If PC is target level or higher, abort
int nNewXP = ((nStartLevel * (nStartLevel-1)) / 2 * 1000)+1;
int nPCXP = GetXP(oPC);
SetXP(oPC, nNewXP);
}

Of course, in conversation, oPC will be GetPCSpeaker().

oMe and oMod will be redundant.

1 Like

so far i have the level scripts down;

if level 16 or above;

int StartingConditional()
{

// Restrict based on the player's class
int iPassed = 0;
if(GetHitDice(GetPCSpeaker()) >= 16)
    iPassed = 1;
if(iPassed == 0)
    return FALSE;

return TRUE;

}

and for the one if you are less than level 16, it sets XP to 120 000;

void main()
{
effect eVFX;

// Get the PC who is in this conversation.
object oPC = GetPCSpeaker();

// Apply a visual effect.
eVFX = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oPC);

{
object oCreature = GetPCSpeaker();
int nXP = GetXP(oCreature);
if (nXP < 120000)
{
SetXP(oCreature, 120000);
}
}
}

but now, the gold one is kind of throwing me for a loop, although i think i want to change it up now, so during conversation i need two scripts;

a) if pc has 25000 gold or more, nothing happens
b) if pc has less than 25000 set gold to 25000

and the reason why i need this in 2 scripts is because if the pc has more than 25k the merchane acknowledges and continues on with the conversation, and if the pc has less than 25k, the merchane will top it off to 25k

Should this only happen when talking to the merchant for the first time, or should it happen every time?

If the former, the routine way of handling this is to set a flag (e.g. “intro”) on the merchant after the initial conversation. The dialogue will then have at least two opening merchannt lines, firstly for the case where “intro” is not set, the other unconditional.

Notice that you don’t need two scripts - if the first condition is met, the second line isn’t spoken.

Much the same applies to the gold check.

The function is GetGold() - otherwise the logic is similar to your HD case.

P.S. that can be written more simply:

int StartingConditional()
{
```
// Restrict based on the player's class
return (GetHitDice(GetPCSpeaker()) >= 16);
```
}

though if you’re using Lilac Soul you may be more comfortable with the long-winded version.

its only going to happen with the mercane once, the reason why i need to checks is because there will be two different responses the merchane says depending on how much good you have for example;

response a) if player has more than 25k;

ah i see you have more than enough gold already, so i do not need to provide you with more…

response b) if player has under 25k;

ah, i see your gold is a bit low, here, let me help bring you up to speed ( gives enough gold to set gold to 25000 )

thats how i did it with the levels, and i will no doubt need to do it that way with the gold as well, and i thought about writing it out the same way as i did with the levels, but i dont know what to replace what with where, i dont know where to use the < / > i dont know what “gold” word to use ect…

okay after some more detective/ lucky guess work i finally got the results i was looking for the script to check if the pc has x amount of gold in conversation is;

int StartingConditional()
{

{
// Get the PC who is in this conversation.
object oPC = GetPCSpeaker();

// If the PC has at least 25000 gold.
if ( GetGold(oPC) >= 25000 )
{
}

}
return TRUE;
}

and then if the player has less than 25k in conversation the npc will set it to 25k;

void main()
{
object oPC = GetPCSpeaker();

// Make sure it only happens on the first entry of the player
// * Note: If the module resets (multiplayer), they'll yet
//    again get a minimum of 500 gold because
//    SetLocalInt isn't persistent over resets.
if (GetLocalInt(oPC, "gold_reset")) return;

// Set so they can't get the gold again. This won't be persistent
// over module resets.
SetLocalInt(oPC, "gold_reset", TRUE);

// How much gold does the PC already have?
int nGold=GetGold(oPC);

//Too much, too little, or just enough?
if ( GetGold(oPC) >= 25000 )
{
    //Too much!
    // * See the TakeGoldFromCreature() comments to see why
    //    it requires AssignCommand().
    AssignCommand(oPC, TakeGoldFromCreature(nGold-25000, oPC, TRUE));
}
else if ( GetGold(oPC) <= 25000 )
{
    //Too little!
    GiveGoldToCreature(oPC, 25000-nGold);
}

}