/// <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(); }
GameStaticItem CreateItem(GameClient client, string itemClassName) { GameStaticItem obj; if (!string.IsNullOrEmpty(itemClassName)) { obj = CreateItemInstance(client, itemClassName); } else { obj = new GameStaticItem(); } if (obj == null) { client.Out.SendMessage("There was an error creating an instance of " + itemClassName + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow); return(null); } // Fill the object variables obj.LoadedFromScript = false; obj.X = client.Player.X; obj.Y = client.Player.Y; obj.Z = client.Player.Z; obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = "New Object"; obj.Model = 100; obj.Emblem = 0; obj.Realm = 0; obj.AddToWorld(); obj.SaveIntoDatabase(); return(obj); }
private void CreateTempPathObject(GameClient client, PathPoint pp, string name) { // Create a new object GameStaticItem obj = new GameStaticItem(); // Fill the object variables obj.X = pp.X; obj.Y = pp.Y; obj.Z = pp.Z + 1; // raise a bit off of ground level obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = name; obj.Model = 488; obj.Emblem = 0; obj.AddToWorld(); ArrayList objs = (ArrayList)client.Player.TempProperties.getProperty <object>(TEMP_PATH_OBJS, null); if (objs == null) { objs = new ArrayList(); } objs.Add(obj); client.Player.TempProperties.setProperty(TEMP_PATH_OBJS, objs); }
GameStaticItem CreateItemInstance(GameClient client, string itemClassName) { GameStaticItem obj = null; ArrayList asms = new ArrayList(ScriptMgr.Scripts); asms.Add(typeof(GameServer).Assembly); foreach (Assembly script in asms) { try { client.Out.SendDebugMessage(script.FullName); obj = (GameStaticItem)script.CreateInstance(itemClassName, false); if (obj != null) { break; } } catch (Exception e) { DisplayMessage(client, e.ToString()); } } return(obj); }
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 override void Stop() { if (_cauldron != null) { _cauldron.Delete(); _cauldron = null; } if (_effectOwner != null) { GameEventMgr.RemoveHandler(_effectOwner, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld)); } base.Stop(); }
// Summon the cauldron private void SummonCauldron() { Cauldron = new GameStaticItem(); Cauldron.CurrentRegion = EffectOwner.CurrentRegion; Cauldron.Heading = (ushort)((EffectOwner.Heading + 2048) % 4096); Cauldron.Level = cauldronLevel; Cauldron.Realm = EffectOwner.Realm; Cauldron.Name = cauldronName; Cauldron.Model = cauldronModel; Cauldron.Position = EffectOwner.Position; Cauldron.AddToWorld(); new RegionTimer(EffectOwner, new RegionTimerCallback(CauldronCallBack), RealmAbilities.BoilingCauldronAbility.DURATION - 1000); }
// Summon the cauldron private void SummonCauldron() { Cauldron = new GameStaticItem(); Cauldron.CurrentRegion = EffectOwner.CurrentRegion; Cauldron.Heading = (ushort)((EffectOwner.Heading + 2048) % 4096); Cauldron.Level = cauldronLevel; Cauldron.Realm = EffectOwner.Realm; Cauldron.Name = cauldronName; Cauldron.Model = cauldronModel; Cauldron.X = EffectOwner.X; Cauldron.Y = EffectOwner.Y; Cauldron.Z = EffectOwner.Z; Cauldron.AddToWorld(); new RegionTimer(EffectOwner, new RegionTimerCallback(CauldronCallBack), RealmAbilities.BoilingCauldronAbility.DURATION - 1000); }
// Summon the cauldron private void SummonCauldron() { _cauldron = new GameStaticItem(); _cauldron.CurrentRegion = _effectOwner.CurrentRegion; _cauldron.Heading = (ushort)((_effectOwner.Heading + 2048) % 4096); _cauldron.Level = CauldronLevel; _cauldron.Realm = _effectOwner.Realm; _cauldron.Name = CauldronName; _cauldron.Model = CauldronModel; _cauldron.X = _effectOwner.X; _cauldron.Y = _effectOwner.Y; _cauldron.Z = _effectOwner.Z; _cauldron.AddToWorld(); new RegionTimer(_effectOwner, new RegionTimerCallback(CauldronCallBack), Duration - 1000); }
/// <summary> /// We are interacting with an object, check to see if this quest and step needs to respond /// </summary> /// <param name="player"></param> /// <param name="staticItem"></param> protected void InteractWithObject(GamePlayer player, GameStaticItem staticItem) { if (m_interactions.Count > 0) { if (m_interactions.ContainsKey(Step)) { QuestStepInteraction info = m_interactions[Step]; if (staticItem.Name == info.objectName) { if (GiveItem(player, info.itemResult, false)) { player.Out.SendMessage(info.interactText, eChatType.CT_System, eChatLoc.CL_SystemWindow); staticItem.RemoveFromWorld(INTERACT_ITEM_RESPAWN_SECONDS); OnObjectInteract(info); } } } } }
private void CreateTempPathObject(GameClient client, PathPoint pp, string name) { GameStaticItem obj = new GameStaticItem(); obj.Position = pp.Position; obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = name; obj.Model = 488; obj.Emblem = 0; obj.AddToWorld(); ArrayList objs = (ArrayList)client.Player.TempProperties.getProperty <object>(TEMP_PATH_OBJS, null); if (objs == null) { objs = new ArrayList(); } objs.Add(obj); client.Player.TempProperties.setProperty(TEMP_PATH_OBJS, objs); }
/// <summary> /// We are interacting with an object, check to see if this quest and step needs to respond /// </summary> /// <param name="player"></param> /// <param name="staticItem"></param> protected void InteractWithObject(GamePlayer player, GameStaticItem staticItem) { if (_interactions.Count > 0) { if (_interactions.ContainsKey(Step)) { QuestStepInteraction info = _interactions[Step]; if (staticItem.Name == info.ObjectName) { if (GiveItem(player, info.ItemResult, false)) { player.Out.SendMessage(info.InteractText, eChatType.CT_System, eChatLoc.CL_SystemWindow); staticItem.RemoveFromWorld(InteractItemRespawnSeconds); OnObjectInteract(info); } } } } }
private void CreateTempPathObject(GameClient client, PathPoint pp, String name) { //Create a new object GameStaticItem obj = new GameStaticItem(); //Fill the object variables obj.X = pp.X; obj.Y = pp.Y; obj.Z = pp.Z + 1; // raise a bit off of ground level obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = name; obj.Model = 488; obj.Emblem = 0; obj.AddToWorld(); ArrayList objs = (ArrayList)client.Player.TempProperties.getProperty<object>(TEMP_PATH_OBJS, null); if (objs == null) objs = new ArrayList(); objs.Add(obj); client.Player.TempProperties.setProperty(TEMP_PATH_OBJS, objs); }
public virtual GameStaticItem PlaceHousingInteriorItem(DOL.GS.Housing.House house, ItemTemplate item, IPoint3D location, ushort heading) { GameStaticItem hookpointObject = new GameStaticItem(); hookpointObject.CurrentHouse = house; hookpointObject.InHouse = true; hookpointObject.OwnerID = item.Id_nb; hookpointObject.X = location.X; hookpointObject.Y = location.Y; hookpointObject.Z = location.Z; hookpointObject.Heading = heading; hookpointObject.CurrentRegionID = house.RegionID; hookpointObject.Name = item.Name; hookpointObject.Model = (ushort)item.Model; hookpointObject.AddToWorld(); return hookpointObject; }
GameStaticItem CreateItem(GameClient client, string itemClassName) { GameStaticItem obj; if (!string.IsNullOrEmpty(itemClassName)) obj = CreateItemInstance(client, itemClassName); else obj = new GameStaticItem(); if (obj == null) { client.Out.SendMessage( "There was an error creating an instance of " + itemClassName + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow ); return null; } //Fill the object variables obj.LoadedFromScript = false; obj.X = client.Player.X; obj.Y = client.Player.Y; obj.Z = client.Player.Z; obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = "New Object"; obj.Model = 100; obj.Emblem = 0; obj.Realm = 0; obj.AddToWorld(); obj.SaveIntoDatabase(); return obj; }
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; } } }
private void CreateTempPathObject(GameClient client, PathPoint pp, string name) { GameStaticItem obj = new GameStaticItem(); obj.X = pp.X; obj.Y = pp.Y; obj.Z = pp.Z; obj.CurrentRegion = client.Player.CurrentRegion; obj.Heading = client.Player.Heading; obj.Name = name; obj.Model = 488; obj.Emblem = 0; obj.AddToWorld(); ArrayList objs = (ArrayList)client.Player.TempProperties.getProperty<object>(TEMP_PATH_OBJS, null); if (objs == null) objs = new ArrayList(); objs.Add(obj); client.Player.TempProperties.setProperty(TEMP_PATH_OBJS, objs); }
/// <summary> /// Creates a tomte hockey game using the coordinates of the judge. /// </summary> /// <param name="judge"></param> public TomteHockeyGame(GameNPC judge) { //We used to use the same x-position as the judge. //However this meant he often 'got in the way' of the games, standing in the middle of the court. Nowadays, we //Use his basis for positioning, but as we can't move him lest the server reboot and reloads him in his altered //position, creating a moved game, we shall simply place him at the side to start. m_xsize = 700; m_ysize = 1150; m_x = judge.X + XSize / 2 + 50; m_y = judge.Y; m_z = judge.Z; m_region = judge.CurrentRegionID; //Initialise rules stuff... m_playerCount = 4; m_canUseMagic = false; m_repositionplayersonGoal = false; //Set the match to 'awaiting players'. playState = ePlayState.Waiting; //We initialise these variables to prevent any nullref exceptions later on. m_playingPlayers = new List <GamePlayer>(); m_blueTeam = new List <GamePlayer>(); m_redTeam = new List <GamePlayer>(); //This section constructs the hockey court. Feel free to use the basis for other interesting games! #region Build match... //Create marker npcs to illustrate the pitch size! //3 along the sides. for (int x = -1; x < 2; x++) { for (int y = 1; y < 4; y++) { if (x == 0) //to prevent single split down the middle. { continue; } int ybias = 2 - y; TomteMarker npc = new TomteMarker(); npc.X = X + XSize * x / 2; npc.Y = Y + YSize * (2 - y) / 2; npc.Z = Z; npc.CurrentRegionID = Region; npc.AddToWorld(); npc.TurnTo(X, Y, true); } } //Create the goal posts. for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { if (y == 0 || x == 0) { continue; } GameStaticItem goalpost = new GameStaticItem(); goalpost.Model = 2963; goalpost.X = X + XSize * x / 4; goalpost.Y = Y + YSize * y / 2; goalpost.Z = Z; goalpost.CurrentRegionID = Region; goalpost.Name = "Goalpost"; //Goalpost colour names... goalpost.Name += (y > 0) ? " [Blue]" : " [Red]"; goalpost.AddToWorld(); } } //Create the colored goal markers... for (int y = -1; y < 2; y++) { if (y == 0) { continue; } TomteMarker stick = new TomteMarker(); if (y > 0) { stick.Model = 907; //Blue goal orb. } else { stick.Model = 908; //Red goal orb. } stick.X = X; stick.Y = Y + YSize * y / 2; stick.Z = Z; stick.CurrentRegionID = Region; stick.Name = "Big Goal Thing"; //Goalpost colour names... stick.Name += (y > 0) ? " [Blue]" : " [Red]"; stick.AddToWorld(); } #endregion }
/// <summary> /// Fill a hookpoint with an object, create it in the database. /// </summary> /// <param name="item">The itemtemplate of the item used to fill the hookpoint (can be null if templateid is filled)</param> /// <param name="position">The position of the hookpoint</param> /// <param name="templateID">The template id of the item (can be blank if item is filled)</param> /// <param name="heading">The requested heading of this house item</param> public bool FillHookpoint(uint position, string templateID, ushort heading, int index) { ItemTemplate item = GameServer.Database.FindObjectByKey<ItemTemplate>(templateID); if (item == null) return false; //get location from slot IPoint3D location = GetHookpointLocation(position); if (location == null) return false; int x = location.X; int y = location.Y; int z = location.Z; GameObject hookpointObject = null; switch ((eObjectType)item.Object_Type) { case eObjectType.HouseVault: { var houseVault = new GameHouseVault(item, index); houseVault.Attach(this, position, heading); hookpointObject = houseVault; break; } case eObjectType.HouseNPC: { hookpointObject = GameServer.ServerRules.PlaceHousingNPC(this, item, location, GetHookpointHeading(position)); break; } case eObjectType.HouseBindstone: { hookpointObject = new GameStaticItem(); hookpointObject.CurrentHouse = this; hookpointObject.InHouse = true; hookpointObject.OwnerID = templateID; hookpointObject.X = x; hookpointObject.Y = y; hookpointObject.Z = z; hookpointObject.Heading = heading; hookpointObject.CurrentRegionID = RegionID; hookpointObject.Name = item.Name; hookpointObject.Model = (ushort) item.Model; hookpointObject.AddToWorld(); //0:07:45.984 S=>C 0xD9 item/door create v171 (oid:0x0DDB emblem:0x0000 heading:0x0DE5 x:596203 y:530174 z:24723 model:0x05D2 health: 0% flags:0x04(realm:0) extraBytes:0 unk1_171:0x0096220C name:"Hibernia bindstone") //add bind point break; } case eObjectType.HouseInteriorObject: { hookpointObject = GameServer.ServerRules.PlaceHousingInteriorItem(this, item, location, heading); break; } } if (hookpointObject != null) { HousepointItems[position].GameObject = hookpointObject; return true; } return false; }