Skip to content

Commit

Permalink
add ACTION_SPINKICK
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Oct 15, 2021
1 parent 38e0b2b commit 4da370c
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 17 deletions.
29 changes: 24 additions & 5 deletions client/src/hero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,10 @@ bool Hero::motionValid(const std::unique_ptr<MotionNode> &motionPtr) const
case MOTION_HITTED:
case MOTION_WHEELWIND:
case MOTION_RANDSWING:
case MOTION_SPINKICK:
{
return !onHorse() && (nLDistance2 == 0);
}
case MOTION_BACKDROPKICK:
{
return false;
}
case MOTION_DIE:
{
return !onHorse() && (nLDistance2 == 0);
Expand Down Expand Up @@ -430,6 +427,7 @@ bool Hero::parseAction(const ActionNode &action)
case ACTION_STAND:
case ACTION_SPELL:
case ACTION_ATTACK:
case ACTION_SPINKICK:
{
m_motionQueue = makeWalkMotionQueue(endX, endY, action.x, action.y, SYS_MAXSPEED);
break;
Expand Down Expand Up @@ -465,6 +463,27 @@ bool Hero::parseAction(const ActionNode &action)
}));
break;
}
case ACTION_SPINKICK:
{
m_motionQueue.push_back(std::unique_ptr<MotionNode>(new MotionNode
{
.type = MOTION_SPINKICK,
.direction = [&action, this]() -> int
{
if(action.aimUID){
if(auto coPtr = m_processRun->findUID(action.aimUID)){
if(mathf::CDistance<int>(coPtr->x(), coPtr->y(), x(), y()) == 1){
return PathFind::GetDirection(coPtr->x(), coPtr->y(), x(), y());
}
}
}
return m_currMotion->direction;
}(),
.x = action.x,
.y = action.y,
}));
break;
}
case ACTION_MOVE:
{
if(auto moveNode = makeWalkMotion(action.x, action.y, action.aimX, action.aimY, action.speed)){
Expand Down Expand Up @@ -1040,7 +1059,7 @@ HeroFrameGfxSeq Hero::getFrameGfxSeq(int motion, int direction) const
case MOTION_HITTED : return {.count = 3};
case MOTION_WHEELWIND : return {.count = 10};
case MOTION_RANDSWING : return {.count = 10};
case MOTION_BACKDROPKICK : return {.count = 10};
case MOTION_SPINKICK : return {.count = 10};
case MOTION_DIE : return {.count = 10};
case MOTION_ONHORSEDIE : return {.count = 10};
case MOTION_WALK : return {.count = 6};
Expand Down
2 changes: 1 addition & 1 deletion client/src/motionnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ inline const char *motionName(int type)
_add_motion_type_case(MOTION_HITTED )
_add_motion_type_case(MOTION_WHEELWIND )
_add_motion_type_case(MOTION_RANDSWING )
_add_motion_type_case(MOTION_BACKDROPKICK )
_add_motion_type_case(MOTION_SPINKICK )
_add_motion_type_case(MOTION_DIE )
_add_motion_type_case(MOTION_ONHORSEDIE )
_add_motion_type_case(MOTION_WALK )
Expand Down
26 changes: 26 additions & 0 deletions client/src/processrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,32 @@ void ProcessRun::checkMagicSpell(const SDL_Event &event)
}

switch(magicID){
case DBCOM_MAGICID(u8"空拳刀法"):
{
getMyHero()->brakeMove();
if(const auto uid = focusUID(FOCUS_MAGIC)){
getMyHero()->emplaceAction(ActionSpinKick
{
.x = getMyHero()->currMotion()->endX,
.y = getMyHero()->currMotion()->endY,
.aimUID = uid,
});
}
else{
// even there is no target UID
// we still cast the magic to show gfx

const auto [aimX, aimY] = getMouseGLoc();
getMyHero()->emplaceAction(ActionSpinKick
{
.x = getMyHero()->currMotion()->endX,
.y = getMyHero()->currMotion()->endY,
.aimX = aimX,
.aimY = aimY,
});
}
break;
}
case DBCOM_MAGICID(u8"烈火剑法"):
case DBCOM_MAGICID(u8"翔空剑法"):
case DBCOM_MAGICID(u8"莲月剑法"):
Expand Down
32 changes: 32 additions & 0 deletions common/src/actionnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum ActionType: int
ACTION_SPELL,
ACTION_TRANSF,
ACTION_HITTED,
ACTION_SPINKICK,
ACTION_DIE,
ACTION_END,
};
Expand Down Expand Up @@ -214,6 +215,36 @@ struct ActionNode
};
#pragma pack(pop)

struct ActionSpinKick
{
const int speed = SYS_DEFSPEED;

const int x = -1;
const int y = -1;

const int aimX = x;
const int aimY = y;

const uint64_t aimUID = 0;

operator ActionNode () const
{
ActionNode node;
std::memset(&node, 0, sizeof(node));

node.type = ACTION_SPINKICK;
node.speed = speed;

node.x = x;
node.y = y;

node.aimX = aimX;
node.aimY = aimY;
node.aimUID = aimUID;
return node;
}
};

struct ActionDie
{
const int x = -1;
Expand Down Expand Up @@ -506,6 +537,7 @@ inline const char *actionName(int type)
_add_action_type_case(ACTION_SPELL )
_add_action_type_case(ACTION_TRANSF )
_add_action_type_case(ACTION_HITTED )
_add_action_type_case(ACTION_SPINKICK )
_add_action_type_case(ACTION_DIE )
default: return "ACTION_UNKNOWN";
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/magicrecord.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@
.type = u8"附着",
.gfxID = 0X020001AE,
.frameCount = 7,
.motion = MOTION_SPELL1,
.motion = MOTION_ATTACKMODE,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion common/src/motion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum MotionType: int
MOTION_HITTED,
MOTION_WHEELWIND,
MOTION_RANDSWING,
MOTION_BACKDROPKICK,
MOTION_SPINKICK,
MOTION_DIE,
MOTION_ONHORSEDIE,
MOTION_WALK,
Expand Down
6 changes: 6 additions & 0 deletions server/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,12 @@ void Player::onCMActionAttack(CMAction stCMA)
});
}

void Player::onCMActionSpinKick(CMAction cmA)
{
fflassert(cmA.action.type == ACTION_SPINKICK);
dispatchAction(cmA.action);
}

void Player::onCMActionSpell(CMAction cmA)
{
fflassert(cmA.action.type == ACTION_SPELL);
Expand Down
9 changes: 5 additions & 4 deletions server/src/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ class Player final: public CharObject
bool MotionValid(const ActionNode &);

protected:
void onCMActionMove (CMAction);
void onCMActionStand (CMAction);
void onCMActionSpell (CMAction);
void onCMActionAttack(CMAction);
void onCMActionMove (CMAction);
void onCMActionStand (CMAction);
void onCMActionSpell (CMAction);
void onCMActionSpinKick(CMAction);
void onCMActionAttack (CMAction);

private:
bool postNetMessage(uint8_t, const void *, size_t);
Expand Down
11 changes: 6 additions & 5 deletions server/src/playernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ void Player::net_CM_ACTION(uint8_t, const uint8_t *pBuf, size_t)
// we may need to filter some actions to anti-cheat, dispatch in onCMActionXXXX(cmA) if legeal

switch(to_d(cmA.action.type)){
case ACTION_STAND : onCMActionStand (cmA); return;
case ACTION_MOVE : onCMActionMove (cmA); return;
case ACTION_ATTACK: onCMActionAttack(cmA); return;
case ACTION_SPELL : onCMActionSpell (cmA); return;
default : return;
case ACTION_STAND : onCMActionStand (cmA); return;
case ACTION_MOVE : onCMActionMove (cmA); return;
case ACTION_ATTACK : onCMActionAttack (cmA); return;
case ACTION_SPELL : onCMActionSpell (cmA); return;
case ACTION_SPINKICK: onCMActionSpinKick(cmA); return;
default : return;
}
}
}
Expand Down

0 comments on commit 4da370c

Please sign in to comment.