Shallina wrote...
If it's a first "scripted" project, start by doing it SP with GetFirstPC(). You ll learn to use the event, and you'l be able to do a proper MP one next time. Catching event right is not something "trivial", even if it's the proper way to do it.
The real problem is that if you don't understand the events, your code is not going to work as you intend no matter if you get it to compile or not. This issues are not obvious in initial testing, when you assume there are no companions, summons, or that there is only one summon. But all the players want to be able to add features willy nilly to your SP module. Unlike MP where i control everything and test it all, it's much more crazy, and from what i've seen the SP code out there tends to really need help from skilled scripters just to ensure those players have a good experience.
Really i set up that list of functions to make it easy, so as to help people learn the correct function. I ask what is the event, and reply back with a copy paste from that thread. This is very situational and i would just ask that new scripters who are not sure about how to do things post a question. Generally you will get far more advice on what to look out for, for each event.
What i suggest is looking at what others have done. Usually the top of the script has things like
oPC = OBJECT_SELF;
oPC = GetWhatever();
The thing is this is a death script, the first thing you should do is look at a death script prior to anything else. Not sure where getFirstPC() is even brought up, just open the event on a given creature, and see what script code is currently in use. Generally all the knowledge you need is right there at the top.
GetFirstPC() does have some usage, but so do heartbeats, it is used far far too often in SP coding and it seems that some think a lower standard where things are not working is acceptable.
for companions and such
object oPM = GetFirstFactionMember( oPC, FALSE );
while ( GetIsObjectValid( oPM ) == TRUE )
{
oPM = GetNextFactionMember( oPC, FALSE );
}
and to get them one at a time ( there is a third parameter if there are multiple ones but usually it's restricted to one, you can do a for loop to iterate them all if needed )
// Get all the possible associates of this PC
object oHench = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
object oDomin = GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC);
object oFamil = GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oPC);
object oSummon = GetAssociate(ASSOCIATE_TYPE_SUMMONED, oPC);
object oAnimalComp = GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION, oPC);
example of when you have more than one ( this gets all the total fiends you have summoned. )
int SCGetControlledFiendTotalHD(object oPC = OBJECT_SELF){ int nTotalHD; int i = 1; object oSummonTest = GetAssociate(ASSOCIATE_TYPE_SUMMONED, oPC, i); while(GetIsObjectValid(oSummonTest)) { if( CSLGetIsFiend(oSummonTest) ) { nTotalHD += GetHitDice(oSummonTest); } if(DEBUGGING)FloatingTextStringOnCreature(GetName(oSummonTest)+" is summon number "+IntToString(i), oPC); i++; oSummonTest = GetAssociate(ASSOCIATE_TYPE_SUMMONED, oPC, i); } return nTotalHD;}