summaryrefslogtreecommitdiff
path: root/src/being.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-10-09Added several sound events and support for spawn animationadd-sound-eventsThorbjørn Lindeijer1-0/+8
- Added "miss" as alias for "strike" (closes #68) - Added "move", "sit" and "spawn" monster sounds
2024-10-08Simplified "drawnWhenBehind" logicThorbjørn Lindeijer1-2/+3
* 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-0/+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-32/+44
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-19/+15
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-7/+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-10-02Fixed potential crash in character selectionThorbjørn Lindeijer1-0/+2
When items with particle effects are equipped.
2024-10-02Removed getter/setter cruft from BeingInfoThorbjørn Lindeijer1-17/+16
Made the class and the code in general more readable by removing all the needless getters and setters. Also used "enum class" for SoundEvent.
2024-09-30Added support for particle effects on equipmentThorbjørn Lindeijer1-19/+78
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-09-28Removed getter/setter cruft from ItemInfoThorbjørn Lindeijer1-11/+7
Made the class and the code in general more readable by removing all the needless getters and setters.
2024-08-04Add to npc option targetSelection to allow/disallow npc selection.Thorbjørn Lindeijer1-1/+6
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-15/+12
* 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-7/+11
* 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-3/+3
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-02Changed server type to "enum class"Thorbjørn Lindeijer1-1/+1
2024-03-02Added support for customizing NPC and Monster hover cursorThorbjørn Lindeijer1-11/+12
To match support for this in M+, since TMW uses this functionality on two of its NPCs.
2024-03-02General code cleanupsThorbjørn Lindeijer1-6/+6
* Don't needlessly store or return raw pointers in BeingInfo * Less copying, more moving * Less else after return * Make AddDEF a template instead of a macro * Removed some unused includes * Use range-based for loops
2024-02-13General code cleanupsThorbjørn Lindeijer1-34/+3
* 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-30Apply readability-delete-null-pointer fixitsThorbjørn Lindeijer1-11/+4
These checks are unnecessary as deleting a null pointer has no effect.
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-19/+19
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2013-05-02Fixed network layer doing delayed actor deletionThorbjørn Lindeijer1-1/+1
The delayed actor deletion was meant to be used during the logic calls, to avoid modifying the container while it is being iterated. The deletions happening from the network layer are not done while iterating the set of actors, so it can delete immediately. This fixes an issue where an NPC would disappear when changing appearance on tmwAthena, because this was implemented as a remove + add, which broke due to the delayed deletion. Mantis-issue: 507 Reviewed-by: Jared Adams
2012-02-02Fix to the hair colors and styles handling.Yohann Ferreira1-15/+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-20Fixed a bug with hurt sounds volume and simplified codeThorbjørn Lindeijer1-1/+1
The hurt sound volume was being played based on the distance in tiles, even though Sound::playSfx was expecting pixels. This would cause hurt sounds of other players to play too loud. There were also several conversions between pixel and tile coordinates that could be simplified. Reviewed-by: Yohann Ferreira
2012-01-18ColorDB -> HairDB.Yohann Ferreira1-1/+1
This will ease the reading of the next patch about hair handling at character creation time in tAthena. As requested by bjorn. Reviewed-by: bjorn
2012-01-14Fixed the chat bubbles position.Yohann Ferreira1-5/+9
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.
2012-01-10player_node -> local_playerYohann Ferreira1-17/+17
Reviewed-by: Ablu
2012-01-10Hopefully fixed the butterfly direction updates.Yohann Ferreira1-25/+17
In fact, the bug was nastier and could also concern many other beings, such as squirels, and some players. The bug came from the distance odd check I added a while ago. This (ugly) hack wasn't needed anymore since I made beings finish their path before starting the new one also a while ago. This also fixes some movement glitches I've seen in manaserv at login time (Hurray). Thanks for Ali-G for spotting this one. Reviewed-by: Ablu
2012-01-09Spotted some more hard-coded files and paths definitions.Yohann Ferreira1-2/+0
Conflicts: src/actorsprite.cpp
2011-09-02The draw order of particles is now Y - 16 pixels.unknown1-7/+7
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-19Fixed visible equipment updates, and made it based on equip.xml.Yohann Ferreira1-2/+0
2011-06-23Made the being death sequence better handled.Yohann Ferreira1-2/+4
Now the death animation is set to the minimum of 1.5 seconds just as in the older versions, but permit longer sequences as well. I didn't put a maximum hard cap on it as it may be a burden for the maintainers whatever the hard cap would be, and as it isn't vital to set one anyway. Resolves: Mana-Mantis #364. Reviewed-by: bjorn, Jaxad0127.
2011-06-22Applied fixes requested by cody.Yohann Ferreira1-2/+2
- Made the map teleport distance fixed for manaserv. - Small cleanups. The branch is considered reviewed by: Cody. Resolves Mana-Mantis: #74.
2011-06-17First pass on removing tile hard coded values.Yohann Ferreira1-3/+3
Every files has been checked against the hard coded 32 values except the map.cpp file. I also added convenience functions in the Game class, centralized the default item icon size, and removed two unused defines in being.cpp.
2011-06-07Added hit effects on victims from monsters attacks.Yohann Ferreira1-1/+11
Resolves: Mana-Mantis #336. Reviewed-by: Jaxad0127.
2011-06-07Fix particle positionsJared Adams1-7/+7
Particles were being drawn with wrong positions due to their Z coordinate being taken into account when sorting actors. Z is now only taken into account when drawing them. Reviewed-by: Bertram
2011-06-02Arbitrary code cleanupsThorbjørn Lindeijer1-4/+4
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-30Fix changing maps with persistant particle effects activeJared Adams1-1/+1
2011-05-30Remove some uneeded offsettingJared Adams1-4/+2
Also fix position of being names. Reviewed-by: Bertram
2011-05-30Fix monsters name display.Yohann Ferreira1-1/+2
The monster offset wasn't counted anymore so I had to readd it in the display coordinates. Part of issue: #345.
2011-05-26Added effects support in monsters attacks.Yohann Ferreira1-18/+21
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-05-15Starting to fix party inviteStefan Dombrowski1-5/+0
2011-04-30Added customizable on-hit effects for characters.Yohann Ferreira1-4/+18
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-206/+162
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-16Made the attackers look at their victims when possible.Yohann Ferreira1-0/+3
That simply make the game a bit more realistic as I saw many archers back fire arrows lately ;) Plus, that's what the servers should expect.
2011-04-16Introduced the Being::lookAt() function.Yohann Ferreira1-0/+80
We're now using it when picking up items. Also, de-overnested the Game::handleInput() function when handling pickups.
2011-04-09Removed the Mana namespaceThorbjørn Lindeijer1-9/+9
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-5/+5
Acked-by: Jared Adams
2011-04-09Moved Events to Mana::Event::TypeThorbjørn Lindeijer1-2/+3
Acked-by: Jared Adams