summaryrefslogtreecommitdiff
path: root/src/being.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-04-29Changed removeColors to work in-placeThorbjørn Lindeijer1-4/+2
Can avoid some memory allocations. Also simplified its implementation a little. Also made ChatLogger::getDateString use the full year.
2025-04-25GUI: Added support for multiple color palettes to ThemeThorbjørn Lindeijer1-22/+20
Each Skin can point to a different palette, which can be used to tweak text colors where necessary. For now there is no generic solution for this, instead a number of locations have been adjusted to take the palette into account: * ChatWindow sets its palette on the BrowserBox used in its tabs. * Popup sets its palette on child widgets when they are added (covering BrowserBox, Label and TextBox). * ItemPopup now uses its palette when looking up colors. The BrowserBox now retrieves its numbered text colors from the theme. Also added OLDCHAT, AWAYCHAT and GLOBAL theme colors, with ##g, ##o and ##a to choose these colors respectively. Fixed ImageRect move constructor. TextPreview class was cleaned up from unused functionality. Being name colors are no longer different between the name shown on the being and the name shown in the SpeechDialog.
2025-04-02Use a consistent naming style for enum class valuesThorbjørn Lindeijer1-8/+8
Sometimes I've used CamelCase and sometimes SNAKE_CASE for these values. Since "enum class" values are always prefixed with the enum name, which uses CamelCase, I find it more fitting to use it for the values as well. Also fixes compilation on Windows where 'ERROR' was conflicting with a define.
2025-04-01Fixed crash on exit when CharCreateDialog is openThorbjørn Lindeijer1-3/+7
* Displayed Being was deleting its SpeechBubble after the WindowContainer had already deleted it. Resolved by registering a DeathListener. * On dialog deletion, the CharHandler had become a roaming pointer but was still accessed.
2025-03-24Define the GUI theme in XMLThorbjørn Lindeijer1-2/+2
Now all images used by the various UI widgets are defined in a `theme.xml`, removing hardcoded requirements on the size of images, borders and sub-images and their locations. The `colors.xml` file was merged into this new file as well. The `<img>` element defines either a plain image, or a 9-scale that is automatically rendered at the size of the widget when any of the `left`, `right`, `top` or `bottom` attributes are given. The `x`, `y`, `width` and `height` attributes determine the sub-rectangle within the image referenced by `src`. `x` and `y` default to 0 and `width` and `height` default to the imge size. The `<state>` element defines in which state its images are used by setting its `selected`, `disabled`, `hovered` or `focused` attributes to either `true` or `false`. Only the first matching state is rendered. The `Text` and `SpeechBubble` classes now use the same skin to draw the bubble, as well as using a newly introduced `BUBBLE_TEXT` color from the theme palette.
2025-03-07Introduced spriteOffsetY setting to replace half tile hackThorbjørn Lindeijer1-5/+2
For historical reasons, sprites get a 16 pixel offset by default, which is used to position them correctly on their tile. When pixel-based movement was added, actors are now positioned on the middle of a tile and the built-in offset was removed. Servers that use sprites that do not rely on this offset can now set the spriteOffsetY option to 0.
2025-03-07Support triggering attacks and play use ability animationsThorbjørn Lindeijer1-1/+8
For now, PlayerHandler::attack just tries to trigger the "Strike" ability. Adjusted the AbilityDB to the removal of ability categories and the addition of the useaction attribute (mana/manaserv@81f126ae001b1446dc0be37341f133dca5ab2923)
2025-02-25Replaced ParticleContainer with a ParticleHandleThorbjørn Lindeijer1-30/+16
The main feature of the ParticleContainer seemed to be to provide persistent access to particles, even though they are generally owned by their parent particle. This allowed particles to be moved along with the ActorSprite and to be killed explicitly when they were no longer wanted. The ParticleHandle now takes care of disabling automatic deletion and of killing the particle along with the handle. It allows the particle references to be stored in whatever container is suitable, like a vector for general ActorSprite particle effects, separate vectors for equipment based particles and finally a map for status effect particles. Moving the particles along with the ActorSprite does need to happen more explicitly now, but overall it's a nice cleanup.
2025-02-25Added support for option, opt1, opt2, opt3 status effect fieldsThorbjørn Lindeijer1-45/+23
Supporting these fields is necessary to correctly identify status effects sent by tmwAthena. This is a manual port of ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4, 542d2ba78d84e0fa051e0620ccab5fb3a0c711e3 and 8800940bb4b94f6dab7dcf80bf0abc3e3b09e35f from M+.
2025-02-21Merged AnimatedSprite into SpriteThorbjørn Lindeijer1-3/+3
With AnimatedSprite being the only implementation of the Sprite interface, there was no longer a point in separating these.
2025-02-21Made ActorSprite aggregate instead of subclass CompoundSpriteThorbjørn Lindeijer1-13/+13
Also, CompoundSprite itself no longer derives from Sprite. This simplifies the class hierarchies and avoids the compiler warning about Being::setDirection shadowing Sprite::setDirection.
2025-02-21Moved stun and status effect handling from ActorSprite to BeingThorbjørn Lindeijer1-6/+79
Since this stuff is only relevant for Being instances and not for FloorItem instances. Also removed the virtual getWidth/getHeight from Actor, since they were not actually used.
2025-02-13Support changing being base typeThorbjørn Lindeijer1-57/+77
The GM command @class (alias @charclass) can be used by GMs to change their character class (also referred to as job, race, base or species). Changes of the class are now supported, even supporting switching between appearing as player, monster or NPC. Part of https://git.themanaworld.org/mana/mana/-/issues/92
2025-02-13Implemented support for item replacementsThorbjørn Lindeijer1-24/+122
Specifying an unknown sprite or direction is reported as error and will not cause any replacements. Specific item replacements are supported also when not specifying the sprite. Replacements do not affect particle effects. Part of https://git.themanaworld.org/mana/mana/-/issues/92
2025-01-21Fixed ConfigOptionChanged eventsThorbjørn Lindeijer1-1/+1
With the statically typed config we no longer get an event for each changed config value. Where relevant, this is now done through `setConfigValue`. The `Event` now uses a `std::any`, which for `ConfigOptionChanged` events is set to the changed `Config` member. This allows for a type-safe check on which config value was changed.
2025-01-20Made client config statically typedThorbjørn Lindeijer1-6/+6
This makes accessing the config values much faster, since it no longer needs to do a lookup nor string conversion, which means we could remove some needless copying of the values. Overall it makes it easier to find out where settings are used and it puts the defaults along with the declaration. Options with default values are no longer saved to the config file. This does not include unrecognized options, which are kept around to provide some compatibility with older clients. While most basic options have kept the same name, more complicated settings like window geometry, shortcuts, outfits, etc. now have their own XML elements. Older clients will ignore these and erase them when saving the configuration.
2024-10-29Turned the PlayerRelation struct into an enum classThorbjørn Lindeijer1-1/+1
Less code to achieve the same thing (strong type and namespaced values). The permissions related values have been moved to a PlayerPermissions struct, which is also a bit less confusing.
2024-10-12Added support for hit/miss sounds on equipment for all playersThorbjørn Lindeijer1-8/+25
Previously only the local player's weapon "strike" sound would play, regardless of hit or miss. Now the sound is played in response to the SMSG_BEING_ACTION message, so it can be played for all players. Also added alias "miss", which is used by TMW in some places. Finally, when no weapon is equipped, it falls back to the sounds defined on the racesprite item (fixes punch sound on TMW). Closes #68
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.