Jump to content
Faller

Fixed forge.lua Request (Partly Solved)

Recommended Posts

Hey there!

I'm looking for a fixed forge.lua with the possibility of setting percentages for each gem level on forge/combine and if possible, 100% fruit add-on.

I'm really having troubles with mine, I properely put the needed parts to put custom percetange, but it gives random percentages anyway.

 

p.s.: I made this modifications to it for custom rates, but it did not work!

 

Spoiler

 

-----------------------------------
Open forge.lua file and search for:
-----------------------------------

        local Check_A = math.max ( 0.02 , math.min ( 1 , ( 1 - Baoshi_NeedLv * 0.1 + Sklv * 0.15 - 0.3 ) ) )
        local CheckFaild = Percentage_Random ( Check_A )
        
        if Baoshi_NeedLv < 4 then
                CheckFaild = 1
        end

        if CheckFaild == 1 then
                Check_Jinglian_Item = Jinglian_Item ( Item_Jinglian , Item_Stone1 , Item_Stone2 )
        else
                local cha_name = GetChaDefaultName ( role )
                local Item_Jinglian_name = GetItemName ( ItemID_Jinglian )
                LG( "JingLian_ShiBai" , "Player ["..cha_name.."] Forging of equipment failed. Equipment is not damaged - "..Item_Jinglian_name )
                SystemNotice ( role , "Sorry, forging has failed. Luckily equipment is not damage" )
        end

----------------------------------
delete this part and replace with:
----------------------------------

        local Check_A
        local CheckFaild
        
        if Baoshi_NeedLv < 4 then               
                Check_A = 1
                CheckFaild = Percentage_Random ( Check_A )

        elseif Baoshi_NeedLv == 4 then
                Check_A = 0.9
                CheckFaild = Percentage_Random ( Check_A )
                
        elseif Baoshi_NeedLv == 5 then
                Check_A = 0.7
                CheckFaild = Percentage_Random ( Check_A )
                                
        elseif Baoshi_NeedLv == 6 then
                Check_A = 0.6
                CheckFaild = Percentage_Random ( Check_A )              
                
        elseif Baoshi_NeedLv == 7 then
                Check_A = 0.5
                CheckFaild = Percentage_Random ( Check_A )      
                
        elseif Baoshi_NeedLv == 8 then
                Check_A = 0.4
                CheckFaild = Percentage_Random ( Check_A )
                
        elseif Baoshi_NeedLv == 9 then
                Check_A = 0.3
                CheckFaild = Percentage_Random ( Check_A )
        end

        if CheckFaild == 1 then
                Check_Jinglian_Item = Jinglian_Item ( Item_Jinglian , Item_Stone1 , Item_Stone2 )
        else
                local cha_name = GetChaDefaultName ( role )
                local Item_Jinglian_name = GetItemName ( ItemID_Jinglian )
                LG( "JingLian_ShiBai" , "Player ["..cha_name.."] Forging of equipment failed. Equipment is not damaged - "..Item_Jinglian_name )
                SystemNotice ( role , "Damn sorry, forging has failed! Luckily equipment is not damaged..." )
        end

----------------

In this code rates can be set in easy way: the Check_A after every Baoshi_NeedLv is the % of success ( for example for level 9 gem you got 0.3 = 30% ).

That's pretty nice and easy to edit. =)

For combining is almost the same, search for:

----------------

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

-----------------
and replace with:
-----------------

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

 

 

Secondary questions:

 

* Any tips on chaning the equipments one gem can be forged?

Example: If I want to allow players to forge Gem of Colossus in weapons, where exactly should I edit?

 

* Excessive use of cha_timer causes critical perfomance issues?

 

* Somehow someone created a blank row in my database, this caused serious problems, I was lucky to quick fix it, else there would be big damages. Is this any kind of hacking or just uncommon bug? This made some of my Admin Panel functions like 'Name Change' unoperational, 

 

Thanks for your attention guys!

 

Faller.

 

Edited by Faller

Share this post


Link to post
Share on other sites

I don't know what exactly or can't understand with all those scripts, hahah.

 

Anyways, I have my own script for combining gems with a formula to determine the percentage needed.

function can_unite_item(...)
	if arg.n ~= 12 then
		return 0
	end
	if can_unite_item_main(arg) == 1 then
		return 1
	else
		return 0
	end
end
function can_unite_item_main(Table)
	local Player = 0
	local ItemBag = {}
	local ItemCount = {}
	local ItemBagCount = {}
	local Get_Count = 4
	local ItemReadCount = 0
	local ItemReadNow = 1
	local ItemReadNext = 0
	local ItemBag_Now = 0
	local ItemCount_Now = 0
	local ItemBagCount_Num = 0
	Player, ItemBag, ItemCount, ItemBagCount, ItemBag_Now, ItemCount_Now, ItemBagCount_Num = Read_Table(Table)
	local i = 0
	for i = 0, 2, 1 do
		if ItemBagCount[i] ~= 1 or ItemCount[i] ~= 1 then
			SystemNotice(Player, "Item target unit and item unit illegal.")
			return 0
		end
	end
	local Scroll = GetChaItem(Player, 2, ItemBag[0])
	local LeftGem = GetChaItem(Player, 2, ItemBag[1])
	local RightGem = GetChaItem(Player, 2, ItemBag[2]) 
	if GetItemType(Scroll) ~= 47 then
		SystemNotice(Player, "This is not a combining scroll.")
		return 0
	end
	if GetItemType(LeftGem) ~= 49 or GetItemType(RightGem) ~= 49 then
		if GetItemType(LeftGem) ~= 50 or GetItemType(RightGem) ~= 50 then
			SystemNotice(Player, "This is not a Gem.")
			return 0
		end
	end
	if Get_StoneLv(LeftGem) ~= Get_StoneLv(RightGem) or GetItemID(LeftGem) ~= GetItemID(RightGem) then
		SystemNotice(Player, "Both gems must be the same level and type in other to combine them.")
		return 0
	end
	for i = 0, table.getn(GemVar), 1 do
		if GetItemID(LeftGem) == GemVar[i].ID then
			if Get_StoneLv(LeftGem) >= GemVar[i].Level or Get_StoneLv(RightGem) >= GemVar[i].Level then
				SystemNotice(Player, "The maximum level for ["..GetItemName(GemVar[i].ID).."] is Level "..GemVar[i].Level..".")
				return 0
			end
		end
	end
	if getunite_money_main(Table) > GetChaAttr(Player, ATTR_GD) then
		SystemNotice(Player, "Insufficient gold, unable to combine gems.")
		return 0
	end
	return 1
end
function begin_unite_item(...)
	if can_unite_item_main(arg) == 0 then
		return 0
	end
	local Player = 0
	local ItemBag = {}
	local ItemCount = {}
	local ItemBagCount = {}
	local Get_Count = 4
	local ItemReadCount = 0
	local ItemReadNow = 1
	local ItemReadNext = 0
	local ItemBag_Now = 0
	local ItemCount_Now = 0
	local ItemBagCount_Num = 0
	Player, ItemBag, ItemCount, ItemBagCount, ItemBag_Now, ItemCount_Now, ItemBagCount_Num = Read_Table(arg)
	local BagItem1 = ItemBag[0]
	local BagItem2 = ItemBag[1]
	local BagItem3 = ItemBag[2]
	local Scroll = GetChaItem(Player, 2, BagItem1)
	local LeftGem = GetChaItem(Player, 2, BagItem2)
	local RightGem = GetChaItem(Player, 2, BagItem3)
	local LeftGemID = GetItemID(LeftGem)
	local LeftGemLevel = Get_StoneLv(LeftGem)
	RemoveChaItem(Player, GetItemID(Scroll), 1, 2, BagItem1, 2, 1, 0)
	RemoveChaItem(Player, GetItemID(RightGem), 1, 2, BagItem3, 2, 1, 0)
	Set_StoneLv(LeftGem,(LeftGemLevel + 1))
	SetCharaAttr((GetChaAttr(Player, ATTR_GD) - getunite_money_main(arg)), Player, ATTR_GD)
	ALLExAttrSet(Player)
	local Random = math.random(0, 100)
	local Percentage = math.floor((1 -((LeftGemLevel - 1)/ 9)) * 100)
	for i = 0, GetKbCap(Player), 1 do
		if GetItemID(GetChaItem(Player, 2, i)) == 3075 then
			RemoveChaItem(Player, 3075, 1, 2, i, 2, 1, 0)
			Random = Random - 10
			if Random < 0 then
				Random = 0
			end
			break
		end
	end
	if Random > Percentage then
		RemoveChaItem(Player, LeftGemID, 1, 2, BagItem2, 2, 1, 0)
		SystemNotice(Player, "Sorry, the combination has failed and the gems has vanished.")
		return 2
	elseif Random <= Percentage then
		if HasMission(Player, 1989) == 1 then
			Checkunite[GetChaDefaultName(Player)] = 1
		end
		return 1
	end
end
function get_item_unite_money(...)
	local Money = getunite_money_main(arg)
	return 0
end
function getunite_money_main(Table)
	return 5000
end

It uses this formula to determine the success rate of combining a gem.

	local Percentage = math.floor((1 -((LeftGemLevel - 1)/ 9)) * 100)

So the rates for making a level X gem would be:

Level 2 = 100%
Level 3 = 88%
Level 4 = 77%
Level 5 = 66%
Level 6 = 55%
Level 7 = 44%
Level 8 = 33%
Level 9 = 22%

Of course my script is custom! So to use it, you would need to modify some parts as well. Since I have all my gems placed on this:

GemVar = {}

The good (maybe bad) part about my scripts is that you don't need the combining effect on character in order to increase success rate, as long as the character has the item in his inventory, it will increase the combining rate and will remove the item. Hope that helps a bit.

  • Like 1

Share this post


Link to post
Share on other sites

@Angelix Hey Angelix! Thanks so much for sharing your custom script with us :) That's so kind of you!

I'll give it a try tomorrow, when I wake up.

If anyone else have other scripts to share, please do it!

Also, it don't need to be the whole script, can be just the forging and combining parts.

Really needing this, my players are expecting big troubles on forging, and must give everyone the best experience possible.

 

Thanks again Angelix! 

 

Faller.

 

Share this post


Link to post
Share on other sites
8 hours ago, Faller said:

      local Check_A
        local CheckFaild
        

 

Have you tried to make it

 

local Check_A = 0

local CheckFaild = 0

 

Didn't test that script but it looks like the local variable wasn't defined

  • Like 1

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
3 hours ago, Shako said:

 

Have you tried to make it

 

local Check_A = 0

local CheckFaild = 0

 

Didn't test that script but it looks like the local variable wasn't defined

 

Hey Shako, thanks for your reply! I'll give it a try :)

Share this post


Link to post
Share on other sites

Sorry for the double post!

@Shako Thanks so much! This seems to have solved my problem! :)

Now I'll try to add 100% fruit into this script if anyone have one to share, I'll apreciate so much!

 

Faller.

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.


×
×
  • Create New...