Commit graph

74 commits

Author SHA1 Message Date
Ramon Bernardo
8b9e0b0d1d
Add Player:onReconnect event (#4837) 2024-11-17 17:53:22 +01:00
Ramon Bernardo
99c5124349
CreatureEvents improvement: avoid registering with similar names, enforce lowercase in all cases (#4817) 2024-10-31 21:00:00 -03:00
Ranieri Althoff
55c0462790
Move static LuaScriptInterface methods to namespace (#4675) 2024-05-27 15:49:32 +02:00
kygo
098ed9c078
Fix possible crash at removing invalid creatureEvents (#4673)
correction of the loop
2024-05-07 12:57:58 +02:00
Sarah Wesker
954bb014ee
Possibility of tracking the text window (#4444)
* Possibility of tracking the text window

* missing const
2023-08-31 00:17:12 +02:00
Ranieri Althoff
a295ea7b88
Use string views to avoid copying strings (#4079) 2023-03-08 21:49:18 -03:00
Marco Oliveira
545516299b
Update copyright year (#4331) 2023-02-18 20:10:02 -03:00
Ranieri Althoff
412950218c
Add code formatting with clang-format (#4029)
- Use base Google style
- Drop column limit override
- Format all files
- Use tabs for indentation
- Move system headers after project headers
- Avoid breaking string literals
- Reflow usage text
- Match breaks before braces and colons to previous style
- Reduce spaces before trailing comments
- Reflow comments and fix macro usage in luascript.cpp
- Fix invalid code
- Don't align newline escapes
- Reflow comment to make more sense
2022-04-13 14:06:08 +00:00
Ranieri Althoff
2f26b7db6c
Use existing boost algorithms where available (#4032) 2022-03-21 21:54:08 -04:00
Ranieri Althoff
c3596491a3
Cleanup & organize includes and PCH (#4019) 2022-03-18 16:20:02 -04:00
Ranieri Althoff
336ea6315c
Replace usages of str*cmp with C++ functions (#4018) 2022-03-17 16:15:08 -03:00
Evil Puncker
2f8a2afb3b
Add AUTHORS file and remade source header (#3969) 2022-02-22 19:41:21 +01:00
Ramon Bernardo
2e3c682905
Remove else after returning branch (#3678) 2021-09-25 14:24:03 +00:00
Evil Puncker
4ade6a0e6b
Fixed a few typos in comments (#3336) 2021-02-21 22:34:23 -05:00
Evil Puncker
09befdca6a
Fixed some inconsistency on OnDeath parameters (#3067) 2020-06-08 21:07:08 -04:00
Sarah Wesker
879f552610
Fix crash when reloading invalid CreatureEvents (#2897)
The server crashes when you reload the CreatureEvents module, this happens when you create an event, and then delete it, the server still tries to use the copy of this event, but the copy is invalid, because it was cleaned in the reload.
2020-04-18 01:38:04 -04:00
Mario Tettei
28798bb75e fix /reload creaturescripts (#2634)
* fix #2623  /reload creaturescripts

- this fixes the crash bug with /reload creaturescripts
made the implement with emplace
2019-08-09 00:16:11 +02:00
Lucas CP
b7ef46dfc7 Update copyright for 2019 (#2590) 2019-05-13 14:22:45 +02:00
Mario Tettei
0b811f4e83 CreatureEvent duplicate crash fix (#2579)
* CreatureEvent fix

-  This fixes so when you try to register more than one creature event with the same name, that it throws an error warning instead of crashing the server.

* changed to direct emplace

- instead of find, we directly apply emplace and get it's boolean return value.
2019-05-07 23:26:22 +02:00
Mario Tettei
af649d0611 rework on /reload (#2566)
* rework on /reload

- reworked the /reload command, from now on it does reload everything regardless of what you want to reload, because if we don't reload the entire scripts folder alongside it might bug/crash.
You can however still use '/reload global' which will reload global.lua and scripts/lib/
- added 'showScriptsLogInConsole = true' to config.lua.dist. If that option is enabled it also shows on /reload that the scripts are reloaded aswell
- removed all deconstructor (__gc) functions for the events as they where the cause of the crash on reload.
- made raw 'event' pointers to std::unique pointers, so on release it doesn't crash the server.
- fixed a bug which stacked attacks/defenses/loot on reload which could lead to a crash aswell.

* updated reload.lua

- removed all the deprecated reload types.

* trailing line space

- remove a trailing line space

* removed stuff

- removed the unnecessary pointers and pushed them directly into the event type list

* rework on /reload

- reworked the /reload command, from now on it does reload everything regardless of what you want to reload, because if we don't reload the entire scripts folder alongside it might bug/crash.
You can however still use '/reload global' which will reload global.lua and scripts/lib/
- added 'showScriptsLogInConsole = true' to config.lua.dist. If that option is enabled it also shows on /reload that the scripts are reloaded aswell
- removed all deconstructor (__gc) functions for the events as they where the cause of the crash on reload.
- made raw 'event' pointers to std::unique pointers, so on release it doesn't crash the server.
- fixed a bug which stacked attacks/defenses/loot on reload which could lead to a crash aswell.

* another rework

- You can now again reload different types again like usual (/reload actions) etc.
- You can also use /reload scripts and /reload libs now

* forgot to include globalevent.cpp

* another rework

- You can now again reload different types again like usual (/reload actions) etc.
- You can also use /reload scripts and /reload libs now

* another addition

- added removing lua stuff before reloading for /reload all

* ranisalt's change request

- clear() functions are now all override final
- removed get/set for fromLua
- added reInitState function to BaseEvents
- made oldEvent a std::unique_ptr

* another rework

- You can now again reload different types again like usual (/reload actions) etc.
- You can also use /reload scripts and /reload libs now

another addition

- added removing lua stuff before reloading for /reload all

ranisalt's change request

- clear() functions are now all override final
- removed get/set for fromLua
- added reInitState function to BaseEvents
- made oldEvent a std::unique_ptr
2019-04-26 14:22:33 +02:00
Mario Tettei
62dac47c01 revscriptsys (#2558)
* initial revscriptsys

creates a new folder called 'scripts' in the data folder.

lua files placed in the 'scripts' or sub folders will automaticly get registered on load with the right setup ofcourse.

Registering happens in the lua file itself, doesn't require xml settings.

lua files can be deactivated by placing a '#' infront of the filename ex: '#positions.lua' it wont get loaded then.

Currently it supports:
-Actions
-TalkActions
-CreatureEvents
-GlobalEvents
-MoveEvents

There is still stuff on the todo list but they'll get added sooner or later.

Co-Authored-By: Sam <thesumm@users.noreply.github.com>

* compiler fixes

added boost-filesystem to appveyor.yml
fixed a few more compiler errors.

* cleanup on script.cpp

removed using namespace for std / boost filesystem

* some fixes

had to make adjustment so lua callbacks and xml settings work alongside and don't crash the server

* small fixes on movements & function additions

Have to revert the function + callback for stepin/stepout & additem/removeitem as it doesn't make sense on the second look and might cause a stackoverflow
I've also reworked the equip/dequip so it doesn't get double calls.
It'll first check if functions return true if not it won't bother to read the callback

accidently used an old spellbook.lua

added :aid(ids) :uid(ids) functions for MoveEvents

* revert to 'using' functions and suggestion of Djarek

Could revert most of movements.h

made the declaration of the static functions more clear

Co-Authored-By: Damian Jarek <djarek@users.noreply.github.com>

* small fixes

removed commentary from movement.cpp
added newline for position.lua
reworked spellbook.lua with table.concat

* Monster handler & other stuff

- MonsterType's can now be created through lua functions.
- added an interface to create MonsterType's easily through lua files (register_monster_type.lua)
- added #example.lua in 'scripts\monsters\'
- renamed action vector functions for a better standard
- renamed _lib folder to lib, this folder gets now loaded when the other lib folder gets loaded aswell
- moved loading lua scripts out of the scriptfilemanager, we need to load everything after monsters etc. is loaded so MonsterType script manipulation does work
- added Loot() & MonsterSpell() metatables

* fix compiler error

* forgot to remove test code

removed test outfit from MonsterType

* small changes

- added createFunctions(class) it virtually creates the get/set functions for the class passed on
- 'events' folder in monsters is excluded from auto parsing files, as we load callbacks for specific monsters which have an eventFile set to 'true' or 'filename' in this folder.

* compiler error fix

* minor change on createFunctions

* stripping path string

* added Game.createMonsterType(name) and small fixes

- added Game.createMonsterType(name)
- reworked MonsterType(name) to return nil if the MonsterType does not exist, so we don't suddenly create a MonsterType if we do not even want to.
- changed reinterpret_cast to static_cast

* config.lua option for console

- added an option to disable scripts console logging, it can be disabled by placing 'showScriptsLogInConsole = false' into config.lua

* initial revscriptsys

creates a new folder called 'scripts' in the data folder.

lua files placed in the 'scripts' or sub folders will automaticly get registered on load with the right setup ofcourse.

Registering happens in the lua file itself, doesn't require xml settings.

lua files can be deactivated by placing a '#' infront of the filename ex: '#positions.lua' it wont get loaded then.

Currently it supports:
-Actions
-TalkActions
-CreatureEvents
-GlobalEvents
-MoveEvents

There is still stuff on the todo list but they'll get added sooner or later.

Co-Authored-By: Sam <thesumm@users.noreply.github.com>

cleanup on script.cpp

removed using namespace for std / boost filesystem

small fixes on movements & function additions

Have to revert the function + callback for stepin/stepout & additem/removeitem as it doesn't make sense on the second look and might cause a stackoverflow
I've also reworked the equip/dequip so it doesn't get double calls.
It'll first check if functions return true if not it won't bother to read the callback

accidently used an old spellbook.lua

added :aid(ids) :uid(ids) functions for MoveEvents

Monster handler & other stuff

- MonsterType's can now be created through lua functions.
- added an interface to create MonsterType's easily through lua files (register_monster_type.lua)
- added #example.lua in 'scripts\monsters\'
- renamed action vector functions for a better standard
- renamed _lib folder to lib, this folder gets now loaded when the other lib folder gets loaded aswell
- moved loading lua scripts out of the scriptfilemanager, we need to load everything after monsters etc. is loaded so MonsterType script manipulation does work
- added Loot() & MonsterSpell() metatables

small changes

- added createFunctions(class) it virtually creates the get/set functions for the class passed on
- 'events' folder in monsters is excluded from auto parsing files, as we load callbacks for specific monsters which have an eventFile set to 'true' or 'filename' in this folder.

stripping path string

added Game.createMonsterType(name) and small fixes

- added Game.createMonsterType(name)
- reworked MonsterType(name) to return nil if the MonsterType does not exist, so we don't suddenly create a MonsterType if we do not even want to.
- changed reinterpret_cast to static_cast

config.lua option for console

- added an option to disable scripts console logging, it can be disabled by placing 'showScriptsLogInConsole = false' into config.lua
2019-04-16 16:33:38 +02:00
ninjalulz
07f919fed5
Fix unwanted behavior (#2535)
The origin of an attack should not reset to `ORIGIN_NONE`
2019-02-27 08:26:55 +01:00
vankk
020ed5fd36 Update copyright for 2018 (#2452) 2018-03-05 00:39:47 +01:00
Mkalo
f7292a77c8 Change all event containers to store objects (#2149)
Use of smart pointers.
2018-01-01 23:03:10 -05:00
Mkalo
1d330233ee Change onManaChange event. (#2198)
Now onManaChange have the same parameters as onHealthChange. That makes
it more flexible to check damage type and secondary damage info.
2017-12-22 01:47:41 +01:00
Ranieri Althoff
b79d74fda2
Move bug report from creaturescripts to events 2017-01-18 00:20:24 -02:00
Ranieri Althoff
28567fafc6 Move bug report to Lua (#1452) 2017-01-17 23:42:32 -02:00
Bruno Minervino
cc8e15e916 Update copyright year for 2017 (#2034) 2017-01-01 15:39:31 +01:00
Ranieri Althoff
dd521db174 Use changes proposed by clang-tidy (#1879)
- Modernize constructors with pass-by-value + move
- Modernize loops to use new range-based loops
- Use auto where it improves code readability and maintainability
2016-10-02 23:52:01 +02:00
Ranieri Althoff
4fa8f3a225 Remove most of underscore names (#1756) 2016-04-10 20:22:32 +02:00
raymondtfr
72949ab3c4 Renamed data members that uses "m_"-style names
Renamed data members whose names begins with prefix "m_".
Use this-> to avoid conflicting names.
2016-02-06 21:40:26 -08:00
Mark Samman
23e9f46829 Update copyright year
Happy new year!
2016-01-01 02:07:18 +01:00
Damian Jarek
f5d99fdf90 Replace reinterpret_casts.
Replaced reinterpret_casts where the semantic meaning of the type
cast is satisfied by a static_cast (in other word where we cast
pointers/references to objects that are related).
2015-08-15 13:52:50 +02:00
Mark Samman
7a60db396b Fix #1402 2015-06-05 14:10:38 +02:00
Mark Samman
c3ef3eeb34 Pass corpse as item userdata in onDeath 2015-03-15 14:26:38 +01:00
Mark Samman
3349be4745 Update copyright year 2015-01-02 21:32:52 +01:00
Mark Samman
e20dba8cdd Major cleanup/refactoring
This commit breaks backwards compatibility with breakchance and
ammoaction in items.xml and also certain global event names. Break
chance and action for weapons are now specified in weapons.xml and can
be applied to any weapon. This commit also removes the config option
"removeAmmoWhenUsingDistanceWeapon" as there were issues with that and
it is preferred that end-users configure actions for their weapons
(which provides better customizability) instead of having a global
variable that toggles it for every weapon.

Closes #1125
2014-12-30 02:41:09 +01:00
dalkon
c9378ca734 Lua changes
You can now access Creature & Item userdata with these keys, "itemid",
"uid", "actionid" and "type".

Item.transform should not debug the client when setting the id to 0, it
does nothing in that case now.
2014-12-04 16:18:29 +01:00
Mark Samman
01e3edea0b Use pushBoolean instead of lua_pushboolean 2014-11-14 18:59:58 +01:00
Mark Samman
d6ffc3bf45 Replace C-style casts with C++-style casts everywhere 2014-11-13 00:59:28 +01:00
Mark Samman
90406a22db Use final/override and remove unnecessary virtual specifiers 2014-11-07 04:33:49 +01:00
Mark Samman
6240a6616e registerEvent optimizations
Use static_cast instead of dynamic_cast to omit run-time checks
2014-11-04 15:23:01 +01:00
Mark Samman
877e42399f Passing userdata instead of cid everywhere
This is a breaking change, and I think it's safe to assume that most NPC
scripts are broken and the NPC system needs a rewrite/some backwards
compatibility patch to pass id's instead of userdata to callbacks.
2014-11-03 19:10:51 +01:00
Mark Samman
4343f34041 Rename onChangeHealth/Mana to onMana/HealthChange
The event name in creatures.xml also changed from:
changehealth and changemana to healthchange and manachange

If you were utilizing any of these creature events, you must update
their names for them to function.
2014-08-19 15:37:56 +02:00
dalkon
a76d683c11 Some fixes
onChangeHealth & onChangeMana now get the full damage instead of
min(health, damage).
2014-07-21 18:21:09 +02:00
dalkon
3d7c7abf06 Make onChangeHealth easier to use. 2014-07-08 21:30:05 +02:00
dalkon
4d1a293bb4 Lua stuff & other things
Added ItemType.usesSlot to global.lua, now the slot constants actually
have a use.
Changed onChangeHealth & onChangeMana to be more flexible.
Added table.create & Item.hasProperty.
Made Game::combatChangeHealth & combatChangeMana a bit faster.
2014-07-08 20:39:58 +02:00
Mark Samman
d89f15320a Lua cleanup & optimizations 2014-03-19 13:20:54 -04:00
Mark Samman
9924457986 Update copyright year 2014-02-17 11:30:36 -05:00
Mark Samman
31ac18866e Remove unused parameters 2013-12-27 11:36:41 +01:00