Announcement

Collapse
No announcement yet.

random style like

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • random style like

    So I'm trying to code a function to return a value like random();

    but I want to use the skill of my FrikaC brand Frikbots to influence the outcome of a random number

    Heres what I whipped together in a few minutes. I know how to program, but not in C. So I guess what I'm saying is I don't know how to code when it comes to quake.

    Code:
    void () bot_skillsets = 
    {
    	local float botss, ssrand;
    	
    	botss = self.b_skill;
    	while (botss)
    	{
    		ssrand = random();
    		if (botss == 0)
    		{
    			return ssrand;
    		}
    		else if (botss == 1)
    		{
    			if (ssrand >= 0.2)
    				return ssrand;
    		}
    		else (botss == 2)
    		{
    			if (ssrand >= 0.4)
    				return ssrand;
    		}
    	}
    };
    So this should loop, and will return a number like random, unless the skill is set to a higher level, in which case, the random return is influenced and won't return a number until a number within range is met for that skill level.

    Right? Or is that not cool with the quake engine, just relooping until an outcome is met. It's not an infinite loop or anything obviously, but.. I guess I could see how the engine might think I'm making a loop for no reason. It works fine in other languages.

    It doesn't work obviously, otherwise I wouldn't be posting. Advice anyone?
    Last edited by sle1pn1r; 03-21-2008, 02:07 PM. Reason: I'm new!!11one

  • #2
    You are posting on the wrong forums. We're just Quakers here.

    Try the Inside 3D You will get much better results and less flame
    QuakeOne.com
    Quake One Resurrection

    QuakeOne.com/qrack
    Great Quake engine

    Qrack 1.60.1 Ubuntu Guide
    Get Qrack 1.60.1 running in Ubuntu!

    Comment


    • #3
      Seriously? Whats with the code tagging in the reply box? I noticed it said Quake C info for this area too.. Well whatever, my appologies.

      I shouldn't have assumed everybody hax max huh?

      Comment


      • #4
        Originally posted by sle1pn1r View Post
        Seriously? Whats with the code tagging in the reply box? I noticed it said Quake C info for this area too.. Well whatever, my appologies.

        I shouldn't have assumed everybody hax max huh?
        I'm just saying the Coder : Player Ratio here is extremely low compared to Inside3D

        Inside3D is FULL of QuakeC programmers. Here there are only a handful, most notibly, Bam, R00k, RenegadeC, Canadian*Sniper and if all else fails, ask Baker
        QuakeOne.com
        Quake One Resurrection

        QuakeOne.com/qrack
        Great Quake engine

        Qrack 1.60.1 Ubuntu Guide
        Get Qrack 1.60.1 running in Ubuntu!

        Comment


        • #5
          thanks man!

          Comment


          • #6
            Originally posted by Phenom View Post
            You are posting on the wrong forums. We're just Quakers here.
            Well let's not kid ourselves Phenom. Some of us here are smart enough to understand this thread I welcome it.

            Comment


            • #7
              Originally posted by Canadian*Sniper View Post
              Well let's not kid ourselves Phenom. Some of us here are smart enough to understand this thread I welcome it.
              Thats why I listed you as one of quakeone.com's coders jackass!
              QuakeOne.com
              Quake One Resurrection

              QuakeOne.com/qrack
              Great Quake engine

              Qrack 1.60.1 Ubuntu Guide
              Get Qrack 1.60.1 running in Ubuntu!

              Comment


              • #8
                Originally posted by Phenom View Post
                Thats why I listed you as one of quakeone.com's coders jackass!
                Ya well you forgot to list Zop, jerkface!

                Comment


                • #9
                  Thanks, Sniper. I once added time and nextthink!

                  In regards to the thread, I think it would be more efficient to ADD self.b_skill and random (), and maximize it. Keep in mind, b_skill would be a range from 0.1 to 1.

                  float () random_skill = {
                  local float f;

                  f = random () + self.b_skill;

                  if (f >= 1) return 1;

                  return (f);

                  };

                  Comment


                  • #10
                    Zop, thanks for the tips man. Good idea. I finessed it a bit and pulled it off without making a new function call at all, it's inside an existing function.

                    Code:
                    botss = self.b_skill;
                    rnumba = random();
                    if (botss != 0)
                    {
                    	rnumba = rnumba + ((botss / 10) + 0.2);
                    }
                    if (rnumba > 1)
                    {
                    	rnumba = 1;
                    }
                    Worked pretty slick. Thanks again!

                    Comment


                    • #11
                      One thing to note is that function calls carry a slight overhead, so if you're trying to do a lot in a short space of time, then it's better to use as few function calls as possible.
                      16:03:04 <gb> when I put in a sng, I think I might need nails
                      16:03:30 <gb> the fact that only playtesting tells me that probably means that my mind is a sieve

                      Comment


                      • #12
                        EDIT: Opps i pulled an ALL-NIGHTER last night and read the title post incorrectly, anyways here's usefull code for someone...

                        Code:
                        // 2001-11-18 Random number function  start
                        /*
                        General solution to always get a valid random number of a given range and stepsize.
                        
                        All possible values have the same chance of being calculated.
                        (Ok, the last value has a slighlty higher chance :)
                        
                        It works for negative and positive parameters, only the stepsize should fit the range:
                          end > start : positive stepsize
                          start > end : negative stepsize
                        
                        Note that the typical "result = START + floor( random() * ( COUNT - 0.01 ) )"
                        only works for positive integer ranges with stepsize +1.
                        */
                        float(float start, float end, float stepsize) rnd_number =
                        {
                        	local float	rcnt;
                        	local float	rnd;
                        	local float result;
                        
                        	// calculate the number of possible different values
                        	rcnt = floor( fabs( ( end - start ) / stepsize ) ) + 1;
                        
                        	// calculate the random part of the result value
                        	rnd = floor( random() * rcnt );
                        	if ( rnd == rcnt )
                        	{
                        		rnd = rnd - 1;
                        	}
                        
                        	// calculate the result value
                        	result = start + ( rnd * stepsize );
                        
                        	return result;
                        };
                        // 2001-11-18 Random number function  end
                        (is there a reason we only have ~54 characters in a [ code ] window? ACK!)
                        www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                        Comment


                        • #13
                          I dunno what you girls are talking about sounds boring tho

                          Comment


                          • #14
                            Sounds boring yes..

                            But since nobody has a CAX pmode style single player mod available to download and play when nobody is at a server, I had to make one, considering you can get QCide and a handful of other Quake C stuff anywhere. My programming sucks but it gets the job done.

                            The idea was setting the skill made the bots have a keener sense of weapon choice, since the frikbots were programmed around finding weapons. I had to hack up the weapon choice since the bots wouldn't normally change weapons mid-combat, which makes them too predictable. CAX you start with everything so the bots were always using the RL. Which isn't bad, but it's more interesting to see them play and make quick weapon changes mid-combat using anything at skill 0 versus RL and LG only at skill 3. Obviously left the code for increased accuracy for each skill as FrikaC did originally.

                            The only way to beat the bots at skill 3 is to move fast, and their rocket prediction is incredible. Doesn't matter how fast you rocket jump, they will air you unless your velocity is obscene. I don't think I realized how great a job the frikbot programming is until you pop it into a CAX style mod.

                            It's still in development I guess you could say, but I don't really work on it anymore. The next thing I did after that was deathmatch 2 calls setspawnparms after you frag, so it makes for a killer 1 on 1 pmode. You frag the other player and he respawns, and you get all your health / armor back right where you stand ready for another round (since you were the victor). The only thing I had to change there was any mid-air rocket or nail or nade had it's damage null and void if the owner was dead, because you'd get your health back and be hurt from some bot spam after he was killed. Pretty simplistic coding, if it took anything remotely more complex I wouldn't have been able to do it.

                            Deathmatch 2 can be fun with a bunch of bots, because after each frag you get your shit back, so it's kind of like king of the hill. You get a frag, you get spawnparms, so in the middle of a big shit show at the mound, you'll probably come out on top as long as you keep making kills. But I did it for 1 on 1.

                            But anyways, make more sense now? I just wanted a quake 3 style bot system for quake 1, and since I play CAX, I need bots for CAX style play. I can't find them anywhere, so if anyone has a better one available, let me know. I got tired of looking.
                            Last edited by sle1pn1r; 05-01-2008, 10:19 AM.

                            Comment


                            • #15
                              I have considered adding Frikbots to CAx, but just havent gotten around to it. I know Mindzx asked for this some time ago... You could easily add to client.qc

                              void () SetPracticeParms =
                              {
                              parm1 = (((((((((IT_SHOTGUN | IT_AXE) | IT_ROCKET_LAUNCHER) | IT_ARMOR3) | IT_SUPER_SHOTGUN) | IT_NAILGUN) | IT_GRENADE_LAUNCHER) | IT_LIGHTNING) | IT_SUPER_NAILGUN) | IT_ARMOR3);
                              parm2 = 100;
                              parm3 = 200;
                              parm4 = 100;
                              parm5 = 100;
                              parm6 = 50;
                              parm7 = 100;
                              parm8 = IT_ROCKET_LAUNCHER;
                              parm9 = 80.001;
                              };
                              then in the function void() SetNewParms =
                              at the bottom add

                              SetPracticeParms ();
                              also add it to respawn() function also
                              void() respawn =
                              {
                              SetPracticeParms ();
                              self.velocity = '0 0 0';
                              PutClientInServer();
                              };
                              now compile it (i suggest frikqcc 2.5+)
                              and your frikbotmod will spawn everyone with full inventory!
                              If you feel bold enough to tinker maybe prioritize the bot's weapon hin hand choice based on distance from bot to player. < 120 then dont use RL etc...
                              www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                              Comment

                              Working...
                              X