summaryrefslogtreecommitdiff
path: root/src/game-server/character.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-09Replaced EventListener with signals based on libsigc++Thorbjørn Lindeijer1-9/+1
This replaces the rather hard to understand event dispatcher with a probably even harder to understand templated library, but fortunately we can rely on the available documentation. Hopefully it will also help with the readability of our code and with adding additional signals to other classes. Added libsigc++ to README and Travis CI configuration. Reviewed-by: Erik Schilling
2013-01-09Replaced 'unsigned int' with 'unsigned'Thorbjørn Lindeijer1-2/+2
Same thing, but shorter.
2013-01-08Work on (Auto)Attack system.Erik Schilling1-53/+41
During the implementation bjorn and I agreed to limit the number of attacks that can be used in the same tick to one. This makes a lot of stuff easier and the client cannot display two frames at the same time Things done: - Implemented setting of attacks when equipping/unequipping items - Single place where the xml attack node is parsed - Finished attack logic - Unified the attack handling of monsters and characters - Added a global cooldown after attack use (not only for next use of same attack) - Removed the temponary attributes for the monster attack values - Priorities for all attacks - Rewrote the attack core: - Attacks now have this attributes: - warmup -> time a attack needs after starting it to actually deal the damage - cooldown -> time a attack needs after dealing damage before another attack can be used - reuse -> time before the same attack can be used again - If no attack is performed at the moment the following is done: - make a list with all ready attacks - check for attack that has the necessarily range and highest priority - start this attack (inform client about it) - when warmup is finished -> trigger damage - when cooldown is finished -> allow to use other (or the same if reusetimer allows) attacks TODO: - sync client with this to allow better timed animations
2013-01-08Rename AutoAttack to AttackErik Schilling1-9/+9
2012-08-05Fixed recalculation of base attributesErik Schilling1-7/+7
We do not need to calculate derived attributes of the derived attributes but the base of the derived attribute. Reviewed-by: bjorn.
2012-08-03Made the character not colliding with monsters.Erik Schilling1-1/+1
Prevents clientside desyncs. Reviewed-by: Stefan Beller.
2012-07-17Added lua binds for issuing request of quest variable + bind for trying to ↵Erik Schilling1-1/+0
read them The difference to the old chr_get_quest bind is that this allows querying quest vars from non npc functions as well. Change is tested. Reviewed-by: bjorn.
2012-07-08Added bind for setting login callbackErik Schilling1-0/+6
Reviewed-by: bjorn.
2012-05-25Fixed handling of skillsErik Schilling1-4/+1
- Removed possibility of skills getting mixed with attributes - Made the server sending the level of the current skill on exp change (currently the client could calculate it itself, but it allows more flexibillity in future this way) - Fixed reading of skills out of the database (for some reason the status effects were added as skills) ** Needs clientside patch as well (coming soon) ** Reviewed-by: Bertram.
2012-04-18Removed not needed trigger for specialupdate when INT attribute changed.Erik Schilling1-4/+0
I removed this dependency a while ago. But forgot to remove this code. Reviewed-by: bjorn.
2012-04-04Enhanced special supportErik Schilling1-72/+131
- Made the current charge being saved. - Added script binds: - chr_set_special_recharge_speed - chr_get_special_recharge_speed - chr_set_special_mana - chr_get_special_mana - get_special_info - Added special info lua class. Functions: - name - needed_mana - rechargeable - on_use - on_recharged - category Further the engine no longer sets charge to 0 after using of specials this allows more flexbilillity (like failing specials). Changes on the xml database: - recharge renamed to rechargeable (needed by client and server) - needed - the needed mana to trigger a special (server only) - rechargespeed - the defailt recharge speed in mana per tick (server only) - target - the type of target (either being or point) (server and client) I also made the lua engine pushing nil instead of a 0 light userdata when the pointer was 0. Database update needed. Change is tested. Mana-Mantis: #167, #156 Reviewed-by: bjorn.
2012-03-26Some general cleanups and merged Being::perform() into update()Thorbjørn Lindeijer1-7/+9
The main change here is to remove the separate calling of 'perform' on all beings, and rather rely on the beings to do whatever they were doing in that function when the virtual 'update' function is called. Reviewed-by: Yohann Ferreira
2012-03-13Added script bind to set walkmask for beingsErik Schilling1-0/+3
TODO: Inform client about this change. Reviewed-by: bjorn.
2012-03-11Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer1-0/+26
When creating an NPC, you now provide its optional talk and update functions directly rather than them being stored in a table on the Lua side and then called in response to a global callback. Also fixed an issue with a missing gender parameter to the delayed NPC creation callback used by NPCs defined on the map (found by Erik while reviewing this patch). Reviewed-by: Erik Schilling
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-1/+7
Rather than wrapping NPC functions up in coroutines in the Lua side, they are now managed on the C++ side as "script threads", which are essentially the same thing. The main purpose is that the server can now know whether any of these long running script interactions are still active, which will probably be useful when adding the ability to reload scripts. Reviewed-by: Erik Schilling
2012-03-05Added possibility to make a being attack an other beingErik Schilling1-5/+9
This allows the script to let the character perform a scripted attack but the character still gets xp and killed monsters give drops. You can now call: mana.being_damage(target, dmg, dmg_delta, accurancy, type, element, source, skill) While on it I also added checks to the being_damage function. Reviewed-by: bjorn, Bertram.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer1-3/+3
This includes the quest reply, post reply, death notification and remove notification. Also, Script::Ref was changed from a typedef to a small class, automating initialization and making the check for validness clearer. Reviewed-by: Erik Schilling
2012-03-02Use callbacks for handling character death and respawnThorbjørn Lindeijer1-4/+22
Rather than relying on the availability of global functions with certain predefined names, the Lua script now calls API functions to set which function should be called on these global events. This mechanism should make it easier to avoid name collisions in the global namespace, which is important now that there is only a single script state. For these global events this was not likely to become a problem, but this solution can also be used for callbacks on specific item or monster types, or even allow setting callbacks on certain instances. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-03-02Merged all the different Lua states into oneThorbjørn Lindeijer1-5/+5
No more Lua state for each status effect, monster, item effect or map. All scripts are loaded into the same state. This should be more efficient overall and make it easier to implement dynamic reloading of the scripts in the future. Now, this introduces the problem of name collisions between different Lua scripts. For now this is solved by using more specific function names, like 'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however to get rid of these globals, and register these callbacks from the script, so that they can be local functions without the danger of colliding with other scripts. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-02-02Added a way to specify the min and max attributes values.Yohann Ferreira1-3/+3
This can now be done in attributes.xml through the minimum and maximum attribute parameters. I also changed the AttributeInfo struct as requested by bjorn. Reviewed-by: Erik Schilling, Thorbjørn Lindeijer
2012-01-10Made the game server execute the chr_respawn_accept script evenYohann Ferreira1-14/+28
in case of disconnection. I made the Character::disconnected() function handle that case, permitting also to centralize GameState::remove() calls there. I also made the GameState::enqueueWarp() function test whether the Character pointer is about to be deleted, so that the warp can be handled directly to avoid a crash. Last but not least, I also made the Character::update() function not update the Character specials and hp to avoid discrepancies seen in the client. Resolves: Mana-Mantis #309. Reviewed-by: Ablu.
2012-01-02Made all beings capable of having a genderErik Schilling1-16/+0
Reviewed-by: o11c, bjorn, Bertram.
2011-11-07Merged three global script states into oneThorbjørn Lindeijer1-1/+2
These scripts could trivially share one script state, since the methods called on them from the server are not overlapping. This does leave them open to access each other's global variables, but that's the problem with global variables. The one remaining global script file name is now configurable, so that it may also be set to a script in a different scripting language. The two related script options are: script_mainFile (default: scripts/main.lua) script_defaultEngine (default: lua) - renamed from defaultScriptEngine Reviewed-by: jurkan Reviewed-by: Yohann Ferreira
2011-11-01Merge github.com:mana/manaservYohann Ferreira1-3/+5
Conflicts: src/game-server/character.cpp src/scripting/lua.cpp
2011-10-22Officially added the being gender to the protocol.Yohann Ferreira1-1/+16
Reviewed-by: o11c.
2011-09-28Started to fix the autoattack system.Yohann Ferreira1-1/+3
I simply made the default autoattack look for the default skill and add exp to it when killing monsters. Now the player can earn xp again even if it's not well handled between two logins.
2011-09-28Officially added the being gender to the protocol.Yohann Ferreira1-1/+14
2011-09-28Small random code format cleanups, and documentation fixes.Yohann Ferreira1-1/+1
This doesn't change anything yet. Reviewed-by: o11c.
2011-07-27Small random code format cleanups, and documentation fixes.Yohann Ferreira1-1/+1
This doesn't change anything yet.
2011-06-24Fixed autoattacks basic handling.Yohann Ferreira1-12/+34
The server is now using the autoattacks system to perform damage based on the attack's timer. I also added a default bare knuckle attack when the character is unequipped. As a result, maggots can be killed again with bare hands now. Known issues left: This isn't tested against equipment changes for now, and the client isn't in sync with the attacks speed. Reviewed-by: Crush.
2011-03-20Renaming stuff to make the code more readableThorbjørn Lindeijer1-3/+3
SCOPE_TYPES -> ScopeType (plural was confusing) ATTR_BEING -> BeingScope ATTR_CHAR -> CharacterScope ATTR_MOD -> MonsterScope ATTR_MAX -> MaxScope AttributeScopes -> AttributeScope (A single scope seems to include multiple lists of attributes. Seems wrong to me to name this type in plural form.) getAttributeInfoForType -> getAttributeScope (just naming it after what it is actually returning) Reviewed-by: Freeyorp
2011-03-11Moved freeing of map position to Actor destructorThorbjørn Lindeijer1-12/+0
It was done in both the Character and the Monster destructors, but I don't see how any Actor should be excluded from this. Now it also happens for NPC, Effect and Item, though only NPC has a relevant walkmask. Also fixed a small issue introduced in 97e0a9eb170499 and added an assert to freeTile. We should be able to assert that a tile can only be freed if it was blocked. Reviewed-by: Stefan Dombrowski
2011-01-06Get rid of the server tick magic number.Yohann Ferreira1-2/+2
Reviewed-by: CodyMartin.
2011-01-03Change Actor::mActionTime to mMoveTime member to reflect more its actual use.Yohann Ferreira1-2/+4
Trivial.
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-19/+19
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.
2010-11-13Readd the calculation of base attributes at character's login.Yohann Ferreira1-0/+3
Reviewed-by: CodyMartin.
2010-11-04Fully shift being scope attributes into being.Freeyorp1-47/+27
Also split updateDerivedAttributes and remove the calc check workaround. Reviewed-by: Bertram.
2010-11-04[PATCH 1/3] Alter the way attribute dependencies are updated.Yohann Ferreira1-32/+50
Also fix movement speed dependency. Reviewed-by: Bertram
2010-11-03Renamed write{Byte,Short,Long} to writeInt{8,16,32}Thorbjørn Lindeijer1-15/+15
Mainly for consistency with the client, and the general consensus was that these numbered versions were clearer.
2010-10-17Dehardcode the tileWidth and height, except for the speed conversion.Yohann Ferreira1-1/+4
The speed conversion needs a standard tile length anyway and can be improved later once the movement code will start to handle beings size. Reviewed-by: Crush.
2010-10-17Fix hp regeneration units.Freeyorp1-2/+2
Reviewed-by: Bertram
2010-09-16Changed maxSkillCap to game_maxSkillCap as I forgot in last commit.Yohann Ferreira1-42/+54
Also made some random code format cleaups. Trivial fix.
2010-09-15Reordered the manaserv.xml.example file and made related code cleanups.Yohann Ferreira1-3/+3
Reviewed-by: Thorbjorn.
2010-08-29Merge branch 'testing'Freeyorp1-165/+160
Conflicts: src/account-server/storage.cpp src/game-server/being.cpp src/game-server/being.hpp src/game-server/character.cpp src/game-server/character.hpp src/game-server/gamehandler.cpp src/game-server/inventory.cpp src/scripting/lua.cpp src/sql/mysql/createTables.sql src/sql/sqlite/createTables.sql
2010-08-22Rename some stuff to conform to naming conventionsThorbjørn Lindeijer1-3/+3
2010-08-07Renamed modifiedAttribute to updateDerivedAttributesThorbjørn Lindeijer1-6/+6
This describes the purpose of the method better.
2010-08-03Add sanity checks for hp when hp or max hp change.Freeyorp1-0/+6
Reviewed-by: Bertram.
2010-08-03Allow default values for attributes at character creation time.Freeyorp1-7/+17
TODO: The game-server also needs to keep track of this for when new attributes or attributes not in the default scope need to be created. Also hopefully fix attribute calculation order for derived attributes. Still hardcoded for now. Reviewed-by: Bertram.
2010-07-10New attribute system and major changes to many low-level areas.Freeyorp1-165/+146
Attribute system: Structure is no longer completely hardcoded. Attributes and structure is defined by new xml file (defaulting to stats.xml) Structure defines non-base modifications to an attribute, to be used by modifiers from items, effects, etc. Calculating the base value for core attributes is still done in C++ (and for such fundamental elements the only reason I can think of to do it any other way is perhaps being able to quickly change scripts without a compile could be useful for testing, but such things are a low priority anyway) Item structure: Modifiers are now through triggers rather than single events. This also removes hardcoded types - an item could be both able to be equipped and be able to be activated. Item activation no longer consumes by default, this must be specified by the property <consumes /> inside the trigger. Currently only attribute modifications, autoattacks, and consumes are defined as effects, but stubs for others do exist. Autoattacks are currently non-functional, and this should be rectified with some urgency. Auto Attacks: AutoAttacks are now separate entities, though not fully complete, nor fully integrated with all beings yet. Integration with the Character class is urgent, integration with other Being children less so. When fully integrated this will allow for multiple autoattacks, through equipping multiple items with this as an equip effect or even through other means if needed. Equipment structure: As ItemClass types are no longer hardcoded, so too are equip types. An item have multiple ways to be equipped across multiple equipment slots with any number in each slot. Character maximums are global but configurable. Miscellaneous: Speed, money, and weight are now attributes. Some managers have been changed into classes such that their associated classes can have them as friends, to avoid (ab)use of public accessors. The serialise procedure should also be set as a friend of Character (both in the account- and game- server) as well; having public accessors returning iterators is simply ridiculous. Some start for such cleanups have been made, but this is not the primary focus here. Significant work will need to be done before this is resolved completely, but the start is there. BuySell::registerPlayerItems() has been completely disabled temporarily. The previous function iterated through equipment, yet in the context I think it is intended to fill items? I have been unable to update this function to fit the modifications made to the Inventory/Equipment/Possessions, as I am unsure what exactly what it should be doing. ItemClass::mSpriteId was previously unused, so had been removed, but I notice that it was used when transmitting equipment to nearby clients. Experimentation showed that this value was never set to anything other than 0, and so has been left out of the ItemManager rewrite. I am not entirely sure what is happening here, but it should be worth looking into at a later time, as I am not sure how equipment appearences would be sent otherwise.
2010-07-09Added LUA script bindings for manipulating the specials available to a ↵Philipp Sehmisch1-15/+23
character. Added script call for getting the cost of a special (recharge only for now) Deleting specials works server-sided but the client isn't informed about it properly. Specials without recharge cost don't appear for the player. Both of these features require an additional netcode message. Reviewed-by: Freeyorp