New Merchant design

Discussions on various DOL development features

Moderator: Support Team

New Merchant design

Postby deathwish » Sun Apr 08, 2012 4:35 pm

I got a new idea for npc merchantsitems,
Every server holds many types of scripts to to turn silly merchants just to select 1 type of merchantitems.
Would it be easier if i remade a version of the NPC merchant script to link the mobs guildname to the merchantitems?

So if you made a new merchant eg, DOL.GS.NewUniMerchant, Set the mobs guild to Epic Armor, it would use Epic Armor as the merchantstradeitems.

It would take alot of database work, to change the merchanttradeitems names to match the guild names, but i dont mind doing them :)

DW

-------------------------------- Test Version .1 --------------------------------------

Right.. here we go, i made a test version, not going to put it under user release yet, want to keep it here for the min, why i remake all the merchantitems for it and fix any bugges i have missed.

How to create use /mob create DOL.GS.NewUniNPC
How to use:
The mobs guild = mobs merchanttradeitems - BP's as defualt
Change the mobs PackageID to BPMerchant for bp's trade window, or NormalMerchant for coin tradewindow.
For Class type merchant, eg, epic armor (can only view items to the players class) use BPClassMerchant for bp's version or NormalClassMerchant for coin version.

With tradeitems like AlbLabbyWeapons if mob.Realm != 0 && mob.PackageID == "BPMerchant/NormalMerchant" - you will not have to have AlbLabbyWeapons as the guild name, the mob will take the players.eRealm and then add the realm part so you dont have to view Alb/mid/hib part if its a merchant in the players realm.

I will Start working on new Merchant items for the merchant right away, just to make them fit the mob guild name better eg change AlbLabWeap to Alb-Labby-Weapons-Merchant, so it looks better ingame ;)

Enjoy please report any bugs or views on this merchant idea :D

DW

------- Added Epic Armor Items to match the npc to use, Set mob guild to Epic Armor and the mob packageID to BPClassMerchant for bps version or NormalClassMerchant for coin version

---- With Labby items -------------
if mob = realm 0, set mob guild to Alb/Hib/Mid Labby Weapons.
if mob is a set realm eg alb, just set mob guild to Labby Weapons.
Remember you can change the type of merchant by setting the mob PackageID to BPMerchant or NormalMerchant for different currenceys

---- Astral items ------
Set mob guild to Astral Armor for armor or Astral Weapons for weapons
Attachments
EpicArmor MerchantItems.rar
(2.53 KiB) Downloaded 49 times
Astral merchantitem.rar
(1.13 KiB) Downloaded 54 times
Labby merchantitem.rar
(4.42 KiB) Downloaded 48 times
New Uni Merchant.rar
(1.76 KiB) Downloaded 57 times
Last edited by deathwish on Sun Apr 08, 2012 10:28 pm, edited 7 times in total.
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby mattress » Sun Apr 08, 2012 4:41 pm

We chatted about this one earlier, I was thinking in addition to what DW setup, adding a realm column to the merchantitem table so when the script checks for guildname to assign merchantlist, it compares merchant realm to the appropriate list before assignment. Also adding a guild column to the merchantitem so the cryptic MerchantItem_ID's won't have to be remapped to current merchants, and making this new merchant a separate class.
Matt450/Variations of "Matt"
User avatar
mattress
Server Team
 
Posts: 277
Joined: Mon Jul 05, 2010 3:30 am
Location: Oceanside, California

Re: New Merchant design

Postby deathwish » Sun Apr 08, 2012 4:50 pm

That can be done within the script very easy, just use the mobs realm :)

eg.
Code: Select all
public override bool Interact(GamePlayer player)
{
if (mob.Realm != 0)
{
TradeItems = new MerchantTradeItems("" + mob.Realm.Name + "" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
else
{
TradeItems = new MerchantTradeItems("" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
Last edited by deathwish on Sun Apr 08, 2012 4:58 pm, edited 1 time in total.
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby mattress » Sun Apr 08, 2012 4:57 pm

With that you'd have to rename every single merchantitem list wouldn't you?
Matt450/Variations of "Matt"
User avatar
mattress
Server Team
 
Posts: 277
Joined: Mon Jul 05, 2010 3:30 am
Location: Oceanside, California

Re: New Merchant design

Postby deathwish » Sun Apr 08, 2012 5:01 pm

hmm, most of them, but most of the itemlists are already set to the merchants name or type, just need to edit somes of them, just to make them fit the guild name
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby deathwish » Sun Apr 08, 2012 5:23 pm

Here i have made the npc to do the following:
If mob realm != 0; it will place mobs realm name afront of the guild name
if mob.MeleeDamageType == 1, sets the npc items to place players classname afront of the guild name for stuff like epic armor
if mob.MeleeDamageType == 2, sets the npc items to place players realm afront of the guild name for stuff like albion armor
Last of all, just select the mobs guildname as MerchantTradeItems
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using DOL.Database;
using DOL.GS.PacketHandler;

namespace DOL.GS
{
public class UniNPC : GameBountyMerchant
{
public void SendMessage(GamePlayer player, string text)
{
player.Out.SendMessage(text, eChatType.CT_Say, eChatLoc.CL_PopupWindow);
}

public override bool Interact(GamePlayer player)
{
if (mob.Realm != 0) // use mobs realm to select MerchantTradeItems for only 1 realm (rvr servers)
{
TradeItems = new MerchantTradeItems("" + mob.Realm.Name + "" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
return true;
}
if (mob.MeleeDamageType == 1) // Use mobs MeleeDamageType to change the mobs items to use CharacterClass Name
{
TradeItems = new MerchantTradeItems("" + player.CharacterClass.Name + "" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
return true;
}
if (mob.MeleeDamageType == 2) // Use mobs MeleeDamageType to change the mobs items to use Character Realm Name (pvp servers)
{
TradeItems = new MerchantTradeItems("" + players.eRealm.Name + "" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
return true;
}
else
{
TradeItems = new MerchantTradeItems("" + mob.GuildName + "");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);

}return true;
}
}
}
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby deathwish » Sun Apr 08, 2012 9:01 pm

Update - Edit First Post
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby Etaew » Sun Apr 08, 2012 9:17 pm

Don't do it on interact, you are changing the entire merchants list for every player when they are clicked on.
LoadFromDatabase or something like that would suffice, after base is called.
Retired DOL Enthusiast | Blog
User avatar
Etaew
Inactive Staff Member
 
Posts: 7602
Joined: Mon Oct 13, 2003 5:04 pm
Website: http://etaew.net
Location: England

Re: New Merchant design

Postby deathwish » Sun Apr 08, 2012 9:23 pm

Once the player has clicked on the merchant and it has send out the merchanttrade window, it shouldn't matter if a different client clicks on it, as it will send them a new window to match that client
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex

Re: New Merchant design

Postby stephenxpimentel » Mon Apr 16, 2012 9:38 pm

it does matter, unfortunatly. this is how i solved the problem when i scripted mine...

Now that i'm thinking about it i tried too hard and made it a bit silly, but it DOES work. I used a temp property.
Code: Select all
/*
* 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.
*
*
* [StephenxPimentel]
* Universal Merchant.
* Add messages to have the NPC open up various merchants.
* Its basically an all-in-one merchant :)
*
* It needs to be tested, but i believe it will work.
*/


using System;
using System.Collections.Generic;
using System.Text;
using DOL.Database;
using DOL.GS.PacketHandler;

namespace DOL.GS
{
public class MerchantArea : Area.Circle
{
public override void OnPlayerEnter(GamePlayer player)
{
player.TempProperties.setProperty("UNI_MERCHANT", "NULL");
base.OnPlayerEnter(player);
}
public override void OnPlayerLeave(GamePlayer player)
{
player.TempProperties.removeProperty("UNI_MERCHANT");
base.OnPlayerLeave(player);
}
public override bool DisplayMessage
{
get
{
return false;
}
}
}
public class UniMerchant : GameBountyMerchant
{
private MerchantArea m_area;

public MerchantArea Area
{
get { return m_area; }
set { m_area = value; }
}
public override bool AddToWorld()
{
if (!(base.AddToWorld()))
return false;

DBArea dbArea = new DBArea();
dbArea.Region = CurrentRegionID;
dbArea.X = X;
dbArea.Y = Y;
dbArea.Z = Z;
dbArea.Radius = 500;
dbArea.AllowAdd = false;

Area = new MerchantArea();
Area.LoadFromDatabase(dbArea);

return true;
}
private const string MERCHANT_KEY = "UNI_MERCHANT";

public void SendMessage(GamePlayer player, string text)
{
player.Out.SendMessage(text, eChatType.CT_Say, eChatLoc.CL_PopupWindow);
}

public override bool Interact(GamePlayer player)
{
SendMessage(player, "What would you like to buy?:\n");
SendMessage(player, "*[Dragonslayer Armor]");
SendMessage(player, "*[Dragonslayer Weapons]");
SendMessage(player, "*[Dragon Weapons]");
SendMessage(player, "*[Artifact Armor]");
SendMessage(player, "*[Artifact Weapons]");
SendMessage(player, "*[Artifact Jewelry]");
SendMessage(player, "*[Labyrinth Weapons]");
SendMessage(player, "*[Mythirians]");
SendMessage(player, "*[Jewelry]");
SendMessage(player, "*[Procs]");
SendMessage(player, "*[Charges]");
return true;
}

public override void OnPlayerBuy(GamePlayer player, int item_slot, int number)
{
TradeItems = new MerchantTradeItems(player.TempProperties.getProperty<string>(MERCHANT_KEY));
base.OnPlayerBuy(player, item_slot, number);
}

public override bool WhisperReceive(GameLiving source, string text)
{
if (!(base.WhisperReceive(source, text)))
return false;

GamePlayer player = source as GamePlayer;
switch (text)
{
case "Artifact Armor":
{
switch (player.Realm)
{
case eRealm.Albion:
{
player.TempProperties.setProperty(MERCHANT_KEY, "AlbArtArmor");
TradeItems = new MerchantTradeItems("AlbArtArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Hibernia:
{
player.TempProperties.setProperty(MERCHANT_KEY, "HibArtArmor");
TradeItems = new MerchantTradeItems("HibArtArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Midgard:
{
player.TempProperties.setProperty(MERCHANT_KEY, "MidArtArmor");
TradeItems = new MerchantTradeItems("MidArtArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}
}
break;
case "Artifact Weapons":
{
switch (player.Realm)
{
case eRealm.Albion:
{
player.TempProperties.setProperty(MERCHANT_KEY, "AlbArtWeaps");
TradeItems = new MerchantTradeItems("AlbArtWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Hibernia:
{
player.TempProperties.setProperty(MERCHANT_KEY, "HibArtWeaps");
TradeItems = new MerchantTradeItems("HibArtWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Midgard:
{
player.TempProperties.setProperty(MERCHANT_KEY, "MidArtWeaps");
TradeItems = new MerchantTradeItems("MidArtWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}
}
break;
case "Artifact Jewelry":
{
player.TempProperties.setProperty(MERCHANT_KEY, "ArtItems");
TradeItems = new MerchantTradeItems("ArtItems");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case "Jewelry":
{
player.TempProperties.setProperty(MERCHANT_KEY, "FringeJewelry");
TradeItems = new MerchantTradeItems("FringeJewelry");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case "Mythirians":
{
player.TempProperties.setProperty(MERCHANT_KEY, "fringe_mythis");
TradeItems = new MerchantTradeItems("fringe_mythis");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case "Dragon Weapons":
{
player.TempProperties.setProperty(MERCHANT_KEY, "DragonWeapons");
TradeItems = new MerchantTradeItems("DragonWeapons");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case "Labyrinth Weapons":
{
switch (player.Realm)
{
case eRealm.Albion:
{
player.TempProperties.setProperty(MERCHANT_KEY, "AlbLabWeaps");
TradeItems = new MerchantTradeItems("AlbLabWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Hibernia:
{
player.TempProperties.setProperty(MERCHANT_KEY, "HibLabWeaps");
TradeItems = new MerchantTradeItems("HibLabWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Midgard:
{
player.TempProperties.setProperty(MERCHANT_KEY, "MidLabWeaps");
TradeItems = new MerchantTradeItems("MidLabWeaps");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}
}
break;
case "Dragonslayer Armor":
{
switch (player.Realm)
{
case eRealm.Albion:
{
player.TempProperties.setProperty(MERCHANT_KEY, "AlbionDragonslayerArmor");
TradeItems = new MerchantTradeItems("AlbionDragonslayerArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Hibernia:
{
player.TempProperties.setProperty(MERCHANT_KEY, "HiberniaDragonslayerArmor");
TradeItems = new MerchantTradeItems("HiberniaDragonslayerArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Midgard:
{
player.TempProperties.setProperty(MERCHANT_KEY, "MidgardDragonslayerArmor");
TradeItems = new MerchantTradeItems("MidgardDragonslayerArmor");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}
}
break;
case "Dragonslayer Weapons":
{
switch (player.Realm)
{
case eRealm.Albion:
{
player.TempProperties.setProperty(MERCHANT_KEY, "AlbionDragonWeapons");
TradeItems = new MerchantTradeItems("AlbionDragonWeapons");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Hibernia:
{
player.TempProperties.setProperty(MERCHANT_KEY, "HiberniaDragonWeapons");
TradeItems = new MerchantTradeItems("HiberniaDragonWeapons");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case eRealm.Midgard:
{
player.TempProperties.setProperty(MERCHANT_KEY, "MidgardDragonWeapons");
TradeItems = new MerchantTradeItems("MidgardDragonWeapons");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}
}
break;

case "Procs":
{
player.TempProperties.setProperty(MERCHANT_KEY, "procs");
TradeItems = new MerchantTradeItems("procs");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
case "Charges":
{
player.TempProperties.setProperty(MERCHANT_KEY, "charges");
TradeItems = new MerchantTradeItems("charges");
player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
}
break;
}

return true;
}
}
}

Notice that OnPlayerBuy method checks the temp property and reloads the correct one BEFORE the buy code is called, so that the players get the correct item. If you don't do something like this, then the merchant will visually be the correct merchant, but its sell list is not, and you WILL receive the wrong item.
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: New Merchant design

Postby deathwish » Tue Apr 17, 2012 11:41 am

Then i better update my version ^^ thx you :D
- Terry - terryammon
User avatar
deathwish
Database Team
 
Posts: 483
Joined: Sun Jul 05, 2009 10:15 pm
Location: England / Essex


Return to “%s” DOL Development Discussion

Who is online

Users browsing this forum: No registered users and 1 guest