Writing Custom XP Rewards

For toolset tutorials as well as question and answers.
Locked
Zelknolf
Chosen of Forumamus, God of Forums
Posts: 6139
Joined: Tue Jul 05, 2005 7:04 pm

Writing Custom XP Rewards

Post by Zelknolf »

So, I know we have some folk who are good enough at scripting where they've been writing their own custom stuff-- let me start by saying that's fabulous. I'm not posting to scold anyone; there are just some common pitfalls I want to let everyone know about.


So, if you're going to be writing your own scripts that reward XP, there are a few functions in acr_xp_i that should be all that you need:

Code: Select all

//! Award XP to oPC for completing a static quest of some sort.
void ACR_AwardStaticQuestXP(object oPC, string sPlotID, int nQuestXP);

//! Awards XP to the party which oPCParty is a member of, for killing oKill.
void ACR_AwardCombatXP(object oPCParty, object oKill);

//! Awards XP to a PC for overcoming a specific challenge which could have
//! lethal consequences.
void ACR_AwardLethalChallengeXP(object oPC, float fCR);

//! Awards XP to a PC for overcoming a specific challenge.
void ACR_AwardNonlethalChallengeXP(object oPC, float fCR);
The comment lines should cover most of what they do, but one that's enticingly hanging out in the open is this fellow:

Code: Select all

//! Gives nXpAmount to oCreature.
//! This function, and none other, must be used whenever XP is directly given to
//! a PC. Any other function may not work reliably, if at all.
//! NOTE: LOGGING WILL NEED TO BE HANDLED BY THE CALLING APPLICATION
void ACR_GiveXPToPC(object oPC, int nXpAmount);
So, firstly, the original author's line wherein caps lock is cruise control for cool covers why this one is dangerous. Particulrly-advanced coders, with familiarity with our database and such, shouldn't be afraid to use this, but should approach knowing that they'll be responsible for their own logs, and that Hialmar might make them upgrade the parser to provide results to less-technically-inclined people who may need to review them in the course of their work (knowing how to write SQL queries is not prerequisite for the PA position or for any PA staff positions, and we're in very big trouble as a community if it ever becomes one)

So, running down the others-- first example, we've reached a point in a conversation where we're providing a simple quest reward; we're not tracking this in a journal-- we didn't update any "quest states". This guy just has a standing thing in his conversation, like a gang rivalry-- the Jets will pay if you rough up any of the Sharks. They might even sing you a song:

Code: Select all

void main()
{
    ACR_AwardStaticQuestXP(GetPCSpeaker(), 
        "BeatUpTheJets", 
        20);
}
Second example-- you've killed something that tried to kill you back. The ACR will be trying to catch all of these itself, and any creature killed by conventional combat should be so handled-- but if you have any special unique circumstances wherein a creature is being killed as part of a legitimate challenge, but the instrument of death wasn't in the core mechanics (systems that manage sea combat would be the standard example of this) you'd probably be looking at...

Code: Select all

void KillCreatureWithOddTool(object oKiller, object oKilled)
{
    if(!GetIsPC(oKilled)) // let's make sure no one exploits this for CvC, hmm?
    {
        ACR_AwardCombatXP(oKiller, oKilled);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oKilled);
    }
}
Third and fourth examples would be used in similar fashion-- and would be catch-alls for things that give XP but don't fit into any other possible category in the ACR. They award XP as if you killed a creature of fCR, with the difference being in how they're logged (lethal challenge or nonlethal challenge)-- so this can be used for things that highbies shouldn't get much reward for: that DC 20 trap is hair raising for a level 1, but a level 15? Deserves 1 xp, if any.

Code: Select all

void main()
{
    ACR_AwardLethalChallengeXP(GetLastUsedBy(), 2.0f);
}
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: Writing Custom XP Rewards

Post by Teric neDhalir »

:idea:
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Re: Writing Custom XP Rewards

Post by Teric neDhalir »

I knew there was a reason I used the wrong function;

http://www.alandfaraway.org/node/829
Zelknolf
Chosen of Forumamus, God of Forums
Posts: 6139
Joined: Tue Jul 05, 2005 7:04 pm

Re: Writing Custom XP Rewards

Post by Zelknolf »

Old page is old. Good find, though.

It now contains the contents of the first post in this thread, save for the introductory paragraph.
Locked