Commit graph

4 commits

Author SHA1 Message Date
Artur Knopik Linux
5bfda8f613 Revert "[Revscriptsys] RevNpcSys version 1.0 (lua npcs / NpcType / new npc system) (#4671)"
This reverts commit 4a89502f46.
2024-12-05 23:56:16 +01:00
Mario
4a89502f46
[Revscriptsys] RevNpcSys version 1.0 (lua npcs / NpcType / new npc system) (#4671)
Co-authored-by: Sarah Wesker <sarahelizabetwesker@gmail.com>
2024-05-30 02:55:42 +02:00
Mario Tettei
6c8e85b90c Revscriptsys Spells (#2584)
* Spell handling through lua

- Basics are done, but this is still wip

* work on reload for spell

- just a few tiny changes

* spell __newindex function

- this include __newindex for spell
- Spell does now return Userdata instead of tabledata

* added Spell Functions

- It includes all necessary Spell functions now

* made use of dynamic_cast

- There is still a cleanup todo, there are still several const_cast which I need to switch over
- applied createFunctions for Spell

* added a few safety checks

- cleaned up some functions
- changed const_cast to dynamic_cast
- exclusive InstantSpell & RuneSpell functions will not crash the server if not used appropriate

* erased duplicate

- erased duplicated g_spells->clear(true);

* enabled strings on Spell creation

- now you can use Spell("rune") & Spell("instant") aswell

* shortened down luaSpellGroup

- created stringToSpellGroup(), so I could get rid of repetitive stuff.

* combined charges and hasCharges

- if we set a rune :charges(1) or higher it'll automaticly mean that it should use charges aswell.
However if we don't set :charges or :charges(0) it means the rune is infinite.

* Final Spell handling

- changed so Spells are getting pushed as Spell now and not as InstantSpell or RuneSpell
- corrected the methods :allowFarUse :blockWalls and :checkFloor
- corrected RuneSpell* Spells::getRuneSpell(uint32_t id) it now can be accessed by either runeId or spellId
- corrected InstantSpell* Spells::getInstantSpellById(uint32_t spellId) it now returns the correct InstantSpell

* compiler error fix

* little update

- removed switch since it's just SPELL_INSTANT and SPELL_RUNE anyway
- changed RuneSpell* Spells::getRuneSpell(uint32_t id)
so it doesn't try to re initialize it again

* Spells #example.lua

- added Spells #example.lua

* safety move

- moved those 2 variables inside the if statements for safety.
2019-05-26 21:16: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