I dont remember which class IsNPC is located in, so ill go as derived as
possible.

Your going to want pKiller to be of the class CBaseCombatCharacter, which is
shared between the player and npc classes.

CBaseCombatCharacter *pKiller = dynamic_cast<CBaseCombatCharacter *>(
GetDeathScorer( info.GetAttacker(), info.GetInflictor() ) );

But imo you might just be able to check GetDeathScorer for IsNPC(). Also
make sure you check for validity here, ToHL2MPPlayer will only cast player
classes, and return everything else NULL.

On Fri, Jun 6, 2008 at 8:47 PM, Matthew Dryden <[EMAIL PROTECTED]> wrote:

> Thank you Chris, for the clarification... I haven't had a moment to give
> this a shot, but based on the snippet you gave me, I think this is what
> needs to go in there:
>
> ---------------------- Start Code ----------------------
>
> CHL2MP_Player *pKiller = ToHL2MPPlayer( GetDeathScorer(
> info.GetAttacker(), info.GetInflictor() ) );
> CHL2MP_Player *pVictimPlayer = ToHL2MPPlayer( pVictim );
>
> int pKillerLvl;
> int pVictimLvl = pVictim->GetLevel();
>
>
> if( pKiller->IsNPC() )
> {
>        if( pNPC->LikesMaster() )
>         {
>                CAI_BaseNPC *pNPC = dynamic_cast<CAI_BaseNPC *>(pKiller);
>                CHL2MP_Player *pMaster = NULL;
>
>                 pMaster = pNPC->GetMasterPlayer()
>                pKillerLvl = pMaster->GetLevel();
>
>                pKiller = pMaster;
>        }
> }
> else
> {
>        int pKillerLvl = pKiller->GetLevel();
> }
>
> ... ( Calculating exp, checking if victim is NPC or killer is on spree )
> ...
>
> pKiller->AddExp( calcExp );
>
> ---------------------- End Code ------------------------
>
> The idea is to make the master of the minion get the experience for any
> player or monster that his minion kills. I also need to make sure that
> it's not the minion's level that is being used for the calcualation of
> exp, but rather the master's exp.
>
> The only thing I'm not 100% sure on is the "pKiller = pMaster;" line. But
> if I don't do that, it'll mean I'll have to check to see if the killer is
> a NPC each time I do a calcuation on the experience modifiers (is killer
> on spree, is killer on spree war, check level difference between killer
> and victim).
>
> If I have to use pMaster for a check each time, I'll probably also have to
> move the pMaster out of the if statement and up to the top where the other
> pointers are. This isn't neccessarily a bad thing, I just don't want to
> bugger up the code more than I have too. Thoughts?
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>


-- 
~Ryan
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to