NPC Template Command

Share files with other Dawn of Light users

Moderator: Support Team

NPC Template Command

Postby Yemla » Tue Mar 08, 2011 12:13 am

Code: Select all
using System;
using DOL.GS.PacketHandler;
using DOL.Database;
using DOL.GS.Spells;

namespace DOL.GS.Commands
{
[CmdAttribute(
"&npctemplate",
ePrivLevel.GM,
"/npctemplate create <TemplateID> - to add a new npctemplate that doesn't alreadt exist.",
"/npctemplate name <TemplateID> <new name> - to modify npc's name.",
"/npctemplate guild <TemplateID> <new guildname> - to modify npc's guild name.",
"/npctemplate model <TemplateID> <model ID> - to modify npc's model.",
"/npctemplate size <TemplateID> <size> - to modify npc's size. (1...255)",
"/npctemplate speed <TemplateID> <speed> - to modify npc's max speed.",
"/npctemplate damagetype <TemplateID> <crush | slash | thrust | ect.> - to modify npc's melee damage type.",
"/npctemplate parry <TemplateID> <value> - to modify's npc's parry chance. 100 = 100%.",
"/npctemplate evade <TemplateID> <value> - to modify's npc's evade chance. 100 = 100%.",
"/npctemplate block <TemplateID> <value> - to modify's npc's block chance. 100 = 100%.",
"/npctemplate lefthand <TemplateID> <value> - to modify's npc's left-hand swing chance. 100 = 100%.",
"/npctemplate stat <TemplateID> <stat type> <value> - to modify's npc's stats. (str, con, dex, qui, int, emp, pie, cha).",
"/npctemplate abilities <TemplateID> <add> <ability name> <rank> - to add a ability to the npc's template.",
"/npctemplate abilities <TemplateID> <remove> - removes all abilities from the npc's template.",
"/npctemplate aggrolevel <TemplateID> <value> - modify's the npc's aggrolevel.",
"/npctemplate aggrorange <TemplateID> <value> - modify's the npc's aggrorange.",
"/npctemplate level <TemplateID> <value> - modify's the npc's level.",
"/npctemplate spells <TemplateID> <add> <spell ID> - to add a spell to the npc's template.",
"/npctemplate spells <TemplateID> <rempve> - removes all spells from the npc's template.",
"/npctemplate styles <TemplateID> <add> <style ID> - to add a style to the npc's template.",
"/npctemplate styles <TemplateID> <remove> - removes all styles from the npc's template.")]

public class NPCTemplateCommandHandler : AbstractCommandHandler, ICommandHandler
{
public static string allowedValue = "1234567890";
public void OnCommand(GameClient client, string[] args)
{
if (args.Length == 1)
{
DisplaySyntax(client);
return;
}
GamePlayer player = client.Player as GamePlayer;
if (player == null) return;
DBNpcTemplate tmp = GameServer.Database.FindObjectByKey<DBNpcTemplate>(args[2]);
switch (args[1].ToLower())
{
case "create":
{
if (args.Length < 2)
{
DisplaySyntax(client);
return;
}
if (tmp != null) return;
tmp = new DBNpcTemplate();
tmp.TemplateId = args[2];
tmp.Level = "1";
tmp.Model = "408";
tmp.GuildName = "";
tmp.Size = "50";
tmp.MeleeDamageType = 0;
tmp.ClassType = "DOL.GS.GameNPC";
tmp.VisibleWeaponSlots = 0;
GameServer.Database.AddObject(tmp);
}
break;
case "name":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
tmp.Name = args[3];
}
break;
case "guild":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
tmp.GuildName = args[3];
}
break;
case "model":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
foreach (char c in args[3])
{
if (allowedValue.IndexOf(char.ToLower(c)) < 0)
{
DisplaySyntax(client);
return;
}
if (tmp.Model != null || tmp.Model != "")
{
tmp.Model = tmp.Model + ";" + args[3];
}
else tmp.Model = args[4];
}
}
break;
case "size":
{
int cap = Convert.ToInt32(args[3]);
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
foreach (char c in args[3])
{
if (allowedValue.IndexOf(char.ToLower(c)) < 0)
{
DisplaySyntax(client);
return;
}
else if (cap > 255)
tmp.Size = "255";
else if (cap <= 0)
tmp.Size = "1";
else
tmp.Size = args[3];
}
}
break;
case "speed":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.MaxSpeed = Convert.ToInt16(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "damagetype":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
switch (args[3].ToLower())
{
case "0":
case "essence":
tmp.MeleeDamageType = 0;
break;
case "1":
case "crush":
tmp.MeleeDamageType = 1;
break;
case "2":
case "slash":
tmp.MeleeDamageType = 2;
break;
case "3":
case "thrust":
tmp.MeleeDamageType = 3;
break;
case "10":
case "body":
tmp.MeleeDamageType = 10;
break;
case "11":
case "cold":
tmp.MeleeDamageType = 11;
break;
case "12":
case "energy":
tmp.MeleeDamageType = 12;
break;
case "13":
case "heat":
tmp.MeleeDamageType = 13;
break;
case "14":
case "matter":
tmp.MeleeDamageType = 14;
break;
case "15":
case "spirit":
tmp.MeleeDamageType = 15;
break;
default:
DisplaySyntax(client);
return;
}
}
break;
case "parry":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.ParryChance = Convert.ToByte(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "evade":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.EvadeChance = Convert.ToByte(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "block":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.BlockChance = Convert.ToByte(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "lefthandchance":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.LeftHandSwingChance = Convert.ToByte(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "stat":
{
if (args.Length < 4)
{
DisplaySyntax(client);
return;
}
switch (args[3].ToLower())
{
case "str":
case "strength":
tmp.Strength = Convert.ToByte(args[4]);
break;
case "con":
case "constitution":
tmp.Constitution = Convert.ToByte(args[4]);
break;
case "dex":
case "dexterity":
tmp.Dexterity = Convert.ToByte(args[4]);
break;
case "qui":
case "quickness":
tmp.Quickness = Convert.ToByte(args[4]);
break;
case "int":
case "intelligence":
tmp.Intelligence = Convert.ToByte(args[4]);
break;
case "pie":
case "piety":
tmp.Piety = Convert.ToByte(args[4]);
break;
case "char":
case "charisma":
tmp.Charisma = Convert.ToByte(args[4]);
break;
case "emp":
case "empathy":
tmp.Empathy = Convert.ToByte(args[4]);
break;
default:
DisplaySyntax(client);
return;
}
}
break;
case "abilities":
{
if (args[3].ToLower() == "add")
{
if (args.Length < 5)
{
DisplaySyntax(client);
return;
}
foreach (char c in args[5])
{
if (allowedValue.IndexOf(char.ToLower(c)) < 0)
{
DisplaySyntax(client);
return;
}
if (tmp.Abilities != null || tmp.Abilities != "")
{
tmp.Abilities = tmp.Abilities + ";" + args[4] + "|" + args[5];
}
else tmp.Abilities = args[4] + "|" + args[5];
}
}
else if (args[3].ToLower() == "remove")
{
tmp.Abilities = "";
}
else DisplaySyntax(client);
}
break;
case "aggrolevel":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.AggroLevel = Convert.ToByte(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}
}
break;
case "aggrorange":
{
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
try
{
tmp.AggroRange = Convert.ToInt32(args[3]);
}
catch (Exception)
{
DisplaySyntax(client);
}

}
break;
case "level":
{
int cap = Convert.ToInt32(args[3]);
if (args.Length < 3)
{
DisplaySyntax(client);
return;
}
foreach (char c in args[3])
{
if (allowedValue.IndexOf(char.ToLower(c)) < 0)
{
DisplaySyntax(client);
return;
}
else if (cap > 255)
tmp.Level = "255";
else if (cap < 0)
tmp.Level = "0";
else
tmp.Level = args[3];
}
}
break;
case "spells":
{
if (args[3].ToLower() == "add")
{
if (args.Length < 4)
{
DisplaySyntax(client);
return;
}
if (tmp.Spells != null || tmp.Spells != "")
{
tmp.Spells = tmp.Spells + ";" + args[4];
}
else tmp.Spells = args[4];
}
else if (args[3].ToLower() == "remove")
{
tmp.Spells = "";
}
else DisplaySyntax(client);
}
break;
case "styles":
{
if (args[3].ToLower() == "add")
{
if (args.Length < 4)
{
DisplaySyntax(client);
return;
}
if (tmp.Styles != null || tmp.Styles != "")
{
tmp.Styles = tmp.Styles + "|1;" + args[4];
}
else tmp.Styles = args[4];
}
else if (args[3].ToLower() == "remove")
{
tmp.Styles = "";
}
else DisplaySyntax(client);
}
break;
}
}
}
}
Not tested yet, but this is the idea for adding new templates ingame with a command and modifying them aswell...thoughts and fixes if seen =]
Yemla
Contributor
 
Posts: 215
Joined: Sat Feb 02, 2008 3:21 am
Website: http://www.facebook.com/J.D.Snelling
Location: California

Re: NPC Template Command

Postby Graveen » Tue Mar 08, 2011 8:17 am

Test it please ;)
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France


Return to “%s” User Files

Who is online

Users browsing this forum: Bing [Bot] and 1 guest