Skip to content

Commit

Permalink
New InventoryItem subclasses to create catapult, ballista and trebuch…
Browse files Browse the repository at this point in the history
…et on battlegrounds (#395)

This PR will be linked to another PR on the db-public repo to have the corresponding 3 new ItemTemplates to complete this enhancement

Co-authored-by: DigitalBox98 <[email protected]>
  • Loading branch information
DigitalBox98 and DigitalBox98 authored Jul 1, 2022
1 parent 888aa8b commit 6002416
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 0 deletions.
90 changes: 90 additions & 0 deletions GameServer/gameobjects/InventoryItem/GameInventorySiegeBallista.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;
using System.Reflection;
using System.Collections.Generic;

using DOL.Language;
using DOL.GS.PacketHandler;
using DOL.Database;
using DOL.GS.Spells;

using log4net;

namespace DOL.GS
{
/// <summary>
/// This class represents a Siege Ballista inventory item
/// </summary>
public class GameInventorySiegeBallista : GameInventoryItem, IGameInventoryItem, ITranslatableObject
{

public GameInventorySiegeBallista()
: base()
{
}

public GameInventorySiegeBallista(ItemTemplate template)
: base(template)
{
}

public GameInventorySiegeBallista(ItemUnique template)
: base(template)
{
}

public GameInventorySiegeBallista(InventoryItem item)
: base(item)
{
OwnerID = item.OwnerID;
ObjectId = item.ObjectId;
}


/// <summary>
/// Try and use this item
/// </summary>
/// <param name="player"></param>
/// <returns>true if item use is handled here</returns>
public bool Use(GamePlayer player)
{
// Create the siege ballista
GameSiegeBallista bal = new GameSiegeBallista();

// Level, name and model of the siege ballista are retrieved from the inventory item
bal.Level = Convert.ToByte(Level);
bal.Name = Name;
bal.Model = (ushort) Model;
bal.X = player.X;
bal.Y = player.Y;
bal.Z = player.Z;
bal.CurrentRegion = player.CurrentRegion;
bal.Realm = player.Realm;
bal.AddToWorld();

// Remove current item from player's inventory
InventoryItem item = player.Inventory.GetItem((eInventorySlot)SlotPosition);
player.Inventory.RemoveItem(item);

return true;
}
}

}
90 changes: 90 additions & 0 deletions GameServer/gameobjects/InventoryItem/GameInventorySiegeCatapult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;
using System.Reflection;
using System.Collections.Generic;

using DOL.Language;
using DOL.GS.PacketHandler;
using DOL.Database;
using DOL.GS.Spells;

using log4net;

namespace DOL.GS
{
/// <summary>
/// This class represents a Siege Catapult inventory item
/// </summary>
public class GameInventorySiegeCatapult : GameInventoryItem, IGameInventoryItem, ITranslatableObject
{

public GameInventorySiegeCatapult()
: base()
{
}

public GameInventorySiegeCatapult(ItemTemplate template)
: base(template)
{
}

public GameInventorySiegeCatapult(ItemUnique template)
: base(template)
{
}

public GameInventorySiegeCatapult(InventoryItem item)
: base(item)
{
OwnerID = item.OwnerID;
ObjectId = item.ObjectId;
}


/// <summary>
/// Try and use this item
/// </summary>
/// <param name="player"></param>
/// <returns>true if item use is handled here</returns>
public bool Use(GamePlayer player)
{
// Create the siege catapult
GameSiegeCatapult cat = new GameSiegeCatapult();

// Level, name and model of the siege catapult are retrieved from the inventory item
cat.Level = Convert.ToByte(Level);
cat.Name = Name;
cat.Model = (ushort) Model;
cat.X = player.X;
cat.Y = player.Y;
cat.Z = player.Z;
cat.CurrentRegion = player.CurrentRegion;
cat.Realm = player.Realm;
cat.AddToWorld();

// Remove current item from player's inventory
InventoryItem item = player.Inventory.GetItem((eInventorySlot)SlotPosition);
player.Inventory.RemoveItem(item);

return true;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;
using System.Reflection;
using System.Collections.Generic;

using DOL.Language;
using DOL.GS.PacketHandler;
using DOL.Database;
using DOL.GS.Spells;

using log4net;

namespace DOL.GS
{
/// <summary>
/// This class represents a Siege Trebuchet inventory item
/// </summary>
public class GameInventorySiegeTrebuchet : GameInventoryItem, IGameInventoryItem, ITranslatableObject
{

public GameInventorySiegeTrebuchet()
: base()
{
}

public GameInventorySiegeTrebuchet(ItemTemplate template)
: base(template)
{
}

public GameInventorySiegeTrebuchet(ItemUnique template)
: base(template)
{
}

public GameInventorySiegeTrebuchet(InventoryItem item)
: base(item)
{
OwnerID = item.OwnerID;
ObjectId = item.ObjectId;
}


/// <summary>
/// Try and use this item
/// </summary>
/// <param name="player"></param>
/// <returns>true if item use is handled here</returns>
public bool Use(GamePlayer player)
{
// Create the siege trebuchet
GameSiegeBallista bal = new GameSiegeBallista();

// Level, name and model of the siege trebuchet are retrieved from the inventory item
bal.Level = Convert.ToByte(Level);
bal.Name = Name;
bal.Model = (ushort) Model;
bal.X = player.X;
bal.Y = player.Y;
bal.Z = player.Z;
bal.CurrentRegion = player.CurrentRegion;
bal.Realm = player.Realm;
bal.AddToWorld();

// Remove current item from player's inventory
InventoryItem item = player.Inventory.GetItem((eInventorySlot)SlotPosition);
player.Inventory.RemoveItem(item);

return true;
}
}

}

0 comments on commit 6002416

Please sign in to comment.