//////////////////////////////////////////////////////////////////////////////// // bard_perform - Perform a song // By Deva Bryson Winblood. 03/19/2005 //////////////////////////////////////////////////////////////////////////////// #include "prc_class_const" void fnBardDelay() { // PURPOSE: reset for responsiveness to bards in future DeleteLocalInt(OBJECT_SELF,"bPaidBard"); } // fnBardDelay() void fnAwardXP(int nAmount) { // PURPOSE: To award XP and make sure if leader is lair they are awarded their take object oMe=OBJECT_SELF; object oMod=GetModule(); string sID=GetLocalString(oMe,"sTeamID"); object oLeader=GetLocalObject(oMe,"oTeamLead"+sID); float fMult; int nAward; object oStart=GetWaypointByTag(sID+"_START"); GiveXPToCreature(oMe,nAmount); if (oLeader!=OBJECT_INVALID&&oLeader!=oMe) { // not leader if (GetArea(oLeader)==GetArea(oStart)) { // leader is in lair fMult=GetLocalFloat(oMod,"fXPMultiplier"); fMult=fMult/100; fMult=IntToFloat(nAmount)*fMult; nAward=FloatToInt(fMult); SendMessageToPC(oLeader,"You were awarded "+IntToString(nAward)+" experience for a song performed by '"+GetName(oMe)+"'."); GiveXPToCreature(oLeader,nAward); } // leader is in lair } // not leader } // fnAwardXP() int fnIsValid(object oNPC) { // PURPOSE: Not enemy and a member of a faction that will play object oMerchant=GetObjectByTag("MERCHANT_FACTION"); object oCommoner=GetObjectByTag("COMMONER_FACTION"); object oCrime=GetObjectByTag("CRIMEGUILD_FACTION"); object oMage=GetObjectByTag("MAGEGUILD_FACTION"); object oCity=GetObjectByTag("CITYGUARD_FACTION"); int bGoodFaction=FALSE; if (GetIsEnemy(oNPC)) return FALSE; if (IsInConversation(oNPC)) return FALSE; if (GetIsInCombat(oNPC)) return FALSE; if (GetFactionEqual(oNPC,oMerchant)) bGoodFaction=TRUE; else if (GetFactionEqual(oNPC,oCommoner)) bGoodFaction=TRUE; else if (GetFactionEqual(oNPC,oCrime)) bGoodFaction=TRUE; else if (GetFactionEqual(oNPC,oMage)) bGoodFaction=TRUE; else if (GetFactionEqual(oNPC,oCity)) bGoodFaction=TRUE; if (!bGoodFaction) return FALSE; return TRUE; } // fnIsValid() void fnFailure(int nFail) { // PURPOSE: hangle failure object oMe=OBJECT_SELF; int nN=1; object oNPC; oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC); while(oNPC!=OBJECT_INVALID&&GetDistanceBetween(oNPC,oMe)<20.0) { // Check all NPCs in range if (fnIsValid(oNPC)) { // fail SetLocalInt(oNPC,"bPaidBard",TRUE); AssignCommand(oNPC,DelayCommand(HoursToSeconds(1),fnBardDelay())); AssignCommand(oNPC,ClearAllActions()); if (nFail>-5) AssignCommand(oNPC,PlayVoiceChat(VOICE_CHAT_LAUGH)); else { AssignCommand(oNPC,PlayVoiceChat(VOICE_CHAT_CUSS)); } AssignCommand(oNPC,ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT,1.0,3.0)); } // fail nN++; oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC); } // Check all NPCs in range } // fnFailure() void fnSuccess(int nGoldDie,int nXP) { // PURPOSE: Look for people to award gold object oMe=OBJECT_SELF; int nN=1; object oNPC; int nRoll; int bXPOkay=FALSE; oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC); while(oNPC!=OBJECT_INVALID&&GetDistanceBetween(oNPC,oMe)<20.0) { // check NPCs within 20 meters if (fnIsValid(oNPC)) { // not enemy if (GetLocalInt(oNPC,"bPaidBard")!=TRUE) { // safe to pay nRoll=Random(nGoldDie)+1; AssignCommand(oNPC,ClearAllActions()); AssignCommand(oNPC,PlayVoiceChat(VOICE_CHAT_CHEER)); AssignCommand(oNPC,ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1,1.0,3.0)); GiveGoldToCreature(oMe,nRoll); bXPOkay=TRUE; } // safe to pay SetLocalInt(oNPC,"bPaidBard",TRUE); AssignCommand(oNPC,DelayCommand(HoursToSeconds(1),fnBardDelay())); } // not enemy nN++; oNPC=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oMe,nN,CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_NOT_PC); } // check NPCs within 20 meters if (bXPOkay) fnAwardXP(nXP); else { SendMessageToPC(oMe,"No one was paying attention. 0 Experience!"); } } // fnSuccess() void fnCompleteSong(location lLoc,int nSong) { // PURPOSE: See if stayed close enough object oMe=OBJECT_SELF; int nLevel = GetLevelByClass(CLASS_TYPE_BARD, oMe) + GetLevelByClass(CLASS_TYPE_HARPER, oMe) + GetLevelByClass(CLASS_TYPE_DIRGESINGER, oMe) + GetLevelByClass(CLASS_TYPE_DRAGONSONG_LYRIST, oMe) + GetLevelByClass(CLASS_TYPE_FOCHLUCAN_LYRIST, oMe) + GetLevelByClass(CLASS_TYPE_SUBLIME_CHORD, oMe) + GetLevelByClass(CLASS_TYPE_VIRTUOSO, oMe); float fD=GetDistanceBetweenLocations(GetLocation(oMe),lLoc); int nDC; int nRoll; int nGoldDie; int nXP; //int nLevel=GetLevelByClass(CLASS_TYPE_BARD); if (fD>4.9) { // you moved too much SendMessageToPC(oMe,"You moved too much while singing and lost the attention of the patrons."); } // you moved too much else { // you stayed where you are if (nSong==1) { nXP=100; nDC=14; nGoldDie=1; } else if (nSong==2) { nXP=200; nDC=20; nGoldDie=2; } else if (nSong==3) { nXP=500; nDC=25; nGoldDie=4; } else if (nSong==4) { nXP=1000; nDC=30; nGoldDie=8; } else if (nSong==5) { nXP=150; nDC=16; nGoldDie=1; } else if (nSong==6) { nXP=300; nDC=22; nGoldDie=2; } else if (nSong==7) { nXP=700; nDC=27; nGoldDie=6; } else if (nSong==8) { nXP=1200; nDC=32; nGoldDie=10; } nRoll=d20(); SendMessageToPC(oMe,"Song DC="+IntToString(nDC)+" You rolled "+IntToString(nRoll)); nRoll=nRoll+GetSkillRank(SKILL_PERFORM); SendMessageToPC(oMe," + Perform Skill = "+IntToString(nRoll)); nRoll=nRoll-nDC; if (nRoll>-1) { // success fnSuccess(nGoldDie,nXP/nLevel); } // success else { // failure fnFailure(nRoll); } // failure } // you stayed where you are } // fnCompleteSong() void fnSimpleSong(location lLoc) { // PURPOSE: Perform a simple song object oMe=OBJECT_SELF; ClearAllActions(); PlayVoiceChat(VOICE_CHAT_CHEER); ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1,1.0,3.0); ActionSpeakString("Come and grab a beer"); ActionWait(2.5); ActionSpeakString("Come hear me cheer"); ActionWait(2.5); ActionSpeakString("While I drink beer"); ActionWait(2.5); ActionSpeakString("Come and grab a kiss"); ActionWait(2.5); ActionSpeakString("As your man doth hiss"); ActionWait(2.5); ActionSpeakString("When I steal his miss"); ActionWait(2.5); ActionSpeakString("Come and grab a beer"); ActionWait(2.5); ActionSpeakString("Come hear me cheer"); ActionWait(2.0); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,1)); } // fnSimpleSong() void fnMediumSong(location lLoc) { // PURPOSE: Perform a medium song object oMe=OBJECT_SELF; string sGender="ladies"; if (GetGender(oMe)==GENDER_FEMALE) sGender="men"; ClearAllActions(); PlayVoiceChat(VOICE_CHAT_CHEER); ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1,1.0,3.0); ActionSpeakString("All "+sGender+" heed my call"); ActionWait(2.5); ActionSpeakString("To my voice thou must listen"); ActionWait(2.5); ActionSpeakString("I will have thee in thrall"); ActionWait(2.5); ActionSpeakString("See how my lips glisten"); ActionWait(2.5); ActionSpeakString("I beckon thee with my voice"); ActionWait(2.5); ActionSpeakString("Thou hast no will of thine own"); ActionWait(2.5); ActionSpeakString("I have made thine choice"); ActionWait(2.5); ActionSpeakString("Listen to my vocal soul tone"); ActionWait(2.5); ActionSpeakString("Thou art mine to sing to"); ActionWait(2.5); ActionSpeakString("And I am who thou wouldst like to cling to"); ActionWait(2.5); ActionSpeakString("Now and forever."); ActionWait(2.0); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,2)); } // fnMediumSong() void fnDo(location lLoc,int nNum) { ActionDoCommand(fnCompleteSong(lLoc,nNum)); } // fnDo() void fnDifficultSong(location lLoc) { // PURPOSE: Sing a difficult song object oMe=OBJECT_SELF; object oMod=GetModule(); object oOb; string sUND; string sDWF; string sUNC; string sSPID; oOb=GetLocalObject(oMod,"oTeamLeadUND"); sUND=GetName(oOb); if (GetStringLength(sUND)<3) sUND="Undead One"; oOb=GetLocalObject(oMod,"oTeamLeadDWF"); sDWF=GetName(oOb); if (GetStringLength(sDWF)<3) sDWF="Noble One"; oOb=GetLocalObject(oMod,"oTeamLeadUNC"); sUNC=GetName(oOb); if (GetStringLength(sUNC)<3) sUNC="Unclean One"; oOb=GetLocalObject(oMod,"oTeamLeadSPID"); sSPID=GetName(oOb); if (GetStringLength(sSPID)<3) sSPID="Verminous One"; ClearAllActions(); PlayVoiceChat(VOICE_CHAT_CHEER); ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1,1.0,3.0); ActionSpeakString("Hearken and listen to a tale of yor"); ActionWait(3.0); ActionSpeakString("Of a time long lost and gods forgotten"); ActionWait(3.0); ActionSpeakString("The time of the mad gods ruled the world"); ActionWait(3.0); ActionSpeakString("Then was the time that those of madness wanted to rule."); ActionWait(3.0); ActionSpeakString("The one known as "+sUND+" sought to cover the world in darkness."); ActionWait(4.0); ActionSpeakString("While "+sDWF+" tried to stop that and push it back with law as their might."); ActionWait(4.0); ActionSpeakString("The mad one known as "+sUNC+" did trick the noble ones and cause more death."); ActionWait(4.0); ActionSpeakString("And the one hidden in the darkness known as "+sSPID+" tricked them all."); ActionWait(4.0); DelayCommand(4.0,ActionSpeakString("This is not where the tale ends.")); DelayCommand(4.1,ActionWait(3.0)); DelayCommand(7.0,ActionSpeakString("For the elder gods awakened to fight.")); DelayCommand(7.1,ActionWait(3.0)); DelayCommand(10.0,ActionSpeakString("Aisada with her light smote the mad ones.")); DelayCommand(10.1,ActionWait(3.0)); DelayCommand(13.0,ActionSpeakString("Umnuikal struck at them within their own darkness.")); DelayCommand(13.1,ActionWait(3.0)); DelayCommand(15.0,ActionSpeakString("Even so, they could not defeat the mad ones.")); DelayCommand(15.1,ActionWait(3.0)); DelayCommand(18.0,ActionSpeakString("And the land did suffer from their attempt.")); DelayCommand(18.1,ActionWait(3.0)); DelayCommand(21.0,ActionSpeakString("Til they found a way.")); DelayCommand(21.1,ActionWait(3.0)); DelayCommand(24.0,ActionSpeakString("To strip the mad powers all away.")); DelayCommand(24.1,ActionWait(3.0)); DelayCommand(27.0,ActionSpeakString("And banish the mad ones far away.")); DelayCommand(27.1,ActionWait(3.0)); DelayCommand(30.0,ActionSpeakString("To where they watch in hunger still today.")); DelayCommand(30.1,ActionWait(4.0)); DelayCommand(34.0,ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0)); DelayCommand(34.1,fnDo(lLoc,3)); } // fnDifficultSong() void fnVDifficultSong(location lLoc) { // PURPOSE: Sing a very difficult song object oMe=OBJECT_SELF; ClearAllActions(); PlayVoiceChat(VOICE_CHAT_CHEER); ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1,1.0,3.0); ActionSpeakString("Andibble did glibbly gloat"); ActionWait(2.0); ActionSpeakString("The tibble's langly limplesnitch"); ActionWait(2.5); ActionSpeakString("As sure you knew the cloat"); ActionWait(2.0); ActionSpeakString("Tis noddle that twas the tister"); ActionWait(2.5); ActionSpeakString("Besotten with Abblie's sister"); ActionWait(2.0); ActionSpeakString("Rangledon and down the tomny spake"); ActionWait(2.5); ActionSpeakString("Lass surely you'll habash this rake"); ActionWait(2.0); ActionSpeakString("Nor tis Mor tis death has a kiss"); ActionWait(2.0); ActionSpeakString("Ganglebon and Pandlpon the metal and the miss"); ActionWait(2.5); ActionSpeakString("Nor more Than sore the gloat was glib!"); ActionWait(3.0); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,4)); } // fnVDifficultSong() void fnPlaySimpleSong(location lLoc) { object oMe=OBJECT_SELF; object oArea=GetArea(oMe); int bIsDay=GetIsDay(); int nOriginal; int nSong=23; float fWait=30.0; if (bIsDay) { // daytime nOriginal=MusicBackgroundGetDayTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeDay(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeDay(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,5)); } // daytime else { // nighttime nOriginal=MusicBackgroundGetNightTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeNight(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeNight(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,5)); } // nighttime } // fnPlaySimpleSong() void fnPlayMediumSong(location lLoc) { object oMe=OBJECT_SELF; object oArea=GetArea(oMe); int bIsDay=GetIsDay(); int nOriginal; int nSong=22; float fWait=30.0; if (bIsDay) { // daytime nOriginal=MusicBackgroundGetDayTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeDay(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeDay(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,6)); } // daytime else { // nighttime nOriginal=MusicBackgroundGetNightTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeNight(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeNight(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,6)); } // nighttime } // fnPlayMediumSong() void fnPlayDifficultSong(location lLoc) { object oMe=OBJECT_SELF; object oArea=GetArea(oMe); int bIsDay=GetIsDay(); int nOriginal; int nSong=24; float fWait=30.0; if (bIsDay) { // daytime nOriginal=MusicBackgroundGetDayTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeDay(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeDay(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,7)); } // daytime else { // nighttime nOriginal=MusicBackgroundGetNightTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeNight(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeNight(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,7)); } // nighttime } // fnPlayDifficultSong() void fnPlayVDifficultSong(location lLoc) { object oMe=OBJECT_SELF; object oArea=GetArea(oMe); int bIsDay=GetIsDay(); int nOriginal; int nSong=20; float fWait=30.0; if (bIsDay) { // daytime nOriginal=MusicBackgroundGetDayTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeDay(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeDay(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,8)); } // daytime else { // nighttime nOriginal=MusicBackgroundGetNightTrack(oArea); MusicBackgroundStop(oArea); MusicBackgroundChangeNight(oArea,nSong); MusicBackgroundPlay(oArea); ActionWait(fWait); ActionDoCommand(MusicBackgroundStop(oArea)); ActionDoCommand(MusicBackgroundChangeNight(oArea,nOriginal)); ActionDoCommand(MusicBackgroundPlay(oArea)); ActionPlayAnimation(ANIMATION_FIREFORGET_BOW,1.0,3.0); ActionDoCommand(fnCompleteSong(lLoc,8)); } // nighttime } // fnPlayVDifficultSong() //////////////////////////////////////////////////////////////////////////////// void main() { object oMe=OBJECT_SELF; int nSong=GetLocalInt(oMe,"nParm"); location lLoc=GetLocation(oMe); object oInstrument; int bHasInstrument=FALSE; if (nSong==1) AssignCommand(oMe,fnSimpleSong(lLoc)); else if (nSong==2) AssignCommand(oMe,fnMediumSong(lLoc)); else if (nSong==3) AssignCommand(oMe,fnDifficultSong(lLoc)); else if (nSong==4) AssignCommand(oMe,fnVDifficultSong(lLoc)); else if (nSong>4) { // must have an instrument oInstrument=GetItemPossessedBy(oMe,"Lute"); if (oInstrument==OBJECT_INVALID) oInstrument=GetItemPossessedBy(oMe,"Harp"); if (oInstrument==OBJECT_INVALID) oInstrument=GetItemPossessedBy(oMe,"PanFlute"); if (oInstrument==OBJECT_INVALID) oInstrument=GetItemPossessedBy(oMe,"rts_it_mag9"); if (oInstrument!=OBJECT_INVALID) bHasInstrument=TRUE; if(bHasInstrument) { // perform okay if (nSong==5) AssignCommand(oMe,fnPlaySimpleSong(lLoc)); else if (nSong==6) AssignCommand(oMe,fnPlayMediumSong(lLoc)); else if (nSong==7) AssignCommand(oMe,fnPlayDifficultSong(lLoc)); else if (nSong==8) AssignCommand(oMe,fnPlayVDifficultSong(lLoc)); } // perform okay else { // must have an instrument SendMessageToPC(oMe,"You must have an additional instrument to perform that song!"); } // must have an instrument } // must have an instrument } ////////////////////////////////////////////////////////////////////////////////