Author Topic: A buffing script for NPC  (Read 685 times)

Legacy_PreyingMantis

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
A buffing script for NPC
« on: April 05, 2011, 08:11:13 pm »


               I put this on a NPC for buffing PCs, it works fine except it will cause lag.  I would like to get all the spells benifits put on the PC with maybe just one FX instead of all the spells FXs at once.  I am not good at scripting, I cut/paste and use Lilac's generator.  Is what I want to achieve possible?


void main()
{
object oPC = GetPCSpeaker();
AssignCommand(oPC, TakeGoldFromCreature(500, oPC, TRUE));
object oTarget;
oTarget = oPC;
ActionCastSpellAtObject(SPELL_AID, oTarget, METAMAGIC_ANY, TRUE, 15, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_BULLS_STRENGTH, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_CATS_GRACE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_DARKFIRE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_EAGLE_SPLEDOR, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_ENDURANCE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_ENDURE_ELEMENTS, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_FOXS_CUNNING, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_MAGIC_WEAPON, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_NEGATIVE_ENERGY_PROTECTION, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionCastSpellAtObject(SPELL_HASTE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
}
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
A buffing script for NPC
« Reply #1 on: April 05, 2011, 09:20:50 pm »


               here you go i put a 2 second delay on each spell after the previous was casted, added spacing and removed unneeded lines and your script will still cast the spells at the player.

if you want more of a delay just change the number in front of the peroid

void main()
{

object oPC = GetPCSpeaker();

AssignCommand(oPC, TakeGoldFromCreature(500, oPC, TRUE));

DelayCommand(2.0,ActionCastSpellAtObject(SPELL_AID, oPC, METAMAGIC_ANY, TRUE, 15, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(4.0, ActionCastSpellAtObject(SPELL_BULLS_STRENGTH, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(6.0, ActionCastSpellAtObject(SPELL_CATS_GRACE, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(8.0, ActionCastSpellAtObject(SPELL_DARKFIRE, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(10.0, ActionCastSpellAtObject(SPELL_EAGLE_SPLEDOR, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(12.0, ActionCastSpellAtObject(SPELL_ENDURANCE, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(14.0, ActionCastSpellAtObject(SPELL_ENDURE_ELEMENTS, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(16.0, ActionCastSpellAtObject(SPELL_FOXS_CUNNING, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(18.0, ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(20.0, ActionCastSpellAtObject(SPELL_MAGIC_WEAPON, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(22.0, ActionCastSpellAtObject(SPELL_NEGATIVE_ENERGY_PROTECTION, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

DelayCommand(24.0, ActionCastSpellAtObject(SPELL_HASTE, oPC, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

}
               
               

               
            

Legacy_PreyingMantis

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
A buffing script for NPC
« Reply #2 on: April 05, 2011, 09:58:02 pm »


               Thank you. '<img'>
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
A buffing script for NPC
« Reply #3 on: April 05, 2011, 10:07:52 pm »


               no problem
               
               

               
            

Legacy_PreyingMantis

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
A buffing script for NPC
« Reply #4 on: April 06, 2011, 02:51:01 pm »


               Thanks for the response Ryuhi200, but I couldn't get yours to work.  And I am really trying to get the enhancements all at once instead of something drawn out.  I did cut my amount of buffs in half hoping to reduce lag, and it works... almost always. 'Posted

Here is what I have so far...

void main()
{
object oPC = GetPCSpeaker();
if (GetGold(oPC) >= 250)
   {
   AssignCommand(oPC, TakeGoldFromCreature(250, oPC, TRUE));
   oTarget = oPC;
   ActionCastSpellAtObject(SPELL_AID, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);
   ActionCastSpellAtObject(SPELL_DARKFIRE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_ENDURE_ELEMENTS, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_HASTE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_MAGIC_WEAPON, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   }
else
   {
   AssignCommand(GetObjectByTag("Marisa"), ActionSpeakString("I'm sorry, but that is not enough gold for a donation."));
   }
}


Everything seems to be working as I would like.. except, once in about 4 tries, the NPC takes the gold starts to cast spell and stops... nothing else happens.  So PC loses gold and gets no buff.

Does anybody have any ideas what could be the problem? 

Thanks in advance for any help. 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
A buffing script for NPC
« Reply #5 on: April 06, 2011, 03:39:05 pm »


               

PreyingMantis wrote...


Everything seems to be working as I would like.. except, once in about 4 tries, the NPC takes the gold starts to cast spell and stops... nothing else happens.  So PC loses gold and gets no buff.

Does anybody have any ideas what could be the problem? 

Thanks in advance for any help. 


It sounds like something is clearing the action Que before he has a chance to cast.

Try this.


void main()
{
object oTarget= GetPCSpeaker();
if (GetGold(oTarget) >= 250)
   {
   /* no reason to assign this -- AssignCommand(oPC,*/ TakeGoldFromCreature(250, oTarget, TRUE)/*)*/;
   ActionCastSpellAtObject(SPELL_AID, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);
   ActionCastSpellAtObject(SPELL_DARKFIRE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_ENDURE_ELEMENTS, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_HASTE, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_MAGIC_VESTMENT, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
   ActionCastSpellAtObject(SPELL_MAGIC_WEAPON, oTarget, METAMAGIC_ANY, TRUE, 12, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
  
ActionDoCommand( SetCommandable(TRUE));
   SetCommandable(FALSE);
   }
else
   {
   /* Again no resion to assign -- AssignCommand(GetObjectByTag("Marisa"),*/ ActionSpeakString("I'm sorry, but that is not enough gold for a donation.")/*)*/;
   }
}
               
               

               
            

Legacy_PreyingMantis

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
A buffing script for NPC
« Reply #6 on: April 06, 2011, 04:12:31 pm »


               Wow, I am a long ways from understanding all this scripting stuff.  After some testing it hasn't failed once now.  Thanks again Lightfoot8 for making it simple for us simpletons.

I think this is just what I want, I really appreciate your help.  'Posted