Ir para conteúdo
  • 0
Entre para seguir isso  
jeduschu

Scripting Como configurar slots do Inventário

Pergunta

jeduschu    12
jeduschu

Salve salve!

Queria saber como eu posso configurar os slots do Inventário do personagem.

No meu caso, eu consigo equipar qualquer coisa nas mãos do personagem, queria que conseguisse somente equipar weapons do lado esquerdo (<-) e spellbooks/shields do lado direito (->).

 

Utilizo o TFS 0.4, e atualmente estou testando a rev 3884.

Compartilhar este post


Link para o post
Compartilhar em outros sites

3 respostass a esta questão

Recommended Posts

  • 0
Majesty    1755
Majesty

data/movements/movements.xml.

Exemplo:

<movevent type="Equip" itemid="2195" slot="feet" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="2195" slot="feet" event="function" value="onDeEquipItem"/>

type = "Equip" e "DeEquip";

itemid = "id do item";

Slots: "head", "necklace", "backpack", "armor", "hand ("right"ou "left"), "two-hand", "legs", "feet", "ring", "ammo";

event = "function";

value = "onEquipItem" e "onDeEquipItem".

 

Informações sobre os slots nas sources:

enums.h:

Spoiler

enum ConditionId_t
{
	CONDITIONID_DEFAULT = -1,
	CONDITIONID_COMBAT = 0,
	CONDITIONID_HEAD,
	CONDITIONID_NECKLACE,
	CONDITIONID_BACKPACK,
	CONDITIONID_ARMOR,
	CONDITIONID_RIGHT,
	CONDITIONID_LEFT,
	CONDITIONID_LEGS,
	CONDITIONID_FEET,
	CONDITIONID_RING,
	CONDITIONID_AMMO,
	CONDITIONID_OUTFIT
};

 

items.cpp:

Spoiler

if(readXMLString(itemAttributesNode, "value", strValue))
				{
					tmpStrValue = asLowerCaseString(strValue);
					if(tmpStrValue == "head")
					{
						it.slotPosition |= SLOTP_HEAD;
						it.wieldPosition = SLOT_HEAD;
					}
					else if(tmpStrValue == "body")
					{
						it.slotPosition |= SLOTP_ARMOR;
						it.wieldPosition = SLOT_ARMOR;
					}
					else if(tmpStrValue == "legs")
					{
						it.slotPosition |= SLOTP_LEGS;
						it.wieldPosition = SLOT_LEGS;
					}
					else if(tmpStrValue == "feet")
					{
						it.slotPosition |= SLOTP_FEET;
						it.wieldPosition = SLOT_FEET;
					}
					else if(tmpStrValue == "backpack")
					{
						it.slotPosition |= SLOTP_BACKPACK;
						it.wieldPosition = SLOT_BACKPACK;
					}
					else if(tmpStrValue == "two-handed")
					{
						it.slotPosition |= SLOTP_TWO_HAND;
						it.wieldPosition = SLOT_TWO_HAND;
					}
					else if(tmpStrValue == "necklace")
					{
						it.slotPosition |= SLOTP_NECKLACE;
						it.wieldPosition = SLOT_NECKLACE;
					}
					else if(tmpStrValue == "ring")
					{
						it.slotPosition |= SLOTP_RING;
						it.wieldPosition = SLOT_RING;
					}
					else if(tmpStrValue == "ammo")
						it.wieldPosition = SLOT_AMMO;
					else if(tmpStrValue == "hand")
						it.wieldPosition = SLOT_HAND;
					else
						std::clog << "[Warning - Items::loadFromXml] Unknown slotType " << strValue << std::endl;
				}

 

items.h:

Spoiler

#define SLOTP_WHEREEVER 0xFFFFFFFF
#define SLOTP_HEAD 1 << 0
#define	SLOTP_NECKLACE 1 << 1
#define	SLOTP_BACKPACK 1 << 2
#define	SLOTP_ARMOR 1 << 3
#define	SLOTP_RIGHT 1 << 4
#define	SLOTP_LEFT 1 << 5
#define	SLOTP_LEGS 1 << 6
#define	SLOTP_FEET 1 << 7
#define	SLOTP_RING 1 << 8
#define	SLOTP_AMMO 1 << 9
#define	SLOTP_DEPOT 1 << 10
#define	SLOTP_TWO_HAND 1 << 11
#define SLOTP_HAND SLOTP_LEFT | SLOTP_RIGHT

 

luascript.cpp.

Movement.cpp:

Spoiler

MoveEvent* MoveEvents::getEvent(Item* item, MoveEvent_t eventType, slots_t slot)
{
	uint32_t slotp = 0;
	switch(slot)
	{
		case SLOT_HEAD:
			slotp = SLOTP_HEAD;
			break;
		case SLOT_NECKLACE:
			slotp = SLOTP_NECKLACE;
			break;
		case SLOT_BACKPACK:
			slotp = SLOTP_BACKPACK;
			break;
		case SLOT_ARMOR:
			slotp = SLOTP_ARMOR;
			break;
		case SLOT_RIGHT:
			slotp = SLOTP_RIGHT;
			break;
		case SLOT_LEFT:
			slotp = SLOTP_LEFT;
			break;
		case SLOT_LEGS:
			slotp = SLOTP_LEGS;
			break;
		case SLOT_FEET:
			slotp = SLOTP_FEET;
			break;
		case SLOT_AMMO:
			slotp = SLOTP_AMMO;
			break;
		case SLOT_RING:
			slotp = SLOTP_RING;
			break;
		default:
			break;
	}

 

Player.cpp:

Spoiler

if((item->getSlotPosition() & SLOTP_HEAD) || (item->getSlotPosition() & SLOTP_NECKLACE) ||
		(item->getSlotPosition() & SLOTP_BACKPACK) || (item->getSlotPosition() & SLOTP_ARMOR) ||
		(item->getSlotPosition() & SLOTP_LEGS) || (item->getSlotPosition() & SLOTP_FEET) ||
		(item->getSlotPosition() & SLOTP_RING))
		ret = RET_CANNOTBEDRESSED;
	else if(item->getSlotPosition() & SLOTP_TWO_HAND)
		ret = RET_PUTTHISOBJECTINBOTHHANDS;
	else if((item->getSlotPosition() & SLOTP_RIGHT) || (item->getSlotPosition() & SLOTP_LEFT))
		ret = RET_PUTTHISOBJECTINYOURHAND;

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
jeduschu    12
jeduschu

Muito obrigado! Isso vai me ajudar de verdade. 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Majesty    1755
Majesty

A questão neste tópico de suporte foi respondida e o autor do tópico resolveu a questão. Este tópico está fechado agora. Se você tiver outras perguntas, crie um novo tópico.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×