summaryrefslogtreecommitdiff
path: root/src/scripting
AgeCommit message (Collapse)AuthorFilesLines
2013-04-14Use a full user data for Entity referencesThorbjørn Lindeijer4-89/+47
Only moved a single script function to a member for now, will do others in a separate commit.
2013-04-12Fixed too long lua documentationErik Schilling1-21/+46
2013-04-12Moved Actor into an ComponentErik Schilling1-39/+46
This was the final step to remove the hierachy with Entity on the top.
2013-04-11Converted Being into a ComponentErik Schilling8-182/+203
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 Schilling5-85/+99
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 Schilling3-21/+25
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-04-02Fixed multiple warnings and errors that blocked c++0xErik Schilling1-1/+1
This allows the server to compile with c++0x (and enables it). This also includes some coding style / readabillity fixes.
2013-04-02Moved fighting code into a componentErik Schilling1-2/+3
All damage dealing is now handeled via CombatComponent. Monsters use a derived MonsterCombatComponent since they can have a damage mutation and have a seperate script callback. The wirering with Being is still not optional since most of the stuff does not exist as components. Things done: - Seperated the fighting code from Being and only let Characters and Monsters add the Component (less overhead for npcs) - Added a getter for Attribute values to prevent searching it all the time in non Being members - Fixed the type if the damage mutation to double (no idea why it was int) I did not want to copy it over incorrectly - Removed the addAttack/removeAttack overrides in Character and made the knuckleAttack being added based on newly added signals Future TODOS: - Remove depedency on Being as soon all needed dependencies are available as components of Entity - Move the monster script callback into the general combatcomponent and make it usuable for characters too
2013-03-25Changed NPC to an NpcComponent added to a BeingThorbjørn Lindeijer3-34/+43
2013-03-25Changed Effect to a component of ActorThorbjørn Lindeijer1-1/+1
Reviewed-by: Yohann Ferreira
2013-03-25Changed Item to a component of ActorThorbjørn Lindeijer1-9/+5
Items also have positions, so the ItemComponent only makes sense as part of an Actor. Later on it will probably be part of an entity that also has an ActorComponent. Since it was annoying to update all the places where items were created, I've introduced a function for this. The component types are now prefixed with "CT_" because I wanted to introduce an 'Item' namespace which would otherwise be conflicting. The component types enum isn't used much in the code so it can look a bit ugly. Reviewed-by: Yohann Ferreira
2013-03-25Changed SpawnArea and TriggerArea to components of EntityThorbjørn Lindeijer1-4/+8
Well, first visible change is that everything just gets longer to read. Reviewed-by: Yohann Ferreira
2013-02-24Documented all lua binds directly in the sourceErik Schilling1-1341/+2201
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-21Introduced Script::ContextErik Schilling7-45/+74
This should allow to finally call functions to lua without having to care about working around situations where a lua call causes a c++ call which needs to call to lua again. Tested against the source of tales repository data.
2013-02-04Moved attribute (re)calculation to the scriptsErik Schilling1-0/+26
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-01-09Replaced EventListener with signals based on libsigc++Thorbjørn Lindeijer5-23/+12
This replaces the rather hard to understand event dispatcher with a probably even harder to understand templated library, but fortunately we can rely on the available documentation. Hopefully it will also help with the readability of our code and with adding additional signals to other classes. Added libsigc++ to README and Travis CI configuration. Reviewed-by: Erik Schilling
2013-01-09Micro-optimizations for pushing strings to LuaThorbjørn Lindeijer4-37/+29
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 Lindeijer3-1/+23
Should still work against Lua 5.1 as well.
2013-01-08Added script binds for getting attack informationErik Schilling2-8/+155
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-07Set the current map when executing being callbacksThorbjørn Lindeijer1-0/+2
The on_death and on_remove callbacks where not being executed in the context of any map. Now they execute in the context of the map of the being. Reviewed-by: Erik Schilling
2012-08-10Fixed item_drop insertion of objectErik Schilling1-3/+2
2012-08-05Fixed wrong error raising in lua.cppErik Schilling1-2/+2
Reviewed-by: bjorn.
2012-08-05Removed old warnings and documentation from chr_inv_change.Erik Schilling1-7/+3
This was forgotten to do when dropping the money checks and introducing the checkItem function. Reviewed-by: bjorn.
2012-08-05Fixed the atinit functionErik Schilling1-0/+1
Previously each map had its own scope. They got merged now but the atinit function was forgotten to adapt. Reviewed-by: bjorn.
2012-07-21Fixed an error message and inlined some one-linersThorbjørn Lindeijer2-30/+29
2012-07-21Removed raiseScriptErrorThorbjørn Lindeijer3-37/+24
It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling
2012-07-17Added lua binds for issuing request of quest variable + bind for trying to ↵Erik Schilling1-2/+67
read them The difference to the old chr_get_quest bind is that this allows querying quest vars from non npc functions as well. Change is tested. Reviewed-by: bjorn.
2012-07-17Added script binds to get full monster anger list + drop anger of monstersErik Schilling1-0/+17
Reviewed-by: bjorn.
2012-07-17Added lua bind to send text effect particle to clientsErik Schilling1-0/+13
Change is tested. Reviewed-by: bjorn.
2012-07-17Made chr_get_level capable of retrieving skill levelsErik Schilling1-3/+12
Reviewed-by: bjorn.
2012-07-14Fixed the get_beings_in_rectangle function.Erik Schilling1-1/+2
Previously it only used the rectangle iterator which in fact iterated over the beings in the map zones and returned often way higher number of beings compared to the actual rectangle. Change is tested. Reviewed-by: Bjorn.
2012-07-11Made sure the map is set for trigger scriptsErik Schilling1-0/+1
Also unsetted maps after execution of scripts to make finding this mistakes easier. Reviewed-by: bjorn.
2012-07-10Made kill count script bind capable of taking the monster name as argumentErik Schilling1-2/+2
Reviewed-by: bjorn.
2012-07-08Added bind for setting login callbackErik Schilling1-0/+8
Reviewed-by: bjorn.
2012-07-07Added script bind for getting specy id of a monster handleErik Schilling1-0/+12
Reviewed-by: bjorn.
2012-05-20Removed no longer needed codeErik Schilling2-24/+0
I forgot to remove this during my special cleanup Reviewed-by: bjorn.
2012-05-06Don't send NPC text as fixed-length stringThorbjørn Lindeijer1-3/+2
This is intended to be used only when the string length is known. The client was deriving the length from the remaining amount of data in the message, but that doesn't work in the new 'debug mode' of the protocol. Reviewed-by: Ben Longbons
2012-05-06Some small optimizations in Lua helper functionsThorbjørn Lindeijer1-6/+3
Reviewed-by: Ben Longbons
2012-04-04Adding monster::on_damage callbackStefan Beller1-0/+9
Reviewed-by: bjorn
2012-04-04Renamed Thing to EntityThorbjørn Lindeijer6-22/+22
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 Schilling6-46/+162
- 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 Schilling3-5/+27
Reviewed-by: bjorn.
2012-03-17Added map update function, moved schedules there to keep map contextErik Schilling1-2/+15
Reviewed-by: bjorn.
2012-03-16Fixed fastRemoveOne when the element isn't foundThorbjørn Lindeijer1-1/+1
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.
2012-03-14Added chr_kick() lua bindErik Schilling1-2/+16
Another step towards scriptable @commands. Reviewed-by: bjorn.
2012-03-14Added being_get_mapid lua bindErik Schilling1-2/+18
Another step for being able to make @commands scriptable Reviewed-by: bjorn.
2012-03-14Added get_character_by_name lua bindErik Schilling1-0/+18
Step to be able to handle chatcommands by scripts. Reviewed-by: bjorn.
2012-03-13Added script bind to set walkmask for beingsErik Schilling1-0/+42
TODO: Inform client about this change. Reviewed-by: bjorn.
2012-03-11Removed "mana." from script function documentationThorbjørn Lindeijer1-102/+99
Forgot to do this in the previous commit.
2012-03-11Register Lua script API functions into the global namespaceThorbjørn Lindeijer1-2/+3
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