149 lines
5.3 KiB
Plaintext
149 lines
5.3 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// OnEnter Swimming Trigger
|
|
// By Deva Bryson Winblood 02/07/2004
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
string fnParse(string sIn,string sDelim=".")
|
|
{ // Parse string using delimiter
|
|
string sRet="";
|
|
string sWork=sIn;
|
|
while(GetStringLeft(sWork,1)!=sDelim&&GetStringLength(sWork)>0)
|
|
{ // build return string
|
|
sRet=sRet+GetStringLeft(sWork,1);
|
|
sWork=GetStringRight(sWork,GetStringLength(sWork)-1);
|
|
} // build return string
|
|
return sRet;
|
|
} // fnParse()
|
|
|
|
string fnRemoveParsed(string sIn, string sRemove, string sDelim=".")
|
|
{ // remove parsed portion of string and return the remaining
|
|
string sRet="";
|
|
if (GetStringLength(sIn)>=GetStringLength(sRemove))
|
|
{ // strip it
|
|
sRet=GetStringRight(sIn,GetStringLength(sIn)-GetStringLength(sRemove));
|
|
if (GetStringLeft(sRet,1)==sDelim)
|
|
sRet=GetStringRight(sRet,GetStringLength(sRet)-1);
|
|
} // strip it
|
|
return sRet;
|
|
} // fnRemoveParsed()
|
|
|
|
int fnSwimModifier(object oPC)
|
|
{ // return the bonus or modifiers for swimming for this PC
|
|
int nRet=GetAbilityModifier(ABILITY_STRENGTH,oPC);
|
|
int nL=1;
|
|
int nClass;
|
|
object oOb;
|
|
while(nL<4)
|
|
{ // check for class bonus
|
|
nClass=GetClassByPosition(nL,oPC);
|
|
nL++;
|
|
if (nClass==CLASS_TYPE_BARBARIAN||nClass==CLASS_TYPE_BARD||nClass==CLASS_TYPE_DRUID) nRet=nRet+2;
|
|
else if (nClass==CLASS_TYPE_FIGHTER||nClass==CLASS_TYPE_MONK||nClass==CLASS_TYPE_RANGER) nRet=nRet+2;
|
|
else if (nClass==CLASS_TYPE_ROGUE) nRet=nRet+2;
|
|
} // check for class bonus
|
|
nL=GetWeight(oPC);
|
|
oOb=GetItemPossessedBy(oPC,"SWIMHELP");
|
|
if (oOb!=OBJECT_INVALID){ // swimming helper item
|
|
nRet=nRet+10;
|
|
nL=nL-GetWeight(oOb); // don't count weight of swim helping item
|
|
} // swimming helper item
|
|
nL=nL/50;
|
|
if (nL<1) nL=0;
|
|
nRet=nRet-nL;
|
|
if(GetLocalInt(oPC,"nWaterWalk")==TRUE) nRet=nRet+25;
|
|
if(GetLocalInt(oPC,"nWaterBreathing")==TRUE) nRet=nRet+35;
|
|
if(GetLocalInt(oPC,"bWaterBreathing")==TRUE) nRet=nRet+100;
|
|
if(GetLocalInt(oPC,"nIsVampire")) nRet=nRet+100;
|
|
if(GetLocalInt(oPC,"bIsLich")) nRet=nRet+100;
|
|
return nRet;
|
|
} // fnSwimModifier()
|
|
|
|
//////////////////////////////////////////////////////////////// MAIN //////////
|
|
void main()
|
|
{
|
|
object oPC=GetClickingObject();
|
|
object oWP=GetNearestObjectByTag("SWIM_DETAILS",oPC,1);
|
|
int nNumDest;
|
|
string sName=GetName(oWP);
|
|
string sParsed;
|
|
int nC;
|
|
string sDesc;
|
|
string sDestWP;
|
|
int nTravelDC;
|
|
int nRecoverDC;
|
|
string sSubP;
|
|
string sFailScript;
|
|
object oDest;
|
|
sParsed=fnParse(sName);
|
|
sName=fnRemoveParsed(sName,sParsed);
|
|
nNumDest=StringToInt(sParsed);
|
|
if (nNumDest>0)
|
|
{ // defined okay
|
|
if (GetLocalInt(oWP,"nParsed")!=TRUE)
|
|
{ // need to parse it
|
|
SetLocalInt(oWP,"nParsed",TRUE); // only parse each trigger once
|
|
SetLocalInt(oWP,"nNumDest",nNumDest);
|
|
nC=0;
|
|
while(nC<nNumDest)
|
|
{ // parse waypoint
|
|
nC++;
|
|
sParsed=fnParse(sName);
|
|
sName=fnRemoveParsed(sName,sParsed);
|
|
sSubP=fnParse(sParsed,"/");
|
|
sParsed=fnRemoveParsed(sParsed,sSubP,"/");
|
|
sDesc=sSubP; // description
|
|
sSubP=fnParse(sParsed,"/");
|
|
sParsed=fnRemoveParsed(sParsed,sSubP,"/");
|
|
sDestWP=sSubP; // Destination waypoint tag
|
|
sSubP=fnParse(sParsed,"/");
|
|
sParsed=fnRemoveParsed(sParsed,sSubP,"/");
|
|
nTravelDC=StringToInt(sSubP);
|
|
sSubP=fnParse(sParsed,"/");
|
|
sParsed=fnRemoveParsed(sParsed,sSubP,"/");
|
|
nRecoverDC=StringToInt(sSubP);
|
|
sFailScript=sParsed;
|
|
SetLocalString(oWP,"sDesc"+IntToString(nC),sDesc);
|
|
SetLocalInt(oWP,"nTravelDC"+IntToString(nC),nTravelDC);
|
|
SetLocalInt(oWP,"nRecoverDC"+IntToString(nC),nRecoverDC);
|
|
SetLocalString(oWP,"sFailScript"+IntToString(nC),sFailScript);
|
|
oDest=GetWaypointByTag(sDestWP);
|
|
SetLocalObject(oWP,"oDest"+IntToString(nC),oDest);
|
|
} // parse waypoint
|
|
} // need to parse it
|
|
// setup custom tokens
|
|
nC=0;
|
|
nNumDest=GetLocalInt(oWP,"nNumDest");
|
|
while(nC<nNumDest)
|
|
{ // setup tokens
|
|
nC++;
|
|
sDesc=GetLocalString(oWP,"sDesc"+IntToString(nC));
|
|
nTravelDC=GetLocalInt(oWP,"nTravelDC"+IntToString(nC));
|
|
sDestWP=sDesc+" [Base Difficulty Check:"+IntToString(nTravelDC)+" not counting armor and other factors].";
|
|
SetCustomToken(9301970+nC,sDestWP);
|
|
SetLocalObject(oPC,"oSwimWP",oWP);
|
|
} // setup tokens
|
|
nC=fnSwimModifier(oPC);
|
|
sDestWP=GetName(OBJECT_SELF);
|
|
if (sDestWP!="SwimmingTrigger")
|
|
{ // underwater destination exists
|
|
sDestWP="DST_"+sDestWP;
|
|
oWP=GetWaypointByTag(sDestWP);
|
|
if (oWP!=OBJECT_INVALID)
|
|
{ // dest exists
|
|
SetLocalObject(oPC,"oDest",oWP);
|
|
} // dest exists
|
|
else
|
|
{ // no dest
|
|
DeleteLocalObject(oPC,"oDest");
|
|
} // no dest
|
|
} // underwater destination exists
|
|
else
|
|
{ // no underwater
|
|
DeleteLocalObject(oPC,"oDest");
|
|
} // no underwater
|
|
SetCustomToken(9301970,IntToString(nC));
|
|
AssignCommand(oPC,ClearAllActions(TRUE));
|
|
AssignCommand(oPC,ActionStartConversation(oPC,"swimming",TRUE,FALSE));
|
|
} // defined okay
|
|
}
|
|
//////////////////////////////////////////////////////////////// MAIN //////////
|