This code should work, right?
Moderator: InsideQC Admins
30 posts
• Page 2 of 2 • 1, 2
ThePlasticBling wrote:still doesn't work. what am i doing wrong?
EVERYTHING! Start with learning some BASIC coding skills before you try to do ANYTHING with the Quake engine.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Thanks! I forgot that little Sucker :p
- Code: Select all
void () mystery_box =
{
local float r;
r = random ();
if (r < 0.9)
self.items = self.items | IT_LIGHTNING;
else if (r < 0.8)
self.items = self.items | IT_SUPER_NAILGUN;
else if (r < 0.7)
self.items = self.items | IT_ROCKET_LAUNCHER;
else if (r < 0.6)
self.items = self.items | IT_GRENADE_LAUNCHER;
else if (r < 0.5)
self.items = self.items | IT_NAILGUN;
else if (r < 0.4)
self.items = self.items | IT_SUPER_SHOTGUN;
else if (r < 0.3)
self.items = self.items | IT_SUPER_SHOTGUN;
else if (r < 0.2)
self.items = self.items | IT_NAILGUN;
else if (r < 0.1)
self.items = self.items | IT_NAILGUN;
else
self.items = self.items | IT_NAILGUN; //If all these return False, then you will get this gun.
};
Last edited by Mexicouger on Wed Nov 03, 2010 2:05 am, edited 1 time in total.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
ftfy
- Code: Select all
void () mystery_box =
{
local float r;
r = random();
if (r < 0.9)
self.items = self.items | IT_LIGHTNING;
else if (r < 0.8)
self.items = self.items | IT_SUPER_NAILGUN;
else if (r < 0.7)
self.items = self.items | IT_ROCKET_LAUNCHER;
else if (r < 0.6)
self.items = self.items | IT_GRENADE_LAUNCHER;
else if (r < 0.5)
self.items = self.items | IT_NAILGUN;
else if (r < 0.4)
self.items = self.items | IT_SUPER_SHOTGUN;
else if (r < 0.3)
self.items = self.items | IT_SUPER_SHOTGUN;
else if (r < 0.2)
self.items = self.items | IT_NAILGUN;
else if (r < 0.1)
self.items = self.items | IT_NAILGUN;
else
self.items = self.items | IT_NAILGUN; //If all these return False, then you will get this gun.
};
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.
Get off my lawn!
-

dreadlorde - Posts: 268
- Joined: Tue Nov 24, 2009 2:20 am
leileilol wrote:also lose your } after it_lightning
Editing code in these text boxes isn't fun or accurate :/
I hate not being able to tab.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
leileilol wrote:But BASIC doesn't teach anything about C, it'll cripple learning of C infact.
Mexicouger - you're missing an else. If someone got a random of >0.9 he'd/she'd get nothing. Try to throw in a debug message in there too
My bad, I meant to put BASIC C.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Mystery box? Hmm sounds like you are making copy of nazi zombies. Take my advice. 1 learn to code. Look almoust all tutorials and quakec specs founded in tutorial section. Then try to merge some things ( like i merged money and exp tut to when i kill monster i get money) And remeber to use that == in if statements.
2. This would give you a random weapon yes. But not like in nazi zombies, i suggest you to try to make an actual box that gives you an weapon. Its not hard. I made that in about 10 mins to our mod ( needed some tweaking but it then worked like in cod waw)
3 try to solve problems your self first, ask when you seriosly are cornered
(4. You are probaply working for böack ops zombies portable, well good luck with that)
2. This would give you a random weapon yes. But not like in nazi zombies, i suggest you to try to make an actual box that gives you an weapon. Its not hard. I made that in about 10 mins to our mod ( needed some tweaking but it then worked like in cod waw)
3 try to solve problems your self first, ask when you seriosly are cornered
(4. You are probaply working for böack ops zombies portable, well good luck with that)
- Jukki
- Posts: 214
- Joined: Wed Apr 07, 2010 4:59 am
Jukki wrote:Mystery box? Hmm sounds like you are making copy of nazi zombies. Take my advice. 1 learn to code. Look almoust all tutorials and quakec specs founded in tutorial section. Then try to merge some things ( like i merged money and exp tut to when i kill monster i get money) And remeber to use that == in if statements.
2. This would give you a random weapon yes. But not like in nazi zombies, i suggest you to try to make an actual box that gives you an weapon. Its not hard. I made that in about 10 mins to our mod ( needed some tweaking but it then worked like in cod waw)
3 try to solve problems your self first, ask when you seriosly are cornered
(4. You are probaply working for böack ops zombies portable, well good luck with that)
actually i'm making my own game and do you think you can give me an example on how you made the mystery box?
- ThePlasticBling
- Posts: 51
- Joined: Fri Jun 04, 2010 10:18 pm
ThePlasticBling wrote:Jukki wrote:Mystery box? Hmm sounds like you are making copy of nazi zombies. Take my advice. 1 learn to code. Look almoust all tutorials and quakec specs founded in tutorial section. Then try to merge some things ( like i merged money and exp tut to when i kill monster i get money) And remeber to use that == in if statements.
2. This would give you a random weapon yes. But not like in nazi zombies, i suggest you to try to make an actual box that gives you an weapon. Its not hard. I made that in about 10 mins to our mod ( needed some tweaking but it then worked like in cod waw)
3 try to solve problems your self first, ask when you seriosly are cornered
(4. You are probaply working for böack ops zombies portable, well good luck with that)
actually i'm making my own game and do you think you can give me an example on how you made the mystery box?
No! Don't help him, make him learn how to do it like everone else did.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
DusterdooSmock wrote:ThePlasticBling wrote:Jukki wrote:Mystery box? Hmm sounds like you are making copy of nazi zombies. Take my advice. 1 learn to code. Look almoust all tutorials and quakec specs founded in tutorial section. Then try to merge some things ( like i merged money and exp tut to when i kill monster i get money) And remeber to use that == in if statements.
2. This would give you a random weapon yes. But not like in nazi zombies, i suggest you to try to make an actual box that gives you an weapon. Its not hard. I made that in about 10 mins to our mod ( needed some tweaking but it then worked like in cod waw)
3 try to solve problems your self first, ask when you seriosly are cornered
(4. You are probaply working for böack ops zombies portable, well good luck with that)
actually i'm making my own game and do you think you can give me an example on how you made the mystery box?
No! Don't help him, make him learn how to do it like everone else did.
dude, I'm trying to learn. I can't learn from my mistakes if i don't get a new code!
- ThePlasticBling
- Posts: 51
- Joined: Fri Jun 04, 2010 10:18 pm
ThePlasticBling wrote:dude, I'm trying to learn. I can't learn from my mistakes if i don't get a new code!
There is nothing wrong with asking for help when you are learning something new. And there is nothing wrong in showing your work and having people point out the mistakes and suggesting fixes/ideas.
If you're trying to learn QC great! Just don't expect to learn from your mistakes if somebody else fixes your code and hands over a perfectly working copy. Chances are all you're going to do is copy and paste it.
You did right by posting your code and asking why it does not work... a few people here have respectfully responded.
The info given to you should be enough for you to figure out what needs to be done, and still, you are struggling to make it work. This shows us that maybe you need to start with something simpler and work your way up to your "Mystery Box" idea.
I think what is ticking people off is that you appear to ignore some of their suggestions. Like learning a few basics first and/or taking a look at some of the tutorials. You didn't respond one way or the other... as if you didn't want to take the time to do so.
Most of the time people here are willing to help, you just need to do your part by being patient and following through with others suggestions, and willing to do most of your own work and not looking for others to do the work for you.
Mexicouger is right... Go play with some of the examples... here are a few examples that may be of interest to you:
http://www.inside3d.com/showtutorial.php?id=229 Take a look at Step #3
http://www.inside3d.com/showtutorial.php?id=8 Look at Step #2 A bit ugly, but works
Good God! You shot my leg off!
-

Junrall - Posts: 191
- Joined: Mon Sep 21, 2009 12:27 am
- Location: North West Oregon, USA
How come no-one notices some logical mistakes here.
(or rather want to point them out)
Let's think about it, if random gives us 0.75, I think ThePlasticBling wants to get the SNG then. This code will give him Lightning instead, because 0.75 (surprisingly) is smaller than 0.9, so only values bigger than 0.9 get through the first check and gives NG.
What you should do is to change all the < to >.
The fact that you had troublesome childhood doesn't mean he has to have one too.
(or rather want to point them out)
dreadlorde wrote:ftfy
- Code: Select all
void () mystery_box =
{
local float r;
r = random();
if (r < 0.9)
self.items = self.items | IT_LIGHTNING;
else if (r < 0.8)
self.items = self.items | IT_SUPER_NAILGUN;
else if (r < 0.7)
self.items = self.items | IT_ROCKET_LAUNCHER;
...
else
self.items = self.items | IT_NAILGUN; //If all these return False, then you will get this gun.
};
Let's think about it, if random gives us 0.75, I think ThePlasticBling wants to get the SNG then. This code will give him Lightning instead, because 0.75 (surprisingly) is smaller than 0.9, so only values bigger than 0.9 get through the first check and gives NG.
What you should do is to change all the < to >.
DusterdooSmock wrote:No! Don't help him, make him learn how to do it like everone else did.
The fact that you had troublesome childhood doesn't mean he has to have one too.
-

Shpuld - Posts: 92
- Joined: Sat Feb 13, 2010 1:48 pm
30 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest