cosmetix
[k8-i-v-a-n.git] / src / game / commands / Kick.cpp
blobf42f13cbd05e6f5a4bd8be7c04a8eed5380ab0ba
1 COMMAND(Kick) {
2 /** No multi-tile support */
3 if (!Char->CheckKick()) return false;
4 if (Char->GetBurdenState() == OVER_LOADED) {
5 ADD_MESSAGE("You try to kick, but you collapse under your load.");
6 Char->EditAP(-100000/APBonus(Char->GetAttribute(AGILITY)));
7 return true;
9 int Dir = game::DirectionQuestion(CONST_S("In what direction do you wish to kick? [press a direction key]"), false);
10 if (Dir == DIR_ERROR || !Char->GetArea()->IsValidPos(Char->GetPos()+game::GetMoveVector(Dir))) return false;
11 lsquare *Square = Char->GetNearLSquare(Char->GetPos()+game::GetMoveVector(Dir));
12 if (!Square->CheckKick(Char)) return false;
13 character *Enemy = Square->GetCharacter();
14 if (Enemy && !(Enemy->IsMasochist() && Char->GetRelation(Enemy) == FRIEND) && Char->GetRelation(Enemy) != HOSTILE) {
15 if (!game::TruthQuestion(CONST_S("This might cause a hostile reaction. Are you sure? [y/N]"))) return false;
17 game::ClearEventData();
18 game::mActor = Square->GetCharacter();
19 game::mSecondActor = Char;
20 if (game::RunOnCharEvent(Char, CONST_S("before_kick"))) { game::ClearEventData(); return game::mResult != 0; }
21 game::ClearEventData();
22 game::mActor = Char;
23 game::mSecondActor = Square->GetCharacter();
24 if (game::RunOnCharEvent(Square->GetCharacter(), CONST_S("before_kicked_by"))) { game::ClearEventData(); return game::mResult != 0; }
25 game::ClearEventData();
26 Char->Hostility(Square->GetCharacter());
27 Char->Kick(Square, Dir);
28 return true;