Jump to content
Sign in to follow this  
kyleflow

Combine 100%

Recommended Posts

Change the value of 'a' here into 1 making it 100% combine rate. How do I made the 100 combine fruit item to change that 'a' value.

 

function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv )
	     
        Item_Lv = Item_Lv - 1
        if Item_Type == 49 or Item_Type == 50 then
                local a
                local b

                if Item_Lv < 3 then
                        a = 1
                        b = Percentage_Random ( a )

                elseif Item_Lv == 3 then
                        a = 0.9
                        b = Percentage_Random ( a )

                elseif Item_Lv == 4 then
                        a = 0.8
                        b = Percentage_Random ( a )

                elseif Item_Lv == 5 then
                        a = 0.7
                        b = Percentage_Random ( a )

                elseif Item_Lv == 6 then
                        a = 0.6
                        b = Percentage_Random ( a )

                elseif Item_Lv == 7 then
                        a = 0.5
                        b = Percentage_Random ( a )

                elseif Item_Lv == 8 then
                        a = 0.4
                        b = Percentage_Random ( a )

                elseif Item_Lv == 9 then
                        a = 0.3
                        b = Percentage_Random ( a )
                end
                return b
        else
                LG( "Hecheng_BS","probability check determine item type is not a gem" )
                return 0
        end
end

 

Share this post


Link to post
Share on other sites

Looking at the "Composition Catalyst" or "Red Combining Fruit" that ordinarily increase combining success, their item effect calls the function "ItemUse_HSDZG()" in "ItemEffect.lua".

 

function ItemUse_HSDZG ( role , Item )
	local statelv = 2
	local statetime = 60
	local Cha_Boat = 0
	Cha_Boat = GetCtrlBoat ( role )
--	SystemNotice( role , Cha_Boat )
	if Cha_Boat ==  nil then
		AddState( role , role , STATE_HCGLJB , statelv , statetime )
	else
		SystemNotice( role , "Cannot use while sailing" )
		UseItemFailed ( role )
		return
	end
end

 

This function adds the state "STATE_HCGLJB" with a set state level ("statelv") - by default the state level is 2. The function to combine two gems is "begin_unite_item()" in "forge.lua". In this function, we call back on that same state to check the state level when calculating the success rate.

 

function begin_unite_item (...)
	-- ... --
  	-- snip --
	
	local Sklv = 1
	local StateLv = GetChaStateLv ( role , STATE_HCGLJB )
	
	Sklv = Sklv + StateLv


	local b = Check_CG_HechengBS ( Item2_Lv , ItemType2 , Sklv )
	if b == 0 then
		i = RemoveChaItem ( role , ItemID2 , 1 , 2 , BagItem2 , 2 , 1 , 0)		--移除宝石	
		if i == 0 then
			LG( "Hecheng_BS" , "Delete item failed" )
		end
		local cha_name = GetChaDefaultName ( role )
		LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining failed" )
		SystemNotice( role , "Very sorry, combining has failed. Gem has vanished…")

		return 2	
	end
	local cha_name = GetChaDefaultName ( role )
	LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining successful" )
	return 1
end

 

Inside "begin_unite_item()" the function you have posted, "Check_CG_HechengBS()", is called to determine whether or not combining was successful. To calculate this, we pass in "Sklv" which is calculated as "1 + STATE_HCGLJB state level", so by default the value passed in is 3.

 

Originally "Check_CG_HechengBS()" used a function of "Sklv" to determine whether or not combining was successful. In the function as you have posted it, "Sklv" goes completely unused. I will assume you are intentionally not using the original function, and will not refer to specific modifications of the original function.

 

If you want to make combining 100% successful when the user has used a "Composition Catalyst" or "Red Combining Fruit", there are two places you could do it. Either

a) Inside "begin_unite_item()", instead of calculating "b" you could first check the "Sklv", and if the user has used the appropriate fruit you could simply assume success already. This way we only use the function that includes randomness when no catalyst/fruit has been used. e.g.

 

function begin_unite_item (...)
    -- ... --
    -- snip --
	
    local Sklv = 1
    local StateLv = GetChaStateLv ( role , STATE_HCGLJB )
	
    Sklv = Sklv + StateLv

	
    if Sklv == 1 then
        local b = Check_CG_HechengBS ( Item2_Lv , ItemType2 , Sklv )
        if b == 0 then
          i = RemoveChaItem ( role , ItemID2 , 1 , 2 , BagItem2 , 2 , 1 , 0)		--移除宝石	
          if i == 0 then
              LG( "Hecheng_BS" , "Delete item failed" )
          end
          local cha_name = GetChaDefaultName ( role )
          LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining failed" )
          SystemNotice( role , "Very sorry, combining has failed. Gem has vanished…")

          return 2	
        end
    end
    local cha_name = GetChaDefaultName ( role )
    LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining successful" )
    return 1
end

 

or

b) Inside "Check_CG_HechengBS()" you change the function to actually make the calculation of "a" some function of "Sklv" again. That modification / function could be very simple. e.g. working from the function as it is in your post (and slightly refactoring it for the sake of simplicity)

 

function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv )
	     
        Item_Lv = Item_Lv - 1
        if Item_Type == 49 or Item_Type == 50 then
                local a
                local b

                if Sklv == 3 then
                        a = 1
      
                elseif Item_Lv < 3 then
                        a = 1

                elseif Item_Lv == 3 then
                        a = 0.9

                elseif Item_Lv == 4 then
                        a = 0.8

                elseif Item_Lv == 5 then
                        a = 0.7

                elseif Item_Lv == 6 then
                        a = 0.6

                elseif Item_Lv == 7 then
                        a = 0.5

                elseif Item_Lv == 8 then
                        a = 0.4

                elseif Item_Lv == 9 then
                        a = 0.3
                end
                
    			b = Percentage_Random ( a )
                return b
        else
                LG( "Hecheng_BS","probability check determine item type is not a gem" )
                return 0
        end
end

 

Whether or not that specific modification works depends whether of the rest of the functions involved have been modified on your server too, so try to follow the information and don't just copy and paste my solution.

 

If you want to create a completely new fruit to make combining 100% successful, you will need to make the item call a different function than "ItemUse_HSDZG()" which in turn changes the state level of "STATE_HCGLJB" to a different state level, and then again modify how that state level gets used in either "begin_unite_item()" or "Check_CG_HechengBS()". As alluded to above though, your current iteration of "Check_CG_HechengBS()" means that neither the "Composition Catalyst" nor the "Red Combining Fruit" hold any effect on the combining success rate, so creating an entirely new catalyst / fruit may be unnecessary.

 

Let me know if this explanation makes sense or if you have any further questions.

  • Thanks 1

Share this post


Link to post
Share on other sites

@Jonathan, thanks for the lengthy explanation. The Check_CG_HechengBS() that I have here is the default script i get  from the Lucky Server Files and I did not know that they disregards totally the usage of catalyst or even the fruit. Lets says I able to find the original Check_CG_HechengBS() script, I could then implement the said fruit with manipulation of STATE_HCGLJB right ? Am I able to understand exactly on your explanation or not ? Thanks a lot.

Share this post


Link to post
Share on other sites

No problem at all @kyleflow!

 

Your understanding is correct. The default "Check_CG_HechengBS()" per the 1.38 files posted by V3ct0r at

 

 

is

 

function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv )
	local a = 0
	local b = 0
	Item_Lv = Item_Lv - 1
	if Item_Type == 49 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.10 + Sklv * 0.10 ) ) )
		b = Percentage_Random ( a )
		if Item_Lv < 3 then
			b = 1
		end
		return b
	elseif Item_Type == 50 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.05 + Sklv * 0.15 ) ) )
		b = Percentage_Random ( a )
		return b
	else
		LG( "Hecheng_BS","probability check determine item type is not a gem" )
		return 0
	end
end

 

So for this we would just need to work backwards. When "ItemType" is 49, for 100% success rate the calculation "1 - Item_Lv * 0.10 + Sklv * 0.10" needs to evaluate to 1, and when the "ItemType" is 50, for 100% success rate the calculation "1 - Item_Lv * 0.05 + Sklv * 0.15" needs to evaluate to 1. In both scenarios you just need to - as you correctly said - manipulate "STATE_HCGLJB" which will in turn manipulate "Sklv" in each of these calculations.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, Jonathan said:

No problem at all @kyleflow!

 

Your understanding is correct. The default "Check_CG_HechengBS()" per the 1.38 files posted by V3ct0r at

 

 

is

 


function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv )
	local a = 0
	local b = 0
	Item_Lv = Item_Lv - 1
	if Item_Type == 49 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.10 + Sklv * 0.10 ) ) )
		b = Percentage_Random ( a )
		if Item_Lv < 3 then
			b = 1
		end
		return b
	elseif Item_Type == 50 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.05 + Sklv * 0.15 ) ) )
		b = Percentage_Random ( a )
		return b
	else
		LG( "Hecheng_BS","probability check determine item type is not a gem" )
		return 0
	end
end

 

So for this we would just need to work backwards. When "ItemType" is 49, for 100% success rate the calculation "1 - Item_Lv * 0.10 + Sklv * 0.10" needs to evaluate to 1, and when the "ItemType" is 50, for 100% success rate the calculation "1 - Item_Lv * 0.05 + Sklv * 0.15" needs to evaluate to 1. In both scenarios you just need to - as you correctly said - manipulate "STATE_HCGLJB" which will in turn manipulate "Sklv" in each of these calculations.

Work like a charm thanks to you @Jonathan

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...