/// <summary> /// The callback function that will remove this bag after some time /// </summary> protected override void OnTick() { GameStaticItem item = (GameStaticItem)m_actionSource; // remove this object from the world after some time item.Delete(); }
public override void Stop() { if (_cauldron != null) { _cauldron.Delete(); _cauldron = null; } if (_effectOwner != null) { GameEventMgr.RemoveHandler(_effectOwner, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld)); } base.Stop(); }
public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } string param = string.Empty; if (args.Length > 2) { param = string.Join(" ", args, 2, args.Length - 2); } GameStaticItem targetObject = client.Player.TargetObject as GameStaticItem; if (targetObject == null && args[1] != "create" && args[1] != "fastcreate" && args[1] != "target" && args[1] != "quests") { client.Out.SendMessage("Type /object for command overview", eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } switch (args[1]) { case "info": { List <string> info = new List <string>(); string name = "(blank name)"; if (!string.IsNullOrEmpty(targetObject.Name)) { name = targetObject.Name; } info.Add(" OID: " + targetObject.ObjectID); info.Add(" Type: " + targetObject.GetType()); info.Add(" "); info.Add(" Name: " + name); info.Add(" Model: " + targetObject.Model); info.Add(" Emblem: " + targetObject.Emblem); info.Add(" Realm: " + targetObject.Realm); if (targetObject.Owners.LongLength > 0) { info.Add(" "); info.Add(" Owner: " + targetObject.Owners[0].Name); } if (string.IsNullOrEmpty(targetObject.OwnerID) == false) { info.Add(" "); info.Add(" OwnerID: " + targetObject.OwnerID); } if (targetObject.RespawnInterval > 0) { info.Add("RespawnInterval (seconds): " + targetObject.RespawnInterval); } info.Add(" "); WorldInventoryItem invItem = targetObject as WorldInventoryItem; if (invItem != null) { info.Add(" Count: " + invItem.Item.Count); } info.Add(" "); info.Add(" Location: X= " + targetObject.X + " ,Y= " + targetObject.Y + " ,Z= " + targetObject.Z); client.Out.SendCustomTextWindow("[ " + name + " ]", info); break; } case "movehere": { targetObject.X = client.Player.X; targetObject.Y = client.Player.Y; targetObject.Z = client.Player.Z; targetObject.Heading = client.Player.Heading; targetObject.SaveIntoDatabase(); break; } case "create": { string theType = "DOL.GS.GameStaticItem"; if (args.Length > 2) { theType = args[2]; } GameStaticItem obj = CreateItem(client, theType); if (obj != null) { DisplayMessage(client, "Obj created: OID=" + obj.ObjectID); } break; } case "fastcreate": { string objName = "new object"; ushort modelID = 100; if (args.Length > 2) { objName = args[2]; } if (args.Length > 3) { ushort.TryParse(args[3], out modelID); } GameStaticItem obj = CreateItem(client, null); if (obj != null) { obj.Name = objName; obj.Model = modelID; DisplayMessage(client, "Object created: OID = " + obj.ObjectID); } break; } case "model": { ushort model; try { model = Convert.ToUInt16(args[2]); targetObject.Model = model; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object model changed to: " + targetObject.Model); } catch (Exception) { DisplayMessage(client, "Type /object for command overview"); return; } break; } case "modelinc": { ushort model = targetObject.Model; try { if (model < 4249) { model++; targetObject.Model = model; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object model changed to: " + targetObject.Model); } else { DisplayMessage(client, "Highest object model reached!"); } } catch (Exception) { DisplayMessage(client, "Type /object for command overview"); return; } break; } case "modeldec": { ushort model = targetObject.Model; try { if (model != 1) { model--; targetObject.Model = model; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object model changed to: " + targetObject.Model); } else { DisplayMessage(client, "Object model cannot be 0!"); } } catch (Exception) { DisplayMessage(client, "Type /object for command overview"); return; } break; } case "emblem": { int emblem; try { emblem = Convert.ToInt32(args[2]); targetObject.Emblem = emblem; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object emblem changed to: " + targetObject.Emblem); } catch (Exception) { DisplayMessage(client, "Type /object for command overview"); return; } break; } case "realm": { eRealm realm = eRealm.None; if (args[2] == "0") { realm = eRealm.None; } if (args[2] == "1") { realm = eRealm.Albion; } if (args[2] == "2") { realm = eRealm.Midgard; } if (args[2] == "3") { realm = eRealm.Hibernia; } targetObject.Realm = realm; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object realm changed to: " + targetObject.Realm); break; } case "name": { if (param != string.Empty) { targetObject.Name = param; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object name changed to: " + targetObject.Name); } break; } case "noname": { targetObject.Name = string.Empty; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object name removed"); break; } case "copy": { GameStaticItem item = CreateItemInstance(client, targetObject.GetType().FullName); if (item == null) { ChatUtil.SendSystemMessage(client, "There was an error creating an instance of " + targetObject.GetType().FullName + "!"); return; } item.X = client.Player.X; item.Y = client.Player.Y; item.Z = client.Player.Z; item.CurrentRegion = client.Player.CurrentRegion; item.Heading = client.Player.Heading; item.Level = targetObject.Level; item.Name = targetObject.Name; item.Model = targetObject.Model; item.Realm = targetObject.Realm; item.Emblem = targetObject.Emblem; item.LoadedFromScript = targetObject.LoadedFromScript; item.AddToWorld(); item.SaveIntoDatabase(); DisplayMessage(client, "Obj created: OID=" + item.ObjectID); break; } case "save": { targetObject.LoadedFromScript = false; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object saved to Database"); break; } case "remove": { targetObject.DeleteFromDatabase(); targetObject.Delete(); DisplayMessage(client, "Object removed from Clients and Database"); break; } case "target": { foreach (GameStaticItem item in client.Player.GetItemsInRadius(1000)) { client.Player.TargetObject = item; DisplayMessage(client, "Target set to nearest object!"); return; } DisplayMessage(client, "No objects in 1000 unit range!"); break; } case "respawn": { int respawn = 0; if (int.TryParse(args[2], out respawn)) { targetObject.RespawnInterval = respawn; targetObject.SaveIntoDatabase(); DisplayMessage(client, "Object RespawnInterval set to " + targetObject.RespawnInterval + " seconds."); } break; } case "quests": { try { GameObject.FillDataQuestCache(); client.Player.TargetObject.LoadDataQuests(); if (client.Player.TargetObject is GameNPC) { foreach (GamePlayer player in client.Player.TargetObject.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { player.Out.SendNPCsQuestEffect(client.Player.TargetObject as GameNPC, (client.Player.TargetObject as GameNPC).GetQuestIndicator(player)); } } client.Out.SendMessage(targetObject.DataQuestList.Count + " Data Quests loaded for this object.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } catch (Exception) { DisplayMessage(client, "Error refreshing quests."); } break; } } }