Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/modules/Bots/playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PlayerbotAI::PlayerbotAI() : PlayerbotAIBase(), bot(NULL), aiObjectContext(NULL)
m_isJumping(false), m_jumpStartTime(0),
m_jumpStartX(0.f), m_jumpStartY(0.f), m_jumpStartZ(0.f),
m_jumpSinAngle(0.f), m_jumpCosAngle(1.f), m_jumpXYSpeed(0.f),
m_pendingJump(false), m_jumpRequestTime(0),
m_pendingJump(false), m_jumpHere(false), m_jumpRequestTime(0),
m_jumpTargetX(0.f), m_jumpTargetY(0.f), m_jumpTargetZ(0.f), m_jumpTargetO(0.f)
{
for (int i = 0 ; i < BOT_STATE_MAX; i++)
Expand All @@ -101,7 +101,7 @@ PlayerbotAI::PlayerbotAI(Player* bot) :
m_isJumping(false), m_jumpStartTime(0),
m_jumpStartX(0.f), m_jumpStartY(0.f), m_jumpStartZ(0.f),
m_jumpSinAngle(0.f), m_jumpCosAngle(1.f), m_jumpXYSpeed(0.f),
m_pendingJump(false), m_jumpRequestTime(0),
m_pendingJump(false), m_jumpHere(false), m_jumpRequestTime(0),
m_jumpTargetX(0.f), m_jumpTargetY(0.f), m_jumpTargetZ(0.f), m_jumpTargetO(0.f)
{
this->bot = bot;
Expand Down Expand Up @@ -175,7 +175,7 @@ PlayerbotAI::~PlayerbotAI()
static const float BOT_JUMP_VELOCITY = 7.9557f;
static const float BOT_JUMP_GRAVITY = 19.2911f;

void PlayerbotAI::RequestJump()
void PlayerbotAI::RequestJump(bool here)
{
if (m_pendingJump || m_isJumping)
return;
Expand All @@ -189,6 +189,7 @@ void PlayerbotAI::RequestJump()
m_jumpTargetZ = master->GetPositionZ();
m_jumpTargetO = master->GetOrientation();
m_pendingJump = true;
m_jumpHere = here;
m_jumpRequestTime = getMSTime();
}

Expand Down Expand Up @@ -243,7 +244,10 @@ void PlayerbotAI::UpdateJump()
if (dist2d <= 0.5f)
{
m_pendingJump = false;
StartJump(true, m_jumpTargetO);
if (m_jumpHere)
StartJump(false);
else
StartJump(true, m_jumpTargetO);
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion src/modules/Bots/playerbot/PlayerbotAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class PlayerbotAI : public PlayerbotAIBase
PlayerbotSecurity* GetSecurity() { return &security; }

void StartJump(bool forward, float orientation = -1.f);
void RequestJump();
void RequestJump(bool here = false);
bool IsJumping() const { return m_isJumping; }
bool IsPendingJump() const { return m_pendingJump; }

Expand Down Expand Up @@ -229,6 +229,7 @@ class PlayerbotAI : public PlayerbotAIBase
float m_jumpStartX, m_jumpStartY, m_jumpStartZ;
float m_jumpSinAngle, m_jumpCosAngle, m_jumpXYSpeed;
bool m_pendingJump;
bool m_jumpHere;
uint32 m_jumpRequestTime;
float m_jumpTargetX, m_jumpTargetY, m_jumpTargetZ, m_jumpTargetO;

Expand Down
3 changes: 1 addition & 2 deletions src/modules/Bots/playerbot/strategy/actions/ActionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace ai
creators["attack duel opponent"] = &ActionContext::attack_duel_opponent;
creators["drop target"] = &ActionContext::drop_target;
creators["jump"] = &ActionContext::jump;
creators["jump up"] = &ActionContext::jump_up;
creators["back off"] = &ActionContext::back_off;
}

Expand Down Expand Up @@ -119,6 +118,6 @@ namespace ai
static Action* move_out_of_enemy_contact(PlayerbotAI* ai) { return new MoveOutOfEnemyContactAction(ai); }
static Action* set_facing(PlayerbotAI* ai) { return new SetFacingTargetAction(ai); }
static Action* jump(PlayerbotAI* ai) { return new JumpAction(ai); }
static Action* jump_up(PlayerbotAI* ai) { return new JumpInPlaceAction(ai); }

};
};
36 changes: 29 additions & 7 deletions src/modules/Bots/playerbot/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,37 @@ bool SetFacingTargetAction::isUseful()

bool JumpAction::Execute(Event event)
{
if (ai->IsJumping() || ai->IsPendingJump())
return false;
string const param = event.getParam();

ai->RequestJump();
return ai->IsPendingJump();
}
if (param == "forward")
{
if (ai->IsJumping())
return false;
ai->StartJump(true);
return true;
}

if (param == "master")
{
if (ai->IsJumping())
return false;
Player* master = ai->GetMaster();
if (!master)
return false;
float angle = bot->GetAngle(master);
bot->SetFacingTo(angle);
ai->StartJump(true, angle);
return true;
}

if (param == "here")
{
if (ai->IsJumping() || ai->IsPendingJump())
return false;
ai->RequestJump();
return ai->IsPendingJump();
}

bool JumpInPlaceAction::Execute(Event event)
{
if (ai->IsJumping())
return false;

Expand Down
7 changes: 0 additions & 7 deletions src/modules/Bots/playerbot/strategy/actions/MovementActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,4 @@ namespace ai
virtual bool Execute(Event event);
};

class JumpInPlaceAction : public MovementAction
{
public:
JumpInPlaceAction(PlayerbotAI* ai) : MovementAction(ai, "jump up") {}
virtual bool Execute(Event event);
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ void ChatCommandHandlerStrategy::InitTriggers(std::list<TriggerNode*> &triggers)
triggers.push_back(new TriggerNode(
"jump",
NextAction::array(0, new NextAction("jump", relevance), NULL)));

triggers.push_back(new TriggerNode(
"jump up",
NextAction::array(0, new NextAction("jump up", relevance), NULL)));
}


Expand Down Expand Up @@ -182,5 +178,7 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* ai) : PassTr
supported.push_back("who");
supported.push_back("save mana");
supported.push_back("jump");
supported.push_back("jump up");
supported.push_back("jump here");
supported.push_back("jump forward");
supported.push_back("jump master");
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ namespace ai
creators["max dps"] = &ChatTriggerContext::max_dps;
creators["attackers"] = &ChatTriggerContext::attackers;
creators["jump"] = &ChatTriggerContext::jump;
creators["jump up"] = &ChatTriggerContext::jump_up;
}

private:
static Trigger* attackers(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "attackers"); }
static Trigger* jump(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "jump"); }
static Trigger* jump_up(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "jump up"); }
static Trigger* max_dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "max dps"); }
static Trigger* save_mana(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "save mana"); }
static Trigger* who(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "who"); }
Expand Down
Loading