Announcement

Collapse
No announcement yet.

Coding advice

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

  • Coding advice

    I'm trying to set up a global variable that will keep a track of what dungeon level the players are on in my mod. I was trying to set up a global 'level' that started at zero and then went up one each time the player(s) exit a map. This way the game knows what types of monsters to spawn on that map, the idea being it gets harder the deeper into the dungeon you go. Anyhoo, I can't get the global to work. I've tried declaring it in defs.qc and it either gives errors during compiling, or simply ignores it.

    I'm simply using the 'skill' variable as a substitute at the moment, but thats not ideal. Can anyone give me some advice? Thanks.

  • #2
    If you want to keep it simple, just use the scratch1 instead of skill (or scratch2, scratch3 or 4). It's only used by mods and that's what it is made for.
    Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

    So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

    Comment


    • #3
      Originally posted by Baker View Post
      If you want to keep it simple, just use the scratch1 instead of skill (or scratch2, scratch3 or 4). It's only used by mods and that's what it is made for.
      Sounds perfect, cheers matey. I'm already having fun with my little mod. The randomisation is working really well. First run through a map your facing just grunts and dogs, with maybe an enforcer or and orge if your really unlucky. Next map your facing grunts, enforcers and orgre. Next map theres fiends and ogres...

      And of course, you never know where they are gonna spawn. :d I think this mod will live or die by how I randomise the monsters. The balance need to be just right. Although the monsters get tougher and items get better as you go along, you still need the chance of getting 'out of depth' drops on the lower levels. Just because it's the first level, doesn't mean you won't bump into a shambler or a vore. Or find a '+3 brutal rocket launcher of pwange' if your really lucky :d

      Comment


      • #4
        I had an idea where you could randomly place walls. One way for it to be workable is to have a level that's mazelike- with multiple paths to the exit. Then, place special entities to mark off possible blocks for each path. In quakec, it'd be necessary to copy a wall to all but one of these locations. This would require having a wall that can be copied by quakec, so you'll need to place a func_wall in the map (some place hidden or unnoticeable) with an appropriately sized wall, and give it a field for quakec to look for... like a netname or health value (since regular func_walls don't have health values).

        Comment


        • #5
          Originally posted by Zop View Post
          I had an idea where you could randomly place walls. One way for it to be workable is to have a level that's mazelike- with multiple paths to the exit. Then, place special entities to mark off possible blocks for each path. In quakec, it'd be necessary to copy a wall to all but one of these locations. This would require having a wall that can be copied by quakec, so you'll need to place a func_wall in the map (some place hidden or unnoticeable) with an appropriately sized wall, and give it a field for quakec to look for... like a netname or health value (since regular func_walls don't have health values).
          I was thinking of something similar to that, having immovable door entites that are randomly either open or closed at the start. Your idea works better though, cutting off or opening specific routes. For now though, I'm just using a bunch of fairly linier maps that are chosen at random. But when I get monsters and items randomised nicely I'm gonna look into it. If you get it working, let me know. We could collabarate. :d

          Comment


          • #6
            You could give each of your wall entites a numeric value which designated their 'group' so that Quake picks out one of each group to leave open. I have to get better at using C to do that kind of thing, though it should be easy. Using BlitzBasic3D for so long has made me soft

            Comment


            • #7
              Would require an engine that can host > 1000 entities
              www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

              Comment


              • #8
                Originally posted by R00k View Post
                Would require an engine that can host > 1000 entities
                Yeah? I had wondered if there was an entity limit. I figured using modern
                a PC I'd be ok to stress the engine a bit. I'm using DarkPlaces and it's holding up fine so far.

                Comment


                • #9
                  Dark Places is the BEST engine for quake mods.

                  i'm considering migrating all my mods to support dp mainly.
                  www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                  Comment


                  • #10
                    OK, I'm going crazy.

                    scratch1 doesn't work, compiler doesn't like it.

                    I can declare a float 'level' but if I try putting 'level = 1;' anywhere except in my monster_random function right before I use it, it seems to ignore it. WTF? I know it's been declared ok, because I use it within my function without having to declare it there as a local. Why is it being ignored? Are globals not preserved during map changes? If they are not, how the hell do I preserve information across maps?

                    Comment


                    • #11
                      To change and get scratch1 values, use the functions cvar_set ("scratch1",levelvalue); and later, scratch1 = cvar ("scratch1");.

                      Everything but a player's parms (look at the first few functions in client.qc that work with them) is reset.
                      Last edited by Zop; 09-27-2007, 09:50 PM. Reason: more

                      Comment


                      • #12
                        Originally posted by Zop View Post
                        To change and get scratch1 values, use the functions cvar_set ("scratch1",levelvalue); and later, scratch1 = cvar ("scratch1");.

                        Everything but a player's parms (look at the first few functions in client.qc that work with them) is reset.
                        [lightbulb appears over Hendar23's head]

                        Ahhhh.

                        Thanks. I realised that my level variable still wasn't working even without a mapchange, but I'll use scratch now anyway so I'll worry about that later. Thanks for the help.

                        Comment


                        • #13
                          I can create a concept map/mod for the multiple path things if you want to see it in action.

                          Comment


                          • #14
                            Originally posted by Zop View Post
                            I can create a concept map/mod for the multiple path things if you want to see it in action.
                            Fo' sure. I'll send you my email.


                            I'm not sure if using cvars is going to work with my mod. For a start, the player could cheat and simply set scratch1 to whatever they like. Also....

                            I got the monsters spawning dependent on the value of scratch1 ok, but then I wanted scratch1 to go up one every time you exit a level, so I did this:

                            lev = cvar("scratch1");
                            lev = lev + 1;
                            cvar_set ("scratch1", "lev");

                            Except scratch1 then become "lev" and not 1 as it should (assuming scratch1 starts at zero) lol.

                            cvar_set ("scratch1", lev); is rejected. So you can't assign variable values to cvars? That sucks. I can hard code the number in, i.e.

                            cvar_set ("scratch1", "1");

                            But then I'd have to code in the changes for each map, and have the maps running in a pre-prescribed order. i.e.
                            If map = map1, scratch1 = 2
                            if map = map2, scratch1 = 3
                            ....etc.

                            Comment


                            • #15
                              Yeah, the set function takes strings. You can change a value into a string for cvar_set using ftos. If your compiler allows you to use nested functions, you could do:

                              cvar_set ("scratch1",ftos(lev));

                              Comment

                              Working...
                              X