Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: features OTCR natively in canary #3061

Open
wants to merge 69 commits into
base: main
Choose a base branch
from

Conversation

kokekanon
Copy link
Contributor

@kokekanon kokekanon commented Nov 4, 2024

6/6

for test use this client.exe https://github.com/mehah/otclient/actions/runs/12600452102
pr # 962 of otcr

or use this in terminal

ProtocolGame.registerOpcode(0x43, function(protocol, msg)
    local count = msg:getU16()
    for i = 1, count do
      local feature = msg:getU8()
	  local enable = msg:getU8()
	  if enable == 1 then
		g_game.enableFeature(feature)
	  end
	end
end)

Description

Feature Done No break v8 or cipsoft
1.- Creature AE + Shader
2.- send disableFeature / enableFeature . easy to modify in config.lua mehah/otclient#962
3.- outfit (wings,aura,shader)
4.- TypingIcon
5.- map shader support
6- item Shader

1.-Creature AE + Shader

no break cipsoft or v8
image
img
Haskanoid Video

2.-send disableFeature / enableFeature . easy to modify in config.lua

it is easier for the server administrator to modify config.lua than to compile every time he wants to add or remove a feature.
note1: v8 and otcr send the same packets, so it could be only 1 function, but i don't want to break anything.

note2 : In otcr requires modification in the client * is not yet ready

image

3.- outfit (wings,aura,shader)

image

4.- TypingIcon

Haskanoid Video

5.- map shader support

Peoplemon by Alex Stuart

6.- item Shader

Peoplemon by Alex Stuart

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested

1/6 Creature : AttachedEffect | Shader

Client:
--   g_game.enableFeature(GameCreatureAttachedEffect)
--   g_game.enableFeature(GameCreatureShader)
Server:
	player:setShader("Outfit - Rainbow")
	player:attachEffectById(7)
	player:attachEffectById(8)

2/6 Player: Map Shader

	player:setMapShader("Map - Party")

4/6 feature: Item Shader

--Client:
	g_game.enableFeature(GameItemShader)
-- Server:
	player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK):setShader("Map - Party")

5/6 send disableFeature / enableFeature. easy to modify in config.lua

const auto &enabledFeatures = g_configManager().getEnabledOTCFeatures();
const auto &disabledFeatures = g_configManager().getDisabledOTCFeatures();

for (auto feature : enabledFeatures) {
g_logger().info("Feature enabled: {}", feature);
}

for (auto feature : disabledFeatures) {
g_logger().info("Feature disabled: {}", feature);
}

6/6

image
image

x:addCustomOutfit("aura", 8)
x:removeCustomOutfit("aura", 8)
local talkAction = TalkAction("!testOTCR")

local options = {
	Creature = {
		{
			name = "set attach Effect 7",
			action = function(player)
				player:attachEffectById(7)
			end,
		},
		{
			name = "get all attach Effect",
			action = function(player)
				local effects = player:getAttachedEffects()
				if #effects > 0 then
					local effectsString = "your AE are: " .. table.concat(effects, ", ")
					player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, effectsString)
				else
					player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "you do not have any AE.")
				end
			end,
		},
		{
			name = "detach Effect 7",
			action = function(player)
				player:detachEffectById(7)
			end,
		},
		{
			name = "set Shader player",
			action = function(player)
				player:setShader("Outfit - Rainbow")
			end,
		},
		{
			name = "no shader player",
			action = function(player)
				player:setShader("")
			end,
		},
		{
			name = "get Shader player",
			action = function(player)
				player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getShader())
			end,
		},
	},
	Map = {
		{
			name = "set Shader Map",
			action = function(player)
				player:setMapShader("Map - Party")
			end,
		},
		{
			name = "no shader Map",
			action = function(player)
				player:setMapShader("")
			end,
		},
		{
			name = "get Shader Map",
			action = function(player)
				player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getMapShader())
			end,
		},
	},
	Items = { {
		name = "Shader",
		action = function(player)
			local item = player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
			item:setShader("Map - Party")
			player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "item have shader : " .. item:getShader())
		end,
	} },
	game_outfit = {
		{
			name = "Add permanent aura 8",
			action = function(player)
				player:addCustomOutfit("aura", 8)
				player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "add aura 8")
			end,
		},
		{
			name = "remove permanent aura 8",
			action = function(player)
				player:removeCustomOutfit("aura", 8)
				player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "remove aura 8")
			end,
		},
	},
}

function talkAction.onSay(player, words, param, type)
	local modalWindow = ModalWindow({
		title = "Fast Test",
		message = "Choose one of the following options:",
	})

	for category, subOptions in pairs(options) do
		modalWindow:addChoice(category, function(player, button, choice)
			local subModalWindow = ModalWindow({
				title = "Select a Sub-Option",
				message = "Choose one of the following sub-options for " .. category .. ":",
			})

			for _, subOption in ipairs(subOptions) do
				subModalWindow:addChoice(subOption.name, function(plyr, btn, ch)
					if button.name == "OK" then
						subOption.action(plyr)
					end
				end)
			end

			subModalWindow:addButton("OK")
			subModalWindow:addButton("Cancel", function(plyr)
				subModalWindow:clear()
			end)
			subModalWindow:sendToPlayer(player)
		end)
	end

	modalWindow:addButton("OK")
	modalWindow:addButton("Cancel", function(player)
		modalWindow:clear()
	end)
	modalWindow:sendToPlayer(player)
	return false
end

talkAction:groupType("normal")
talkAction:separator(" ")
talkAction:register()

local playerLoginTestOTCR = CreatureEvent("simpletest")

function playerLoginTestOTCR.onLogin(player)
	if player:getClient().os >= 10 and player:getClient().os < 12 then
		player:say("say !testOTCR", TALKTYPE_SAY)
	end
	return true
end

playerLoginTestOTCR:register()

Test Configuration:

  • Server Version: 13.40
  • Client: OTCR
  • Operating System: 11

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Note: To be honest, I'm not good at C++, and I don't use Canary.

Sorry, something went wrong.

attachEffectById
detachEffectById
getShader
setShader
player:setMapShader("Map - Party")
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
Copy link
Member

@dudantas dudantas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I have a few observations that could help further improve the work.

src/creatures/creature.cpp Outdated Show resolved Hide resolved
src/creatures/creature.cpp Outdated Show resolved Hide resolved
src/creatures/creature.hpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/items/item.hpp Outdated Show resolved Hide resolved
const auto &enabledFeatures = g_configManager().getEnabledOTCFeatures();
const auto &disabledFeatures = g_configManager().getDisabledOTCFeatures();

				for (int32_t feature : enabledFeatures) {
					g_logger().info("Feature enabled: {}", feature);
				}

				for (int32_t feature : disabledFeatures) {
					g_logger().info("Feature disabled: {}", feature);
				}

Update configmanager.hpp
src/creatures/creature.hpp Outdated Show resolved Hide resolved
@dudantas
Copy link
Member

dudantas commented Nov 5, 2024

Apologies for the confusion. In the setShader method, you can continue using std::string_view, but for all other methods, they can remain as std::string.

PS: If you need, I can help commit.

dudantas and others added 2 commits November 5, 2024 03:10
@dudantas
Copy link
Member

dudantas commented Nov 5, 2024

@kokekanon
I couldn't commit directly to your fork, but here's the commit if you want to cherry pick it
1437b7e

kokekanon and others added 8 commits December 27, 2024 20:33
…re-redemption
…re-redemption
…re-redemption
…re-redemption
…/kokekanon/canary3 into kokekanon/all-feature-redemption
@kokekanon kokekanon marked this pull request as ready for review January 3, 2025 17:16
…re-redemption
…re-redemption
…re-redemption
…re-redemption
…re-redemption
…re-redemption
Copy link
Member

@dudantas dudantas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. I have some small observations that may impact performance/stability.

src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/lua/functions/creatures/creature_functions.cpp Outdated Show resolved Hide resolved
src/server/network/protocol/protocolgame.cpp Outdated Show resolved Hide resolved
src/server/network/protocol/protocolgame.cpp Outdated Show resolved Hide resolved
src/server/network/protocol/protocolgame.cpp Outdated Show resolved Hide resolved
…re-redemption
…re-redemption
…re-redemption
fix
…re-redemption
…re-redemption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants