summaryrefslogtreecommitdiff
path: root/src/game-server/character.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-04-27Merge branch 'master' into lpc2012Thorbjørn Lindeijer1-4/+4
2013-04-27Use nullptr instead of NULL everywhereErik Schilling1-4/+4
2013-04-15Merge branch 'master' into lpc2012Thorbjørn Lindeijer1-167/+163
Conflicts: src/account-server/accounthandler.cpp src/game-server/character.cpp
2013-04-12Removed CharacterData member from CharacterComponentThorbjørn Lindeijer1-3/+2
It is only needed temporarily while serializing and deserializing.
2013-04-12Moved Actor into an ComponentErik Schilling1-11/+8
This was the final step to remove the hierachy with Entity on the top.
2013-04-11Converted Being into a ComponentErik Schilling1-47/+43
I did not really care too much about staying consistent with the use of static_casts to Actors since they are only temporary anyway until Actor is a component too.
2013-04-11Converted the Character class into a componentErik Schilling1-165/+153
A CharacterData was created as a proxy class in order to allow using the old serialization method.
2013-04-02Fixed multiple warnings and errors that blocked c++0xErik Schilling1-1/+2
This allows the server to compile with c++0x (and enables it). This also includes some coding style / readabillity fixes.
2013-04-02Moved fighting code into a componentErik Schilling1-22/+33
All damage dealing is now handeled via CombatComponent. Monsters use a derived MonsterCombatComponent since they can have a damage mutation and have a seperate script callback. The wirering with Being is still not optional since most of the stuff does not exist as components. Things done: - Seperated the fighting code from Being and only let Characters and Monsters add the Component (less overhead for npcs) - Added a getter for Attribute values to prevent searching it all the time in non Being members - Fixed the type if the damage mutation to double (no idea why it was int) I did not want to copy it over incorrectly - Removed the addAttack/removeAttack overrides in Character and made the knuckleAttack being added based on newly added signals Future TODOS: - Remove depedency on Being as soon all needed dependencies are available as components of Entity - Move the monster script callback into the general combatcomponent and make it usuable for characters too
2013-03-25Changed NPC to an NpcComponent added to a BeingThorbjørn Lindeijer1-0/+4
2013-02-21Merge branch 'master' into lpc2012Erik Schilling1-7/+4
2013-02-21Introduced Script::ContextErik Schilling1-7/+4
This should allow to finally call functions to lua without having to care about working around situations where a lua call causes a c++ call which needs to call to lua again. Tested against the source of tales repository data.
2013-02-20Merge branch 'master' into lpc2012Erik Schilling1-91/+17
Conflicts: gameserver.cbp src/account-server/accounthandler.cpp src/game-server/attack.cpp src/game-server/attack.h src/game-server/being.cpp src/game-server/being.h src/game-server/character.cpp src/game-server/character.h src/game-server/inventory.cpp src/game-server/item.h src/game-server/monster.cpp src/game-server/monster.h
2013-02-04Moved attribute (re)calculation to the scriptsErik Schilling1-76/+13
This introduces two callbacks: - on_update_derived_attribute -> Called to recalculate other derived attributes. - on_recalculate_base_attribute -> Called to recalculate a base attribute (only called for characters. However the function passed as callback can be useful for recalculating the derived attributes as well) Monsters no longer block recalculation of attributes except HP and Speed. I saw no sense to keep this. Fixed constant value in libmana-constants.lua Dropped bool type of the recalculation functions. It would be difficult to keep it while pushing all to the script engine and it was unused anyway. All in all this adds a LOT more flexibillity to projects since they can now adapt all attributes in the way they want.
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-08-01adjust experience curve.Stefan Beller1-4/+4
2012-08-01Fixed removing of unarmed attack when equipping other weaponsErik Schilling1-2/+1
2012-08-01Fixed recalculation of base attributesErik Schilling1-7/+7
2012-07-28Made the character not colliding with monsters.Erik Schilling1-1/+1
Prevents clientside desyncs
2012-07-17Merge branch 'master' into lpc2012Erik Schilling1-1/+0
Conflicts: src/game-server/character.h
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-07-08Added bind for setting login callbackErik Schilling1-0/+6
Reviewed-by: bjorn.
2012-07-07Work on (Auto)Attack system.Erik Schilling1-53/+45
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
2012-07-07Rename AutoAttack to AttackErik Schilling1-9/+9
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.