summaryrefslogtreecommitdiff
path: root/src/scripting/luautil.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-09-19Have Lua use entity IDs instead of direct pointersThorbjørn Lindeijer1-25/+86
Allows to report access to removed entities instead of crashing.
2013-09-13Added basic questlog supportErik Schilling1-0/+10
I did this patch quite a while ago. Big thx to Stefan Beller for "rebasing" it.
2013-09-08Renamed character.cpp to charactercomponent.cppErik Schilling1-1/+1
Now we do not have two character.cpp files in the repository.
2013-08-26Moved AttributeInfo into a seperate fileErik Schilling1-2/+2
2013-08-26Allowed to push attributeinfos for the attribute recalculationErik Schilling1-4/+13
While on it I replaced the id usage in the server with the usage of the AttributeInfo directly. Next steps: - Dehardcode the core attribute ids and store their attributeinfos somewhere in AttributeManager (for now i simply wrapped the ids with getAttributeInfo(). - Move AttributeInfo out of AttributeManager to shorten the usage + to allow using a pointer in ModifierLocation without forward declaring it.
2013-08-26Removed skillsErik Schilling1-11/+0
This removes support for skills. The plan is to allow to implement the skills as they were implemented before via attributes. This adds a lot more flexibility to the server creators while also removing the confusion about skills and attributes. So this change does: - Remove the skillmanager with all its calls, the skill xml file, etc - Move exp giving to the script engine: --> Allows to implement the old behaviour (and more) in the scripts - Remove the exp tag from the monster definition: + Since the server itself does not require it anymore it feels wrong to require it for EVERY monster. TODO: Add a system to add properties to the monsters/items.xml which allow defining things like the exp and allows to read the value from the script engine. + Small drawback, but it should not be hard to implement this property system. - Drop the level networking and calculation. + level calculation will happen via the attribute system later but i would prefer to do this in a seperate patch since this patch already got longer than expected especially since this requires to make setting correction points and available status points scriptable. + The level would be simply set as a attribute, the int number of it will be the level, the remaining digits will be the % number till the next levelup. - NOT remove any existing skill tables in the database update scripts. + There is no way to move them into the attribute table in a unified way (there are too many different way they could have been used). So server admins have to care about moving theirs skills to attributes themselves. + Keeping the old tables does not hurt for existing databases. So removing does not give any advantage/is required anyway. The now obsolote info about the EXP transaction is not removed for updated databases either. (The update script basically only bumps the version number without doing anything else. - bump the network protocol version --> old clients won't be able to connect. - bump the database version --> serveradmins need to update their db.
2013-08-26Allow names instead of ids for attributes + cleanupErik Schilling1-0/+12
I did not adapt the scripts yet since we need some special handling for the attributes which are required by the server directly. So you still have to use the ids for those. I will change that later. In the future I want to use the AttributeInfo class instead of the int id everywhere possible. So I did a small start on that too.
2013-08-26Added function to check for length of a possible pathErik Schilling1-0/+16
2013-08-26[Abilities] Added support for a global cooldownErik Schilling1-5/+7
Each ability can now define a cooldown that prevents the player from using other abilities for a while. The time of this cooldown can be set to any attribute. The modified value of the attribute is the value of the cooldown in game ticks. The cooldown will be automatically started if the ability has `autoconsume` set to true. Otherwise a script has to call entity:cooldown_ability(ability).
2013-08-26[Abilities] Renamed specials to abilitiesErik Schilling1-3/+3
2013-04-14Use a full user data for Entity referencesThorbjørn Lindeijer1-47/+19
Only moved a single script function to a member for now, will do others in a separate commit.
2013-04-11Converted Being into a ComponentErik Schilling1-16/+16
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-4/+4
A CharacterData was created as a proxy class in order to allow using the old serialization method.
2013-04-03Moved the Monster class to a ComponentErik Schilling1-4/+4
Things done: - Allowed to create new Attributes outside of the protected scope of Being - Moved Monster to MonsterComponent - Some minor cleanup in the Attribute setting code of monsters
2013-03-25Changed NPC to an NpcComponent added to a BeingThorbjørn Lindeijer1-4/+4
2013-02-21Introduced Script::ContextErik Schilling1-1/+1
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-01-09Micro-optimizations for pushing strings to LuaThorbjørn Lindeijer1-2/+2
Use lua_pushliteral and lua_pushlstring instead of lua_pushstring, which avoids Lua having to determine the length of the string.
2012-07-21Fixed an error message and inlined some one-linersThorbjørn Lindeijer1-22/+1
2012-07-21Removed raiseScriptErrorThorbjørn Lindeijer1-12/+0
It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling
2012-04-04Renamed Thing to EntityThorbjørn Lindeijer1-4/+4
In preparation for using an entity/component system for the entities in the game world, this name will be more recognizable and easier to talk about. Reviewed-by: Yohann Ferreira
2012-04-04Enhanced special supportErik Schilling1-7/+16
- 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-17Made skill related function capable of taking the skill name as parameterErik Schilling1-0/+12
Reviewed-by: bjorn.
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-0/+12
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-07Added a function that returns the current map or raises an errorThorbjørn Lindeijer1-0/+25
The new function 'checkCurrentMap' will raise an error when no current map has been set, eliminating the need to do custom error handling all over the place. This also fixes several functions that would otherwise have simply crashed when there was no current map. Also cleaned up some "empty string parameter" checks. Reviewed-by: Erik Schilling
2012-03-05Improved Lua API argument checkingThorbjørn Lindeijer1-8/+31
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-03Improved handling of item and monster class parametersThorbjørn Lindeijer1-7/+69
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-02-03Added a generic Lua user data cacheThorbjørn Lindeijer1-0/+59
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-01-31Use a full user data object for MapObject referencesThorbjørn Lindeijer1-5/+0
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
2011-10-15Added script bindings for reading map objectsErik Schilling1-0/+5
map_get_objects([string filter]): returns all object of the current map optionally filtered by type. map_get_object_property(handle object, string key): returns the value of the property of the object. map_get_object_bounds(handle object): returns x, y, width, height of an object. map_get_object_name(handle object): returns name of an object. map_get_object_type(handle object): returns type of an object. Mantis-issue: 397 Reviewed-by: Thorbjørn Lindeijer
2011-08-19Created function to make getting monsters easier in scripts.Erik Schilling1-0/+11
2010-12-08Fix many compiler warnings.Freeyorp1-2/+2
Reviewed-by: Bertram
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-3/+3
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.
2010-08-22Some coding style tweaksThorbjørn Lindeijer1-6/+12
2010-05-28Modified the npc_trade() lua function to permit selling the whole player ↵Yohann Ferreira1-1/+12
inventory. It permits to open a sell box with every items in the player inventory as requested by Striker. Also added different return value support to both the buy selling functions, and made fixes where relevant. The test.lua script will be upgraded to show examples in a next commit. What's left to be done is to fix the inventory handling for both selling functions. (Sigh...) Concerns: Manasource mantis: #78, #101. Reviewed-by: Jaxad0127
2010-02-07Update Copyright date for Manaserv.Bertram1-1/+1
2009-12-06Fixed name of the project in copyright headersThorbjørn Lindeijer1-7/+6
Also updated the headers to refer to the GPL by URL instead of suggesting to contact the FSF by snail mail, as per the latest GPL usage instructions.
2009-01-22Reduced the size of lua.cpp by putting the class LuaScript and the utility ↵Philipp Sehmisch1-0/+91
functions in separate files leaving only the script bindings themself. Unified internal and external names of lua script bindings.