mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-28 16:06:25 +00:00
Stay strategy improvement (#1072)
* - Stay Strategy work in combat and with RTSC * - Fixed summon with stay strategy * - Added new stay strategy support for chat commands
This commit is contained in:
@@ -63,3 +63,25 @@ bool PositionValue::Load(std::string const text)
|
||||
}
|
||||
|
||||
WorldPosition CurrentPositionValue::Calculate() { return WorldPosition(bot); }
|
||||
|
||||
PositionInfo SinglePositionValue::Calculate()
|
||||
{
|
||||
PositionMap& posMap = AI_VALUE(PositionMap&, "position");
|
||||
return posMap[getQualifier()];
|
||||
}
|
||||
|
||||
void SinglePositionValue::Set(PositionInfo value)
|
||||
{
|
||||
PositionMap& posMap = AI_VALUE(PositionMap&, "position");
|
||||
PositionInfo pos = posMap[getQualifier()];
|
||||
pos = value;
|
||||
posMap[getQualifier()] = pos;
|
||||
}
|
||||
|
||||
void SinglePositionValue::Reset()
|
||||
{
|
||||
PositionMap& posMap = AI_VALUE(PositionMap&, "position");
|
||||
PositionInfo pos = posMap[getQualifier()];
|
||||
pos.Reset();
|
||||
posMap[getQualifier()] = pos;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef _PLAYERBOT_POSITIONVALUE_H
|
||||
#define _PLAYERBOT_POSITIONVALUE_H
|
||||
|
||||
#include "NamedObjectContext.h"
|
||||
#include "TravelMgr.h"
|
||||
#include "Value.h"
|
||||
|
||||
@@ -15,6 +16,10 @@ class PositionInfo
|
||||
{
|
||||
public:
|
||||
PositionInfo() : valueSet(false), x(0), y(0), z(0), mapId(0) {}
|
||||
PositionInfo(float x, float y, float z, uint32 mapId, bool valueSet = true)
|
||||
: valueSet(valueSet), x(x), y(y), z(z), mapId(mapId)
|
||||
{
|
||||
}
|
||||
PositionInfo(PositionInfo const& other)
|
||||
: valueSet(other.valueSet), x(other.x), y(other.y), z(other.z), mapId(other.mapId)
|
||||
{
|
||||
@@ -72,4 +77,13 @@ public:
|
||||
WorldPosition Calculate() override;
|
||||
};
|
||||
|
||||
class SinglePositionValue : public CalculatedValue<PositionInfo>, public Qualified
|
||||
{
|
||||
public:
|
||||
SinglePositionValue(PlayerbotAI* ai, std::string name = "pos") : CalculatedValue(ai, name), Qualified() {};
|
||||
virtual PositionInfo Calculate() override;
|
||||
virtual void Set(PositionInfo value) override;
|
||||
virtual void Reset() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -194,6 +194,7 @@ public:
|
||||
creators["rti cc"] = &ValueContext::rti_cc;
|
||||
creators["rti"] = &ValueContext::rti;
|
||||
creators["position"] = &ValueContext::position;
|
||||
creators["pos"] = &ValueContext::pos;
|
||||
creators["current position"] = &ValueContext::current_position;
|
||||
creators["threat"] = &ValueContext::threat;
|
||||
|
||||
@@ -342,6 +343,7 @@ private:
|
||||
static UntypedValue* attackers(PlayerbotAI* botAI) { return new AttackersValue(botAI); }
|
||||
|
||||
static UntypedValue* position(PlayerbotAI* botAI) { return new PositionValue(botAI); }
|
||||
static UntypedValue* pos(PlayerbotAI* ai) { return new SinglePositionValue(ai); }
|
||||
static UntypedValue* current_position(PlayerbotAI* botAI) { return new CurrentPositionValue(botAI); }
|
||||
static UntypedValue* rti(PlayerbotAI* botAI) { return new RtiValue(botAI); }
|
||||
static UntypedValue* rti_cc(PlayerbotAI* botAI) { return new RtiCcValue(botAI); }
|
||||
|
||||
Reference in New Issue
Block a user