-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use_ring_action_added #339
base: master
Are you sure you want to change the base?
Conversation
list<Item*> rings; | ||
list<Item*> result; | ||
|
||
Player* bot = ai->GetBot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a Player* bot defined in the values class, no need for this
if (Item* ring1 = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_FINGER1)) | ||
rings.push_back(ring1); | ||
|
||
if (Item* ring2 = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_FINGER2)) | ||
rings.push_back(ring2); | ||
|
||
if (rings.empty()) | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the list<Item*> rings is not needed, you should put the spell check and cooldown condition in a separate method and pass the ring there, if the method returns true then the ring is valid
{ | ||
public: | ||
UseRingTrigger(PlayerbotAI* ai) : BoostTrigger(ai, "use ring", 3) {} | ||
virtual bool IsActive() { return AI_VALUE(list<Item*>, "rings on use").size() > 0; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !AI_VALUE(list<Item*>, "rings on use").empty();
|
||
bool UseRingAction::isPossible() | ||
{ | ||
return AI_VALUE(list<Item*>, "rings on use").size() > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !AI_VALUE(list<Item*>, "rings on use").empty();
{ | ||
if (bot->CanUseItem(item) == EQUIP_ERR_OK && !item->IsInTrade()) | ||
{ | ||
return UseItemAuto(GetMaster(), item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the requester like this
Player* requester = event.getOwner() ? event.getOwner() : GetMaster();
if (rings.empty()) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check for empty, the for already does it for you
|
||
for (Item * item : rings) | ||
{ | ||
ItemPrototype const* proto = item->GetProto(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ItemPrototype* proto = item->GetProto();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In server files ItemPrototype const* proto is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmangos code doesn't follow any standards, but I'm trying to improve that atleast in our side
@@ -928,6 +928,13 @@ namespace ai | |||
virtual bool IsActive() override; | |||
}; | |||
|
|||
class UseRingTrigger : public BoostTrigger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to inherit from BoostTrigger if nothing gets reused from that class. Better inherit from Trigger
Providing a code for rings usage by bots