Jump to content
kyleflow

Harden Skillls Affected by Spirit Issue

Recommended Posts

Okay with assistance from @mkhzaleh. I'm able to make the buff worked with Spirit stats.

Few bugs that occur to me when using this code.

 

1. The buff retain the 1st buff without poss even after rebuff with poss and vice versa.

2. Sometimes the buff did not calculated when teleporting into other region. It seem like the value changes by location.

 E.g If i buff a char in Argent, the value when entering Shaitan is original value, same goes to other location. But, if I then go to Shaitan and buff the same char, the value sustain in Argent and Shaitan and not other location. AND if I swap into poss and buff the same char, the value change into the last buff recorded in the previous location and when I get back to the location of the buff with poss, the value calculated to the new value. Seem like there is a memory issues here which I don't know how to resolved.

 

Here is the code.

 

function Skill_Shpf_End ( ATKER , DEFER , sklv ) 
	c = { STATE_JLFT1 , STATE_JLFT2 , STATE_JLFT3 , STATE_JLFT4, STATE_JLFT5, STATE_JLFT6 , STATE_JLFT7, STATE_JLFT8 }
	local semak_state = 0
	if semak_state == c[1] or semak_state == c[2] or semak_state == c[3] or semak_state == c[4] or semak_state == c[5] or semak_state == c[6] or semak_state == c[7] or semak_state == c[8] then
		local sta_buff = Sta(ATKER)--try tambah
		a = {}
		table.insert(a,1,sta_buff)
		local statelv = sklv
		local statetime = 600
		AddState ( ATKER, DEFER, STATE_SHPF, statelv, statetime )
	
	else
	
		local sta_buff = Sta(ATKER)--try tambah
		a = {}
		table.insert(a,1,sta_buff)
		local statelv = sklv
		local statetime = 600
		AddState ( ATKER, DEFER, STATE_SHPF, statelv, statetime )
	
	end
	 
	--local sta_buff = Sta(ATKER)--try tambah
	--a = {}
	--table.insert(a,1,sta_buff)
	--local statelv = sklv 
	--local statetime =  600    --ubah jd 10min. khairul ubah, asl 180
	--AddState ( ATKER , DEFER , STATE_SHPF , statelv , statetime ) --asal atker depan
	--LG("skill_Shpf", "function Skill_Def_Shpf : " , "role = " , role , "sklv =  " , sklv , "\n" ) --xterlibat
end 



function State_Shpf_Add ( role , statelv ) 
	--LG("state", "function State_Shpf_Add : " , " role = ", role, "statelv = " , statelv , "\n" ) 
	--local sta_buff = Sta(role)
	
	local def_dif = 10  + a[1] + statelv * 4 -- asal 10 + statelv * 4
	local def = DefSb(role) + def_dif 
	SetCharaAttr( def , role , ATTR_STATEV_DEF )	
	ALLExAttrSet(role)

end 



function State_Shpf_Rem ( role , statelv ) 
--	LG("state", "function State_Shpf_Rem : " ,"statelv = " , statelv , " role = ", role, "\n" ) 
	--local sta_buff = Sta(role)
	
	local def_dif = 10 + a[1] + statelv * 4 
	local def = DefSb(role) - def_dif
	SetCharaAttr( def , role , ATTR_STATEV_DEF )
	ALLExAttrSet(role)
end 

 

Edited by kyleflow
more info

Share this post


Link to post
Share on other sites

as basic start , use readable variables so you can understand your code later on, or anyone trying to read it of ur team or who help you
your bug due multi gameserver, your current variable exist inside gameserver1 but gameserver2 hasn't it, you can use luaall to update it to all gs , but not sure if really worth it
you can workaround alot to get it works first:
1- using luaall
2- change your table to better method ,, you can store player name , as index then filter with cha name or player id  to get correct values  "globalBuff["PlayerName"] etc
"don't forget to clean up your table from time to other /or when buff is over otherwise u get even worst issues
3-worst workaround if won't use luaall u can use .txt file to store them but that even worst as addstates would call it every sec etc , 

Edited by mkhzaleh
  • Thanks 1

Share this post


Link to post
Share on other sites

the syntax that you provide such as luall and globalBuff, I tried to check on how to use it properly but to no avail. not at my level of understanding for now. Need a solid case of an example for me to implemented it myself. Do you mind provide me with an example of it ?

Share this post


Link to post
Share on other sites
53 minutes ago, kyleflow said:

the syntax that you provide such as luall and globalBuff, I tried to check on how to use it properly but to no avail. not at my level of understanding for now. Need a solid case of an example for me to implemented it myself. Do you mind provide me with an example of it ?

i gave random table name, use what ever you want 
luaall u can find it in any co files or released files, , 

function lua_all(role, cmd)
	local packet = GetPacket()
	WriteCmd(packet, CMD_MM_DO_STRING)
	WriteDword(packet, 0)
	WriteString(packet, cmd)
	SendPacket(role, packet)
end

and nonot willing to write function now i just gave some ideas,  u have to update your table to all gs if want use that method 

  • Thanks 1

Share this post


Link to post
Share on other sites

I know you have been helpful @mkhzaleh. Probably hope other can help me more. I just can't understand the way to make it work for now. Or somehow with trials, I might find the correct way. Anyways, hats off to you for the help.

Share this post


Link to post
Share on other sites

Hello @kyleflow,

 

@mkhzaleh says that you need implement interproccess communication mechanism between the instances of your GameServer, or in other words synchronize some global variables. You can achive it using, for example, a file, or with &lua_all GM-command as a lua-function (see implemenation above). 

 

What exactly is your problem?


Share this post


Link to post
Share on other sites
10 hours ago, V3ct0r said:

What exactly is your problem?

I actually don't have knowledge on how to to implement it as a global function or make a separate files.

 

1. Lets says that in a table array, I construct it like this.

 

local buff_table = {}
local buff_atker = {}
--i simplified it on the table.insert here for now. 
buff_table[buff_atker]  = { Buff_targetID = "ChaID" , State = "skill state", Timer = "needed?" }

Lets says when the buff given to a target "Buff_targetID" by "buff_atker" with a certain skill "State". How do I made it check inside other gameserver when it is only a readable table.

 

2. If lets say the buffer buff multiple target, the duration of the buff state itself would not be the same and lets say after the buff duration end, how do I clear individual table data?

 

 

Share this post


Link to post
Share on other sites

@kyleflow Hello, I've written this code it should work pretty well replace this code to yours. Haven't tested it, try it and let me know the results.

 

If player has Harden skill activated, the following will be applied:

1. Player will gain additional defense stat according to gained spr

2. Player will gain x2 defense stat if Fairy Body skill (Poss) is active

3. Once buff wears off all of the additional stats will go back to normal

function Skill_Shpf_End(ATKER, DEFER, sklv)
    local statelv = sklv
    local statetime = 600
    AddState(ATKER, DEFER, STATE_SHPF, statelv, statetime)
end

function State_Shpf_Add(role, statelv)
	-- Spr
	local spr_dif = 0
	
	-- Grants additonal stat for gained Spr
	spr_dif = spr_dif + Sta(role)
	
	-- Check fairy poss if active will grant x2
	for i = 168,174 do
		if(GetChaStateLv(role,i) ~= 0)then
			spr_dif = math.floor(spr_dif * 2)
		end
	end
	
    local def_dif = 10 + spr_dif + (statelv * 4)
    local def = DefSb(role) + def_dif
    SetCharaAttr(def, role, ATTR_STATEV_DEF)
    ALLExAttrSet(role)
end

function State_Shpf_Rem(role, statelv)
	-- Spr
	local spr_dif = 0
	
	-- Grants additonal stat for gained Spr
	spr_dif = spr_dif + Sta(role)
	
	-- Check fairy poss if active will grant x2
	for i = 168,174 do
		if(GetChaStateLv(role,i) ~= 0)then
			spr_dif = math.floor(spr_dif * 2)
		end
	end
	
    local def_dif = 10 + spr_dif + (statelv * 4)
    local def = DefSb(role) - def_dif
    SetCharaAttr(def, role, ATTR_STATEV_DEF)
    ALLExAttrSet(role)
end

 

  • Like 1

Share this post


Link to post
Share on other sites
38 minutes ago, Sultan said:

@kyleflow Hello, I've written this code it should work pretty well replace this code to yours. Haven't tested it, try it and let me know the results.

 

If player has Harden skill activated, the following will be applied:

1. Player will gain additional defense stat according to gained spr

2. Player will gain x2 defense stat if Fairy Body skill (Poss) is active

3. Once buff wears off all of the additional stats will go back to normal

 

Tested out on all the possible ways and here is the result.

 

1. The target player get double the buff based on your script calculation if in poss before being buff by the buffer. The SPR amount that calculated is not the buffer but instead the player itself.

 

2. The cross server buff effect registered but the end result is not as expected. I prefer the buffer SPR affect the calculation of the def and benefit of the buff given to the targeted player. But your poss script is much much simple than what I tried to do and that something new.

 

Share this post


Link to post
Share on other sites

@kyleflow

Maybe it's not optimal, but try this, it should work:

 

HardenTable = {}

function Skill_Shpf_End ( ATKER , DEFER , sklv )
	local statelv = sklv 
	local statetime =  180   
	
	local deferId = GetPlayerID(GetChaPlayer(DEFER))
	local bufferSpr = Sta(ATKER)
	HardenTable[deferId] = bufferSpr

	AddState ( ATKER , DEFER , STATE_SHPF , statelv , statetime )
end
function State_Shpf_Add ( role , statelv )
	local buffer_spr = 0

	local deferId = GetPlayerID(GetChaPlayer(role))
	if HardenTable[deferId] ~= nil then
		buffer_spr = HardenTable[deferId]
	end

	local def_dif = 10 + statelv * 4 + buffer_spr
	local def = DefSb(role) + def_dif 
	SetCharaAttr( def , role , ATTR_STATEV_DEF )	
	ALLExAttrSet(role)

end
function State_Shpf_Rem ( role , statelv )
	local buffer_spr = 0
	local deferId = GetPlayerID(GetChaPlayer(role))
	if HardenTable[deferId] ~= nil then
		buffer_spr = HardenTable[deferId]
		HardenTable[deferId] = nil
	end
	
	local def_dif = 10 + statelv * 4 + buffer_spr
	local def = DefSb(role) - def_dif
	SetCharaAttr( def , role , ATTR_STATEV_DEF )
	ALLExAttrSet(role)
end

 

  • Like 1

Share this post


Link to post
Share on other sites
51 minutes ago, Wilhelm said:

@kyleflow

Maybe it's not optimal, but try this, it should work:

I did get this result before with different code but same issues where when I change location into different map server ( since its not advisable to put 3 big map in 1 server ), the calculation remove the SPR effect leaving the original buff calculation. Clean code btw bro. Better version than what I do.

 

Share this post


Link to post
Share on other sites

i have mentioned it above 

your only way to use lua_all or save buffer spr value in .txt and load it back on remove states 

all codes about talk about player role, not buffer role so the spr is different
as i mentioned it before too, addstate/removestate have info only of current player that's why i said u have to save it inside skill first then use it later 

--the code above as example 
	local sprvalue = 5 --this example 
	local cmd = string.format("HardenTable[%d]=%d",deferId,sprvalue)
	lua_all(cmd,role)

this will update table cross all gameservers for u 

Edited by mkhzaleh

Share this post


Link to post
Share on other sites
11 hours ago, mkhzaleh said:

i have mentioned it above 

your only way to use lua_all or save buffer spr value in .txt and load it back on remove states 

all codes about talk about player role, not buffer role so the spr is different
as i mentioned it before too, addstate/removestate have info only of current player that's why i said u have to save it inside skill first then use it later 


--the code above as example 
	local sprvalue = 5 --this example 
	local cmd = string.format("HardenTable[%d]=%d",deferId,sprvalue)
	lua_all(cmd,role)

this will update table cross all gameservers for u 

I took your advice and changes a bit the code suggested above and here the code. First I put the code of lua_all load in the same files of serialize.lua so that it load before other files load. Here is the code that I changes from above but the results say lua_cmd error from the game notice.

 

HardenTable = {}

function Skill_Shpf_End ( ATKER , DEFER , sklv )
	local statelv = sklv 
	local statetime =  600   
	
	local deferId = GetPlayerID(GetChaPlayer(DEFER))
	local bufferSpr = Sta(ATKER) 
	local cmd = string.format("HardenTable[%d]=%d",deferId,bufferSpr)
	lua_all(cmd,role)

	AddState ( ATKER , DEFER , STATE_SHPF , statelv , statetime )
end
function State_Shpf_Add ( role , statelv )
	local buffer_spr = 0

	local deferId = GetPlayerID(GetChaPlayer(role))
	if HardenTable[deferId] ~= nil then
	buffer_spr = HardenTable[deferId][bufferSpr]
	end

	local def_dif = 10 + statelv * 4 + buffer_spr
	local def = DefSb(role) + def_dif 
	SetCharaAttr( def , role , ATTR_STATEV_DEF )	
	ALLExAttrSet(role)

end
function State_Shpf_Rem ( role , statelv )
	local buffer_spr = 0
	local deferId = GetPlayerID(GetChaPlayer(role))
	if HardenTable[deferId] ~= nil then
	buffer_spr = HardenTable[deferId][bufferSpr]
	HardenTable[deferId] = nil
	end
	
	local def_dif = 10 + statelv * 4 + buffer_spr
	local def = DefSb(role) - def_dif
	SetCharaAttr( def , role , ATTR_STATEV_DEF )
	ALLExAttrSet(role)
end

 

Share this post


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

define the CMD_MM_DO_STRING = 4015 -- lua_all
and try

function lua_all(role, cmd)
	local packet = GetPacket()
	local CMD_MM_DO_STRING = 4015
	WriteCmd(packet, CMD_MM_DO_STRING)
	WriteDword(packet, 0)
	WriteString(packet, cmd)
	SendPacket(role, packet)
end

Still error

Share this post


Link to post
Share on other sites

As a side note, when using global variables, try checking for consistency. If you do not do this, every time you use "&updateall" it will refresh the variable and delete everything you have stored in it, which might also cause trouble when going through all this testing you're doing.

 

HardenTable = HardenTable or {}

 

Share this post


Link to post
Share on other sites
On 2/9/2024 at 1:10 PM, Angelix said:

As a side note, when using global variables, try checking for consistency. If you do not do this, every time you use "&updateall" it will refresh the variable and delete everything you have stored in it, which might also cause trouble when going through all this testing you're doing.

 


HardenTable = HardenTable or {}

 

Based on the code example made by other people (simpler form),the declaration for your code should be a header only or inside the function of SHPF? &updateall code, I dont have it.The code for lua_all shared here is not working as expected. Could you assist more on this ?

Share this post


Link to post
Share on other sites
On 2/11/2024 at 9:55 AM, kyleflow said:

Based on the code example made by other people (simpler form),the declaration for your code should be a header only or inside the function of SHPF? &updateall code, I dont have it.The code for lua_all shared here is not working as expected. Could you assist more on this ?

The tip I shared has nothing to do with the functions shared. It's just a tip.

Also, yes, yes you do have the "&updateall". It's integrated on all GameServer by default, maybe renamed, but it's in there. This is basic knowledge, I'm wondering why you're saying you don't have it...

As for your code, it's already stated you need knowledge on persistency between GameServers. Other people have stated the ways this can be done, but you still need knowledge on how it works. If you haven't been able to get it to work, you're better off learning about those methods instead of trying to brute-force a function onto your files that you have no understanding of how it works because you won't be able to fix it if it breaks something on your files. When you learn how to work with either method mention, then come back and try to re-write your function to work.

  • Confused 1

Share this post


Link to post
Share on other sites
On 2/14/2024 at 1:23 PM, Angelix said:

The tip I shared has nothing to do with the functions shared. It's just a tip.

Also, yes, yes you do have the "&updateall". It's integrated on all GameServer by default, maybe renamed, but it's in there. This is basic knowledge, I'm wondering why you're saying you don't have it...

As for your code, it's already stated you need knowledge on persistency between GameServers. Other people have stated the ways this can be done, but you still need knowledge on how it works. If you haven't been able to get it to work, you're better off learning about those methods instead of trying to brute-force a function onto your files that you have no understanding of how it works because you won't be able to fix it if it breaks something on your files. When you learn how to work with either method mention, then come back and try to re-write your function to work.

I'm saying I dont know about it since I never come across any code related to the game that I need to use it. Does it seem appropriate that I dont know of it existance ? I check through the code but unable to find any with Lua that function or simply I dont know how to find it. Tried my best to understand but unable to. Also I'm not actually gaining anything from the code if its working, simply something that should be implement since as the game development tweak mobs and item sets, the role of a support healer lose it purpose. Hope anyone who knows, please do contribute.

Share this post


Link to post
Share on other sites

Since I made the code and just don't to sit on it since it has no use for me, I'll share it.

 

The following script is a different method of approaching the desired result you want.

 

    function Skill_Xlzh_End(ATKER, DEFER, SkillLevel)
        if GetCtrlBoat(DEFER) ~= nil then
            SkillUnable(ATKER)
            return
        end
        local Time = 180 + SkillLevel * 20
        if SkillLevel == 10 then
            SkillLevel = SkillLevel + math.floor(Sta(ATKER) / 20)
            SkillLevel = math.min(SkillLevel, 20)
        end
        AddState(ATKER, DEFER, STATE_XLZH, SkillLevel, Time)
    end
    function State_Xlzh_Add(Player, StateLevel)
        local MnATK_DIF = 0.1 + 0.01 * StateLevel
        local MxATK_DIF = 0.1 + 0.01 * StateLevel
        if StateLevel >= 10 then
            StateLevel = StateLevel - 10
            MnATK_DIF = 0.1 + (0.01 * 10) + (StateLevel * 0.001)
            MxATK_DIF = 0.1 + (0.01 * 10) + (StateLevel * 0.001)
        end
        local MnATK = math.floor((MnatkSa(Player) + MnATK_DIF) * ATTR_RADIX)
        local MxATK = math.floor((MxatkSa(Player) + MxATK_DIF) * ATTR_RADIX)
        SetCharaAttr(MnATK, Player, ATTR_STATEC_MNATK)
        SetCharaAttr(MxATK, Player, ATTR_STATEC_MXATK)
        ALLExAttrSet(Player)
    end
    function State_Xlzh_Rem(Player, StateLevel)
        local MnATK_DIF = 0.1 + 0.01 * StateLevel
        local MxATK_DIF = 0.1 + 0.01 * StateLevel
        if StateLevel >= 10 then
            StateLevel = StateLevel - 10
            MnATK_DIF = 0.1 + (0.01 * 10) + (StateLevel * 0.001)
            MxATK_DIF = 0.1 + (0.01 * 10) + (StateLevel * 0.001)
        end
        local MnATK = math.floor((MnatkSa(Player) - MnATK_DIF) * ATTR_RADIX)
        local MxATK = math.floor((MxatkSa(Player) - MxATK_DIF) * ATTR_RADIX)
        SetCharaAttr(MnATK, Player, ATTR_STATEC_MNATK)
        SetCharaAttr(MxATK, Player, ATTR_STATEC_MXATK)
        ALLExAttrSet(Player)
    end

 

The script above is a quick example of the Herbalist skill "Spiritual Fire" (little modified though(. Normally a character only has access to skill levels from 1 through 10. If I'm not mistaken the default formula is a base 10% increase in attack plus an additional 1% per skill level, this means it gives 11% at level 1 and a maximum of 20% at level 10.

 

The modified script above uses the default process and amplifies it with the character's spirit stat only if the skill casted is level 10. This means that from skill level 1 through 9, the calculation is the same. At skill level 10, every 20 points of spirit will give it an extra level which in turn give the other player an extra 0.1% of attack. This is up to a maximum of 10 extra levels. In the script this would mean that the character using the skill needs to have the skill at level 10 and a minimum of 200 spirit to be able to fully maximize the buff given to another player.

 

This method uses the server's regular functions and has a limit of skill level of 20, anything above will make the skill not work at all. 

 

From this point on, it's up to you to edit the values to the ones you desire and apply it to any other skill wanted.

 

I will not explain further since I think it's straight and simple.

 

Share this post


Link to post
Share on other sites

Thanks a lot bro. Really sorry about the issues. Did not know you would work into it that soon. Hope this help versatile the way we look into the game mechanic in term of buff

Share this post


Link to post
Share on other sites

After the discussion with @Angelix confirming that some of the thing I look into is not going to work. I contempt into this code for now. As an example here the skills for tempest boost.

The value for movement speed will not work if I simply use " a_mux ". So I need to reduce it down more into a_mvspd and the effect into the character just nice. This value will not retain across gameserver but it will detect the highest value of the buffed character to be calculate into the buff effect.

 

 

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...