Mirage Source
Question... - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Question... (/showthread.php?tid=337)



Question... - Rian - 01-10-2006

Int(Rnd * 10)

Right so lets say m = Int(Rnd * 10)

Is there any way to say:

Code:
If m = even-number then

Basically, I want to know if a variable is an even number.


- Spodi - 01-10-2006

Code:
If m mod 2 = 0 then

Just off the top of my head, but believe it'd work. :wink:

Then for odd:

Code:
if m mod 2 = 1 then



- William - 01-10-2006

Nooo, the mod thingy..


- pingu - 01-10-2006

I love the mod operation. It has so many cool uses and most people don't know about it.


- Leighland - 01-10-2006

wow im suddenly really glad i clicked on this ... rofl


- Rian - 02-10-2006

Spodi Wrote:
Code:
If m mod 2 = 0 then

Just off the top of my head, but believe it'd work. :wink:

Then for odd:

Code:
if m mod 2 = 1 then

Tongue Thanks
Works perfectly (if you hadn't guessed, I needed "m" to be only a 50% chance)


- Spodi - 02-10-2006

Why not use:

Code:
If Int(Rnd * 2) = 1 Then ...

That'll give you a pseudo-50/50 chance and require less processing/code. :wink:


- Rian - 02-10-2006

Spodi Wrote:Why not use:

Code:
If Int(Rnd * 2) = 1 Then ...

That'll give you a pseudo-50/50 chance and require less processing/code. :wink:

Well, theres more to my code than just needing a 50% chance. It's part of my mining sub:

[code]
m = Int(Rnd * GetPlayerMining(Index))
' Narrow Odds to 50%, no matter how good the skill is
If m Mod 2 = 1 Then
m = 0
End If
' Give them nothing
If m = 0 Then
Call PlayerMsg(Index, "You find nothing.", Yellow)
Call SetPlayerMiningEXP(Index, GetPlayerMiningEXP(Index) + 1)
End If

' Give Them Loot1
If m >= 1 And m


- Spodi - 02-10-2006

Ah ok, I figured there was more to the story. :wink:


- William - 03-10-2006

Mining is basicly only used for quests, right?


- Matt - 03-10-2006

Not really, it's a job in TPO (Another game Sonire is working on, sort of. Lol).

Meaning, the players have an obligation to mine in order to make money and items and such.