Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Message when players enter floor

  • Loading branch information...
commit 75d4cd7917e124439100876b7440723a43172881 1 parent 504b487
@ludamad authored
View
2  fedora-deps.sh
@@ -1 +1 @@
-sudo yum install SDL-static SDL_image SDL_image-devel freetype-devel gcc-c++ SDL_net SDL_net-devel cmake
+sudo yum install SDL-static SDL_image SDL_image-devel SDL_mixer-devel freetype-devel gcc-c++ SDL_net SDL_net-devel cmake
View
29 src/lanarts/src/objects/player/PlayerInst.cpp
@@ -5,12 +5,15 @@
#include <typeinfo>
+#include <lcommon/SerializeBuffer.h>
+#include <lcommon/strformat.h>
+
+#include "draw/colour_constants.h"
#include "display/display.h"
#include "display/SpriteEntry.h"
#include "display/TileEntry.h"
#include "gamestate/GameState.h"
-#include <lcommon/SerializeBuffer.h>
#include "stats/items/WeaponEntry.h"
@@ -35,12 +38,32 @@ PlayerInst::PlayerInst(const CombatStats& stats, sprite_id sprite, int x, int y,
last_chosen_weaponclass = "unarmed";
}
+std::string player_name(GameState* gs, PlayerInst* p) {
+ std::vector<PlayerDataEntry>& players = gs->player_data().all_players();
+ for (int i = 0; i < players.size(); i++) {
+ if (players[i].player_inst.get() == p) {
+ return players[i].player_name;
+ }
+ }
+ LANARTS_ASSERT(false);
+ return "";
+}
+
void PlayerInst::init(GameState* gs) {
+ int previous_level = current_level;
CombatGameInst::init(gs);
teamid = gs->teams().default_player_team();
_path_to_player.calculate_path(gs, x, y, PLAYER_PATHING_RADIUS);
collision_simulation_id() = gs->collision_avoidance().add_player_object(
this);
+ if (!is_local_player() && current_level > 0) {
+ std::string pname = player_name(gs, this);
+ gs->game_chat().add_message(
+ format(
+ current_level < previous_level ?
+ "%s ascends to floor %d" : "%s descends to floor %d",
+ pname.c_str(), current_level), COL_PALE_BLUE);
+ }
}
PlayerInst::~PlayerInst() {
@@ -128,7 +151,7 @@ void PlayerInst::shift_autotarget(GameState* gs) {
// Exit when we wrap around if we have a target
return;
}
- EnemyInst* e = (EnemyInst*) gs->get_instance(mids[j]);
+ EnemyInst* e = (EnemyInst*)gs->get_instance(mids[j]);
bool isvisible = e != NULL && gs->object_visible_test(e, this, false);
if (isvisible) {
current_target = e->id;
@@ -200,7 +223,7 @@ void PlayerInst::draw(GameState* gs) {
void PlayerInst::copy_to(GameInst *inst) const {
LANARTS_ASSERT(typeid(*this) == typeid(*inst));
- *(PlayerInst*) inst = *this;
+ *(PlayerInst*)inst = *this;
}
void PlayerInst::serialize(GameState* gs, SerializeBuffer& serializer) {
View
1  src/lanarts/src/objects/player/PlayerInst.h
@@ -148,6 +148,7 @@ class PlayerInst: public CombatGameInst {
int previous_spellselect, spellselect;
};
+std::string player_name(GameState* gs, PlayerInst* p);
bool find_safest_square(PlayerInst* p, GameState* gs, Pos& position);
#endif /* PLAYERINST_H_ */
View
1  src/lanarts/src/objects/player/PlayerInstAttackActions.cpp
@@ -120,6 +120,7 @@ static GameInst* get_weapon_autotarget(GameState* gs, PlayerInst* p,
}
return NULL;
}
+
bool find_safest_square(PlayerInst* p, GameState* gs, Pos& position) {
PlayerData& pc = gs->player_data();
Please sign in to comment.
Something went wrong with that request. Please try again.