本文整理汇总了C#中DOL.GS.GameNPC.AddToWorld方法的典型用法代码示例。如果您正苦于以下问题:C# GameNPC.AddToWorld方法的具体用法?C# GameNPC.AddToWorld怎么用?C# GameNPC.AddToWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOL.GS.GameNPC
的用法示例。
在下文中一共展示了GameNPC.AddToWorld方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScriptLoaded
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
{
if (!ServerProperties.Properties.LOAD_EXAMPLES)
return;
#region defineNPCs
GameNPC[] npcs = WorldMgr.GetNPCsByName("Sir Quait", eRealm.Albion);
npcs = WorldMgr.GetNPCsByName("Sir Quait", (eRealm)1);
GameNPC SirQuait = null;
if (npcs.Length == 0)
{
SirQuait = new DOL.GS.GameNPC();
SirQuait.Model = 40;
SirQuait.Name = "Sir Quait";
if (log.IsWarnEnabled)
log.Warn("Could not find " + SirQuait.Name + ", creating ...");
SirQuait.Realm = eRealm.Albion;
SirQuait.CurrentRegionID = 1;
SirQuait.Size = 50;
SirQuait.Level = 10;
SirQuait.MaxSpeedBase = 100;
SirQuait.Faction = FactionMgr.GetFactionByID(0);
SirQuait.X = 531971;
SirQuait.Y = 478955;
SirQuait.Z = 0;
SirQuait.Heading = 3570;
SirQuait.RespawnInterval = 0;
SirQuait.BodyType = 0;
StandardMobBrain brain = new StandardMobBrain();
brain.AggroLevel = 0;
brain.AggroRange = 0;
SirQuait.SetOwnBrain(brain);
SirQuait.AddToWorld();
}
else
{
SirQuait = npcs[0];
}
#endregion
#region defineBehaviours
BaseBehaviour b = new BaseBehaviour(SirQuait);
MessageAction a = new MessageAction(SirQuait,"This is just a simple test bahaviour.",eTextType.Emote);
b.AddAction(a);
InteractTrigger t = new InteractTrigger(SirQuait,b.NotifyHandler,SirQuait);
b.AddTrigger(t);
// store the behaviour in a list so it won't be garbage collected
behaviours.Add(b);
#endregion
log.Info("Simple Test Behaviour added");
}
示例2: CreateKillTask
[Test] public void CreateKillTask()
{
GamePlayer player = CreateMockGamePlayer();
player.Level=5;
player.AddToWorld();
// Trainer for taks
GameTrainer trainer = new GameTrainer();
trainer.Name ="Tester";
Console.WriteLine(player.Name);
// player must have trainer selected when task given.
player.TargetObject = trainer;
// mob for task
if (KillTask.BuildTask(player,trainer))
{
KillTask task =(KillTask) player.Task;
Assert.IsNotNull(task);
Assert.IsTrue(task.TaskActive);
Console.WriteLine("Mob:"+ task.MobName);
Console.WriteLine("Item:"+ task.ItemName);
Console.WriteLine(""+ task.Description);
// Check Notify Event handling
InventoryItem item = GameInventoryItem.Create(new ItemTemplate());
item.Name = task.ItemName;
GameNPC mob = new GameNPC();
mob.Name = task.MobName;
mob.X = player.X;
mob.Y = player.Y;
mob.Z = player.Z;
mob.Level = player.Level;
mob.CurrentRegionID = player.CurrentRegionID;
mob.AddToWorld();
// First we kill mob
mob.XPGainers.Add(player,1.0F);
task.Notify(GameNPCEvent.EnemyKilled,player,new EnemyKilledEventArgs(mob));
// arificial pickup Item
player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item);
// Check item in Inventory
if (player.Inventory.GetFirstItemByName(task.ItemName,eInventorySlot.FirstBackpack,eInventorySlot.LastBackpack) != null)
Assert.Fail("Player didn't recieve task item.");
// Now give item tro trainer
task.Notify(GamePlayerEvent.GiveItem,player,new GiveItemEventArgs(player,trainer,item));
if (player.Task.TaskActive || player.Task==null)
Assert.Fail("Task did not finished proper in Notify");
}
}
示例3: AddObject
[Test] public void AddObject()
{
Region region = WorldMgr.GetRegion(1);
GameObject obj = new GameNPC();
obj.Name="TestObject";
obj.X = 400000;
obj.Y = 200000;
obj.Z = 2000;
obj.CurrentRegion = region;
obj.AddToWorld();
if (obj.ObjectID<0)
Assert.Fail("Failed to add object to Region. ObjectId < 0");
Assert.AreEqual(region.GetObject((ushort)obj.ObjectID),obj);
}
示例4: LockRelic
public static bool LockRelic()
{
//make sure the relic exists before you lock it!
if (Relic == null)
return false;
LockedEffect = new GameNPC();
LockedEffect.Model = 1583;
LockedEffect.Name = "LOCKED_RELIC";
LockedEffect.X = Relic.X;
LockedEffect.Y = Relic.Y;
LockedEffect.Z = Relic.Z;
LockedEffect.Heading = Relic.Heading;
LockedEffect.CurrentRegionID = Relic.CurrentRegionID;
LockedEffect.Flags = GameNPC.eFlags.CANTTARGET;
LockedEffect.AddToWorld();
return true;
}
示例5: SpawnTimedAdd
/// <summary>
/// Create an add from the specified template.
/// </summary>
/// <param name="templateID"></param>
/// <param name="level"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="uptime"></param>
/// <returns></returns>
protected GameNPC SpawnTimedAdd(int templateID, int level, int x, int y, int uptime, bool isRetriever)
{
GameNPC add = null;
try
{
if (m_addTemplate == null || m_addTemplate.TemplateId != templateID)
{
m_addTemplate = NpcTemplateMgr.GetTemplate(templateID);
}
// Create add from template.
// The add will automatically despawn after 30 seconds.
if (m_addTemplate != null)
{
add = new GameNPC(m_addTemplate);
if (isRetriever)
{
add.SetOwnBrain(new RetrieverMobBrain());
}
add.CurrentRegion = this.CurrentRegion;
add.Heading = (ushort)(Util.Random(0, 4095));
add.Realm = 0;
add.X = x;
add.Y = y;
add.Z = Z;
add.CurrentSpeed = 0;
add.Level = (byte)level;
add.RespawnInterval = -1;
add.AddToWorld();
new DespawnTimer(this, add, uptime * 1000);
}
}
catch
{
log.Warn(String.Format("Unable to get template for {0}", Name));
}
return add;
}
示例6: ApplyEffectOnTarget
/// <summary>
/// Apply effect on target or do spell action if non duration spell
/// </summary>
/// <param name="target">target that gets the effect</param>
/// <param name="effectiveness">factor from 0..1 (0%-100%)</param>
public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
{
GamePlayer player = Caster as GamePlayer;
if (player == null)
{
return;
}
INpcTemplate template = NpcTemplateMgr.GetTemplate(Spell.LifeDrainReturn);
if (template == null)
{
if (log.IsWarnEnabled)
log.WarnFormat("NPC template {0} not found! Spell: {1}", Spell.LifeDrainReturn, Spell.ToString());
MessageToCaster("NPC template " + Spell.LifeDrainReturn + " not found!", eChatType.CT_System);
return;
}
GameSpellEffect effect = CreateSpellEffect(target, effectiveness);
TitanBrain controlledBrain = new TitanBrain(player);
controlledBrain.IsMainPet = false;
controlledBrain.WalkState = eWalkState.Stay;
summoned = new GameNPC(template);
summoned.SetOwnBrain(controlledBrain);
//Suncheck:
// Is needed, else it can cause error (i.e. /cast-command)
if (x == 0 || y == 0)
CheckCastLocation();
summoned.X = x;
summoned.Y = y;
summoned.Z = z;
summoned.CurrentRegion = player.CurrentRegion;
summoned.Heading = (ushort)((player.Heading + 2048) % 4096);
summoned.Realm = player.Realm;
summoned.CurrentSpeed = 0;
summoned.Size = 10;
summoned.Level = 100;
summoned.Flags |= GameNPC.eFlags.PEACE;
summoned.AddToWorld();
controlledBrain.AggressionState = eAggressionState.Aggressive;
effect.Start(summoned);
m_growTimer = new RegionTimer((GameObject)m_caster, new RegionTimerCallback(TitanGrows), C_GROWTIMER);
}
示例7: Zephyr
private void Zephyr(GamePlayer target)
{
if (!target.IsAlive || target.ObjectState != GameLiving.eObjectState.Active) return;
GameNPC npc = new GameNPC();
m_npc = npc;
npc.Realm = Caster.Realm;
npc.Heading = Caster.Heading;
npc.Model = 1269;
npc.Y = Caster.Y;
npc.X = Caster.X;
npc.Z = Caster.Z;
npc.Name = "Forceful Zephyr";
npc.MaxSpeedBase = 400;
npc.Level = 55;
npc.CurrentRegion = Caster.CurrentRegion;
npc.Flags |= GameNPC.eFlags.PEACE;
npc.Flags |= GameNPC.eFlags.DONTSHOWNAME;
npc.Flags |= GameNPC.eFlags.CANTTARGET;
BlankBrain brain = new BlankBrain();
npc.SetOwnBrain(brain);
npc.AddToWorld();
npc.TempProperties.setProperty("target", target);
GameEventMgr.AddHandler(npc, GameNPCEvent.ArriveAtTarget, new DOLEventHandler(ArriveAtTarget));
npc.Follow(target, 10, 1500);
m_target = target;
StartTimer();
}