Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 23:26

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



How To Do An Item Check On Kill

Discussion on How To Do An Item Check On Kill within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
How To Do An Item Check On Kill

Can anyone help with the code below to add a check on the person having a specific item equipped when they kill the monster, For instance they would only get the reward if they had a hammer equipped when they kill that monster?

Code:
            if (this.Name == "Phesant")

            {

                {

                    killer.SubClasses.StudyPoints += 100;

                    ServerBase.Kernel.SendWorldMessage(new Network.GamePackets.Message("  " + killer.Name + "Has Killed " + Owner.Name + " And Take 10000 StudyPoints!", System.Drawing.Color.Yellow, 2011), ServerBase.Kernel.GamePool.Values);

                }

            }
ajstyles316 is offline  
Old 01/23/2013, 11:17   #2
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
trinity base ?
if (client.inventory.contains(uid,times))
{

}
and it's way better to do this.ID == mobID so you don't break point alot debugging to figure out you got a typo to figure out it's "Pheasant" and not "Phesant"
go for it is offline  
Old 01/23/2013, 11:35   #3
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
Haha yeah i had just noticed it was spelt wrong, Thanks for the advice i shall look at switching names to ID's, wouldnt: if (client.inventory.contains(uid,times)) only check if the item was in the persons inventory and not actually equipped in there hand when they killed the mob? And yes trinity based source.
ajstyles316 is offline  
Old 01/23/2013, 12:04   #4
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
sorry i was in rush didn't read well you want to check if it's equipped
you need a bool at entinity, set this bool from
set it from public static void EquipItem(ItemUsage itemUsage, GameState client , byte[] packet)
also from public static void UnequipItem(ItemUsage usage, GameState client)

once on equip to set it to true
once on unequip to set it on false
you gona do the check at EquipItem UnequipItem with the item id you will get in the packets , you don't need to know much about the structure of packets you get on eq/ueq because it's already done in there , but it's way better to have a look at the packet handlers to understand the source

and finally you will do the check on killing monster with your bool
sorry for my poor english , feel free to pm me if you failed (gota show me what you done cuz i won't do it for you just help out)

and to avoid anyone say it's not efficient way i never said it is , it's just an example
goodluck mate

EDIT:
i've gave it a try , item id at those methods (eq,uneq) is static as it get that static id from the dynamic id throw "TryGetItem" method , so yup all you need to do is create item or get any item id from itemtype
and do the following
at entinity
Code:
        public bool IsWearingTheItem { get; set; }
at the packet handler add this
at EquipItem
Code:
if (item.ID == itemid) client.Entity.IsWearingTheItem = true;
and it's inverse at unequip

then at the monsterinfo
do the check as simple as this
Code:
             if (killer.IsWearingTheItem)
            {

            }
that's it
go for it is offline  
Thanks
2 Users
Old 01/23/2013, 15:57   #5
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
Thanks just got home n gave it a quick test, Seems to work But if you just right click another weapon in your inventory to equip it then it seems to not notice the previous weapon has been removed, but works fine when you open the char screen n take the weapon off manually. So im wondering if right clicking to equip another item is handled differently to just taking it off manually, Going to have a look in a min.
ajstyles316 is offline  
Old 01/23/2013, 16:18   #6
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
well at the public static void EquipItem(ItemUsage itemUsage, GameState client , byte[] packet)
add check for the item position , if it's as same position as your item then set your bool to false
if you are good to go lemme know , if you need it in way of codes then tell me what your item position is or what it is so i give you the check can't debug with some break points atm cuz i've removed every npc and re-coding them in better way , will check it out once im done and shoot you pm or edit this post
goodluck
edit : should be something like this

Code:
Positions YourItemPos = GetPositionFromID(YourItemId); //this is how to get your item position


                    if (positionFromID == YourItemPos )
                    client.Entity.IsWearingTheItem = false;
go for it is offline  
Thanks
1 User
Old 01/23/2013, 17:48   #7
 
elite*gold: 0
Join Date: Jan 2013
Posts: 24
Received Thanks: 0
I fixed it by just putting all of it in the equip code like:

Code:
if (item.ID == itemid) client.Entity.IsWearingTheItem = true;
else
client.Entity.IsWearingTheItem = false;
which seems to work fine and covers all angles, Thanks for you help


Works well for a little timed event, spawning a bunch of monsters at certain times of the day for a short while. Orignal idea was bopping moles on the head with a hammer for points & prizes but as we dont have moles in this game will have to find another creature worthy of bashing on the head with a hammer, lol
ajstyles316 is offline  
Old 01/23/2013, 18:27   #8
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
goodluck mate
go for it is offline  
Reply


Similar Threads Similar Threads
Check whether user already item has
09/03/2012 - EO PServer Hosting - 2 Replies
Hello, I would like create a test, User can only 1x buy and use only 1x VIP5 Ticket if it is already active. Checking whether the user has the item I would have to implement so I think i must check in cq_item OwnerID and TYPE when it comes to the purchase OwnerID = Owner/User
How to check id of an item...
12/04/2008 - World of Warcraft - 5 Replies
Like in the topic: I want to know can I and how to check id number of an item on a private server.
item price check
02/06/2008 - Silkroad Online - 1 Replies
pacific 5th degree sos bow with +3 int, and 2 other blues as well as a high critical... how many mil? chinese



All times are GMT +2. The time now is 23:26.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.