Register for your free account! | Forgot your password?

You last visited: Today at 10:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Shaiya Library

Discussion on Shaiya Library within the Shaiya PServer Guides & Releases forum part of the Shaiya Private Server category.

Reply
 
Old   #1


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Shaiya Library

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





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!
Attached Files
File Type: zip ShaiyaLibraryEpvp.zip (233.0 KB, 749 views)
Cups is offline  
Thanks
35 Users
Old 08/17/2019, 21:37   #2
 
elite*gold: 0
Join Date: Mar 2017
Posts: 33
Received Thanks: 2
What version of Visual Studio? I am trying to compile with 2013.
Can you post the compiled file please?
Bacкa is offline  
Old 08/18/2019, 00:28   #3


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
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.
Attached Files
File Type: zip Debug.zip (9.65 MB, 419 views)
Cups is offline  
Thanks
2 Users
Old 08/18/2019, 23:17   #4
 
elite*gold: 0
Join Date: Mar 2017
Posts: 33
Received Thanks: 2
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.
Bacкa is offline  
Old 08/19/2019, 02:18   #5
 
[ADM]Sky's Avatar
 
elite*gold: 0
Join Date: Jul 2016
Posts: 91
Received Thanks: 243
[ADM]Sky is offline  
Old 08/19/2019, 04:20   #6
 
elite*gold: 0
Join Date: Mar 2017
Posts: 33
Received Thanks: 2
Quote:
Originally Posted by [ADM]Sky View Post
Bacкa is offline  
Old 08/19/2019, 20:34   #7

 
elite*gold: 150
Join Date: Apr 2007
Posts: 2,394
Received Thanks: 6,644
Make sure to start the Injector / Cheat Engine as Administrator
wurstbrot123 is offline  
Old 08/19/2019, 23:38   #8
 
elite*gold: 0
Join Date: Mar 2017
Posts: 33
Received Thanks: 2
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?
Bacкa is offline  
Old 08/20/2019, 14:23   #9


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
This is why I suggested you build it yourself :P It's trying to load Lua libraries but you don't have any.
Cups is offline  
Old 09/04/2019, 11:22   #10
 
elite*gold: 0
Join Date: Apr 2019
Posts: 42
Received Thanks: 2
Talking

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 .

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 ?
LibPor22 is offline  
Old 02/04/2020, 11:03   #11
 
elite*gold: 0
Join Date: Jun 2014
Posts: 134
Received Thanks: 124
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 .



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 ?
nop, you need to open ShaiyaEden and dllmain.cpp create this folder: /Eden/Scripts and install libary lua for use lua51.dll, i think.
perlisson is offline  
Old 10/13/2020, 09:06   #12
 
elite*gold: 0
Join Date: Nov 2013
Posts: 6
Received Thanks: 0
Would it be possible to do something like that in the lower episodes, like 6 or 5.4?
DSADASDASD51 is offline  
Old 11/15/2020, 11:30   #13
 
elite*gold: 0
Join Date: Sep 2020
Posts: 3
Received Thanks: 0
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.
Yahooize is offline  
Old 03/24/2022, 04:05   #14
 
elite*gold: 0
Join Date: Jul 2019
Posts: 79
Received Thanks: 5
Do you have a database of EP8?
rsq110 is offline  
Old 08/08/2023, 20:33   #15
 
elite*gold: 0
Join Date: Jun 2018
Posts: 16
Received Thanks: 13
Hi @,

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.
arwekaj09 is offline  
Reply




All times are GMT +1. The time now is 10:45.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.