summaryrefslogtreecommitdiff
path: root/src/being.h
AgeCommit message (Collapse)AuthorFilesLines
2024-10-08Simplified "drawnWhenBehind" logicThorbjørn Lindeijer1-7/+1
* Removed `Actor::getNumberOfLayers`, since we really only cared about whether they should be visible when behind other stuff. * Removed `CompoundSprite::drawnWhenBehind`, since this property was only relevant for actors.
2024-10-08Smoother keyboard movementThorbjørn Lindeijer1-3/+8
This change addresses the slight stutter and broken animation playback when walking with the keyboard. Once the end of the path has been reached but a movement key is still held, the LocalPlayer now immediately calculates a new path rather than waiting on the next logic update.
2024-10-08Smoother being movementThorbjørn Lindeijer1-9/+3
There was a slight stutter in being movement, since each time a being reached the next position along its path, it would only continue to the following position with the next logic tick. Now the logic has been adjusted to keep moving until all the time for the current frame was used up, or the path was exhausted. A slight stutter remains for keyboard movement, as well as broken walk animation playback, since it will only set a new path once the current one is finished (see e554d9b2be1ec2fcb15065ae70151302adeef602). Also simplified some logic in Viewport::draw and removed some obsolete code in LocalPlayer::startWalking.
2024-10-08Do a single logic update each frameThorbjørn Lindeijer1-6/+5
The logic update now uses Time::deltaTimeMs() where needed to make it framerate-independent. This means there will no longer be multiple logic calls per frame (as was usually the case with logic ticking at 100 fps whereas the game would generally run at 60 fps). At the same time, the game can be more precise at higher framerates and should now run smoother at 144 Hz, for example. Previously the game would sometimes skip logic ticks at that rate. This change affects: * Updating of animations * Being movement speed * More moving of manual time variables to Timer Notoriously, the particle system still does 100 ticks/second.
2024-10-08Added convenient and efficient Timer classThorbjørn Lindeijer1-1/+3
The Timer is efficient because it does not depend on incrementing a counter to keep track of time, nor does it call SDL_GetTicks every time its state is checked (this happens once per frame instead). Along with global functions Time::absoluteTimeMs() and Time::deltaTimeMs(), this replaces previous globals tick_time, cur_time and get_elapsed_time(). For now, there is still a fixed 100 times per second logic call rate, but the new Time::deltaTimeMs() function should allow getting rid of this.
2024-09-30Added support for particle effects on equipmentThorbjørn Lindeijer1-5/+17
The effect is also there when the equipment is dropped, because it uses the same field as the floor item. Removed unused ItemInfo::particle. Based roughly on M+ commit 44e5d8bcb7fea443ca9ed3844454b11ac6e4dbed. Closes #85
2024-08-04Add to npc option targetSelection to allow/disallow npc selection.Thorbjørn Lindeijer1-2/+4
The targetSelection attribute is supported on monsters and NPCs. Also changed return value of Being::getInfo to indicate it can't return nullptr. (cherry picked from M+ commit dbc3b324a0c5dcb1a0ee29b289e71423a06e85fd)
2024-04-02General code cleanupsThorbjørn Lindeijer1-1/+0
* Removed some unused includes * Removed unused ListBox::mFont * Removed wrong cast to SDL_Scancode * Removed superfluous .c_str() * Removed superfluous explicit std::string construction * Removed unused variable * Use more emplace_back * Turned FindBeingFunctor into a lambda * Avoid needless pointer references for ambient layers and use a vector
2024-03-06General code cleanupsThorbjørn Lindeijer1-3/+3
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
2024-03-04Fixed character displayThorbjørn Lindeijer1-5/+6
This change fixes hair style to take into account "race", which makes the faces visible again. Hair colors should also be fixed now, with partial support for itemcolors.xml added. The Mana client now also supports per-character gender, and it now hides the hair style and color buttons on character creation, when there are none to choose from. Closes #43
2024-03-02Added support for customizing NPC and Monster hover cursorThorbjørn Lindeijer1-0/+3
To match support for this in M+, since TMW uses this functionality on two of its NPCs.
2024-02-22General code cleanupsThorbjørn Lindeijer1-1/+2
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
2024-02-13General code cleanupsThorbjørn Lindeijer1-19/+19
* Removing unused includes * Use member initialization * Use range-based for loops * Use nullptr * Removed no longer used aliases * Use override * Don't use else after return * Use '= delete' to remove implicit members * Use std::string::empty instead of comparing to ""
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-13/+13
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2012-04-02Fixed problems with using the last emotev0.6.1Thorbjørn Lindeijer1-2/+0
The tmwa/BeingHandler was adjusting the effect id rather than the emote id, causing it to not find the last emote (and the rest of the emotes only worked correctly because the effect ids were consecutive in the same order as the emote ids). Furthermore, the EmoteShortcutContainer refused to draw the icon for the last emote due to an off-by-one error in dealing with the 1-adjusted emote ids used by the EmoteShortcut class. Also cleaned up some old remains of a player ignore strategy that used to use the two balloon emotes (this had been their original purpose). Reviewed-by: Erik Schilling
2012-02-02Fixed player's character direction.Yohann Ferreira1-1/+3
Made the player's character look at where it is going even when using the keyboard, by setting its direction after getting the actual destination, and not before. I also used the lookAt() function to avoid yet another custom way of setting the direction. Reviewed-by: Erik Schilling
2012-02-02Fix to the hair colors and styles handling.Yohann Ferreira1-10/+0
- I made the charCreatedialog handle a possible max permitted color Id and a minimum hair style id for tA. - Added a foundation to later load the styles and colors from the same file, to handle the Mana-issue #224 for manaserv. - Support for non-contiguous hair color and style ids has also been added. - I also replaced the < and > arrow signs with images. Reviewed-by: Ben Longbons, Thorbjørn Lindeijer
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2012-01-26Removed 'inline' keyword where it's not of any valueThorbjørn Lindeijer1-1/+1
Members that are implemented inline are already inline, there is no need to mark them as such. Made two inline members of OpenGLGraphics private since because they are marked as inline, they can't be used from other classes. Reviewed-by: Erik Schilling
2012-01-14Fixed the chat bubbles position.Yohann Ferreira1-0/+5
This issue was much nastier than it first sounded. The issue was happening when using a long weapon (like the scythe) with the SDL backend. The algorithm computing the sprite compound frames into one would then update the sprite height to a high value (127 in my case), leading to put the bubble too far away from the player. The algorithm not being in cause about the needed height, I noticed that the simplest way to set a good Y position of the text bubbles was to simply set a maximum. A config option can be added later. I also unified the way the position is computed in the being class. + Function description sentence removal requested by bjorn. Resolves: Mana-Mantis #447. Reviewed-by: bjorn.
2011-09-02The draw order of particles is now Y - 16 pixels.unknown1-0/+3
This means that the order point of the sprites relative to the particles is no longer the lowest point of the image but instead a point which is approximately between the feet of the characters. The intent of the latest commits to treat sprites as perpendicular to the ground instead of perpendicular to the view line is retained by this approach. I tested this with various particle effects and it results in exactly the expected behavior. Note that this does NOT fix the current problems on TMW with the snail slime effect, because the TMW content team accidently placed this one 10px in the air. Sorry, garbage in, garbage out. getDrawPixelY was re-renamed to getPixelY to be consistent with getPixelX, while getPixelY was renamed to getDrawOrder, to make its purpose clear. Further, particles are no longer drawn when behind other objects. This is implemented by adding a drawnWhenBehind member function to Actor, which currently returns true for everything except particles and compound- sprites with more than one sub-sprites (the later case is consistent with the previous behavior of them). An exception are text particles which are excempt from this exception and whose drawing order is also biased by 16 pixels south instead of north to make them more visible. Plus some minor changes from Bertram. Reviewed-by: Bertram. Resolves: Mana-Mantis #362.
2011-08-11Made the delay between to keyboard move calls functional.Yohann Ferreira1-1/+1
It has been fixed and be made adapted to the being movement speed. Now, for instance, the client sends 3x times less move calls to the tA server, and roughly 20x times for the Manaserv's one. Resolves: Mana-Mantis #346.
2011-06-17Made the client officially handle attack ids.Yohann Ferreira1-1/+1
It already was, but now the the api is clear about it. Client part of the mana issue: #363. Reviewed-by: Bjorn.
2011-06-07Added hit effects on victims from monsters attacks.Yohann Ferreira1-1/+3
Resolves: Mana-Mantis #336. Reviewed-by: Jaxad0127.
2011-06-03Replace SDL_types.h with cstdintJared Adams1-9/+7
This required moving to C++0x, so it does that too, and fixes a few errors with that. Reviewed-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
2011-06-02Arbitrary code cleanupsThorbjørn Lindeijer1-1/+2
Just some stuff that piles up while "looking" at the code, which eventually gets annoying to ignore while staging real changes. * Replaced a few NULL occurrences with 0 * Rely on default parameter for std::vector::resize. * Replaced a few "" with std::string() * Prefer .empty() to == "" * Removed a few comparisons with NULL * Don't check pointers before deleting them * Removed a bunch of redundant semicolons * Made some global variables static (local to their compilation unit) * Prefer prefix ++/-- operators to postfix versions when possible * Corrected location of a comment
2011-05-26Added effects support in monsters attacks.Yohann Ferreira1-3/+2
This is provided through the use of the 'effect-id' property of the <attack> tag. Note that the 'particle-effect' support has been removed as it was redundant, but can be kept for backward compatibility. Now, on both Manaserv and tA, only the attack id 1 is supported, i.e: <monster> ... <attack id="1" effect-id="11" action="attack" /> </monster> More to come with re-enabling of the attack type support. I had to fix a crash in the Being::takeDamage() function when there were no attacker (in Manaserv), and add rotation support to the effectManager to achieve this. Reviwed-by: Jaxad0127.
2011-05-17Fix sprite buffering size issuesJared Adams1-10/+0
Reviewed-by: Yohann Ferreira
2011-04-30Fixed documentation about beings attack speed unit.Yohann Ferreira1-2/+3
2011-04-30Added customizable on-hit effects for characters.Yohann Ferreira1-0/+3
This patch adds support for the following two parameters in weapon items: hit-effect-id: Effect triggered on the victim on normal hit. critical-hit-effect-id: Triggered on the victim on critical hit. (Specified in effects.xml) The patch also permits the use of custom defaults set in paths.xml by setting the following keys: (Paths are relative to the 'particles' key value, here.) hitEffectId: defaulted to effect id 26. criticalHitEffectId: defaulted to effect id 28. Resolves: Mana-mantis #337. Reviewed-by: bcs86
2011-04-26Made the client use a unique kind of movement code.Yohann Ferreira1-61/+29
This is fixng many issues and (hopefully) will make the movement rendering much smoother. Merge branch 'master' of gitorious.org:~bertram/mana/mana-movement-code-merge Conflicts: src/being.cpp src/net/manaserv/beinghandler.cpp Resolves: TMW-Mantis #946. Reviewed-by: Thorbjorn.
2011-04-16Introduced the Being::lookAt() function.Yohann Ferreira1-0/+5
We're now using it when picking up items. Also, de-overnested the Game::handleInput() function when handling pickups.
2011-04-09Renamed Listener to EventListenerThorbjørn Lindeijer1-2/+2
Makes it clear what kind of listener it is, since there are other listener classes as well. Acked-by: Jared Adams
2011-04-09Removed the Mana namespaceThorbjørn Lindeijer1-2/+2
It's just an annoyance when it's only applied to a few classes. Either we place everything in this namespace or nothing, and at the moment I don't see any rationale for placing everything in a Mana namespace. Acked-by: Jared Adams
2011-04-09Moved Channels to Mana::Event::ChannelThorbjørn Lindeijer1-1/+1
Acked-by: Jared Adams
2011-03-28Random code cleanups requested righteously by Thorbjorn - part 1.Yohann Ferreira1-4/+4
- Fixed bogus documentation. - Fixed Vector parameters to const Vector& where releavant. - Removed a false comment. - Removed superfluous headers in src/net/tmwa/beinghandler.h. - Optimize a bit the tmwa::beingHandler::getPixelsPerTickMoveSpeed() function.
2011-03-15Basically merged the two movement algorithms into one.Yohann Ferreira1-58/+21
This was made in favour of the manaserv way of doing things. I also added a way to keep the original server speed value so the pixel value can be recomputed at each map change, as this was necessary since the speed is given before the first map is loaded. The code is much more simpler now about movement handling, and we can already see improvements on other characters movements in The Mana World with this. Everything can't be perfect the first time; here are bugs identified so far: - Monsters direction isn't updated on TmwAthena for obscure reasons. - Remote players walking animation is sometimes reset on each steps. - When changing map, the local player sometimes walks randomly until the player reacts. Stay tuned!
2010-12-06Removed superfluous #includes taken from checkheaders list.Yohann Ferreira1-1/+0
Resolves: Mana-Mantis #265. Trivial fix.
2010-11-13Replace config listeners with the event systemChuck Miller1-4/+1
Reviewed-by: Jared Adams
2010-11-11Have the event system channels use enums instead of stringsChuck Miller1-1/+1
Reviewed-by: Freeyorp
2010-11-07Convert the emote system to use particlesChuck Miller1-23/+0
Reviewed-by: Jared Adams
2010-11-01Merge branch '0.5' of gitorious.org:mana/manaYohann Ferreira1-0/+14
Conflicts: src/being.cpp src/client.cpp src/commandhandler.cpp src/gui/setup_video.cpp src/gui/socialwindow.cpp src/gui/viewport.cpp src/gui/widgets/browserbox.cpp src/gui/widgets/itemcontainer.cpp src/imageparticle.cpp src/localplayer.cpp src/localplayer.h src/map.cpp src/net/tmwa/beinghandler.cpp src/particle.cpp src/particle.h src/player.cpp src/player.h
2010-08-05Have Being manage speech creation and add permissions to eventsJared Adams1-1/+4
The Being and Player Chat events now have the precomuted permissions for SPEECH_LOG and SPEECH_FLOAT. The Being class now acts on those events to show speech (if SPEECH_FLOAT is present). ChatWindow now checks for the SPEECH_LOG permission. Reviewed-by: Freeyorp
2010-08-01Remove isActive methods from buy/sell windowsJared Adams1-2/+0
Uses a state variable in PlayerInfo instead. Moves isTalking from Being to PlayerInfo. Also some small cleanups. Reviewed-by: Chuck Miller
2010-07-29Changed the items loading to handle a new 'attack-action' parameter.Yohann Ferreira1-1/+1
The old behaviour was to load the weapon-type value and do many unnecessary checks and transformation on it: The weapon-type was transformed using hard-coded values into an integer enum value. The exact same thing was done on the opposite side in the animation files before comparing the two. As both data were string values, I simplified all of it by using the value taken in items.xml to call the corresponding action. This now also permit to set up new attack animation in items.xml and in the playerset.xml without having the need to modify the client code. Last but not least, the weapon-type value was used by both the skills and the actions and avoided the possibility to set up a definite action for a weapon-type. Note: The weapon-type parameter will become deprecated for the server in favor of a 'skill' parameter to reflect more it's actual use. This patch is the first step to fix Manasource issue: #157.
2010-07-19Merge branch '1.0'Yohann Ferreira1-1/+7
Conflicts: src/gui/itempopup.cpp src/item.cpp src/monster.cpp src/net/manaserv/playerhandler.cpp src/net/tmwa/partyhandler.cpp src/npc.cpp src/player.cpp src/resources/itemdb.cpp src/resources/monsterdb.cpp src/resources/monsterinfo.cpp src/resources/npcdb.cpp src/resources/spritedef.cpp
2010-07-11Made the different hard-coded paths and files be now taken from theYohann Ferreira1-1/+7
data/paths.xml configuration file. Also added default gui theme path in branding and default wallpaper path and file searched respectively in the branding and paths.xml files. Hard-coded values are still used as fallbacks. Resolves: Manasource Mantis #148. Reviewed-by: jaxad0127.
2010-06-09Fix dead Beings not being removed using tmwAthenaJared Adams1-12/+5
Rename mWalkTime to mActionTime in Being and have Being manage death. Reviewed-by: 4144
2010-06-09Remove hard-coded frame counts from Being classJared Adams1-14/+0
Also removes the Monster/Player difference in tmwAthena's Being::logic and moves the particle code from Being::setAttack to Being::Logic for tmwAthena. Reviewed-by: Chuck Miller
2010-05-17Remove Monster, Player, and NPC classesJared Adams1-23/+142
Instead of having these three subclasses with minor differences, this commit merges them back into Being. In the future, we can make Beings that are talkable to some, attackable by others, etc. This also puts back support for monster equipment. Also changes remaining references to Being::Type and the constants to refer to ActorSprite::Type. Reviewed-by: Freeyorp