diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-05-31 22:23:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-05-31 22:23:23 +0300 |
commit | fc5ba333f8832f3d8e054e7c74df1e3cd353645f (patch) | |
tree | 16aabceaaa2b197d006bd357d3176acac292cde7 /src | |
parent | 9875c00dc37b1d7b55e1154075a0cd2d997a490d (diff) | |
download | manaverse-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.gz manaverse-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.bz2 manaverse-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.tar.xz manaverse-fc5ba333f8832f3d8e054e7c74df1e3cd353645f.zip |
Add sittop sprites support.
Add groundtop collision support (not collision but special selected tiles).
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 25 | ||||
-rw-r--r-- | src/being.h | 5 | ||||
-rw-r--r-- | src/gui/setup_colors.cpp | 2 | ||||
-rw-r--r-- | src/gui/userpalette.cpp | 3 | ||||
-rw-r--r-- | src/gui/userpalette.h | 1 | ||||
-rw-r--r-- | src/map.cpp | 109 | ||||
-rw-r--r-- | src/map.h | 15 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 1 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 3 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 4 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 1 | ||||
-rw-r--r-- | src/resources/spritedef.h | 1 |
12 files changed, 83 insertions, 87 deletions
diff --git a/src/being.cpp b/src/being.cpp index f1a3e0169..a9aade448 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1004,6 +1004,20 @@ void Being::fireMissile(Being *victim, const std::string &particle) } +std::string Being::getSitAction() const +{ + if (serverVersion < 0) + { + return SpriteAction::SIT; + } + else + { + if (mMap && !mMap->getWalk(mX, mY, Map::BLOCKMASK_GROUNDTOP)) + return SpriteAction::SITTOP; + return SpriteAction::SIT; + } +} + void Being::setAction(Action action, int attackType A_UNUSED) { std::string currentAction = SpriteAction::INVALID; @@ -1019,9 +1033,16 @@ void Being::setAction(Action action, int attackType A_UNUSED) // while using only the ACTION_MOVE. break; case SIT: - currentAction = SpriteAction::SIT; + currentAction = getSitAction(); if (mInfo) - sound.playSfx(mInfo->getSound(SOUND_EVENT_SIT), mX, mY); + { + SoundEvent event; + if (currentAction == SpriteAction::SITTOP) + event = SOUND_EVENT_SITTOP; + else + event = SOUND_EVENT_SIT; + sound.playSfx(mInfo->getSound(event), mX, mY); + } break; case ATTACK: if (mEquippedWeapon) diff --git a/src/being.h b/src/being.h index 6337e30f1..f366a37c5 100644 --- a/src/being.h +++ b/src/being.h @@ -613,6 +613,11 @@ class Being : public ActorSprite, public ConfigListener { return mGender; } /** + * Return sprite sit action for current environment. + */ + std::string getSitAction() const; + + /** * Whether or not this player is a GM. */ bool isGM() const diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 800b38337..cbad6f4d9 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -262,6 +262,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED) { case UserPalette::AIR_COLLISION_HIGHLIGHT: case UserPalette::WATER_COLLISION_HIGHLIGHT: + case UserPalette::GROUNDTOP_COLLISION_HIGHLIGHT: case UserPalette::COLLISION_HIGHLIGHT: case UserPalette::PORTAL_HIGHLIGHT: case UserPalette::HOME_PLACE: @@ -305,6 +306,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED) case UserPalette::HOME_PLACE_BORDER: case UserPalette::AIR_COLLISION_HIGHLIGHT: case UserPalette::WATER_COLLISION_HIGHLIGHT: + case UserPalette::GROUNDTOP_COLLISION_HIGHLIGHT: case UserPalette::COLLISION_HIGHLIGHT: case UserPalette::WALKABLE_HIGHLIGHT: case UserPalette::ROAD_POINT: diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 49a81c4dc..60f99b66c 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -69,6 +69,7 @@ const std::string ColorTypeNames[] = "ColorCollisionHighlight", "ColorCollisionAirHighlight", "ColorCollisionWaterHighlight", + "ColorCollisionGroundtopHighlight", "ColorWalkableTileHighlight", "ColorAttackRange", "ColorAttackRangeBorder", @@ -153,6 +154,8 @@ UserPalette::UserPalette(): _("Air collision Highlight"), 64); addColor(WATER_COLLISION_HIGHLIGHT, 0x2050e0, STATIC, _("Water collision Highlight"), 64); + addColor(GROUNDTOP_COLLISION_HIGHLIGHT, 0xffff00, STATIC, + _("Special ground collision Highlight"), 20); addColor(WALKABLE_HIGHLIGHT, 0x00D000, STATIC, _("Walkable Highlight"), 255); addColor(ATTACK_RANGE, 0xffffff, STATIC, diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 6fba30abc..3d53cc26c 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -68,6 +68,7 @@ class UserPalette : public Palette, public gcn::ListModel COLLISION_HIGHLIGHT, AIR_COLLISION_HIGHLIGHT, WATER_COLLISION_HIGHLIGHT, + GROUNDTOP_COLLISION_HIGHLIGHT, WALKABLE_HIGHLIGHT, ATTACK_RANGE, ATTACK_RANGE_BORDER, diff --git a/src/map.cpp b/src/map.cpp index f843479c0..6afaaa727 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -465,6 +465,29 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) drawAmbientLayers(graphics, FOREGROUND_LAYERS, mOverlayDetail); } +#define fillCollision(collision, color) \ + if (x < endX && mMetaTiles[tilePtr].blockmask & collision)\ + {\ + width = 32;\ + for (int x2 = tilePtr + 1; x < endX; x2 ++)\ + {\ + if (!(mMetaTiles[x2].blockmask & collision))\ + break;\ + width += 32;\ + x ++;\ + tilePtr ++;\ + }\ + if (width && userPalette)\ + {\ + graphics->setColor(userPalette->getColorWithAlpha(\ + UserPalette::color));\ + graphics->fillRectangle(gcn::Rectangle(\ + x0 * mTileWidth - scrollX,\ + y * mTileHeight - scrollY,\ + width, 32));\ + }\ + }\ + void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY, int debugFlags) { @@ -500,85 +523,10 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY, int width = 0; int x0 = x; - if (mMetaTiles[tilePtr].blockmask & BLOCKMASK_WALL) - { - width = 32; - for (int x2 = tilePtr + 1; x < endX; x2 ++) - { - if (!(mMetaTiles[x2].blockmask - & BLOCKMASK_WALL)) - { - break; - } - width += 32; - x ++; - tilePtr ++; - } - if (width && userPalette) - { - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::COLLISION_HIGHLIGHT)); - - graphics->fillRectangle(gcn::Rectangle( - x0 * mTileWidth - scrollX, - y * mTileHeight - scrollY, - width, 32)); - } - } - - if (x < endX && mMetaTiles[tilePtr].blockmask - & BLOCKMASK_AIR) - { - width = 32; - for (int x2 = tilePtr + 1; x < endX; x2 ++) - { - if (!(mMetaTiles[x2].blockmask - & BLOCKMASK_AIR)) - { - break; - } - width += 32; - x ++; - tilePtr ++; - } - if (width && userPalette) - { - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::AIR_COLLISION_HIGHLIGHT)); - - graphics->fillRectangle(gcn::Rectangle( - x0 * mTileWidth - scrollX, - y * mTileHeight - scrollY, - width, 32)); - } - } - - if (x < endX && mMetaTiles[tilePtr].blockmask - & BLOCKMASK_WATER) - { - width = 32; - for (int x2 = tilePtr + 1; x < endX; x2 ++) - { - if (!(mMetaTiles[x2].blockmask - & BLOCKMASK_WATER)) - { - break; - } - width += 32; - x ++; - tilePtr ++; - } - if (width && userPalette) - { - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::WATER_COLLISION_HIGHLIGHT)); - - graphics->fillRectangle(gcn::Rectangle( - x0 * mTileWidth - scrollX, - y * mTileHeight - scrollY, - width, 32)); - } - } + fillCollision(BLOCKMASK_WALL, COLLISION_HIGHLIGHT); + fillCollision(BLOCKMASK_AIR, AIR_COLLISION_HIGHLIGHT); + fillCollision(BLOCKMASK_WATER, WATER_COLLISION_HIGHLIGHT); + fillCollision(BLOCKMASK_GROUNDTOP, GROUNDTOP_COLLISION_HIGHLIGHT); } } } @@ -691,6 +639,9 @@ void Map::blockTile(int x, int y, BlockType type) case BLOCKTYPE_GROUND: mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUND; break; + case BLOCKTYPE_GROUNDTOP: + mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUNDTOP; + break; default: case BLOCKTYPE_NONE: case NB_BLOCKTYPES: @@ -114,16 +114,18 @@ class Map : public Properties, public ConfigListener BLOCKTYPE_AIR, BLOCKTYPE_WATER, BLOCKTYPE_GROUND, + BLOCKTYPE_GROUNDTOP, NB_BLOCKTYPES }; enum CollisionTypes { - COLLISION_EMPTY = 0, - COLLISION_WALL = 1, - COLLISION_AIR = 2, - COLLISION_WATER = 3, - COLLISION_MAX = 4 + COLLISION_EMPTY = 0, // no collision + COLLISION_WALL = 1, // full collison + COLLISION_AIR = 2, // air units can walk + COLLISION_WATER = 3, // water units can walk + COLLISION_GROUNDTOP = 4, // no collision (chair, bed, etc) + COLLISION_MAX = 5 // count index }; enum BlockMask @@ -133,7 +135,8 @@ class Map : public Properties, public ConfigListener BLOCKMASK_MONSTER = 0x02, // 0000 0010 BLOCKMASK_AIR = 0x04, // 0000 0100 BLOCKMASK_WATER = 0x08, // 0000 1000 - BLOCKMASK_GROUND = 0x16 // 0001 0000 + BLOCKMASK_GROUND = 0x16, // 0001 0000 + BLOCKMASK_GROUNDTOP = 0x32 // 0010 0000 }; enum DebugType diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index bd2043fba..8142cc194 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -55,6 +55,7 @@ enum SoundEvent SOUND_EVENT_DIE, SOUND_EVENT_MOVE, SOUND_EVENT_SIT, + SOUND_EVENT_SITTOP, SOUND_EVENT_SPAWN }; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 19f9ab3f2..3f1ef1239 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -431,6 +431,9 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) case Map::COLLISION_WATER: map->blockTile(x, y, Map::BLOCKTYPE_WATER); break; + case Map::COLLISION_GROUNDTOP: + map->blockTile(x, y, Map::BLOCKTYPE_GROUNDTOP); + break; default: break; } diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 2c9448fc3..d76585fd2 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -160,6 +160,10 @@ void MonsterDB::load() { currentInfo->addSound(SOUND_EVENT_SIT, filename); } + else if (event == "sittop") + { + currentInfo->addSound(SOUND_EVENT_SITTOP, filename); + } else if (event == "spawn") { currentInfo->addSound(SOUND_EVENT_SPAWN, filename); diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 4aa0eada4..da3b70559 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -143,6 +143,7 @@ void SpriteDef::substituteActions() substituteAction(SpriteAction::CAST_MAGIC, SpriteAction::ATTACK); substituteAction(SpriteAction::USE_ITEM, SpriteAction::CAST_MAGIC); substituteAction(SpriteAction::SIT, SpriteAction::STAND); + substituteAction(SpriteAction::SITTOP, SpriteAction::SIT); substituteAction(SpriteAction::SLEEP, SpriteAction::SIT); substituteAction(SpriteAction::HURT, SpriteAction::STAND); substituteAction(SpriteAction::DEAD, SpriteAction::HURT); diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index e59e4bd1f..b0cb5f1b6 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -78,6 +78,7 @@ namespace SpriteAction static const std::string DEFAULT = "stand"; static const std::string STAND = "stand"; static const std::string SIT = "sit"; + static const std::string SITTOP = "sittop"; static const std::string SLEEP = "sleep"; static const std::string DEAD = "dead"; static const std::string MOVE = "walk"; |