Age | Commit message (Collapse) | Author | Files | Lines |
|
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
|
|
Reviewed-by: bjorn.
|
|
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
|
|
This was meant to be amended to the previous commit...
|
|
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
|
|
mana.map_get_pvp() now returns one of the constants in libmana-constants.lua
Reviewed-by: Bertram.
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
Reviewed-by: bjorn.
|
|
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
|
|
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
|
|
Mainly introduced a helper function for getting to the Script instance for
the current Lua state.
Reviewed-by: Erik Schilling
Reviewed-by: Yohann Ferreira
|
|
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
|
|
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
|
|
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
|
|
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
|
|
luaL_checkstring might not return so the destructor of string will not be called.
Reviewed-by: Bjorn.
|
|
The function will cause a global announcement.
If no sender ist set "Server" will be used.
Reviewed-by: Bjorn.
|
|
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
|
|
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
|
|
Part of Mana-Mantis #339.
Reviewed-by: Ablu
|
|
As requested by Ablu.
Reviewed-by: Ablu.
|
|
Reviewed-by: Ablu
|
|
You can unequip using the slot or an item id.
+ Fixes from Ablu's review.
Resolves: Mana-Mantis #350.
Reviewed-by: Ablu.
|
|
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.
|
|
Reviewed-by: o11c, bjorn, Bertram.
|
|
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
|
|
Conflicts:
src/game-server/character.cpp
src/scripting/lua.cpp
|
|
Reviewed-by: Bjorn, Bertram.
|
|
Thanks to Ablu.
|
|
Reviewed-by: Ablu.
|
|
Reviewed-by: Ablu.
|
|
Conflicts:
src/game-server/accountconnection.cpp
|
|
Instead of giving the x, y coordinates of the circle you can give a being which
is in the center of the circle.
|
|
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
|
|
|
|
|
|
As the server was exitting when the insertion was failing
anyway, and because the GameState::update() doesn't allow
actor insertion while the update process, it was then
pretty weird to not use an enqueued insertion for it.
Plus, it fixes an assertion failure when scheduling
an npc creation.
Resolves: Mana-Mantis #360.
Reviewed-by: o11c.
|
|
A race condition on the being pointer could happen when
the being queue was highly requested.
IMHO, using queues to add being but remove them directly
is the way to go.
Resolves: Mana-Mantis #384
|
|
As the server was exitting when the insertion was failing
anyway, and because the GameState::update() doesn't allow
actor insertion while the update process, it was then
pretty weird to not use an enqueued insertion for it.
Plus, it fixes an assertion failure when scheduling
an npc creation.
Resolves: Mana-Mantis #360.
|
|
|
|
Resolves: Mana-Mantis #293.
Reviewed-by: Bertram.
|
|
|
|
Resolves: Mana-Mantis #293.
Reviewed-by: Bertram.
|
|
|
|
You now can change the anger of a monster to a being using
mana.monster_change_anger(monster, being, anger)
Resolves: Mana-Mantis #366.
|
|
You now can change the anger of a monster to a being using
mana.monster_change_anger(monster, being, anger)
Resolves: Mana-Mantis #366.
|