Age | Commit message (Collapse) | Author | Files | Lines |
|
- 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.
|
|
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
|
|
The main change here is to remove the separate calling of 'perform' on all
beings, and rather rely on the beings to do whatever they were doing in
that function when the virtual 'update' function is called.
Reviewed-by: Yohann Ferreira
|
|
Only 1/4th of the floor items were being restored after a reboot of the game
server.
Reviewed-by: jurkan
|
|
This was broken in ba66fbeda8ef9afb6c33eba66d109bac85ebf628 where we forgot
to make sure to invert the condition when moving it into the function.
Reviewed-by: Erik Schilling
|
|
Reviewed-by: bjorn.
|
|
Reviewed-by: bjorn.
|
|
While the plan is to allow only one guild per player, the database currently
doesn't enforce this. The expected behavior of this API is that it changes
the rights only for the specified guild, but the query was changing the
rights of the player in all his guilds.
Reviewed-by: Erik Schilling
|
|
These were unused parameters and one return type with an ignored 'const'
qualifier.
Reviewed-by: Yohann Ferreira
|
|
Due to a misplaced semicolon, it always returned false after the first
instance. This function is only used by the script function
chr_unequip_item.
Reviewed-by: Yohann Ferreira
|
|
For a non-empty vectors that did not contain the element to remove, the
loop would go on forever because a size_t can't become smaller than 0.
Fixed by simply iterating forwards.
|
|
Forgot this in 1afbfb7e5fb5c133924ed8d376c6064575fc1c36.
Reviewed-by: Bertram, Ablu.
|
|
|
|
The bugfix is not likely to affect us, but better to be up to date anyway.
|
|
Another step towards scriptable @commands.
Reviewed-by: bjorn.
|
|
Another step for being able to make @commands scriptable
Reviewed-by: bjorn.
|
|
Step to be able to handle chatcommands by scripts.
Reviewed-by: bjorn.
|
|
Due to a wrong primary key, which covered only the state name, it was
impossible to use the same state name on different maps. This has now
been fixed.
Another problem was that the map variables were being included in the
global variables, because the related database query did not filter on
the map_id column properly. While fixing that, the map_id column now
allows explicitly marking a state variable as global (with the value 0)
or system variables (with the value -1).
System variables are currently not accessible from scripts, but that
could be changed later.
Reviewed-by: Yohann Ferreira
Reviewed-by: Erik Schilling
|
|
When a prepared SQL statement would have returned multiple rows, this
function would try to set the column header names multiple times which
throws the AlreadySetException.
Currently it doesn't seem that any prepared statements are meant to return
multiple rows.
Reviewed-by: Yohann Ferreira
|
|
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
|
|
The AGMSG_REGISTER_RESPONSE message should be sent _after_ adding the
global world state variables to it rather than before.
Reviewed-by: Yohann Ferreira
|
|
TODO: Inform client about this change.
Reviewed-by: bjorn.
|
|
Forgot to do this in the previous commit.
|
|
|
|
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
|
|
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: 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
|
|
Reviewed-by: PjotrOrial.
|
|
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
|
|
|
|
Usage:
@effect <id>
@effect <id> <char>
@effect <id> <x> <y>
Reviewed-by: Bertram.
|
|
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
|
|
Without a timeout, trying to write to a locked database fails immediately.
Now it will only fail when it can't retrieve a write lock within a second.
Still, we need to go through all the SQLite code some time, since there
is a lot of error handling missing. We also need to make sure that errors
are handled correctly on the higher level.
Reviewed-by: Yohann Ferreira
|
|
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
|
|
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
|
|
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
|
|
Mostly removed bulky copyright headers and fixed indentation and line length.
Reviewed-by: Yohann Ferreira
Reviewed-by: Erik Schilling
|
|
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
|
|
It's not nice to use ++ on an iterator that may be std::map::end(),
in my case this caused it to hang indefinitely.
Reviewed-by: Yohann Ferreira
|
|
Reviewed-by: Bertram.
|