Guest User

Untitled

a guest
Apr 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. //listener onDialogue
  2.  
  3. #include "bg_spell_teleport_inc"
  4.  
  5. void StopSending(object oPC, object oListener)
  6. {
  7. if(GetIsObjectValid(oListener) == TRUE)
  8. {
  9. DeleteLocalInt(oPC, "Can_Send_Magical_Sending");
  10. DestroyObject(oListener, 0.0f, TRUE);
  11. }
  12. }
  13.  
  14. void main()
  15. {
  16. int nMatch = GetListenPatternNumber();
  17. if(nMatch != 100) {return;}
  18.  
  19. string sSaid = GetMatchedSubstring(0);
  20. object oSpeaker = GetLastSpeaker();
  21. object oSendor = GetLocalObject(OBJECT_SELF, "Sendor");
  22.  
  23. if(oSpeaker != oSendor) {return;}
  24.  
  25. //check message parts
  26. int nFirst = FindSubString(sSaid, " Message:", 0);
  27. if(nFirst == -1) {nFirst = FindSubString(sSaid, " message:", 0);}
  28.  
  29. if(nFirst == -1) {FloatingTextStringOnCreature("Your attempt at imbueing a message fails, you used an improper formula", oSendor, FALSE, 5.0); return;}
  30. else
  31. {
  32. int iAnonymous = GetLocalInt(OBJECT_SELF, "anonymous");
  33. string sNamePart = GetSubString(sSaid, 0, nFirst - 0);
  34. string sMessagePart = GetSubString(sSaid, nFirst + 8, GetStringLength(sSaid) - (nFirst + 8));
  35. string sName = GetName(oSendor);
  36.  
  37. //25 words or less after "Message:"?
  38. //Detect spaces..
  39. string sSpaces = " ";
  40. int nIndex = FindSubString(sMessagePart, sSpaces, 0);
  41. int nSpaces;
  42. int nIndex2;
  43. while(nIndex != -1 && nSpaces < 27)
  44. {
  45. //count spaces
  46. if(nIndex != -1 && nIndex != nIndex2)
  47. {nSpaces = nSpaces + 1; nIndex2 = nIndex + 1;}
  48. else
  49. {break;}
  50. nIndex = FindSubString(sMessagePart, sSpaces, nIndex2);
  51. }
  52.  
  53. //AssignCommand(OBJECT_SELF, SpeakString("Spaces = "+IntToString(nSpaces), TALKVOLUME_TALK));
  54.  
  55. if(nSpaces > 26) {FloatingTextStringOnCreature("The sending failed, the message was too long", oSendor, FALSE, 5.0); return;}
  56.  
  57. //alternative - use amount of characters
  58. //if(GetStringLength(sMessagePart) > 175) {FloatingTextStringOnCreature("The sending failed, the message was too long", oSendor, FALSE, 5.0); return;}
  59.  
  60. //detect the recipient
  61. int iFound;
  62. object oReceiver = GetFirstPC(TRUE);
  63. string sReceiverName;
  64. while(GetIsObjectValid(oReceiver) == TRUE && iFound == FALSE)
  65. {
  66. sReceiverName = GetName(oReceiver);
  67. if(sReceiverName == sNamePart) {iFound = TRUE; break;}
  68. oReceiver = GetNextPC(TRUE);
  69. }
  70.  
  71. if(iFound == FALSE) {FloatingTextStringOnCreature("You know no one by that name", oSendor, FALSE, 5.0); return;}
  72.  
  73. int iRoll = d20() + GetSkillRank(SKILL_SPELLCRAFT, oReceiver, FALSE);
  74.  
  75.  
  76. //AssignCommand(OBJECT_SELF, SpeakString(sNamePart, TALKVOLUME_TALK));
  77. //AssignCommand(OBJECT_SELF, SpeakString(sMessagePart, TALKVOLUME_TALK));
  78.  
  79. if(iAnonymous == 0)
  80. {
  81. //check if valid Target and send message if so
  82. string sTell = "<color=LightPink><i>A magical sending arrives from "+sName+", you can respond immediately:</i> "+sMessagePart+" (respond by typing /r [message])";
  83. SendChatMessage(oSendor, oReceiver, CHAT_MODE_TELL, sTell, FALSE);
  84. /*
  85. //don't do this in normal sendings - will see it not used
  86. int iDC1 = 26;
  87. int iDC2 = 31;
  88.  
  89. if(iRoll > iDC1)
  90. {
  91. SendMessageToPC(oReceiver, "You discern that the sending spell likely originated from "+GetName(GetArea(OBJECT_SELF)));
  92. }
  93. if(iRoll > iDC2)
  94. {
  95. if(GetIsLocationValid(GetLocation(oReceiver)) == TRUE)
  96. {
  97. 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");
  98. CreateTeleportTrail(GetLocation(oReceiver), GetLocation(OBJECT_SELF), 60.0);
  99. }
  100. }
  101. */
  102. }
  103. if(iAnonymous == 1)
  104. {
  105. int iCL = GetSkillRank(SKILL_SPELLCRAFT, oSendor, FALSE);//GetLocalInt(OBJECT_SELF, "Casterlevel");
  106. int iDC1 = iCL + 6;
  107. int iDC2 = iCL + 11;
  108. int iDC3 = iCL + 16;
  109. //check if valid Target and send message if so
  110.  
  111. 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)";
  112.  
  113. if(iRoll > iDC1)
  114. {
  115. SendMessageToPC(oReceiver, "You discern that the sending spell likely originated from "+GetName(GetArea(OBJECT_SELF)));
  116. }
  117. if(iRoll > iDC2)
  118. {
  119. if(GetIsLocationValid(GetLocation(oReceiver)) == TRUE)
  120. {
  121. 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");
  122. CreateTeleportTrail(GetLocation(oReceiver), GetLocation(OBJECT_SELF), 60.0);
  123. }
  124. }
  125. //author detected
  126. if(iRoll > iDC3)
  127. {
  128. int iRollLore = d20() + GetSkillRank(SKILL_LORE, oReceiver, FALSE);
  129. if(iRollLore > 15 + 37 - (GetHitDice(oSendor)/ 2))
  130. {
  131. 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)+"!");
  132. }
  133. else
  134. {
  135. 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.");
  136. }
  137.  
  138. }
  139.  
  140. SendChatMessage(OBJECT_SELF, oReceiver, CHAT_MODE_TELL, sTell, FALSE);
  141. //not needed anymore since author's name is attached to the message with a metagaming warning
  142. //WriteTimestampedLogEntry("Anonymous Sending --> Sender: "+GetName(oSendor)+" to Recipient:"+GetName(oReceiver)+" - "+sTell);
  143. }
  144.  
  145. DelayCommand(1.0, StopSending(oSendor, OBJECT_SELF));
  146. }
  147. }
Add Comment
Please, Sign In to add comment