Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //listener onDialogue
- #include "bg_spell_teleport_inc"
- void StopSending(object oPC, object oListener)
- {
- if(GetIsObjectValid(oListener) == TRUE)
- {
- DeleteLocalInt(oPC, "Can_Send_Magical_Sending");
- DestroyObject(oListener, 0.0f, TRUE);
- }
- }
- void main()
- {
- int nMatch = GetListenPatternNumber();
- if(nMatch != 100) {return;}
- string sSaid = GetMatchedSubstring(0);
- object oSpeaker = GetLastSpeaker();
- object oSendor = GetLocalObject(OBJECT_SELF, "Sendor");
- if(oSpeaker != oSendor) {return;}
- //check message parts
- int nFirst = FindSubString(sSaid, " Message:", 0);
- if(nFirst == -1) {nFirst = FindSubString(sSaid, " message:", 0);}
- if(nFirst == -1) {FloatingTextStringOnCreature("Your attempt at imbueing a message fails, you used an improper formula", oSendor, FALSE, 5.0); return;}
- else
- {
- int iAnonymous = GetLocalInt(OBJECT_SELF, "anonymous");
- string sNamePart = GetSubString(sSaid, 0, nFirst - 0);
- string sMessagePart = GetSubString(sSaid, nFirst + 8, GetStringLength(sSaid) - (nFirst + 8));
- string sName = GetName(oSendor);
- //25 words or less after "Message:"?
- //Detect spaces..
- string sSpaces = " ";
- int nIndex = FindSubString(sMessagePart, sSpaces, 0);
- int nSpaces;
- int nIndex2;
- while(nIndex != -1 && nSpaces < 27)
- {
- //count spaces
- if(nIndex != -1 && nIndex != nIndex2)
- {nSpaces = nSpaces + 1; nIndex2 = nIndex + 1;}
- else
- {break;}
- nIndex = FindSubString(sMessagePart, sSpaces, nIndex2);
- }
- //AssignCommand(OBJECT_SELF, SpeakString("Spaces = "+IntToString(nSpaces), TALKVOLUME_TALK));
- if(nSpaces > 26) {FloatingTextStringOnCreature("The sending failed, the message was too long", oSendor, FALSE, 5.0); return;}
- //alternative - use amount of characters
- //if(GetStringLength(sMessagePart) > 175) {FloatingTextStringOnCreature("The sending failed, the message was too long", oSendor, FALSE, 5.0); return;}
- //detect the recipient
- int iFound;
- object oReceiver = GetFirstPC(TRUE);
- string sReceiverName;
- while(GetIsObjectValid(oReceiver) == TRUE && iFound == FALSE)
- {
- sReceiverName = GetName(oReceiver);
- if(sReceiverName == sNamePart) {iFound = TRUE; break;}
- oReceiver = GetNextPC(TRUE);
- }
- if(iFound == FALSE) {FloatingTextStringOnCreature("You know no one by that name", oSendor, FALSE, 5.0); return;}
- int iRoll = d20() + GetSkillRank(SKILL_SPELLCRAFT, oReceiver, FALSE);
- //AssignCommand(OBJECT_SELF, SpeakString(sNamePart, TALKVOLUME_TALK));
- //AssignCommand(OBJECT_SELF, SpeakString(sMessagePart, TALKVOLUME_TALK));
- if(iAnonymous == 0)
- {
- //check if valid Target and send message if so
- string sTell = "<color=LightPink><i>A magical sending arrives from "+sName+", you can respond immediately:</i> "+sMessagePart+" (respond by typing /r [message])";
- SendChatMessage(oSendor, oReceiver, CHAT_MODE_TELL, sTell, FALSE);
- /*
- //don't do this in normal sendings - will see it not used
- int iDC1 = 26;
- int iDC2 = 31;
- if(iRoll > iDC1)
- {
- SendMessageToPC(oReceiver, "You discern that the sending spell likely originated from "+GetName(GetArea(OBJECT_SELF)));
- }
- if(iRoll > iDC2)
- {
- if(GetIsLocationValid(GetLocation(oReceiver)) == TRUE)
- {
- SendMessageToPC(oReceiver, "You notice a strand in the weaving of the sending spell that you might be able to trace with a Trace Teleport spell");
- CreateTeleportTrail(GetLocation(oReceiver), GetLocation(OBJECT_SELF), 60.0);
- }
- }
- */
- }
- if(iAnonymous == 1)
- {
- int iCL = GetSkillRank(SKILL_SPELLCRAFT, oSendor, FALSE);//GetLocalInt(OBJECT_SELF, "Casterlevel");
- int iDC1 = iCL + 6;
- int iDC2 = iCL + 11;
- int iDC3 = iCL + 16;
- //check if valid Target and send message if so
- string sTell = "<color=LightPink><i>An anonymous magical sending arrives, you cannot respond to it</i>: "+sMessagePart+" (Sent by "+GetName(oSendor)+", your character doesn't know this unless the spell says so)";
- if(iRoll > iDC1)
- {
- SendMessageToPC(oReceiver, "You discern that the sending spell likely originated from "+GetName(GetArea(OBJECT_SELF)));
- }
- if(iRoll > iDC2)
- {
- if(GetIsLocationValid(GetLocation(oReceiver)) == TRUE)
- {
- SendMessageToPC(oReceiver, "You notice a strand in the weaving of the sending spell that you might be able to trace with a Trace Teleport spell");
- CreateTeleportTrail(GetLocation(oReceiver), GetLocation(OBJECT_SELF), 60.0);
- }
- }
- //author detected
- if(iRoll > iDC3)
- {
- int iRollLore = d20() + GetSkillRank(SKILL_LORE, oReceiver, FALSE);
- if(iRollLore > 15 + 37 - (GetHitDice(oSendor)/ 2))
- {
- SendMessageToPC(oReceiver, "Adept as you are at crafting spells you notice a pattern of luminescent barely visible strands at the heart of the Anonymous Sending spell that appear to coalesce into the sigil of "+GetName(oSendor)+"!");
- }
- else
- {
- SendMessageToPC(oReceiver, "Adept as you are at crafting spells you notice a pattern of luminescent barely visible strands at the heart of the Anonymous Sending spell that appear to coalesce into into a sigil. You don't recognise who it belongs to however.");
- }
- }
- SendChatMessage(OBJECT_SELF, oReceiver, CHAT_MODE_TELL, sTell, FALSE);
- //not needed anymore since author's name is attached to the message with a metagaming warning
- //WriteTimestampedLogEntry("Anonymous Sending --> Sender: "+GetName(oSendor)+" to Recipient:"+GetName(oReceiver)+" - "+sTell);
- }
- DelayCommand(1.0, StopSending(oSendor, OBJECT_SELF));
- }
- }
Add Comment
Please, Sign In to add comment