[EO] Is there any way to make stats decrease?

So I added a new stat. It’s a badge stat. I want it to work like the badge stat from the Paper Mario series. But there’s no way to make an Item decrease a user’s stat. So you cant lose any badge points when equiping a badge. 😕

Basically I want to know if it’s possible to make the “scrlStatBonus” in Items Editor to decrease a stat as well as increase it.

I’ve tried making the scrollbar min -255 but that just gives me an overflow error.

I’m stumped. Thanks! I will credit you in UMWO if you find the solution! :)

An overflow error in VB6 is when data is outside of the data type parameters. For example, bytes store (0 to 255), so any negatives or numbers higher than 256 will give you an overflow.

Bytes in VB6 are what we called an unsigned data type - a fancy way of saying always 0 or higher. If you’d like negatives, change to a signed type (I recommend long). In modTypes both client and server-side:


    Add_Stat(1 To Stats.Stat_Count - 1) As Byte

to


    Add_Stat(1 To Stats.Stat_Count - 1) As Long

Then, do as you’ve done with the scrl bars. I did a quick check and couldn’t find any other data type needing changed for this feature. If you get another overflow errors, search “stat” and look for relevant bytes and change them to long. Note that player stats are also stored as bytes, which you may or may not want to change.

oks… this will give me a headache i bet

there is a tut for a stat reset item, or min stat item how ever you wanna see it.

www.touchofdeathforums.com/community/index.php?/topic/110003-eo-stat-reset-item/

idk much bout it, eztel did it and ik hes pretty good on programming so try looking at it. best thing and if you want it tobe different try applying the idea to what ever you wanted.

Thanks Zeno!!

I dont seem to get the overflow error anymore after deleting all Items and accounts.

And it seems to decrease stats now! :D

Though I have one question, how would I prevent players from getting their stats below 1?

Like if the equip make the stat below 1 then don’t equip.

actual to advoid that from happening i make sure that the - stat equip is in a higher lvl where it wont need to worry. thats my input for that.

That Or I could just make it so the player have to have above a certain amount of Badgepoints.

Example, This badge takes away 5 BP and lowers 1 DEF and raises 2 Attack.

I would prob have to make sure the stat requirements are like: Make sure stat above 5 BP and 1 DEF.

Lol, well I think Flame fixed that prob for the most part.

-EDIT-

I forgot requirements dont make it a specific number… Only if you have above 8 for max stat. I’m dumb…

So yeah, it didnt work.

Though I have one question, how would I prevent players from getting their stats below 1?

Like if the equip make the stat below 1 then don’t equip.

Much easier than adjusting your editing patterns.

In all relevant use item cases in modPlayer subUseItem:

For I = 1 to Stats.StatsCount

If Item(itemnum).Add_Stat(I) + GetPlayerStat(Index,I) < 1 Then

Call PlayerMsg(index, "This item would drain all your stats", Red)

End if

Exit Sub

Next

This will prevent any item being used that will reduce the player’s stat below 1 (in other words, to 0 or into negatives. Change to <0 to allow 0).

I forgot something, which happens to be another place you could do that. Server-side in modPlayer function GetPlayerStat you’ll need to remove the >0 requirement on AddStats. You could equally change this bit such that the game would allow the item to be equipped but just set your stat to 0 were it to become negative. (remove that if/then and add in the one line if x<0 then x=0 at the end)

Wow, Thank you so much Zeno! I would put your name in the credits, but it’s already in there! lol

Strange. For some reason the player message isnt beng sent. I even copied a message from the requirements code, Still no message. o.e

well for my stats will be in 2 types, xD so ik 100 % i wouldnt need to worry, 😜

Well I’ve tested and I find that Zeno’s code:


For I = 1 to Stats.StatsCount

If Item(itemnum).Add_Stat(I) + GetPlayerStat(Index,I) < 1 Then

Call PlayerMsg(index, "This item would drain all your stats", Red)

End if

Exit Sub

Next

Doesn’t work right. The code prevents equip If the ITEM reduces the stat at all. Instead of making it not equip only if the STAT number goes below 0.

If anyone knows why please speak up. :c

That’s because I messed up. The Exit Sub should be before the End If. Sorry about that. Do you see why it was always just doing nothing? The actual equipping comes much later in the sub.

That restriction compares the raw stat rather than total stats including equipment. You could use GetPlayerStat instead of Player(index).Stat, but without some more coding it would be possible for players to shuffle equipment around to get stats below 0.

Regardless of which you choose to use, just in case, let any negative stats become 0:


Public Function GetPlayerStat(ByVal index As Long, ByVal Stat As Stats) As Long

    Dim x As Long, i As Long

    If index > MAX_PLAYERS Then Exit Function

    x = Player(index).Stat(Stat)

    For i = 1 To Equipment.Equipment_Count - 1

	    If Player(index).Equipment(i) > 0 Then

		    If Item(Player(index).Equipment(i)).Add_Stat(Stat) + Player(index).Stat(i) > 0 Then

			    x = x + Item(Player(index).Equipment(i)).Add_Stat(Stat)

		    Else: x = 0

		    End If

	    End If

    Next

    GetPlayerStat = x

End Function

Well, now it just makes the badge stat go to 1 point no matter how many badgepoints my equip takes away. :S

Well, now it just makes the badge stat go to 1 point no matter how many badgepoints my equip takes away. :S

Does this work with other stats? Your issue might be exclusive to badgepoints.

Well other stats it doesnt auto make it 1. But it still doesnt keep the item from not being able to be equiped if it makes a stat go below 1. wtff

The GetPlayerStats edit wouldn’t - it only prevents stats from going negative and causing an overflow.

Are badgepoints going to 1 because you’re subtracting more than you have? I dunno - maybe you only have few badgepoints.

Here’s a more efficient alternative to what I first posted. Wherever you see a stat requirement, replace it with this. I’m assuming you’ll never have 0 in a stat, and if you did you would never be able to equip anything with this code (a simple one-line fix to check, but what’s the point if it’s never needed). If the Add_Stat array is type long this should work.


			    ' stat requirements

			    For i = 1 To Stats.Stat_Count - 1

				    If GetPlayerRawStat(index, i) < Item(itemnum).Stat_Req(i) Then

					    PlayerMsg index, "You do not meet the stat requirements to equip this item.", BrightRed

					    Exit Sub

				    End If

				    If GetPlayerRawStat(index, i) + Item(itemnum).Add_Stat(i) < 1 Then

					    PlayerMsg index, "That would drain all your stats!", BrightRed

					    Exit Sub

				    End If

			    Next

If that doesn’t work, run a breakpoint to read the values of Item(itemnum).Add_Stat(i) and GetPlayerRawStat(index,i).

Hmm. well I have 16 points in the badge stat. But for some reason if any stat loses anymore then 1 point from an equip, it makes the stat go to 1. Strange.

Log in to reply