Rappelz Skills Card Combiner help

01/16/2024 04:29 lordfarthhold#1
Hey guys , I've been racking my brain with this LUA for auto combining skill cards . I can get everything working besides the actual combination when clicking the +1 to +2 combine option . Auth emu doesnt spit any issues , so i've tried racking Chatgpt's brain but no luck doing it's suggestions. Working with modified version of Revos 9.5.2 database

01/16/2024 15:46 yosiemelo#2
oh :D here we go again :P
contact me on discord when you still need help with that :D
01/16/2024 18:42 lordfarthhold#3
Not asking for anyone to redo it , just asking for guidance in the right direction for someone fairly new to LUA/ and or if someone see's something wrong with what I've got . What I'm asking for isn't justifiable IMO by paying you . So no thanks.
01/16/2024 18:54 yosiemelo#4
Quote:
Originally Posted by lordfarthhold View Post
Not asking for anyone to redo it , just asking for guidance in the right direction for someone fairly new to LUA/ and or if someone see's something wrong with what I've got . What I'm asking for isn't justifiable IMO by paying you . So no thanks.
I don't mean paying for that; I just wanted to give you some tips that might be easier than on this forum.
Your script is ALMOST completely wrong from start to finish, except when it comes to talking with NPCs. So, you are approaching it the wrong way.

1.You need an array of cards for specific races.

2.Your logic for combining them is incorrect. When you have 1000 cards and encounter a failure, it removes your cards. Instead, you should use a for loop or a while loop and independently randomize chances each time.

3.You don't ask about the enchant item anywhere.

4.You don't have checks, which leads to more bugs in your script.

etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc
01/16/2024 19:30 lordfarthhold#5
Ohhh gotcha my bad for assuming XD , So just for helping other's who may come across this issue . I'd like to keep it on the forum for some extra resource material for up and coming dev's .

Could you possibly explain the logic that I should be using a little more? I pulled a good portion of this script from some old files I had lying around from a 7.3 project. So I know some stuff changed from there to the new Epic's.

Like as in some stuff you mentioned above
@2.Your logic for combining them is incorrect. When you have 1000 cards and encounter a failure, it removes your cards. Instead, you should use a for loop or a while loop and independently randomize chances each time. < Primarily this for the Loop

and

3.You don't ask about the enchant item anywhere.
01/16/2024 19:41 yosiemelo#6
Quote:
Originally Posted by lordfarthhold View Post
Ohhh gotcha my bad for assuming XD , So just for helping other's who may come across this issue . I'd like to keep it on the forum for some extra resource material for up and coming dev's .

Could you possibly explain the logic that I should be using a little more? I pulled a good portion of this script from some old files I had lying around from a 7.3 project. So I know some stuff changed from there to the new Epic's.

Like as in some stuff you mentioned above
@2.Your logic for combining them is incorrect. When you have 1000 cards and encounter a failure, it removes your cards. Instead, you should use a for loop or a while loop and independently randomize chances each time. < Primarily this for the Loop

and

3.You don't ask about the enchant item anywhere.

ok i do that when im home later :)

Quote:
Originally Posted by lordfarthhold View Post
Ohhh gotcha my bad for assuming XD , So just for helping other's who may come across this issue . I'd like to keep it on the forum for some extra resource material for up and coming dev's .
Could you possibly explain the logic that I should be using a little more? I pulled a good portion of this script from some old files I had lying around from a 7.3 project. So I know some stuff changed from there to the new Epic's.

Like as in some stuff you mentioned above
@2.Your logic for combining them is incorrect. When you have 1000 cards and encounter a failure, it removes your cards. Instead, you should use a for loop or a while loop and independently randomize chances each time. < Primarily this for the Loop

and

3.You don't ask about the enchant item anywhere.


So... let's start by defining the LOCAL table with card IDs for different races.
You can do this inside the combine function or outside.

Code:
local SkillCardsID = {}
    SkillCardsID[1] = {	-- Devaskills
        502001, 502011, 502012, 502013, 502014, 502018, 502019, 502020, 502021,
        502022, 502061, 502063, 502064, 502067, 502068, 502611, 502615, 502635,
        503001, 503002, 503003, 503004, 503005, 503011, 503037, 503040, 503201,
        503202, 503203, 503204, 503205, 503210, 503401, 503402, 503454, 503492,
        503621, 503814, 503815, 504001, 504002, 504003, 504012, 504201, 504202,
        504207, 504402, 506010, 521124, 521302, 521304, 521308, 521320, 521417,
        521427, 521504, 521506, 521524, 521525, 521526, 521527, 522001, 522002,
        522003, 522004, 522005, 522006, 522007, 522008, 523001, 523002, 523003,
        523004, 523009, 523010, 523011, 523012, 523013, 523014, 523201, 523202,
        523204, 523205, 523206, 523401, 523402, 523403, 523404, 523405, 523406,
        523407, 523408, 523409, 523410, 523411, 523412, 523413, 523414, 523415,
        523416, 523417, 523432, 523433, 523434, 523435, 523436, 523437, 523438,
        523439, 523601, 523606, 524204, 524401, 524402, 524403, 524404, 550101,
        550102, 550401
    } 
    SkillCardsID[2] = {	-- Asuraskills
        502001, 502031, 502032, 502033, 502034, 502051, 502060, 502070, 502071,
        502074, 502075, 502076, 502077, 502078, 502303, 502304, 502331, 502332,
        502333, 502334, 502337, 502339, 502340, 502501, 502502, 502503, 502601,
        502620, 502621, 502622, 502623, 502624, 502626, 502630, 502637, 502638,
        502639, 502649, 502671, 502672, 502673, 502676, 502677, 502678, 502679,
        503012, 503013, 503014, 503015, 503016, 503017, 503027, 503030, 503033,
        503035, 503156, 503185, 503186, 503211, 503212, 503411, 503412, 503435,
        503458, 503460, 503461, 503601, 503602, 503603, 503607, 503608, 503613,
        503614, 503616, 503750, 503753, 503803, 503806, 503810, 503811, 504001,
        504002, 504003, 504012, 504211, 504412, 504413, 504612, 504613, 504614,
        504801, 504802, 504901, 506010, 522011, 522301, 522302, 522303, 522304,
        522307, 523005, 523006, 523007, 523008, 523017, 523203, 523428, 523429,
        523430, 523431, 523444, 523445, 523605, 523801, 523802, 524201, 524405,
        524406, 524407, 524802, 524803, 524804, 524805, 531105, 531108, 531116,
        531117, 531124, 531204, 531208, 531308, 531314, 531315, 531320, 531329,
        531407, 531504, 531505, 531512, 531524, 531526, 550201, 550401
    } 
    SkillCardsID[3] = {	-- Gaiaskills
        502001, 502041, 502043, 502044, 502045, 502046, 502052, 502053, 502055,
        502056, 502058, 502082, 502311, 502312, 502313, 502315, 502321, 502322,
        502326, 502328, 502602, 502616, 502617, 502631, 502635, 502641, 502642,
        502645, 502655, 502656, 502661, 502662, 502663, 502664, 502668, 502681,
        502682, 503021, 503022, 503023, 503024, 503025, 503103, 503151, 503181,
        503183, 503187, 503188, 503209, 503220, 503222, 503224, 503423, 503424,
        503425, 503426, 503427, 503428, 503429, 503430, 503431, 503472, 503622,
        503751, 503752, 503754, 503901, 504001, 504002, 504003, 504012, 506010,
        522009, 522010, 522012, 522305, 522306, 522501, 523015, 523016, 523418,
        523419, 523420, 523421, 523422, 523423, 523424, 523425, 523426, 523427,
        523441, 523442, 523443, 523602, 523603, 523604, 524001, 524002, 524202,
        524203, 524801, 541107, 541124, 541211, 541224, 541225, 541306, 541315,
        541329, 541330, 541406, 541413, 541506, 541513, 541523, 550301, 550401
    }
Additionally, you did not consider different chances for each enhancement level.
This can be done using a local array variable that contains both arrays of chances, one for the normal cube, the other for the ancient cube.

Code:
	local success_percent=		{ 	{100, 60, 50, 40, 30, 20, 15, 10, 5, 3},		--- normal cube
									{100, 90, 80, 70, 60, 50, 45, 40, 35, 33 }		--- ancient cube
	local cube_array = {700401,700402}	--cube ids
Below is a function from my friend InkDevil. It checks true if an item is removable (not equipped) and has the appropriate enhance.

Code:
---With Enhancement Filter, nonstackable items
function check_hlist_amount_with_enhance(nItemId , amount, nEnhance)
	
	local hList 		= get_item_handle_list(nItemId)
	local hDeletionList = {}
	local nAmount = 0
	for i,v in ipairs(hList) do
		if is_erasable_item(v) == 1 and get_item_enhance(v) == nEnhance then
			nAmount = nAmount + 1
			table.insert(hDeletionList, v)
			if nAmount == amount then
				return true,hDeletionList
			end
		end
	end
	hDeletionList = {}
	return false,hDeletionList
end
The full 'combine' function looks like this, I recommend you read it carefully and draw conclusions from it.
If you don't understand a part of the code, ChatGPT can help you perfectly with that.
Unfortunately, GPT does not know the Rappelz environment, so it cannot write scripts specifically for Rappelz.
However, I thought about creating GPTs that I would teach Rappelz functions and train them in using them, but I don't have time for that :c

Code:
function new_skillcard_upgrade(nCard, current_enhance, nCubeType, bMessage)
	local success_percent=		{ 	{100, 60, 50, 40, 30, 20, 15, 10, 5, 3},		--- normal cube
									{100, 90, 80, 70, 60, 50, 45, 40, 35, 33 }		
								}
	local cube_array = {700401,700402}
	
	local checkS, itemS = check_hlist_amount_for_stackable_items(nCard,2,current_enhance)
	local checkC, itemC = check_hlist_amount_for_stackable_items(cube_array[nCubeType],1,0)
	local count = 0
	local bWithMessage = bMessage
	if bWithMessage == nil or bWithMessage == "" then
		bWithMessage = false
	end	
	while checkS == true and checkC == true do

		delete_item(itemS,2)
		delete_item(itemC,1)
		local serverrate = get_env("game.skillcard_enhance_rate")
		if math.random( 1, 100) <= (success_percent[nCubeType][current_enhance+1] * serverrate) then
			insert_item(nCard,1,current_enhance +1)
			count = count + 1
		end
		
		checkS, itemS = check_hlist_amount_for_stackable_items(nCard,2,current_enhance)
		checkC, itemC = check_hlist_amount_for_stackable_items(cube_array[nCubeType],1,0)
	end
	
	if checkS == false and bWithMessage == true and count > 0 then
	--	message("You don't have enough skillcards to use this function further!")
		message("Processing skillcard...done!")
	elseif checkC == false and bWithMessage == true and count > 0  then
		message("You don't have enough of the selected skillcubes to use this service further!")
	end
	
	if bWithMessage == true and count > 0 then
		message(sconv("<#B3EE3A>Process-Result: #@amount@#x #@itemname@ +#@new_enhance@#!","#@amount@#",count,"#@itemname@","@"..get_item_name_id(nCard),"#@new_enhance@#",current_enhance +1))
	end
	
	return count
end
01/17/2024 22:05 InkDevil#7
You didn't post the fitting functions for it.
In new_skillcard_upgrade you're calling check_hlist_amount_for_stackable_items, you was posting check_hlist_amount_with_enhance, which actually had a fkin comment above from me that this one is for NONSTACKABLE items.

The version for stackables contains functions which I've added in sourcecode (for checking stack-size), so not really useable for a non-source-server - but you might have known that at least.

You can use the nonstack-version, sure, but it wouldn't work that way as the stackable one does...
@[Only registered and activated users can see links. Click Here To Register...] sry I have to interfere in your thread, but it would actually confuse you more if you'd use those parts of my script than leading to your requested help.