Announcement

Collapse
No announcement yet.

Enemies dropping items?

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

  • #16
    Thanks a ton for all of your help Primal.

    I thought about not limiting the health to 100, but I am actually combining this with some weapon modifications I have been tweaking that involves critical hits and slightly amped up weapon, and I didn't want to make it too easy on the player. That's also why I kept the amount of health gained a bit low in order to balance things out a bit. But I think I will give it a try with your idea of a 150 max to see how it plays out.

    item.health = 6 + 20*random();

    //change it to

    item.health = floor(6 + 20*random());

    //if you decide to define this you'll need to set a float much like you did with r=random ().
    Not totally sure what you meant by that last line. How would defining it differ from how I did for "r=random()"?

    Was also already thinking of what you mentioned about making the amount bigger for tougher enemies, but went against it cause with the weapon mods, the shambler is a little bit easier to kill so I didn't want the reward to be too big.

    I am more of a newbie than you obviously and I really appreciate the help. Have mostly been learning by looking at available code and tinkering with some copy/paste testing. I knew there mus have been some unneeded code still in there, but I wasn't totally clear on what could and couldn't be left out.

    Word of caution when using tuts from Inside3d. They often have lots of typos :/ So quite a few of the examples and tuts won't work if you simply copy and paste them. So check the syntax first.
    Speaking of which, I don't know if you saw my edit at the bottom of the op, but I was having issues getting the pitching monsters to work. Any ideas what might be wrong with that one?

    Thanks again very much.
    Last edited by Legend; 08-15-2014, 01:42 AM.

    Comment


    • #17
      Ah that one. Ok. Looking at the code I see two problems. Both of them are just defining. fight.qc will compile before ai.qc so when it calleds for ChangePitch() you will get an error and ideal_pitch entity hasn't been defined at all. So here is a quick hack solution. Place this code at the top of fight.qc:

      Code:
      void() ChangePitch;
      .float ideal_pitch;
      That should allow it to compile no problem. You use .float and not float because it's directed at an entity and float is used for variables only. Compile and play. I didn't test this one myself but I see no reason why it won't compile once you include those. Good luck! I will note just looking at the code it's incomplete. ID has a built in function called idealpitch but without the _. Dunno if that is what they meant. But my thought is it will not reset itself when deciding to look down. This will likely lead to strange activity in game. I'll test this out later myself and see if im right.
      Last edited by PrimalLove; 08-16-2014, 02:16 AM.

      Comment


      • #18
        Ok when I got home I tried it out. I was right. It does some crazy stuff lol and never resets the pitch accordingly. I decided to rewrite this. Feel free to try the first one for a laugh.


        Now this one isn't perfect either. I tested it in game on several maps with several monsters. It looks a bit silly with certain monsters and for others the effects are less noticeable (shambler, ogre, etc.) But it is quite enjoyable!

        Also I went ahead and added the ability for zombies and ogres to throw and fire grens along the z axis to add to this effect of them looking up at you. So they now fire up towards you. It's just an added bonus to having them look at you. You'll notice this looks a bit funny with grunts but you can adjust the angle limit and I'll show you that below. So lets get started.

        First I rewrote the ChangePitch function so place this at the end of ai.qc

        Code:
        void() ChangePitch =
        {
        	local float             ideal, move;
        
        	
        	current_pitch = self.angles_x;
        	ideal = self.ideal_pitch;
        	
        	 
        	if (ideal > 34)
        	  ideal = 34;
        	else if (ideal < -34)
        	  ideal = -34;
        
        	if (current_pitch == ideal)
        		return;
        	
        move = ideal - current_pitch;
        		
        	if (move > 0)
        	{
        		if (move > 6)
        			move = 6;
        	}
        	else
        	{
        		if (move < -6 )
        			move = -6;
        	}
        
        	current_pitch = current_pitch + move;
        
        	self.angles_x = current_pitch;
        };
        Also remember you'll still need to place this at the top just under float current_yaw;

        Code:
        float current_pitch;
        That's it for ai.qc Save.

        Now fight.qc:

        Go to the ai_face () function and completely delete it and add this:

        Code:
        void() ai_face =
        {
        	self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin);
        	ChangeYaw ();
        	
        	local vector lad;
          local vector lad_angles;
          local float  o_range; 
        
          o_range = vlen(self.enemy.origin - self.origin);
        	
            lad = self.enemy.origin - self.origin + self.enemy.velocity;
        
            lad_angles = vectoangles (lad);
            self.ideal_pitch = lad_angles_x;
            if (self.ideal_pitch > 180)
              self.ideal_pitch = self.ideal_pitch - 360;  
        
            ChangePitch();
        };
        You'll notice this is much different than the tuts example. Rewrite This one works much better and doesn't have the strange pitch not reseting problem. Also you are much less likely to have enemies die in midair while dying in a highly pitched position. Which is kinda silly.

        Ok, at the top of the file you'll still need to put these two things just below void() ai_face or close by:

        Code:
        void() ChangePitch;
        .float ideal_pitch;
        I wrote previously on what these do. Self explanatory now. hehe.

        Now lets go over the function we created in ai.qc. In there you'll see this code:

        Code:
        if (ideal > 34)
        	  ideal = 34;
        	else if (ideal < -34)
        	  ideal = -34;
        This is the code I added to limit the amount of pitch that is possible. If you adjust this lower it will limit even more the amount of pitch and if you increase it the pitch will get more extreme. If you remove it basically they have no limit. Its funny but not useful for gameplay. I chose 34 because it was acceptable for the Grunt (of whom this effect most dramatically affects his pitch) but still allows for enough of a pitch to notice it. But play around with it if you'd like. You could even theoretically limit each monster to different pitches if you wanted. I'll let you decide.

        Now if you want to add to add the z axis stuff for the ogre and zombie read on. If not, compile and play.


        Open up ogre.qc and scroll down to the OgreFireGrenade function. You'll need to add these to the top of the function.

        Code:
        local vector distancedelta; 
        	local vector nozdistancedelta; 
        	local vector move;
        	local float	fly;
        Ok that will define a few things for us first so we don't get those errors. Hehe Ok now look for these three lines:

        Code:
        missile.velocity = normalize(self.enemy.origin - self.origin);
        	missile.velocity = missile.velocity * 600;
        	missile.velocity_z = 200;
        Delete'em. And replace them with this instead:

        Code:
        distancedelta = self.enemy.origin - self.origin; 
        	nozdistancedelta = distancedelta; 
        	
        	nozdistancedelta_z = 0;  
        	
        	missile.velocity = normalize(distancedelta);  
        	missile.velocity = missile.velocity * 600;   
        	
        	missile.velocity_z = missile.velocity_z + vlen(nozdistancedelta)*0.70;
        You can tweak these as you like but basically it works out the distance, determines velocity and height and combines them for some fun!
        Added bonus is leading the shot. Basically it can anticipate where you will be or should be when it fires. For this just simple add this under the above code:

        Code:
        move = self.enemy.velocity;
        	move_z = 0;
        
        	fly = vlen(self.enemy.origin - self.origin) / 400;
        
        	missile.velocity = missile.velocity + (fly * move);
        That's it. I wouldn't mess with this one too much but you can experiment to get a feel for this. You can also add this to the zombie.qc as it is almost identical code. It's self explanatory if you go into zombie.qc you'll see the function you should put it in and the steps are the same. Tho you might want to tweak some of the settings. Ok have fun. if any questions let me know!
        Last edited by PrimalLove; 08-16-2014, 04:32 AM.

        Comment


        • #19
          I guess I shoulda made a vid for this. :/ Eh, lazy. hehe

          Comment


          • #20
            Another quick point about adding these void() and float references because of order of compile. The order of compile is important because certain functions have to be defined first. There is a good solution for defining these things ahead of time so you don't have to do floats, etc. at the top of a file or in a particular function as a local. The solution is either to place this info in defs.qc (which gets compiled first) or make your own qc file and place it after subs.qc with all the defined variables, functions, etc. you have in your mod. This is just a nice way to clean up your code and get some order after you have finished tweaking your mod. Just my two cents on that. Hope this thing help you out!.

            Comment


            • #21
              Also to note the order of compile is listed in progs.src
              For my mods i use def2.qc and define all my globals and prototypes
              www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

              Comment


              • #22
                Ah good call R00k! Forgot to mention that! Thanks!

                Comment


                • #23
                  I got this working. Just having one little issue. I took your idea of letting the player getting over 100 health from the essence's. Though I dropped the limit to 125 instead of 150. But somehow, the player is able to gain up to 135. I double checked. There was no typo in that part of the code. So not sure why that's happening.

                  Haven't tried yet, but thinking about trying 115 instead and seeing if that actually some how caps it at 125.

                  Comment


                  • #24
                    Ah yes
                    Last edited by PrimalLove; 08-18-2014, 09:15 PM.

                    Comment


                    • #25
                      Originally posted by PrimalLove View Post
                      Ah yes
                      awww. I was about to try to implement what you said, but you seem to have edited it out. I can't quite remember what it was now.

                      Comment


                      • #26
                        Oh oops. My bad. Pressed wrong button.

                        I was going to say depends on how you want to approach it but this will do better than what I was going to suggest I think.

                        In this code in essence_Touch:

                        Code:
                        if (self.health)
                        		if ((other.items & self.items) == 0)
                        		{
                        			acount = 1;
                        			sprint (other, "it's ");
                        			sprint (other, self.netname);
                        			
                        		  }
                        	               sprint (other, "\n");
                        Just add this:

                        Code:
                        if (self.health)
                        		if ((other.items & self.items) == 0)
                        		{
                        			acount = 1;
                        			sprint (other, "it's ");
                        			sprint (other, self.netname);
                        			if (other.health >= 125) //this is new
                        			other.health = 125;      //so is this
                        		}
                        	sprint (other, "\n");
                        So when it runs self.health above that it will automatically reset your health to 125 if you are over it.

                        Also I noticed something I messed up that makes your code allow you to keep picking up the essence even when they don't give you any health. Now it is fine to keep it this way to keep the map clean of extra hearts but in this code:

                        Code:
                        if (other.health >= 125)
                        		return;    
                        	
                        		
                        	if (!T_Heal(other, self.health))

                        I didn't define the third option in !T_Heal. Either a 1 or 0. If it is a 1 once it reaches your other.health level it will stop allowing you to pick up after 125. However, if you want it to keep picking it up you can just leave it as it is. Otherwise change it to this:

                        Code:
                        	if (other.health >= 125)
                        		return;    
                        	
                        		
                        	if (!T_Heal(other, self.health, 1))
                        Hope all that makes sense.

                        Comment


                        • #27
                          THanks again Primal.

                          I was trying to figure it myself. Got close, but was pretty much putting it in the wrong spot with some syntax flubs.

                          Comment

                          Working...
                          X