Shaiya Library

08/17/2019 14:30 Cups#1
I haven't been active in Shaiya in the last couple months as I've recently started a new job working on another game, which has been occupying my time. This library is a bundle of C++ functions and a Lua scripting implementation designed to make Shaiya development easier, and also contains a half-finished implementation of Ep8 packets.

This also contains a half-assed attempt at an "actor" system, which could be considered an artificial player disguised as an NPC for "intelligent" npc systems, though this is far from implemented. Unfortunately, I no longer have the Lua scripts on hand, but it shouldn't be too hard to figure out :)

[Only registered and activated users can see links. Click Here To Register...]

[Only registered and activated users can see links. Click Here To Register...]

I can't help you a whole lot with the scripts other than providing a few examples that I toyed around with, but you should be able to figure it out from reading the functions and models that is exposed in the ShaiyaScriptingEngine project.

Code:
:
NAKED_MAP_ID = 60 -- The map id for naked events to be hosted on

-- Disallow users to equip items on the naked map
on_can_equip(function(user, item, slot)

    if (user.map == NAKED_MAP_ID) then
        user:send_notice("You cannot equip items on this map!")
        return false
    end

    return true
end)

The following are valid functions:
Code:
on_login(function(user)
end)

on_enter_map(function(user))
end

on_item_effect(effect, function(user, variant)
end

on_can_recreate(function(itemdef, runedef, stats)
end)

on_recreation(function(itemdef, runedef, stats, maxreroll, rerollcount)
end)

on_can_equip(function(user, item, slot)
end)
The list of types:
Code:
/**
 * Defines the CUser type.
 */
void ScriptingEnvironment::defineUser() {
	using namespace Shaiya::Models;

	lua.new_usertype<CUser>("user",

		// Get user fields
		"get_name", [](CUser* self) -> const char* {
			return self->name;
		},

		// Stats
		"level", &CUser::level,
		"kills", &CUser::kills,
		"deaths", &CUser::deaths,
		"victories", &CUser::victories,
		"defeats", &CUser::defeats,
		"statpoints", &CUser::statpoints,
		"skillpoints", &CUser::skillpoints,
		"current_hitpoints", &CUser::hitpoints,
		"max_hitpoints", &CUser::maxHitpoints,
		"current_mana", &CUser::mana,
		"max_mana", &CUser::maxMana,
		"current_stamina", &CUser::stamina,
		"max_stamina", &CUser::maxStamina,

		// Position
		"zone", &CUser::zone,
		"map", &CUser::map,
		"x", &CUser::posX,
		"y", &CUser::posY,
		"z", &CUser::posZ,

		// Appearance
		"gender", &CUser::gender,

		// Items
		"equipment", &CUser::equipment,

		// Ability Values
		"health_regen", &CUser::regenHitpoints,
		"mana_regen", &CUser::regenMana,
		"stamina_regen", &CUser::regenStamina,

		// Account
		"points", &CUser::points,
		"status", &CUser::adminStatus,

		// Teleports the user
		"teleport", [](CUser * self, int map, float x, float y, float z) {
			Shaiya::Utils::UserUtils::teleport(self, map, x, y, z);
		},

		// Heals the user
		"heal", [](CUser* self, int heal) {
			int health[3] = { heal, 0, 0 };
			Shaiya::Utils::UserUtils::heal(self, health);
		},

		// Send a notice to the user
		"send_notice", [](CUser* self, std::string message) {
			Shaiya::Utils::UserUtils::sendNotice(self, message);
		},

		// Get an item to the user
		"give_item", [](CUser* self, int type, int typeId, int count) {
			Shaiya::Utils::UserUtils::giveItem(self, type, typeId, count);
		},

		// Delete an item from the user's inventory
		"delete_item", [](CUser* self, int bag, int slot) {
			Shaiya::Utils::UserUtils::deleteItem(self, bag, slot);
		},

		// Spawn a mob on the user
		"spawn_mob", [](CUser* self, int mob) {
			Shaiya::Utils::MobUtils::spawnMob(self, mob);
		}
	);
}

/**
 * Defines the item types
 */
void ScriptingEnvironment::defineItems() {
	using namespace Shaiya::Models;

	// Item definition
	lua.new_usertype<stItemInfo>("item_info",
		"type", &stItemInfo::type,
		"type_id", &stItemInfo::typeId,
		"item_id", &stItemInfo::itemId,
		"effect", &stItemInfo::effect,
		"variant", &stItemInfo::variant,
		"max_reroll", &stItemInfo::maxReroll,
		"reroll_count", &stItemInfo::rerollCount,
		"get_name", [](stItemInfo* self) {
			return self->name;
		}
	);
}

/**
 * Defines the actor type
 */
void ScriptingEnvironment::defineActors() {
	using namespace Shaiya::Entity;

	// Attributes
	lua.new_usertype<Attributes>("Attributes",
		"hitpoints",		&Attributes::hitpoints,
		"max_hitpoints",	&Attributes::maxHitpoints
	);

	// Position
	lua.new_usertype<Position>("Position",
		"map",	&Position::map,
		"x",	&Position::x,
		"y",	&Position::y,
		"z",	&Position::z
	);

	// Render Info
	lua.new_usertype<RenderInfo>("RenderInfo",
		"set_mob_transform", &RenderInfo::setMobTransformation,
		"get_mob_transform", &RenderInfo::getMobTransformation,
		"is_visible", &RenderInfo::isVisible,
		"set_visible", &RenderInfo::setVisible
	);

	// Actor definition
	lua.new_usertype<Actor>("Actor",

		// Define the constructor for the actor
		"create", [](std::string name) -> Actor* {
			return new Actor(name);
		},

		"get_render_info", &Actor::getRenderInfo,
		"get_position", &Actor::getPosition,
		"set_position", [](Actor* self, int map, float x, float y, float z) {
			auto position = self->getPosition();
			position.x = x;
			position.y = y;
			position.z = z;
		}
	);
}
Good luck!
08/17/2019 21:37 Bacкa#2
What version of Visual Studio? I am trying to compile with 2013.
Can you post the compiled file please?
08/18/2019 00:28 Cups#3
Quote:
Originally Posted by Bacкa View Post
What version of Visual Studio? I am trying to compile with 2013.
Can you post the compiled file please?
I used 2017, but there are a few libraries you'll need to find to get it compiling correctly (you can find these referenced in the vcxproj files)
  • LuaJIT
  • Boost 1.70

I've also attached the compiled libraries and DLL. Please note that this compiled copy by default searches for scripts in the "./Eden/Scripts/" folder, relative to your ps_game. The DLL should be injected into the ps_game. This compiled copy does not load any of the Ep8 code, though can be enabled by compiling from source.
08/18/2019 23:17 Bacкa#4
Quote:
Originally Posted by Cups View Post
I used 2017, but there are a few libraries you'll need to find to get it compiling correctly (you can find these referenced in the vcxproj files)
  • LuaJIT
  • Boost 1.70

I've also attached the compiled libraries and DLL. Please note that this compiled copy by default searches for scripts in the "./Eden/Scripts/" folder, relative to your ps_game. The DLL should be injected into the ps_game. This compiled copy does not load any of the Ep8 code, though can be enabled by compiling from source.
[Only registered and activated users can see links. Click Here To Register...]
08/19/2019 02:18 [ADM]Sky#5
[Only registered and activated users can see links. Click Here To Register...]
08/19/2019 04:20 Bacкa#6
Quote:
Originally Posted by [ADM]Sky View Post
[Only registered and activated users can see links. Click Here To Register...]
08/19/2019 20:34 wurstbrot123#7
Make sure to start the Injector / Cheat Engine as Administrator
08/19/2019 23:38 Bacкa#8
Quote:
Originally Posted by wurstbrot123 View Post
Make sure to start the Injector / Cheat Engine as Administrator
Thanks for trying to help but, have I tried before and the same thing happens, any other solution?
08/20/2019 14:23 Cups#9
This is why I suggested you build it yourself :P It's trying to load Lua libraries but you don't have any.
09/04/2019 11:22 LibPor22#10
This is just AWESOME!!!

Quote:
Originally Posted by Bacкa View Post
Thanks for trying to help but, have I tried before and the same thing happens, any other solution?
Hi there, i had same problem as you did, looks like you need to inject it using cheat engine 6.4 :D.

Quote:
Originally Posted by Cups View Post
just a quote
Judging that lua files are used as AI for mobs, if i create a file called Etain.lua it will run my code or is there anything else I should do :confused: ?
02/04/2020 11:03 perlisson#11
Quote:
Originally Posted by LibPor22 View Post
This is just AWESOME!!!



Hi there, i had same problem as you did, looks like you need to inject it using cheat engine 6.4 :D.



Judging that lua files are used as AI for mobs, if i create a file called Etain.lua it will run my code or is there anything else I should do :confused: ?
nop, you need to open ShaiyaEden and dllmain.cpp create this folder: /Eden/Scripts and install libary lua for use lua51.dll, i think.
10/13/2020 09:06 DSADASDASD51#12
Would it be possible to do something like that in the lower episodes, like 6 or 5.4?
11/15/2020 11:30 Yahooize#13
Quote:
Originally Posted by Bacкa View Post
Thanks for trying to help but, have I tried before and the same thing happens, any other solution?
Use other cheat engine , 7.4 should work.
03/24/2022 04:05 rsq110#14
Do you have a database of EP8?
08/08/2023 20:33 arwekaj09#15
Hi @[Only registered and activated users can see links. Click Here To Register...],

Already compiled it. But it seems to be not working, when i tried to inject it, I encounter some error, related to allocation memory. I wonder if there's a fix for this.