summaryrefslogtreecommitdiff
path: root/example
AgeCommit message (Collapse)AuthorFilesLines
2013-02-17Monsters no longer load their script filesErik Schilling1-1/+0
Before monsters loaded their script file on *each* spawn. This is rather wrong since the script state keeps growing for each monster. However all of this was unnessecary since the main.lua can simply require the script file. If you do not want to spam the main.lua (or any other file) with all the requires: I guess we can add script binds to iterate over all monsters and add some custom properties to the monsters.xml (See Mana-Mantis #356)
2013-02-16Fixed last second reordering of function parameters in last commitErik Schilling1-5/+5
Accidently only reordered the order in the definition but not in the calls
2013-02-04Moved attribute (re)calculation to the scriptsErik Schilling2-0/+75
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-02-04Changed Sword to Vit bonus since it has a lot derived attributesErik Schilling1-1/+1
Only done for easier debugging
2013-02-01Added emote support.Yohann Ferreira2-20/+19
2013-01-08Added Vulnerabilities for monstersErik Schilling2-2/+2
You can now actually use the already used node in the monsters.xml Monsters can have different vulnerabillities against elements: <vulnerabillity element="earth" factor="2.0" /> This will double damage of the element earth to this monster.
2013-01-08Added script binds for getting attack informationErik Schilling1-1/+4
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
2013-01-08Work on (Auto)Attack system.Erik Schilling3-61/+71
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-3/+3
2012-04-04Enhanced special supportErik Schilling3-27/+37
- 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-11Converted two Lua scripts from DOS to UNIX line endingsThorbjørn Lindeijer2-132/+132
2012-03-11Register Lua script API functions into the global namespaceThorbjørn Lindeijer16-196/+196
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-7/+7
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 Lindeijer8-68/+68
Reviewed-by: Erik Schilling
2012-03-10Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer1-2/+0
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 @effect commandErik Schilling1-0/+1
Usage: @effect <id> @effect <id> <char> @effect <id> <x> <y> Reviewed-by: Bertram.
2012-03-03Made some global Lua variables localThorbjørn Lindeijer2-47/+46
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 Lindeijer7-9/+22
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 Schilling2-0/+5
Reviewed-by: bjorn.
2012-03-02Converted functions called by LuaScript to callbacksThorbjørn Lindeijer1-4/+4
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-6/+11
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-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 Lindeijer7-7/+9
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-25Merged the example client and server dataThorbjørn Lindeijer187-1/+1
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-02Added a way to specify the min and max attributes values.Yohann Ferreira1-22/+135
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 Lindeijer1-0/+10
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-22Added announce(text [, sender]) lua functionErik Schilling1-0/+1
The function will cause a global announcement. If no sender ist set "Server" will be used. Reviewed-by: Bjorn.
2012-01-18Added the chr_get_inventory and chr_get_equipment functions.Yohann Ferreira1-0/+28
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 Ferreira1-2/+11
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-02Made all beings capable of having a genderErik Schilling4-10/+11
Reviewed-by: o11c, bjorn, Bertram.
2012-01-02Made do_npc_close to be called by default after the end of the talk functionErik Schilling8-11/+1
Reviewed-by: Bertram.
2011-12-04Added @skills command which lists all skillsErik Schilling1-0/+1
Reviewed-by: o11c.
2011-11-13Added the background parameter values to the equip.xml file.Yohann Ferreira1-10/+10
Reviewed-by: Thorbjorn Lindeijer
2011-11-07Merged three global script states into oneThorbjørn Lindeijer1-0/+17
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-02Added @permissions commandErik Schilling1-0/+1
Added @permissions <character> which lists the permissions of a player. Made @givepermission giving feedback on success. Reviewed-by: Thorbjørn Lindeijer.
2011-10-19Merge branch 'master' of github.com:mana/manaservYohann Ferreira1-7/+12
Conflicts: src/game-server/accountconnection.cpp
2011-10-19Prevent server crash by not having beings talk after spawn for nowThorbjørn Lindeijer1-7/+12
At the moment it is the responsibility of the script to make sure any references to beings passed into script functions are valid. This means you can't schedule delayed scripts like the one making maggots say 'Roaaarrrr!!!', since the being might have been removed before the script gets executed. In the case of this bug the maggots are removed by some script code testing 'mana.monster_remove'. We should of course fix the way actor handles are used in Lua so that scripts can't end up crashing the server. Mantis-issue: 384 Reviewed-by: Yohann Ferreira
2011-09-28Added a default skill id getter in the skill manager.Yohann Ferreira1-1/+1
I also added a link to the skillmanager object in its header file. This will later be used to get info from elsewhere than the server main loop.
2011-09-28Fixed the items.xml fileYohann Ferreira1-14/+17
The file is now setting the correct attack for the given weapons. I also updated the auto attack parameter to correspond the ones needed in the code.
2011-09-28Added the chr_get_level script function.Yohann Ferreira1-0/+1
2011-09-15Added chatcommand to get position of a character.Erik Schilling1-0/+1
Add chatcommand @getpos <character> which return the mapid and location of the character. Part of: Mana-Mantis: #385. Reviewed-by: Bertram.
2011-09-12Changed specials.xml to reflect the current capabilitiesPhilipp Sehmisch1-3/+4
2011-09-01Added chatcommand to get position of a character.Erik Schilling1-0/+1
Add chatcommand @getpos <character> which return the mapid and location of the character. Part of: Mana-Mantis: #385.
2011-08-30As requested, changed the trigger 'existence' to 'in-inventory'.Yohann Ferreira1-9/+9
2011-08-30Merge branch 'equipment-fix'Yohann Ferreira1-10/+29
2011-08-30Synced the equip.xml file to the latest changes.Yohann Ferreira1-10/+29
2011-08-25Merge branch 'equipment-fix' of github.com:Bertram25/manaservYohann Ferreira15-12/+415
2011-08-25Updated specials.xml to better illustrate the features which are currentlyunknown1-3/+4
working and expected by the server to be known by the client. Note: I would like to get rid of specials.xml on the client side and make the gameserver provide all information relevant for the players character at runtime to allow for proceduarally generated specials.