Redyz
-
Posts
7 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Calendar
Posts posted by Redyz
-
-
I'm not familiar with arrays, but anyways, I tried understanding your code, basicly what it does is it checks for the value after the ".", and if it's over 5 or under 4.. Etc (Rounding, I believe?)
I tried implementing it in my OnAttack.ess File (I forgot to mention I was using ES, Might be different?) but now it just doesn't affect the NPC in any way, It just never seems to do any damage.
Here's my Sub OnAttack, I might be doing something wrong.
```
Sub OnAttack(Index, Damage)
ADamage = Split(Rand(Int((GetPlayerSTR(Index)) - (Int((GetPlayerSTR(Index)) * 0.05))), Int((GetPlayerSTR(Index)) + ((GetPlayerSTR(Index)) * 0.05))), ".")
Round = Left(Damage(1), 1)
If CInt(Round) > 4 Then
Round = 1
ElseIf CInt(Round) < 5 Then
Round = 0
End If
Damage = ADamage + Round
If Damage < 1 Then
Exit Sub
End If
If GetPlayerTarget(Index) > 0 Then
Call DamageNPC(Index, GetPlayerTargetNPC(Index), Damage)
Exit Sub
End If
End Sub
``` -
Hello, this is my first post around here, but I've been lurking for almost a year already, so I'd like to say Hi to everyone. (Well, at least everyone that browses this section)
Anyways, enough of this already, on to the main question.
I want to change the OnAttack, but instead of just adding +5 or -5 like someone [mentioned](http://www.touchofdeathforums.com/smf/index.php?topic=55259.0), I would like it to add +/- 5%.
So I did this algorithm:
Damage = Rand(Int((GetPlayerSTR(Index)) - (Int((GetPlayerSTR(Index)) * 0.05))), Int((GetPlayerSTR(Index)) + ((GetPlayerSTR(Index)) * 0.05)))
(The code might be messy, I'm kinda tired of looking at all the parantheses)
Obviously sometimes the value returned is something like 2.3 or so, and so It doesnt show (E.G Doesn't affect the NPC)
So, for it to show, It needs to be rounded, and that is my question.
Short version: Need to round the value of a variable, what do
Thank you. -
Will do, Just hoping that I will find one Eh.
EDIT: Found one, After 30 mins (Wow :P) Of searching
www.atbhost.net
I don't really know If Im allowed to post offsite links, But Im pretty sure that this one will help some.
Again, Thanks again for the hand. -
Well a big thanks for that response, That's actually more than what I asked, And It looks simple to use too.
I'll try it and see If It works, Thanks for the quick post too.
~Redyz
Edit: Everything works fine, I just go a message from my host that said :
![](http://img14.imageshack.us/img14/1131/errorrkx.png)
(Removed some of the stuff)
Any idea on how to sort this out?
I'm not sure if that means that I can't Enable it or that I must enable it before.. Anyways thanks still I'll try a few things -
-
First, I'd like to say hello there since It's my or one of my first posts, So hello everyone out there.
I'm Kinda noob at PHP (Actually I just started) And I wanted to insert an online/offline status of my game.
Like this one there: http://freemmorpgmaker.com/status/
But I would Like to change the image and such, and since this is, I believe, A script from PHP, I need your help guys.
If anyone could tell me how to use a php script to do what I want to do, I'd greatly appreciate it.
My website is hosted on 000webhost and I'm pretty sure the PHP there is compatible with what I want.
Anyway, Here's the end of my post, And thanks for reading.
:renzo: ~Redyz
Rounding a variable
in Programming Questions
Posted
I believe a random attacking script that uses percentage would be a good addition to SE.
Anyways, you guys can manually replace your Sub OnAttack by this
```
Sub OnAttack(Index, Damage)
Damage = Cint(Rand(Int(GetPlayerSTR(Index) - GetPlayerSTR(Index) * 0.20), Int(GetPlayerSTR(Index) + GetPlayerSTR(Index) * 0.20)))
If Damage < 1 Then
Exit Sub
End If
If GetPlayerTarget(Index) > 0 Then
Call DamagePlayer(Index, GetPlayerTarget(Index), Damage)
Exit Sub
End If
If GetPlayerTargetNPC(Index) > 0 Then
Call DamageNPC(Index, GetPlayerTargetNPC(Index), Damage)
Exit Sub
End If
End Sub
```
0.20 = 20% So this means +/- 20%
Thanks Soul and Admiral Refuge, and Lol, Sorry If it sounds like Im giving this script, It's just that I had trouble finding a random attack script using the search bar, So I figured that posting this one might be helpful to some.
~Redyz