| Mirage Source http://web.miragesource.net/forums/ |
|
| Not good with Math http://web.miragesource.net/forums/viewtopic.php?f=201&t=5367 |
Page 1 of 1 |
| Author: | jsventor [ Sat Apr 04, 2009 4:09 pm ] |
| Post subject: | Not good with Math |
I want it so that the players speed gives them a bonus to the exp they gain, heres what I have.. Code: Call SetPlayerExp(Attacker, (GetPlayerExp(Attacker) + EXP) + ((GetPlayerSPEED(Attacker)) * EXP) / 2)
|
|
| Author: | Matt [ Sat Apr 04, 2009 6:31 pm ] |
| Post subject: | Re: Not good with Math |
That's basically giving the player a LOT of extra xp. If you have 10 spd, and you get 100 xp, that's 1000 exp, for a bonus of 500 xp, since you divide it by 2. Lol. |
|
| Author: | jsventor [ Sat Apr 04, 2009 6:42 pm ] |
| Post subject: | Re: Not good with Math |
yea I fixed it lmao, I relaized that after I killed omehitng giving 5 exp :/ i got another question, See, I made it so that depending on the NPC's Speed and Your speed, the NPC can miss its attack on you, but 9/10 NPC attacks are missssed even if their Speed is higher then mine.. Heres the check code Code: Function CanNpcMiss(ByVal index As Long, NpcNum As Long) As Boolean Dim i As Long, n As Long CanNpcMiss = False If Npc(NpcNum).SPEED >= GetPlayerSPEED(index) Then CanNpcMiss = False Else n = Int(Rnd * 2) If n = 1 Then i = Int(GetPlayerSPEED(index)) n = Int(Rnd * Npc(NpcNum).SPEED) + 1 If n <= i Then CanNpcMiss = True End If End If End If End Function And heres the AI code Code: ' Can the npc attack the player? If CanNpcMiss(Target, x) Then Call PlayerMsg(Target, "NPC missed its attack!", Blue) Exit Sub End If can you see where I went wrong here? |
|
| Author: | Matt [ Sat Apr 04, 2009 10:47 pm ] |
| Post subject: | Re: Not good with Math |
Try changing: n = Int(Rnd * 2) To: n = Int(Rnd * 2) + 1 See if that works. |
|
| Author: | Egon [ Sat Apr 04, 2009 11:03 pm ] |
| Post subject: | Re: Not good with Math |
Matt wrote: Try changing: n = Int(Rnd * 2) To: n = Int(Rnd * 2) + 1 See if that works. Int(Rnd*2) will generate 0 and 1 Int(Rnd*2)+1 will generate 1 and 2 |
|
| Author: | Matt [ Sun Apr 05, 2009 1:47 am ] |
| Post subject: | Re: Not good with Math |
Egon wrote: Matt wrote: Try changing: n = Int(Rnd * 2) To: n = Int(Rnd * 2) + 1 See if that works. Int(Rnd*2) will generate 0 and 1 Int(Rnd*2)+1 will generate 1 and 2 Mhm, I know. See, when I was messin' with this stuff, I had a hard time of ever getting a 0. When I changed it to get from 1 or 2, it worked a lot better. |
|
| Author: | Egon [ Sun Apr 05, 2009 3:04 am ] |
| Post subject: | Re: Not good with Math |
Is Randomize Timer called anywhere in the source? Hopefully just once on form load. |
|
| Author: | Matt [ Sun Apr 05, 2009 3:07 am ] |
| Post subject: | Re: Not good with Math |
Egon wrote: Is Randomize Timer called anywhere in the source? Hopefully just once on form load. I don't think it's "Randomize Timer", just "Randomize". It is needed for the rnd function to properly work though.. |
|
| Author: | Egon [ Sun Apr 05, 2009 2:04 pm ] |
| Post subject: | Re: Not good with Math |
Randomize Timer is more random then just Randomize. |
|
| Author: | Matt [ Sun Apr 05, 2009 3:43 pm ] |
| Post subject: | Re: Not good with Math |
Egon wrote: Randomize Timer is more random then just Randomize. Ah. Okay. |
|
| Author: | GIAKEN [ Sun Apr 05, 2009 10:01 pm ] |
| Post subject: | Re: Not good with Math |
I read this somewhere: Quote: By the way, as of VB6 anyway, 'Randomize Timer' is redundant, as that is the default behavior of 'Randomize'. And this is a good random function: Code: Function Random(Lowerbound As Integer, Upperbound As Integer) As Integer Random = Int((Upperbound - Lowerbound + 1) * Rnd) + Lowerbound End Function For example Random(0, 10) will produce numbers from 0-10. |
|
| Author: | Egon [ Sun Apr 05, 2009 10:28 pm ] |
| Post subject: | Re: Not good with Math |
Quote: Basically...
Randomize reseeds the pseudo random sequence generated by Rnd. Unfortunately (because it uses a two byte hash) it only has access to a small portion of the full sequence (1/256th of 2^24 possible entry points). Calling it more than once does not make the sequence more Random it increases the chances of a repeat sequences coming up. As a side note, rather than calling Randomize at all you can use Rnd -number to reseed Rnd. This provides full access to the sequence and so gets more out of Rnd than reseeding with Randomize. Code: Private Sub Form_Load() Rnd -Now - Timer '<-- alternative to calling randomize End Sub |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|