Advertisement
FunkySwerve

fky_chat_event

May 2nd, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.97 KB | None | 0 0
  1. //::////////////////////////////////////////////////////////////////////////:://
  2. //:: SIMTools V3.0 Speech Integration & Management Tools Version 3.0        :://
  3. //:: Created By: FunkySwerve                                                :://
  4. //:: Created On: April 4 2006                                               :://
  5. //:: Last Updated: March 27 2007                                            :://
  6. //:: With Thanks To:                                                        :://
  7. //:: Dumbo - for his amazing plugin                                         :://
  8. //:: Virusman - for Linux versions, and for the reset plugin, and for       :://
  9. //::    his excellent events plugin, without which this update would not    :://
  10. //::    be possible                                                         :://
  11. //:: Dazzle - for his script samples                                        :://
  12. //:: Butch - for the emote wand scripts                                     :://
  13. //:: The DMFI project - for the languages conversions and many of the emotes:://
  14. //:: Lanessar and the players of the Myth Drannor PW - for the new languages:://
  15. //:: The players and DMs of Higher Ground for their input and playtesting   :://
  16. //::////////////////////////////////////////////////////////////////////////:://
  17. //This script is only used by Linux users, to tell what conversation node was selected in the popup menus.
  18. //The other events shown will work with the Linux version but are commented out
  19.  
  20. //#include "aps_include"
  21. //#include "nwnx_events"
  22.  
  23. #include "hg_inc"
  24.  
  25. #include "fky_chat_instant"
  26.  
  27.  
  28. void main() {
  29.     int nEventType = GetEventType();
  30.     int nSubType;
  31.     string sCommand;
  32.     location lTarget;
  33.     object oTarget, oItem;
  34.  
  35.     switch (nEventType) {
  36.         case EVENT_TYPE_CAST_SPELL:
  37.             SetActionMode(OBJECT_SELF, ACTION_MODE_COUNTERSPELL, FALSE);
  38.  
  39.             nSubType = GetEventSubType();
  40.  
  41.             // 0x08000000 = already an instant spell; 0x03000000 = last legit class slot
  42.             if (GetIsPC(OBJECT_SELF) && !(nSubType & 0x08000000) && (nSubType & 0x07000000) < 0x03000000) {
  43.                 switch (nSubType & 0xFFFF) {
  44.                     case SPELL_TRUE_STRIKE:     /* don't let Nightblades cast True Strike swiftly when they go in */
  45.  
  46.                     case SPELL_LESSER_RESTORATION:
  47.                     case SPELL_RESTORATION:
  48.                     case HGSPELL_CRITICAL_STRIKE:
  49.                     case HGSPELL_DOLOROUS_BLOW:
  50.                         if (GetObjectType(GetEventTarget()) != OBJECT_TYPE_ITEM) {
  51.                             SetLocalInt(OBJECT_SELF, "EventSpell", nSubType);
  52.                             SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  53.                             DelayCommand(0.0, ExecuteScript("ev_swiftspell", OBJECT_SELF));
  54.                             BypassEvent();
  55.                         }
  56.                         break;
  57.  
  58.                     case SPELL_HOLD_PERSON:
  59.                         if (GetClassByPosition(((nSubType >> 24) & 0x7) + 1, OBJECT_SELF) != CLASS_TYPE_CLERIC)
  60.                             break;
  61.                         if (GetObjectType(GetEventTarget()) != OBJECT_TYPE_ITEM) {
  62.                             SetLocalInt(OBJECT_SELF, "EventSpell", nSubType);
  63.                             SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  64.                             DelayCommand(0.0, ExecuteScript("ev_swiftspell", OBJECT_SELF));
  65.                             BypassEvent();
  66.                         }
  67.                         break;
  68.  
  69.                     case HGSPELL_VOCALIZE:
  70.                         if (1 || GetClassByPosition(((nSubType >> 24) & 0x7) + 1, OBJECT_SELF) != CLASS_TYPE_WIZARD)
  71.                             break;
  72.                         if (GetObjectType(GetEventTarget()) != OBJECT_TYPE_ITEM) {
  73.                             SetLocalInt(OBJECT_SELF, "EventSpell", nSubType);
  74.                             SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  75.                             DelayCommand(0.0, ExecuteScript("ev_swiftspell", OBJECT_SELF));
  76.                             BypassEvent();
  77.                         }
  78.                         break;
  79.  
  80.                 }
  81.             }
  82.             break;
  83.  
  84.         case EVENT_TYPE_USE_ITEM:
  85.             oItem = GetEventItem();
  86.  
  87.             if (GetLocalInt(oItem, "FKY_CHAT_INSTANT")) {
  88.                 oTarget = GetEventTarget();
  89.                 if (GetObjectType(oTarget) == OBJECT_TYPE_TRIGGER)
  90.                     lTarget = GetLocation(OBJECT_SELF);
  91.                 else
  92.                     lTarget = Location(GetArea(OBJECT_SELF), GetEventPosition(), GetFacing(OBJECT_SELF));
  93.  
  94.                 if (DoInstantUse(OBJECT_SELF, oItem, oTarget, lTarget))
  95.                     BypassEvent();
  96.             }
  97.             break;
  98.  
  99.         case EVENT_TYPE_USE_FEAT:
  100.             nSubType = GetEventSubType();
  101.  
  102.             if (nSubType == FEAT_STUNNING_FIST && GetLLControlClass(OBJECT_SELF) == CLASS_TYPE_MONK) {
  103.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  104.                 DelayCommand(0.0, ExecuteScript("ev_stunningfist", OBJECT_SELF));
  105.                 BypassEvent();
  106.             } else if (nSubType == FEAT_QUIVERING_PALM) {
  107.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  108.                 DelayCommand(0.0, ExecuteScript("ev_quiveringpalm", OBJECT_SELF));
  109.                 BypassEvent();
  110.             } else if (nSubType == FEAT_CALLED_SHOT                   &&
  111.                 GetLevelByClass(CLASS_TYPE_RANGER, OBJECT_SELF) >= 35 &&
  112.                 GetHasFeat(FEAT_EPIC_BANE_OF_ENEMIES, OBJECT_SELF)) {
  113.  
  114.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  115.                 DelayCommand(0.0, ExecuteScript("ev_calledshot", OBJECT_SELF));
  116.                 BypassEvent();
  117.             } else if (nSubType == FEAT_DISARM || nSubType == FEAT_IMPROVED_DISARM || nSubType == HGFEAT_LEG_DISARM || nSubType == HGFEAT_PAR_DISARM) {
  118.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  119.                 DelayCommand(0.0, ExecuteScript("ev_disarm", OBJECT_SELF));
  120.                 BypassEvent();
  121.             } else if (nSubType == FEAT_KNOCKDOWN || nSubType == FEAT_IMPROVED_KNOCKDOWN || nSubType == HGFEAT_LEG_KNOCKDOWN || nSubType == HGFEAT_PAR_KNOCKDOWN) {
  122.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  123.                 DelayCommand(0.0, ExecuteScript("ev_knockdown", OBJECT_SELF));
  124.                 BypassEvent();
  125.             } else if (FindSubString(" 304 305 335 336 337 338 339 340 341 342 872 873 898 900 901 902 903 1060 1061 ", " " + IntToString(nSubType) + " ") >= 0) {
  126.                 if (GetHasEffectOfType(EFFECT_TYPE_POLYMORPH, OBJECT_SELF)) {
  127.                     FloatingTextStringOnCreature("You cannot change shape while already polymorphed!", OBJECT_SELF, FALSE);
  128.                     BypassEvent();
  129.                 }
  130.             }
  131.  
  132.             break;
  133.  
  134.         case EVENT_TYPE_USE_SKILL:
  135.             nSubType = GetEventSubType();
  136.  
  137.             if (nSubType == SKILL_TAUNT) {
  138.                 SetLocalObject(OBJECT_SELF, "EventTarget", GetEventTarget());
  139.                 DelayCommand(0.0, ExecuteScript("ev_taunt", OBJECT_SELF));
  140.                 BypassEvent();
  141.             }
  142.             break;
  143.  
  144.         case EVENT_TYPE_TOGGLE_MODE:
  145.             nSubType = GetEventSubType();
  146.  
  147.             if (nSubType == ACTION_MODE_COUNTERSPELL) {
  148.                 if (GetIsObjectValid(GetAttackTarget(OBJECT_SELF)))
  149.                     ClearAllActions(TRUE);
  150.                 RemoveEffectsOfType(EFFECT_TYPE_ETHEREAL, OBJECT_SELF);
  151.             }
  152.  
  153.             break;
  154.  
  155.         case EVENT_TYPE_PICKPOCKET:
  156.             oTarget = GetEventTarget();
  157.  
  158.             if (GetIsPC(OBJECT_SELF) && GetIsPC(oTarget)) {
  159.                 if (GetLocalInt(GetArea(OBJECT_SELF), "nopp")) {
  160.                     FloatingTextStringOnCreature("You cannot pickpocket other players!", OBJECT_SELF, FALSE);
  161.                     BypassEvent();
  162.                 }
  163.                 if (abs(GetHitDice(oTarget) - GetHitDice(OBJECT_SELF)) > 6) {
  164.                     FloatingTextStringOnCreature("You cannot pickpocket players more than 6 levels above or below you!", OBJECT_SELF, FALSE);
  165.                     BypassEvent();
  166.                 }
  167.                 if (GetIsHardcore(OBJECT_SELF) || GetIsHardcore(oTarget)) {
  168.                     FloatingTextStringOnCreature("Hardcore players cannot pickpocket or be pickpocketed by other players!", OBJECT_SELF, FALSE);
  169.                     BypassEvent();
  170.                 }
  171.             }
  172.             RemoveEffectsOfType(EFFECT_TYPE_ETHEREAL, OBJECT_SELF);
  173.             break;
  174.  
  175.         case EVENT_TYPE_QUICKCHAT:
  176.             nSubType = GetEventSubType();
  177.             sCommand = GetLocalString(OBJECT_SELF, "VoiceBind_" + IntToString(nSubType));
  178.  
  179.             if (GetLocalString(OBJECT_SELF, "VoiceBind_Save") != "") {
  180.                 sCommand = GetLocalString(OBJECT_SELF, "VoiceBind_Save");
  181.                 DeleteLocalString(OBJECT_SELF, "VoiceBind_Save");
  182.  
  183.                 if (nSubType >= 100                                                          ||
  184.                     (nSubType >= VOICE_CHAT_ENEMIES  && nSubType <= VOICE_CHAT_FLEE)         ||
  185.                     (nSubType >= VOICE_CHAT_LOOKHERE && nSubType <= VOICE_CHAT_TASKCOMPLETE) ||
  186.                     (nSubType >= VOICE_CHAT_TALKTOME && nSubType <= VOICE_CHAT_BADIDEA)) {
  187.                     if (GetStringLowerCase(sCommand) == "clear") {
  188.                         DeleteLocalString(OBJECT_SELF, "VoiceBind_" + IntToString(nSubType));
  189.                         DeletePersistentVariable(OBJECT_SELF, "VoiceBind_" + IntToString(nSubType));
  190.  
  191.                         FloatingTextStringOnCreature(COLOR_GREEN + "Voice chat cleared!", OBJECT_SELF, FALSE);
  192.                     } else {
  193.                         SetLocalString(OBJECT_SELF, "VoiceBind_" + IntToString(nSubType), sCommand);
  194.                         SetPersistentString(OBJECT_SELF, "VoiceBind_" + IntToString(nSubType), sCommand);
  195.  
  196.                         FloatingTextStringOnCreature(COLOR_GREEN + "Voice chat bound!", OBJECT_SELF, FALSE);
  197.                     }
  198.                 } else
  199.                     FloatingTextStringOnCreature(COLOR_RED + "You cannot bind that voice chat!", OBJECT_SELF, FALSE);
  200.  
  201.                 BypassEvent();
  202.             } else if (sCommand != "" || (nSubType >= 100 && nSubType <= 110)) {
  203.                 if (sCommand == "") {
  204.                     switch (nSubType) {
  205.                         case 100: sCommand = "!autocast";                    break;
  206.                         case 101: sCommand = "!list imm";                    break;
  207.                         case 102: sCommand = "!effects";                     break;
  208.                         case 103: sCommand = "!who inparty class";           break;
  209.                         case 104: sCommand = "!effects eq";                  break;
  210.                         case 105: sCommand = "!list servers";                break;
  211.                         case 107: sCommand = "!who player class group=area"; break;
  212.                         case 108: sCommand = "!list voicebinds";             break;
  213.                         case 109: sCommand = "!render";                      break;
  214.                         case 110: sCommand = "!stuck";                       break;
  215.                         default:  sCommand = "!time";                        break;
  216.                     }
  217.                 }
  218.  
  219.                 if (GetStringLeft(sCommand, 8) == "!target ") {
  220.                     sCommand = GetSubString(sCommand, 8, 255);
  221.                     DeleteLocalObject(OBJECT_SELF, "FKY_CHAT_TARGET");
  222.                 } else {
  223.                     SetLocalObject(OBJECT_SELF, "FKY_CHAT_TARGET", OBJECT_SELF);
  224.                     SetLocalInt(OBJECT_SELF, "FKY_CHAT_TARGET_CLEANUP", 1);
  225.                 }
  226.  
  227.                 AssignCommand(OBJECT_SELF, SpeakString(sCommand, TALKVOLUME_WHISPER));
  228.                 BypassEvent();
  229.             }
  230.             break;
  231.     }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement