[Rhisis] Rhisis Emulator, inventory.

Results 1 to 8 of 8
  1. #1
    Member Dumle is offline
    MemberRank
    Nov 2008 Join Date
    SwedenLocation
    82Posts

    [Rhisis] Rhisis Emulator, inventory.

    Hey everyone! I've been working at the Rhisis emulator source for some days and mainly focused on the inventory part. But I can't get the item stacking to work properly.

    I've gotten one slot working but when the other ones are trying to stack it turns out like this:



    I've been working on this part for some hours now and starts to get abit irritated :3
    If someone has gotten this to work, please show me how you did :)
    Last edited by Dumle; 08-04-09 at 02:03 PM.


  2. #2
    Enthusiast imboredare you is offline
    MemberRank
    Nov 2008 Join Date
    31Posts

    Re: [Help] Rhisis Emulator, inventory.

    hmm not sure if this will help but in the database u can set there stack limit mabye that might be your problem.

  3. #3
    Enthusiast imboredare you is offline
    MemberRank
    Nov 2008 Join Date
    31Posts

    Re: [Help] Rhisis Emulator, inventory.

    stupid cookies .----. my bad on double post

    we need a delete button ._.

  4. #4
    Alpha Member GlaphanKing is offline
    MemberRank
    Sep 2008 Join Date
    World of MorrowLocation
    2,594Posts

    Re: [Help] Rhisis Emulator, inventory.

    ok. when you add an item you need to first check the inventory to see if there is the same item and then check it against the item bank to see how many max items you can have in the stack.

    So now you need to first get the item in inventory and see how many there are of that item and then see if the new item can be put on the stack without going over the max limit. if it does then it should go into the next slot with the overflow.

    Hope that makes sense.

  5. #5
    Member Dumle is offline
    MemberRank
    Nov 2008 Join Date
    SwedenLocation
    82Posts

    Re: [Help] Rhisis Emulator, inventory.

    @imboredare you, Already checked the database, thanks anyway ^^
    @GlaphanKing Yeah I know, I've checked that. But the stacking is not implented yet(or atleast not at rev 20 o.o). In the part of inventory.cpp where the stacking should be it's a function that makes a new slot. Or am I just a failed programmer? :3

    Atm, my stacking function gets the amount of the item in the slot, deletes the slot makes a new slot with the amount:"amount_list.at(index) + item->getAmount()". But I don't understand why it dosen't work with other slots than "0"?

    Should I post the full code? :)
    Btw, how's the development going? ;3

  6. #6
    Rhisis Developer Akitasha is offline
    MemberRank
    Jun 2005 Join Date
    NY, USALocation
    220Posts

    Re: [Help] Rhisis Emulator, inventory.

    Quote Originally Posted by Dumle View Post
    @imboredare you, Already checked the database, thanks anyway ^^
    @GlaphanKing Yeah I know, I've checked that. But the stacking is not implented yet(or atleast not at rev 20 o.o). In the part of inventory.cpp where the stacking should be it's a function that makes a new slot. Or am I just a failed programmer? :3

    Atm, my stacking function gets the amount of the item in the slot, deletes the slot makes a new slot with the amount:"amount_list.at(index) + item->getAmount()". But I don't understand why it dosen't work with other slots than "0"?

    Should I post the full code? :)
    Btw, how's the development going? ;3
    Code:
    /**
    * Moving an item around in the inventory
    **/
    bool Inventory::moveItem(Player* player, unsigned char* packet, int len){
    	int oldSlot = getByte(packet+1);
    	int newSlot = getByte(packet+2);
    	if(oldSlot==newSlot)
    		return true;
    	PlayerInventory* inventory = player->inv;
    	Item* item = inventory->getItemBySlot(oldSlot);
    	Item* item2 = inventory->getItemBySlot(newSlot);
    	if(item==NULL)
    		return true;
    	// remove used old slot and add it in the unused slot
    	if(item2==NULL)
    	{
    		inventory->removeUsedSlot(oldSlot);
    	}
    	else
    	{
    		if(item2->getItemId()!=item->getItemId())
    		{
    			item2->setSlot(oldSlot);
    			InventoryPacket::updateSlot(player,item2,oldSlot);
    		}
    		else
    		{
    			if(item2->getAmount()==item2->getItemData()->maxItems)
    			{
    				item2->setSlot(oldSlot);
    				InventoryPacket::updateSlot(player,item2,oldSlot);
    			}
    			else
    			{
    				int qtychange = item2->getAmount()+item->getAmount();
    				if(qtychange > item2->getItemData()->maxItems)
    				{
    					int moveamt = item2->getItemData()->maxItems-item2->getAmount();
    					int newamt = moveamt-item->getAmount();
    					item->setAmount(newamt);
    					item2->setAmount(item2->getAmount()+moveamt);
    					InventoryPacket::updateSlot(player,item2,newSlot);
    				}
    				else
    				{
    					item2->setAmount(item2->getAmount()+item->getAmount());
    					item->setAmount(0);
    					inventory->removeUsedSlot(item->getSlot());
    					inventory->removeItem(item);
    					InventoryPacket::updateSlot(player,item2,newSlot);
    					InventoryPacket::updateSlot(player,item,oldSlot);
    					return true;
    				}
    			}
    		}
    	}
    	inventory->addUsedSlot(newSlot);
    	item->setSlot(newSlot);
    	InventoryPacket::updateSlot(player,item,oldSlot);
    	return true;
    }
    That was the stacking code I implemented
    int qtychange = item2->getAmount()+item->getAmount();
    starts around there

  7. #7
    Member Dumle is offline
    MemberRank
    Nov 2008 Join Date
    SwedenLocation
    82Posts

    Re: [Help] Rhisis Emulator, inventory.

    Thanks for the respond but I'm working on stacking in the "Inventory::addItem" function ^^ Ex. When you pick up drops so they stack. I might be close to a solution *testing* :3

    Edit: It works o.o. Now they stack when you pick up items, and it saves ;>
    Last edited by Dumle; 07-04-09 at 12:53 PM. Reason: It works o.o

  8. #8
    Account Upgraded | Title Enabled! Xc3sz is offline
    MemberRank
    Nov 2008 Join Date
    Mostly at..Location
    260Posts

    Re: [Help] Rhisis Emulator, inventory.

    :P,

    cant w8 to be like u guys,currently stdying C++

    and learning fast :P,without missing any lesson..



Advertisement