summaryrefslogtreecommitdiff
path: root/src/scripting/luautil.h
AgeCommit message (Collapse)AuthorFilesLines
2013-08-26Removed skillsErik Schilling1-1/+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-12/+14
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/+1
2013-08-26Added get_monster_classes() bindErik Schilling1-0/+5
It returns all monster classes in a id->monsterclass table.
2013-08-26[Abilities] Removed the old autoattack systemErik Schilling1-8/+0
As a side effect i had to remove the monster attack AI for now. I will readd this as next thing.
2013-08-26[Abilities] Added support for a global cooldownErik Schilling1-14/+14
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-05-03Made member function tables available as a globalsThorbjørn Lindeijer1-0/+5
This way the scripts can add or replace existing member functions, which can be useful. As demonstration chr_money and chr_money_change are now added as Entity.money and Entity.change_money. Also fixed the banker to use ask_number instead of ask_integer (I had decided to rename this and apparently forgot the banker). Mantis-issue: 503 Reviewed-by: Ablu
2013-05-02Fixed a bunch of cppcheck warningsErik Schilling1-3/+3
2013-04-27Use nullptr instead of NULL everywhereErik Schilling1-1/+1
2013-04-14Use a full user data for Entity referencesThorbjørn Lindeijer1-5/+3
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-9/+8
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-3/+3
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-3/+2
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-3/+2
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.
2013-01-09Added support for Lua 5.2Thorbjørn Lindeijer1-1/+10
Should still work against Lua 5.1 as well.
2013-01-08Added script binds for getting attack informationErik Schilling1-1/+9
New binds: - Damage: - id - skill - base - delta - cth - element - type - truestrike - range - Attack: - priority - cooldown - warmup - global_cooldown - damage - on_attack - MonsterClass: - attacks - ItemClass: - attacks
2012-07-21Fixed an error message and inlined some one-linersThorbjørn Lindeijer1-8/+28
2012-07-21Removed raiseScriptErrorThorbjørn Lindeijer1-3/+0
It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling
2012-05-06Some small optimizations in Lua helper functionsThorbjørn Lindeijer1-6/+3
Reviewed-by: Ben Longbons
2012-04-04Renamed Thing to EntityThorbjørn Lindeijer1-2/+2
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-0/+4
- 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/+1
Reviewed-by: bjorn.
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-1/+4
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/+5
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-0/+4
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-4/+10
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-03Use callbacks for items, monsters and status effectsThorbjørn Lindeijer1-7/+16
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-02-03Added a generic Lua user data cacheThorbjørn Lindeijer1-7/+45
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-2/+64
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 Lindeijer1-3/+3
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
2011-10-15Added script bindings for reading map objectsErik Schilling1-1/+4
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/+2
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-0/+126
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.