summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2012-03-07Updated Doxyfile to Doxygen 1.7.4Thorbjørn Lindeijer1-45/+79
2012-03-05Added @effect commandErik Schilling2-0/+49
Usage: @effect <id> @effect <id> <char> @effect <id> <x> <y> Reviewed-by: Bertram.
2012-03-05Added lua function for getting pvp status of mapErik Schilling3-2/+19
mana.map_get_pvp() now returns one of the constants in libmana-constants.lua Reviewed-by: Bertram.
2012-03-05Added possibility to make a being attack an other beingErik Schilling4-35/+61
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-05Improved Lua API argument checkingThorbjørn Lindeijer3-580/+194
It's a bit embarrassing the way this has gotten out of hand. The error checking was inconsistent, and in some cases wrong. A host of new helper functions, starting with 'check' rather than 'get', perform error handling on function arguments (they will not return when encountering an error). Reviewed-by: Erik Schilling
2012-03-04SQLite: Added a timeout for trying to acquire a database lockThorbjørn Lindeijer1-0/+4
Without a timeout, trying to write to a locked database fails immediately. Now it will only fail when it can't retrieve a write lock within a second. Still, we need to go through all the SQLite code some time, since there is a lot of error handling missing. We also need to make sure that errors are handled correctly on the higher level. Reviewed-by: Yohann Ferreira
2012-03-03Removed the last direct call to global script functionThorbjørn Lindeijer6-39/+30
The ScriptAction of the TriggerArea (which can be created by mana.trigger_create) was still using a named global function for its callback. Now it also uses a reference to a script function. Since it was the last occurrence of a call to a global script function, I've also removed the Script::prepare(std::string) overload. Reviewed-by: Erik Schilling Mantis-issue: 299
2012-03-03Improved handling of item and monster class parametersThorbjørn Lindeijer3-163/+108
Item and monster classes could already be identified by either their id or their name. Now the explicit values returned by 'get_item_class' and 'get_monster_class' can also be used as parameter. In addition the above two getters learned to understand all three types of parameter as well, rather than only supporting a name. Reviewed-by: Erik Schilling
2012-03-03Made some global Lua variables localThorbjørn Lindeijer3-93/+93
We have to be careful with introducing globals now that there is only a single Lua state, so we shouldn't use globals unnecessarily. Any variable should be declared 'local' unless there is a reason to make it global. For additional safety we can also think about disallowing the use of globals entirely. This also helps to catch typos in scripts. Reviewed-by: Erik Schilling
2012-03-03Use callbacks for items, monsters and status effectsThorbjørn Lindeijer20-136/+263
Previously, global function names were defined in the respective XML definitions of items, monsters and status effects. This was reasonable when they all had the same state, but now they're sharing the single global Lua state. Now the Lua API provides access to the ItemClass, MonsterClass and StatusEffect instances, on which callbacks for both standard and custom events can be explicitly set. Reviewed-by: Erik Schilling
2012-03-03Added further missing callbacksErik Schilling12-20/+238
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer11-80/+139
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 Lindeijer10-33/+125
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-02Simplified some of the Lua backendThorbjørn Lindeijer2-70/+30
Mainly introduced a helper function for getting to the Script instance for the current Lua state. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-03-02A bunch of cleanups to example Lua scriptsThorbjørn Lindeijer10-181/+126
Mostly removed bulky copyright headers and fixed indentation and line length. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
2012-03-02Merged all the different Lua states into oneThorbjørn Lindeijer28-277/+271
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-28Fixed bug with erasing the last status effectThorbjørn Lindeijer1-3/+9
It's not nice to use ++ on an iterator that may be std::map::end(), in my case this caused it to hang indefinitely. Reviewed-by: Yohann Ferreira
2012-02-28Removed unnessecary second check for same conditionErik Schilling1-65/+62
Reviewed-by: Bertram.
2012-02-27Prevent calculating movement of being further if it does not moveErik Schilling1-0/+4
Reviewed-by: bjorn.
2012-02-27Fixed compilation again + some more code cleanupErik Schilling5-20/+21
I did some cleanup but i had a wrong path set inside qtcreator. So i recompiled old versions and it all worked fine. But when i recompiled from console i got a whole bunch of errors. Sorry for pushing broken commits. Reviewed-by: bjorn.
2012-02-26Some random code cleanupErik Schilling1-33/+25
Moved a code comment about syncmessages to the bugtracker: #473. Reviewed-by: bjorn.
2012-02-26Renamed some iterators + fixed one TODO (stored guilds in a map)Erik Schilling2-46/+23
Reviewed-by: bjorn.
2012-02-25Merged the example client and server dataThorbjørn Lindeijer190-11/+6
It's easier to just talk about world data and to modify it as a whole. If there is really a need to separate it, a project can still choose to do that (and in whatever suitable way). There is no need to enforce this separation or to do it in our example. Reviewed-by: Erik Schilling
2012-02-05Moved @announce permission to GM groupThorbjørn Lindeijer1-1/+1
Reviewed-by: Erik Schilling
2012-02-04Simplified merchant.luaThorbjørn Lindeijer1-80/+85
Just defined an inline function to make talking to the player easier. Would be nice when NPC scripts could look more like this by default. Also indented with 4 spaces, which we do in C++ so why not Lua files (the file had mixed 2 and 4 space indentation before).
2012-02-03Added a generic Lua user data cacheThorbjørn Lindeijer3-9/+106
Based on a native Lua table with weak values, so that the user data objects that are created can be garbage collected when no longer referenced. Reviewed-by: Yohann Ferreira
2012-02-03Clear the gid flags before processing themThorbjørn Lindeijer3-13/+22
Also read the gids as unsigned integers since that's how Tiled writes them to prevent the number going negative when the highest flag is used. Reviewed-by: Yohann Ferreira
2012-02-02Added a way to specify the min and max attributes values.Yohann Ferreira10-103/+264
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-31Use a full user data object for MapObject referencesThorbjørn Lindeijer4-53/+94
Based on a templated helper class, MapObject references in Lua scripts are now full user data objects. Using the '__index' member of their metatable, a library is associated with it so that member functions can be called directly on the object. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
2012-01-30Fixed some lua_newtable/createtable usageThorbjørn Lindeijer2-5/+5
When creating a Lua table, it is possible to specify in advance how many array elements and how many non-array elements this table will contain, to avoid dynamic reallocations while filling the table. This wasn't used optimally by the pushSTLContainer helper methods and some other cases. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
2012-01-29Removed unused createRandomPassword functionThorbjørn Lindeijer4-101/+0
Reviewed-by: Erik Schilling
2012-01-25Fixed use of checkstring method in the script functionsErik Schilling1-4/+7
luaL_checkstring might not return so the destructor of string will not be called. Reviewed-by: Bjorn.
2012-01-22Added announce(text [, sender]) lua functionErik Schilling2-4/+19
The function will cause a global announcement. If no sender ist set "Server" will be used. Reviewed-by: Bjorn.
2012-01-22Removed logging of chatErik Schilling2-15/+0
Reviewed-by: Bertram
2012-01-21Made @announce fully functionalErik Schilling5-47/+40
- Added announcements having senders now. - Removed /announcement support. Reviewed-by: Bjorn.
2012-01-18Added the chr_get_inventory and chr_get_equipment functions.Yohann Ferreira2-0/+165
Those will make the scripters able to get a full view of the current player's possessions. Use with care. + Fixes following Ablu's review. Resolves: Mana-Mantis #207. Reviewed-by: Ablu
2012-01-18Fixed the chr_inv_count function to handle equipment.Yohann Ferreira4-18/+59
the function can now count in the inventory and/or the player's equipment. I also fixed the script function and added a use case in the example map. + Fixes after Ablu's review. + 2nd fix after Ablu's review: Fix the inventory remove behaviour. Resolves: Mana-Mantis #288 Reviewed-by: Ablu
2012-01-16Made the lua item_drop script function returns whether it succeeded.Yohann Ferreira1-4/+4
Part of Mana-Mantis #339. Reviewed-by: Ablu
2012-01-16Added several script warnings on errors.Yohann Ferreira1-7/+10
As requested by Ablu. Reviewed-by: Ablu.
2012-01-13Fixed naming of MySQL build optionjurkan1-1/+1
2012-01-10Made the game server execute the chr_respawn_accept script evenYohann Ferreira4-19/+52
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-10Random small fixes linked to lua c++ scripting functions.Yohann Ferreira1-10/+39
Reviewed-by: Ablu
2012-01-10Added unequip lua script functions.Yohann Ferreira3-0/+111
You can unequip using the slot or an item id. + Fixes from Ablu's review. Resolves: Mana-Mantis #350. Reviewed-by: Ablu.
2012-01-10Added equip lua script functions.Yohann Ferreira3-1/+87
One per inventory slot, one per item id or name. + Fixes from 2 Ablu's reviews. Reviewed-by: Ablu. 1st part of Mana-Mantis #339, 350.
2012-01-03Fixed code not getting executed since it was behind a returnErik Schilling1-1/+1
Reviewed-by: o11c.
2012-01-02Made all beings capable of having a genderErik Schilling17-56/+104
Reviewed-by: o11c, bjorn, Bertram.
2012-01-02Made do_npc_close to be called by default after the end of the talk functionErik Schilling9-12/+7
Reviewed-by: Bertram.
2011-12-16Added explanation for include feature in the configuration fileErik Schilling1-0/+7
Reviewed-by: Bertram.
2011-12-04Added @skills command which lists all skillsErik Schilling2-0/+42
Reviewed-by: o11c.
2011-12-03Allowed larger item amounts for mysql database.Erik Schilling5-4/+20
Changed range of amount to unsigned int(10). Sqlite update scripts is empty since no change was required here. Reviewed-by: Bertram.