summaryrefslogtreecommitdiff
path: root/scripts/lua
AgeCommit message (Collapse)AuthorFilesLines
2023-05-01CMake: Use cmake-format to reformat all CMakeLists.txtThorbjørn Lindeijer1-6/+2
Especially to change them to lowercase.
2013-09-13Added basic questlog supportErik Schilling1-0/+5
I did this patch quite a while ago. Big thx to Stefan Beller for "rebasing" it.
2013-08-26Removed skillsErik Schilling1-13/+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-26Call the on_remove handler with the being as parameterErik Schilling1-6/+7
2013-08-26[Abilities] Added support for a global cooldownErik Schilling1-0/+2
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-07-19Adapted the inline documentation for markdown docsErik Schilling1-8/+12
2013-05-03Made member function tables available as a globalsThorbjørn Lindeijer1-14/+14
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-04-22Removed old monster attributesErik Schilling1-3/+0
2013-04-15Moved functions to entity members where appropriateThorbjørn Lindeijer2-17/+13
Some functions were skipped for now because they may need a new name or change of behavior. Changes: chr_warp entity:warp chr_get_inventory entity:inventory chr_inv_change entity:inv_change chr_inv_count entity:inv_count chr_get_equipment entity:equipment chr_equip_slot entity:equip_slot chr_equip_item entity:equip_item chr_unequip_slot entity:unequip_slot chr_unequip_item entity:unequip_item chr_get_level entity:level chr_get_exp entity:xp chr_give_exp entity:give_xp chr_get_rights entity:rights chr_set_hair_style entity:set_hair_style chr_get_hair_style entity:hair_style chr_set_hair_color entity:set_hair_color chr_get_hair_color entity:hair_color chr_get_kill_count entity:kill_count chr_give_special entity:give_special chr_has_special entity:has_special chr_take_special entity:take_special chr_set_special_recharge_speed entity:set_special_recharge_speed chr_get_special_recharge_speed entity:special_recharge_speed chr_set_special_mana entity:set_special_mana chr_get_special_mana entity:special_mana chr_kick entity:kick exp_for_level xp_for_level monster_get_id entity:monster_id monster_change_anger entity:change_anger monster_drop_anger entity:drop_anger monster_get_angerlist entity:angerlist being_apply_status entity:apply_status being_remove_status entity:remove_status being_has_status entity:has_status being_set_status_time entity:set_status_time being_get_status_time entity:status_time being_get_gender entity:gender being_set_gender entity:set_gender being_type entity:type being_walk entity:walk being_say entity:say being_damage entity:damage being_heal entity:heal being_get_name entity:name being_get_action entity:action being_set_action entity:set_action being_get_direction entity:direction being_set_direction entity:set_direction being_apply_attribute_modifier entity:apply_attribute_modifier being_remove_attribute_modifier entity:remove_attribute_modifier being_set_base_attribute entity:set_base_attribute being_get_modified_attribute entity:modified_attribute being_get_base_attribute entity:base_attribute being_set_walkmask entity:set_walkmask being_get_walkmask entity:walkmask being_get_mapid entity:mapid chat_message entity:message being_register entity:register chr_shake_screen entity:shake_screen chr_create_text_particle entity:show_text_particle - entity:position posX entity:x posY entity:y monster_get_name monsterclass:name item_get_name itemclass:name
2013-02-24Made the scripts being able to installErik Schilling1-0/+7
The game server will now look for the scripts in this order: - serverPath - config value - current working directory - the PKG_DATADIR #define
2013-02-24Documented all lua binds directly in the sourceErik Schilling1-11/+139
This change adds a comment to each lua binding. In the future a script should parse those and generate the docs from them. This should prevent outdated docs and duplicate effort to keep code and docs synced. In C++ categories can be defined in this way: /** LUA_CATEGORY long description of the category (shortname) * further text * goes into * the next lines */ The shortname is only used to bind other comments to the category. In lua the category would look like this: --- LUA_CATEGORY long description of the category (shortname) -- further text -- goes into -- the next lines A comment that describes a bind then can look like this: /** LUA some_function (shortnameofcategory) * some_function(string name) * some_function(int id) ** * Description */ Or in Lua: --- LUA some_function (shortnameofcategory) -- some_function(string name) -- some_function(int id) --- -- Description Autoupdates script follows soon
2013-02-04Moved attribute (re)calculation to the scriptsErik Schilling1-1/+3
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.
2012-08-05Fixed the atinit functionErik Schilling1-4/+8
Previously each map had its own scope. They got merged now but the atinit function was forgotten to adapt. Reviewed-by: bjorn.
2012-03-30Fixed Lua error reporting for NPC scriptsThorbjørn Lindeijer1-3/+4
This was due to a naming conflict between the 'debug' function I had recently introduced and the 'debug' library provided by Lua. This caused problems when trying to use debug.traceback for printing a backtrace of the error. There's multiple ways to avoid the naming conflict. I opted for writing the related helper functions in all-caps. Also added an ERROR log function now. As Erik pointed out, there is no conflict anymore with Lua's 'error' function with the new naming style. Reviewed-by: Erik Schilling
2012-03-17Added map update function, moved schedules there to keep map contextErik Schilling1-13/+31
Reviewed-by: bjorn.
2012-03-13Added some convenience wrappers to libmana.luaThorbjørn Lindeijer1-0/+25
Global functions 'warn', 'info', 'debug' as shortcuts to the respective 'log' call, which also support passing multiple parameters at the same time, which will be separated by spaces. Global tables 'map' and 'world' which provide convenient read/write access to map and world state variables. Reviewed-by: Yohann Ferreira
2012-03-11Register Lua script API functions into the global namespaceThorbjørn Lindeijer2-26/+26
Scripts mostly execute the Mana script API, and it seems like just unnecessary verbosity to refer to the 'mana' table all the time. This table no longer exists now. Reviewed-by: Erik Schilling
2012-03-11Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer1-40/+2
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-11Removed deprecated NPC helper functionsThorbjørn Lindeijer1-9/+0
Reviewed-by: Erik Schilling
2012-03-11Added callbacks for map/worldvar changesErik Schilling1-0/+44
Reviewed-by: bjorn.
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-256/+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-05Added lua function for getting pvp status of mapErik Schilling1-0/+4
mana.map_get_pvp() now returns one of the constants in libmana-constants.lua Reviewed-by: Bertram.
2012-03-03Made some global Lua variables localThorbjørn Lindeijer1-46/+47
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-03Added further missing callbacksErik Schilling1-0/+11
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer1-21/+16
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-02Merged all the different Lua states into oneThorbjørn Lindeijer1-2/+2
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-01-02Made all beings capable of having a genderErik Schilling1-2/+2
Reviewed-by: o11c, bjorn, Bertram.
2012-01-02Made do_npc_close to be called by default after the end of the talk functionErik Schilling1-1/+6
Reviewed-by: Bertram.
2011-10-22Officially added the being gender to the protocol.Yohann Ferreira1-0/+1
Reviewed-by: o11c.
2011-06-27Added Lua function for logging.Ablu1-0/+7
You can now call mana.log(loglevel, message) to log messages with scripts. For loglevel you can use the new constants defined in libmana-constants.lua Resolves: Mana-Mantis #359
2011-03-11Simplified check_schedule a bitThorbjørn Lindeijer1-14/+9
2011-03-10Avoid running newly scheduled jobs by using a fixed time point.Yohann Ferreira1-1/+2
Reviewed-by: Thorbjorn.
2011-02-20Fixed the check_schedule() lua function.Yohann Ferreira1-0/+5
An misleading error was raised when the function dealt with its last remaining job as it didn't return after removing it. Reviewed-by: Ablu.
2011-02-11Added the schedule_per_date() lua function.Yohann Ferreira1-0/+11
Reviewed-by: Ablu, Freeyorp.
2011-02-11Fix basic money handling using the ATTR_GP attribute.Yohann Ferreira1-3/+5
Reviewed-by: Freeyorp.
2011-02-11Synced the libmana-constants.lua file with the current protocol.Yohann Ferreira1-59/+68
Trivial.
2011-02-08Implemented LUA binding to get the gender of a characterPhilipp Sehmisch1-0/+3
The function is named mana.chr_get_gender. It returns 0 for male and 1 for female. libmana-constants.lua defines the variables GENDER_MALE and GENDER_FEMALE with these values. Also made the banker NPC refer to the gender of the player character. Reviewed-by: Jaxad0127
2010-05-30Copied basic Lua libs back from tmwserv-data and added dummy dataThorbjørn Lindeijer3-0/+654
The dummy data is currently mostly empty data though, so still nothing to see as far as the example content is concerned. Reviewed-by: Bertram