Advertisement
henesua

x2_s1_harpycry

Nov 25th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.75 KB | None | 0 0
  1. //::///////////////////////////////////////////////
  2. //:: Harpies Captivating Song
  3. //:: x2_s1_harpycry
  4. //:: Copyright (c) 2003 Bioware Corp.
  5. //:://////////////////////////////////////////////
  6. /*
  7.     Will daze any creature failing saving a will throw
  8.     Dazed creatures will be unable to take any action other than move toward the captivating song
  9.  
  10.     Captivating song in a 10 meter radius
  11.  
  12.     If cast by a Shifter
  13.     DC 15 + Shifter Level /3
  14.     Duration 4 rounds + Performance Skill Ranks/4
  15.  
  16.     Otherwise assume it is a harpy
  17.     DC          = 10 + HD/3 + Cha Bonus + (SpellFocusFeats)
  18.     Duration    = 2 + HD/3 + Performance Skill Ranks/4
  19.  
  20. */
  21. //:://////////////////////////////////////////////
  22. //:: Created By: Georg Zoeller 2003/07/08
  23. //:: Modified: The Magus (2012 feb 20) DC scaling, scry devices
  24. //:: Modified: The Magus (2012 nov 25) added Captivation behavior - CaptivatedBy()
  25. //:://////////////////////////////////////////////
  26.  
  27.  
  28. #include "X0_I0_SPELLS"
  29.  
  30. effect GetThisSpellEffect(object oTarget, object oCaster, effect eTest);
  31.  
  32. void CaptivatedBy(object oHarpy, effect eThis);
  33.  
  34.  
  35. void main()
  36. {
  37.     object oTarget;
  38.     object oHarpy   = OBJECT_SELF;
  39.     string sHarpy   = ObjectToString(OBJECT_SELF);
  40.     int nPerform    = GetSkillRank(SKILL_PERFORM);
  41.     int nHD         = GetHitDice(OBJECT_SELF);
  42.     SetLocalInt(OBJECT_SELF, "CAPTIVATING_INFLUENCE", nHD+GetAbilityScore(OBJECT_SELF,ABILITY_CHARISMA)+nPerform);
  43.     int bPC         = GetIsPC(OBJECT_SELF);
  44.     effect eVis     = EffectVisualEffect(VFX_IMP_CHARM);
  45.     effect eDaze    = EffectDazed();
  46.            eDaze    = EffectLinkEffects(EffectVisualEffect(VFX_DUR_MIND_AFFECTING_NEGATIVE), eDaze);
  47.            eDaze    = EffectLinkEffects(EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE), eDaze);
  48.            eDaze    = SupernaturalEffect(eDaze);
  49.  
  50.     location lSpLoc = GetLocation(OBJECT_SELF);
  51.     int nSpellId    = GetSpellId();
  52.     int nDuration;
  53.     int nSaveDC;
  54.  
  55.     int nShifter    = GetLevelByClass(CLASS_TYPE_SHIFTER);
  56.     if(nShifter)
  57.     {
  58.         nSaveDC     = 15+ (nShifter/3);
  59.         nDuration   = 4 + (nPerform/4);
  60.     }
  61.     else
  62.     {
  63.         int nDCAdj = GetAbilityModifier(ABILITY_CHARISMA);
  64.         if(nDCAdj<0){nDCAdj=0;}
  65.         if(GetHasFeat(FEAT_SPELL_FOCUS_ENCHANTMENT))
  66.             nDCAdj +=2;
  67.         if(GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ENCHANTMENT))
  68.             nDCAdj +=2;
  69.  
  70.         nSaveDC     = 10 +(nHD/3)+nDCAdj;
  71.         nDuration   = 2 +(nHD/3)+(nPerform/4);
  72.     }
  73.  
  74.     float fDuration = RoundsToSeconds(nDuration);
  75.  
  76.     // Apply VFX of casting on Self
  77.     int nSong       = 1930 + d6(); // new vfxs for captivating song - the magus
  78.     effect eSong    = EffectVisualEffect(nSong);
  79.     effect eImpact  = EffectVisualEffect(VFX_FNF_LOS_NORMAL_30);
  80.     ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSong, OBJECT_SELF, fDuration);
  81.     ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, lSpLoc);
  82.  
  83.     object oSensor;
  84.     //float fDelay;
  85.     oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lSpLoc);
  86.     while (GetIsObjectValid(oTarget) )
  87.     {
  88.         // Scrying devices link to the caster - MAGUS
  89.         int bSensor;
  90.         oSensor = GetLocalObject(oTarget, "SCRY_PC");
  91.         if(GetIsObjectValid(oSensor))
  92.         {
  93.             oTarget = oSensor;
  94.             bSensor = TRUE;
  95.         }
  96.  
  97.         if(    spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF)
  98.             && !GetHasEffect(EFFECT_TYPE_SILENCE,oTarget)
  99.             && !GetHasEffect(EFFECT_TYPE_DEAF,oTarget)
  100.           )
  101.         {
  102.             //Fire cast spell at event for the specified target
  103.             SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellId));
  104.             //Make an SR check
  105.             if(MyResistSpell(OBJECT_SELF, oTarget)<1)
  106.             {
  107.                 //Make a Will save to negate
  108.                 if (!MySavingThrow(SAVING_THROW_WILL, oTarget, nSaveDC, SAVING_THROW_TYPE_MIND_SPELLS))
  109.                 {
  110.                     if(bPC)
  111.                         SetPCLike(oTarget, OBJECT_SELF);
  112.                     //Apply the VFX impact
  113.                     ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
  114.                     //Captivate the target - the magus
  115.                     ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDaze, oTarget, fDuration);
  116.                     if(!bSensor) // not possible to travel toward the harpy
  117.                     {
  118.                         SetLocalInt(oTarget,"CAPTIVATING_SONG_FIRST_"+sHarpy, TRUE);
  119.                         AssignCommand(oTarget, CaptivatedBy( oHarpy, GetThisSpellEffect(oTarget, oHarpy, eDaze) ));
  120.                     }
  121.                 }
  122.             }
  123.         }
  124.         //Get next target in spell area
  125.         oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lSpLoc);
  126.     }
  127. }
  128.  
  129. void CaptivatedBy(object oHarpy, effect eThis)
  130. {
  131.     SetCommandable(TRUE);
  132.     string sID          = ObjectToString(oHarpy);
  133.     string sCaptivator  = GetLocalString(OBJECT_SELF, "CAPTIVATING_SONG_ID");
  134.     int nSongInfluence  = GetLocalInt(OBJECT_SELF, "CAPTIVATING_SONG_INFLUENCE");
  135.     int nCompetingSong  = GetLocalInt(oHarpy, "CAPTIVATING_INFLUENCE");
  136.  
  137.     if(     !GetIsEffectValid(GetThisSpellEffect(OBJECT_SELF, oHarpy, eThis))
  138.         ||  GetIsDead(oHarpy)
  139.         ||  !GetIsObjectValid(oHarpy)
  140.         ||  GetIsDead(OBJECT_SELF)
  141.       )
  142.     {
  143.         if(sID==sCaptivator)
  144.         {
  145.             DeleteLocalString(OBJECT_SELF, "CAPTIVATING_SONG_ID");
  146.             DeleteLocalInt(OBJECT_SELF, "CAPTIVATING_SONG_INFLUENCE");
  147.         }
  148.         return;
  149.     }
  150.  
  151.     if( sCaptivator!=sID)
  152.     {
  153.         if(nSongInfluence<nCompetingSong)
  154.         {
  155.             if(GetLocalInt(OBJECT_SELF,"CAPTIVATING_SONG_FIRST_"+sID))
  156.             {
  157.                 DeleteLocalInt(OBJECT_SELF,"CAPTIVATING_SONG_FIRST_"+sID);
  158.                 ClearAllActions(TRUE);
  159.             }
  160.  
  161.             SetLocalString(OBJECT_SELF, "CAPTIVATING_SONG_ID", sID);
  162.             SetLocalInt(OBJECT_SELF, "CAPTIVATING_SONG_INFLUENCE", nCompetingSong);
  163.         }
  164.         else
  165.         {
  166.             DelayCommand(3.0, CaptivatedBy(oHarpy, eThis));
  167.             SetCommandable(FALSE);
  168.             return;
  169.         }
  170.     }
  171.  
  172.     if(GetCurrentAction()!=ACTION_MOVETOPOINT)
  173.         ActionMoveToObject(oHarpy);
  174.  
  175.     DelayCommand(3.0, CaptivatedBy(oHarpy, eThis));
  176.     SetCommandable(FALSE);
  177. }
  178.  
  179. effect GetThisSpellEffect(object oTarget, object oCaster, effect eTest)
  180. {
  181.     effect eEff  = GetFirstEffect(oTarget);
  182.     int nLoop;
  183.     while(GetIsEffectValid(eEff))
  184.     {
  185.         if(GetEffectCreator(eEff)==oCaster)
  186.         {
  187.             if(eEff==eTest)
  188.             {
  189.                 return eEff;
  190.             }
  191.         }
  192.  
  193.         eEff    = GetNextEffect(oTarget);
  194.     }
  195.     return eEff;
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement