12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include "PlayerHand.h"
- #include "Block.h"
- #include "Entity.h"
- PlayerHandItemType::PlayerHandItemType()
- : ItemType()
- {
- setName("PlayerHand");
- setMaxStackSize(0);
- }
- Item* PlayerHandItemType::createItem() const
- {
- return 0; // there is no player hand item
- }
- ItemSkill* PlayerHandItemType::createDefaultItemSkill() const
- {
- return new PlayerHandSkill();
- }
- void PlayerHandItemType::levelUpItemSkill(ItemSkill* zSkill) const {}
- PlayerHandSkill::PlayerHandSkill()
- : ItemSkill()
- {
- setXp(0.f);
- setMaxXp(1.f);
- setLevel(1.f);
- }
- bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
- {
- if (zActor->getStamina() > 0.001f)
- {
- if (zTarget && zTarget->getHardness() <= 1)
- {
- zActor->setStamina(zActor->getStamina() - 0.001f);
- zTarget->setHP(zTarget->getHP() - 1 / (zTarget->getHardness() + 1));
- }
- else
- {
- zActor->setStamina(zActor->getStamina() - 0.001f);
- zActor->setHP(zActor->getCurrentHP() - 0.01f);
- }
- }
- return false; // item was not changed
- }
- bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Entity* zTarget)
- {
- // TODO: make damage on the entity
- return false; // item was not changed
- }
|