(Lack of) Development Blog 14/08/12

As the name of this post suggests, I haven't been able to get all that much coding done today. I only just managed to get onto the PC, as others have been using it.
I seriously need to get some funds together for my own PC. I'll probably get a laptop, as there is nowhere to set up another PC in my house ATM.
I have written out bits of pseudo code though, so I haven't completely wasted the day.
Mostly been thinking about the "combat" system, if you can call it that.
When the player fights a monster, by default they have a 1 in 10 chance of beating them.
The way I plan on accomplishing this is using to Random function to create a random number between 0-100 (Which, if I'm not mistaken, cant actually be 100. I'm not sure if it can be 0, if anyone could give me a heads up on this it would be appreciated) and then using an if statement to see if the number is less than 10.
This way, if I replace the 100 argument when creating my random with an int, which in turn gets it value from a method, which is something like:

Code:
Random.rand = new Random();
 
int chance = myFunction(0);
int thing = rand.Random(0,chance);
if (thing < 10)
 codehereplox
 
static int myFunction(int)
{
    int returnedVal = 100;
    returnedVal -= int;
    return returnedVal
}
This way, if a player finds an item, say a sword I can do something like this:

Code:
myFunction(5);

so the next time I run the code above chance should equal 95.
I cant test this code atm, and I cant remember all the syntax, but this is the approach I'm using for now at least.

I should be able to code tomorrow, it just depends how long it takes me to repair my friends PC.

Comments

I've decided to try and write some proper code out of your pseudo code.
Take a look once you've finished yourself, or if you can't figure it out.
Your use of the Random class was incorrect, it returned an error, just remove the dot in
Code:
Random.rand = new Random();
Here's what I came up with. It compiled perfectly after I correct some things.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SomethingRandom
{
    class Program
    {
	    static void Main(string[] args)
	    {
		    Random rand = new Random();
		    int chance = myFunction(0);
		    int thing = rand.Next(0, chance);

		    if (thing <= 10)
		    {
			    //Execute code
		    }
	    }
	    static int myFunction(int x)
	    {
		    int returnedVal = 100;
		    returnedVal -= x;
		    return returnedVal;
	    }
    }
}
 
Sorry for the silence, I'm laid up with a killer migraine ATM, coding is just impossible.
Thanks for the code mate, looks brill, will try it out when I'm back on my feet.
 

Blog entry information

Author
ThePowerOutage
Views
223
Comments
4
Last update

More entries in Personal Blogs

More entries from ThePowerOutage

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: updated ship of harkinian, gonna install some hd texture pack