summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp26
-rw-r--r--src/engine.cpp32
-rw-r--r--src/engine.h3
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/shop.cpp3
5 files changed, 46 insertions, 21 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 3411d5c7..d3e51a4d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -23,8 +23,10 @@
#include "being.h"
#include "game.h"
+#include "engine.h"
#include "net/protocol.h"
#include "net/network.h"
+#include "resources/resourcemanager.h"
Being *player_node = NULL;
@@ -38,11 +40,25 @@ PATH_NODE::PATH_NODE(unsigned short x, unsigned short y):
void add_node(Being *being) {
beings.push_back(being);
// If the being is a player, request the name
- //if (being-> job < 10) {
- WFIFOW(0) = net_w_value(0x0094);
- WFIFOL(2) = net_l_value(RFIFOL(2));
- WFIFOSET(6);
- // }
+ if (being-> job < 10) {
+ WFIFOW(0) = net_w_value(0x0094);
+ WFIFOL(2) = net_l_value(RFIFOL(2));
+ WFIFOSET(6);
+ }
+ // If the being is a monster then load the monsterset
+ else if (being->job >= 1002 && monsterset[being->job - 1002] == NULL) {
+ std::stringstream filename;
+ filename << "graphics/sprites/monster" << (being->job - 1002) << ".png";
+ logger.log("%s",filename.str().c_str());
+ ResourceManager *resman = ResourceManager::getInstance();
+ Image *monsterbitmap = resman->getImage(filename.str());
+ if (!monsterbitmap) {
+ logger.error("Unable to load monster.png");
+ }
+ else {
+ monsterset[being->job - 1002] = new Spriteset(monsterbitmap, 60, 60);
+ }
+ }
}
diff --git a/src/engine.cpp b/src/engine.cpp
index bdb2ebcd..417bbb92 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -35,6 +35,8 @@
#include "floor_item.h"
#include "gui/requesttrade.h"
+#define MONSTERS_NUMBER 8
+
char itemCurrenyQ[10] = "0";
int map_x, map_y, camera_x, camera_y;
char npc_text[1000] = "";
@@ -64,6 +66,7 @@ EquipmentWindow *equipmentWindow;
ChargeDialog *chargeDialog;
TradeWindow *tradeWindow;
RequestTradeDialog *requestTradeDialog;
+std::vector<Spriteset*> monsterset;
char hairtable[16][4][2] = {
// S(x,y) W(x,y) N(x,y) E(x,y)
@@ -208,8 +211,6 @@ Engine::Engine()
"graphics/sprites/npcs.png");
Image *emotionbmp = resman->getImage(
"graphics/sprites/emotions.png");
- Image *monsterbitmap = resman->getImage(
- "graphics/sprites/monsters.png");
Image *weaponbitmap = resman->getImage(
"graphics/sprites/weapons.png");
Image *itembitmap = resman->getImage(
@@ -217,15 +218,19 @@ Engine::Engine()
if (!npcbmp) logger.error("Unable to load npcs.png");
if (!emotionbmp) logger.error("Unable to load emotions.png");
- if (!monsterbitmap) logger.error("Unable to load monsters.png");
if (!weaponbitmap) logger.error("Unable to load weapons.png");
if (!itembitmap) logger.error("Unable to load items.png");
npcset = new Spriteset(npcbmp, 50, 80);
emotionset = new Spriteset(emotionbmp, 19, 19);
- monsterset = new Spriteset(monsterbitmap, 60, 60);
weaponset = new Spriteset(weaponbitmap, 160, 120);
- itemset = new Spriteset(itembitmap, 20, 20);
+ itemset = new Spriteset(itembitmap, 20, 20);
+
+ // Loads all the monsters
+ for (int i = 0; i < MONSTERS_NUMBER; i++)
+ {
+ monsterset.push_back(NULL);
+ }
}
Engine::~Engine()
@@ -249,7 +254,7 @@ Engine::~Engine()
delete requestTradeDialog;
// Delete sprite sets
- delete monsterset;
+ //delete monsterset;
delete npcset;
delete emotionset;
delete weaponset;
@@ -413,23 +418,23 @@ void Engine::draw()
gcn::Graphics::CENTER);
}
else if (being->job == 45) { // Draw a warp
- } else { // Draw a monster
+ }
+ else { // Draw a monster
if (being->frame >= 4)
being->frame = 3;
being->text_x = sx * 32 - 42 + get_x_offset(being) - offset_x;
being->text_y = sy * 32 - 65 + get_y_offset(being) - offset_y;
- int sprnum = dir + 4 * (being->job - 1002);
int mf = being->frame + being->action;
-
+
if (being->action == MONSTER_DEAD) {
- monsterset->spriteset[sprnum + 20 * MONSTER_DEAD]->draw(screen,
+ monsterset[being->job - 1002]->spriteset[dir + 4 * MONSTER_DEAD]->draw(screen,
being->text_x + 30, being->text_y + 40);
}
else {
- monsterset->spriteset[sprnum + 20 * mf]->draw(screen,
- being->text_x + 30, being->text_y + 40);
+ monsterset[being->job - 1002]->spriteset[dir + 4 * mf]->draw(
+ screen, being->text_x + 30, being->text_y + 40);
}
if (being->action != STAND) {
@@ -501,8 +506,7 @@ void Engine::draw()
std::stringstream debugStream;
debugStream << "[" << fps << " fps] " <<
- (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y) << " "
- << player_node->aspd;
+ (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y);
debugInfo->setCaption(debugStream.str());
debugInfo->adjustSize();
}
diff --git a/src/engine.h b/src/engine.h
index 86be708c..5eebb498 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -73,6 +73,7 @@ extern EquipmentWindow *equipmentWindow;
extern ChargeDialog* chargeDialog;
extern RequestTradeDialog *requestTradeDialog;
extern TradeWindow *tradeWindow;
+extern std::vector<Spriteset*> monsterset;
char get_x_offset(char, char);
char get_y_offset(char, char);
@@ -81,7 +82,7 @@ char get_y_offset(char, char);
*/
class Engine {
private:
- Spriteset *emotionset, *npcset, *monsterset, *weaponset, *itemset;
+ Spriteset *emotionset, *npcset, *weaponset, *itemset;
public:
Engine();
diff --git a/src/game.cpp b/src/game.cpp
index b0fcd7e8..753b5a34 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -686,6 +686,7 @@ void do_parse() {
if (being == NULL) {
being = new Being();
being->id = RFIFOL(2);
+ being->job = RFIFOW(14);
add_node(being);
}
@@ -707,6 +708,7 @@ void do_parse() {
if (being == NULL) {
being = new Being();
being->id = RFIFOL(2);
+ being->job = RFIFOW(14);
add_node(being);
}
@@ -731,6 +733,7 @@ void do_parse() {
if (being == NULL) {
being = new Being();
being->id = RFIFOL(2);
+ being->job = RFIFOW(14);
add_node(being);
}
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index d8000bc7..09d99669 100644
--- a/src/gui/shop.cpp
+++ b/src/gui/shop.cpp
@@ -48,7 +48,8 @@ char *item_db[] = {
"Easter Egg",
"Dagger",
"Sharp knife",
- "Leather shirt","","","","","","","",
+ "Leather shirt",
+ "Fancy hat","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",
"","","","","","","","","","",