Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.05 KB | None | 0 0
  1. using System;
  2. using DOL.GS.PacketHandler;
  3. using DOL.GS.RealmAbilities;
  4.  
  5. namespace DOL.GS.Commands
  6. {
  7.     [CmdAttribute(
  8.         "&gamenpc",
  9.         ePrivLevel.GM,
  10.         "/Gamenpc <spell> <target|targetName|targetGuild> <spellID> <self|enemy|npcguild|npcname>",
  11.         "/Gamenpc <add|remove> <ability|base|spec|debuff> <property> <value> <radius>")]
  12.  
  13.     public class GameNPCCommandHandler : AbstractCommandHandler, ICommandHandler
  14.     {
  15.  
  16.         public void OnCommand(GameClient client, string[] args)
  17.         {
  18.             GameNPC npc = (GameNPC)client.Player.TargetObject;
  19.             if (args.Length < 2)
  20.             {
  21.                 DisplaySyntax(client);
  22.                 return;
  23.             }
  24.             switch (args[1].ToLower())
  25.             {
  26.                 case "add":
  27.                     {
  28.                         switch (args[2].ToLower())
  29.                         {
  30.                             case "ability":
  31.                                 {
  32.                                     if (args.Length < 6)
  33.                                     {
  34.                                         DisplaySyntax(client, args[1]);
  35.                                         return;
  36.                                     }
  37.                                     int property = Convert.ToInt16(args[3]);
  38.                                     if (Convert.ToInt32(args[5]) > 0)
  39.                                     {
  40.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[5])))
  41.                                         {
  42.                                             npcs.AbilityBonus[property] += Convert.ToInt16(args[4]);
  43.                                         }
  44.                                     }
  45.                                     else
  46.                                         npc.AbilityBonus[property] += Convert.ToInt16(args[4]);
  47.                                 }
  48.                                 break;
  49.                             case "base":
  50.                                 {
  51.                                     if (args.Length < 6)
  52.                                     {
  53.                                         DisplaySyntax(client, args[1]);
  54.                                         return;
  55.                                     }
  56.                                     int property = Convert.ToInt16(args[3]);
  57.                                     if (Convert.ToInt32(args[5]) > 0)
  58.                                     {
  59.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[5])))
  60.                                         {
  61.                                             npcs.BaseBuffBonusCategory[property] += Convert.ToInt16(args[4]);
  62.                                         }
  63.                                     }
  64.                                     else
  65.                                         npc.BaseBuffBonusCategory[property] += Convert.ToInt16(args[4]);
  66.                                 }
  67.                                 break;
  68.                             case "spec":
  69.                                 {
  70.                                     if (args.Length < 6)
  71.                                     {
  72.                                         DisplaySyntax(client, args[1]);
  73.                                         return;
  74.                                     }
  75.                                     int property = Convert.ToInt16(args[3]);
  76.                                     if (Convert.ToInt32(args[5]) > 0)
  77.                                     {
  78.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[5])))
  79.                                         {
  80.                                             npcs.BuffBonusCategory4[property] += Convert.ToInt16(args[4]);
  81.                                         }
  82.                                     }
  83.                                     else
  84.                                         npc.BuffBonusCategory4[property] += Convert.ToInt16(args[4]);
  85.                                 }
  86.                                 break;
  87.                         }
  88.                         break;
  89.                     }
  90.                 case "remove":
  91.                     {
  92.                         switch (args[2].ToLower())
  93.                         {
  94.                             case "ability":
  95.                                 {
  96.                                     if (args.Length < 6)
  97.                                     {
  98.                                         DisplaySyntax(client, args[1]);
  99.                                         return;
  100.                                     }
  101.                                     int property = Convert.ToInt16(args[3]);
  102.                                     if (Convert.ToInt32(args[5]) > 0)
  103.                                     {
  104.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[5])))
  105.                                         {
  106.                                             npcs.AbilityBonus[property] -= Convert.ToInt16(args[4]);
  107.                                         }
  108.                                     }
  109.                                     else
  110.                                         npc.AbilityBonus[property] -= Convert.ToInt16(args[4]);
  111.                                 }
  112.                                 break;
  113.                             case "base":
  114.                                 {
  115.                                     if (args.Length < 5)
  116.                                     {
  117.                                         DisplaySyntax(client, args[1]);
  118.                                         return;
  119.                                     }
  120.                                     int property = Convert.ToInt16(args[3]);
  121.                                     if (Convert.ToInt32(args[2]) > 0)
  122.                                     {
  123.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[4])))
  124.                                         {
  125.                                             npcs.BaseBuffBonusCategory[property] -= Convert.ToInt16(args[3]);
  126.                                         }
  127.                                     }
  128.                                     else
  129.                                         npc.BaseBuffBonusCategory[property] -= Convert.ToInt16(args[3]);
  130.                                 }
  131.                                 break;
  132.                             case "spec":
  133.                                 {
  134.                                     if (args.Length < 5)
  135.                                     {
  136.                                         DisplaySyntax(client, args[1]);
  137.                                         return;
  138.                                     }
  139.                                     int property = Convert.ToInt16(args[2]);
  140.                                     if (Convert.ToInt32(args[4]) > 0)
  141.                                     {
  142.                                         foreach (GameNPC npcs in npc.GetNPCsInRadius((ushort)Convert.ToInt32(args[4])))
  143.                                         {
  144.                                             npcs.BuffBonusCategory4[property] -= Convert.ToInt16(args[3]);
  145.                                         }
  146.                                     }
  147.                                     else
  148.                                         npc.BuffBonusCategory4[property] -= Convert.ToInt16(args[3]);
  149.                                 }
  150.                                 break;
  151.                         }
  152.                         break;
  153.                     }
  154.                 case "cast":
  155.                     {
  156.                         if (args.Length != 5)
  157.                         {
  158.                             DisplaySyntax(client, args[1]);
  159.                             return;
  160.                         }
  161.                         if (npc == null || client.Player.TargetObject == null) return;
  162.                         SpellLine line = SkillBase.GetSpellLine("Mob Spells");
  163.                         Spell spell = SkillBase.GetSpellByID(Convert.ToInt32(args[3]));
  164.                         DOL.Database.DBSpell dbs = null;
  165.                         Spell cloneSpell = null;
  166.                         dbs.Description = spell.Description;
  167.                         dbs.Target = args[2];
  168.                         dbs.Type = spell.SpellType;
  169.                         dbs.Range = spell.Range;
  170.                         dbs.Radius = spell.Radius;
  171.                         dbs.Value = spell.Value;
  172.                         dbs.Damage = spell.Damage;
  173.                         dbs.DamageType = (int)spell.DamageType;
  174.                         dbs.Concentration = spell.Concentration;
  175.                         dbs.Duration = spell.Duration;
  176.                         dbs.Frequency = spell.Frequency;
  177.                         dbs.Pulse = spell.Pulse;
  178.                         dbs.PulsePower = spell.PulsePower;
  179.                         dbs.Power = spell.Power;
  180.                         dbs.CastTime = spell.CastTime;
  181.                         dbs.RecastDelay = spell.RecastDelay;
  182.                         dbs.ResurrectHealth = spell.ResurrectHealth;
  183.                         dbs.ResurrectMana = spell.ResurrectMana;
  184.                         dbs.LifeDrainReturn = spell.LifeDrainReturn;
  185.                         dbs.AmnesiaChance = spell.AmnesiaChance;
  186.                         dbs.Message1 = spell.Message1;
  187.                         dbs.Message2 = spell.Message2;
  188.                         dbs.Message3 = spell.Message3;
  189.                         dbs.Message4 = spell.Message4;
  190.                         dbs.ClientEffect = spell.ClientEffect;
  191.                         dbs.Icon = spell.Icon;
  192.                         dbs.InstrumentRequirement = spell.InstrumentRequirement;
  193.                         dbs.EffectGroup = spell.EffectGroup;
  194.                         dbs.SubSpellID = spell.SubSpellID;
  195.                         dbs.MoveCast = spell.MoveCast;
  196.                         dbs.Uninterruptible = spell.Uninterruptible;
  197.                         dbs.IsFocus = spell.IsFocus;
  198.                         dbs.IsPrimary = spell.IsPrimary;
  199.                         dbs.IsSecondary = spell.IsSecondary;
  200.                         dbs.AllowBolt = spell.AllowBolt;
  201.                         dbs.SharedTimerGroup = spell.SharedTimerGroup;
  202.                         cloneSpell = new Spell(dbs, 1);
  203.  
  204.                         if (spell != null && cloneSpell != null)
  205.                         {
  206.                             npc.CastSpell(cloneSpell, line);
  207.                             return;
  208.                         }
  209.  
  210.                         client.Out.SendMessage("Spell with id " + Convert.ToInt16(args[3]) + " not found in db!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  211.  
  212.                         break;
  213.                     }
  214.                 default:
  215.                     {
  216.                         client.Out.SendMessage("'" + args[1] + "' is not a valid arguement.", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
  217.                     }
  218.                     break;
  219.             }
  220.         }
  221.     }
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement