//////////////////////////////////////////////////////////////////////////////// // Swim to the location selected // By Deva Bryson Winblood. 02/07/2004 //////////////////////////////////////////////////////////////////////////////// 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=GetPCSpeaker(); object oWP=GetLocalObject(oPC,"oSwimWP"); int nDestNum=GetLocalInt(oPC,"nSwimNum"); int nDCBonus=fnSwimModifier(oPC); int nTDC=GetLocalInt(oWP,"nTravelDC"+IntToString(nDestNum)); int nRDC=GetLocalInt(oWP,"nRecoverDC"+IntToString(nDestNum)); object oDest=GetLocalObject(oWP,"oDest"+IntToString(nDestNum)); string sFail=GetLocalString(oWP,"sFailScript"+IntToString(nDestNum)); int nDCRoll=d20(); int nDCCheck=nDCRoll+nDCBonus; effect eDie=EffectDeath(); SendMessageToPC(oPC,"Swim DC Check (DC:"+IntToString(nTDC)+") you rolled a "+IntToString(nDCRoll)+"+"+IntToString(nDCBonus)+"="+IntToString(nDCCheck)+"."); if (nDCCheck>=nTDC) { // success AssignCommand(oPC,ClearAllActions(TRUE)); AssignCommand(oPC,JumpToObject(oDest)); } // success else { // failure SendMessageToPC(oPC,"You failed to swim the distance."); nDCRoll=d20(); nDCCheck=nDCRoll+nDCBonus; SendMessageToPC(oPC,"Swim recovery DC Check (DC:"+IntToString(nRDC)+") you rolled a "+IntToString(nDCRoll)+"+"+IntToString(nDCBonus)+"="+IntToString(nDCCheck)+"."); if (nDCCheck>=nRDC) { // recover successful SendMessageToPC(oPC,"You manage to make it back to the location you tried to swim from."); } // recover successful else { // drown or failure script if (sFail!="NA") { // run fail script ExecuteScript(sFail,oPC); } // run fail script else { // drown SendMessageToPC(oPC,"You have drowned."); ApplyEffectToObject(DURATION_TYPE_INSTANT,eDie,oPC,1.0); } // drown } // drown or failure script } // failure } ///////////////////////////////////////////////////////////////////// MAIN /////