Announcement

Collapse
No announcement yet.

Help with dropping weapons

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

  • Help with dropping weapons

    So I thought of an idea for my mod.
    Monsters like Grunts,Enforcers and Ogres would drop weapons and a certain spawnflags would make them drop backpacks instead.
    I need the exact steps,directions and what to enter here as the Inside QC tuts made my mod unplayable once.Please help?
    (Grunts drop shotguns.Soldiers drop my ssg upgrade which is the Arcane Dimensions ssg model,Enforcers drop their semi auto laser guns which I use Ruohis grenade launcher for model and Ogres drop chainsaw or grenade launcher)
    Dude,lets party!
    Bring some food and drink.I got Arcane Dimensions 2.666!?!

  • #2
    off the top of my head,
    firstly you would need to precache the gun models, if they aren't already.
    these models arent the v_ ones but the ones you would see spawned on the map.

    You could then make a generic spawn functions and pass the modelname as a parameter. and then you would need a corresponding touch function assigned to that entity as well.

    something roughly like this:

    Code:
    void() monster_weapon_touch =
    {
    	local float	new, best;
    	local entity	stemp;
    	
    	if (pointcontents(self.origin) == CONTENT_LAVA)	// oops it fell in lava.. it's gone.
    	{
    		remove (self);
    		return;
    	}
    
    	if (!(other.flags & FL_CLIENT)) return;
    
    	if (other.health <= 0) return;
    
    	if (other.classname != "player") return;
    
    	stemp = self;
    	self = other;
    	best = W_BestWeapon();
    	self = stemp;
    
    	if (self.weapon == IT_NAILGUN)
    	{
    		other.ammo_nails  = (other.ammo_nails + 30);
    		new = IT_NAILGUN;
    	}
    	else if (self.weapon == IT_SUPER_NAILGUN)
    	{
    		other.ammo_nails  = (other.ammo_nails + 30);
    		new = IT_SUPER_NAILGUN;
    	}
    
    	else if  (self.weapon == IT_SUPER_SHOTGUN)
    	{
    		other.ammo_shells = (other.ammo_shells + 5);
    		new = IT_SUPER_SHOTGUN;
    	}
    
    	else if  (self.weapon == IT_ROCKET_LAUNCHER)
    	{
    		other.ammo_rockets= (other.ammo_rockets + 5);
    		new = IT_ROCKET_LAUNCHER;
    	}
    
    	else if  (self.weapon == IT_GRENADE_LAUNCHER)
    	{
    		other.ammo_rockets= (other.ammo_rockets + 5);
    		new = IT_GRENADE_LAUNCHER;
    	}
    
    	else if  (self.weapon == IT_LIGHTNING)
    	{
    		other.ammo_cells  = (other.ammo_cells + 30);
    		new = IT_LIGHTNING;
    	}
    	else
    	{
    		remove(self);			//something went wrong
    		activator = other;
    		SUB_UseTargets();
    		return;
    	}
    	
    	sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
    	bound_other_ammo();
    
    	Deathmatch_Weapon (other, self.weapon);
    
    	other.items = other.items | self.weapon;
    
    	if ( other.weapon == best )
    	{
    		other.weapon = W_BestWeapon();
    	}
    	
    	stemp = self;
    	self = other;
    
    	W_SetCurrentAmmo();
    
    	self = stemp;
    
    	remove(self);		//remove the weapon
    	activator = other;
    	SUB_UseTargets();	
    };
    
    void (string weaponstring, float weaponnumber, entity monster) monster_drop_weapon =
    {
    	local entity gun;
    	
    	gun = spawn();
    	
    	setmodel (gun, weaponstring);
    	makevectors(monster.v_angle);
    	setsize(gun, '-16 -16 0', '16 16 56');
    	setorigin(gun, monster.origin + '0 0 16');
    	
    	gun.owner	= monster;
    	gun.velocity 	= aim(monster, 16);
    	gun.velocity 	= gun.velocity * 320;
    	gun.flags 	= FL_ITEM;
    	gun.solid 	= SOLID_TRIGGER;		// so we can touch it.
    	gun.movetype 	= MOVETYPE_BOUNCE;		// can be MOVETYPE_TOSS if you want it not to fall too far.
    	gun.weapon 	= weaponnumber;			// this is like IT_ROCKET_LAUNCHER so we can handle our inventory later on.
    	gun.touch 	= monster_weapon_touch;		// this function will be called when the weapon is picked up
    	gun.think 	= SUB_Remove;			// this function will be called if the weapon is not picked up
    	gun.nextthink 	= time + 20;			// and this is how long until it is removed.
    };
    };
    I remember playing Quake shareware for the first time and after killing the ogre I always though, wait why cant i get his grenade launcher!

    edit: i went ahead and made a rough touch function too. None of this is tested in game but should give you a good start...
    Last edited by R00k; 01-13-2017, 11:38 AM.
    www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

    Comment


    • #3
      Any Luck?? I may try pluggin this into a clean source to finalize the effect for you to play with to get to what you want. imho backpacks should only be for enforcers as theres not a laser model handy in normal Quake. But for soldiers and ogres they dont have a backpack so...
      www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

      Comment


      • #4
        uh,yeah I need to dig up any q1 source file i have as the one in my mod directory have seven's advice in it.

        Where should I add these mon_weap_drop and touch functi()ns?
        Dude,lets party!
        Bring some food and drink.I got Arcane Dimensions 2.666!?!

        Comment


        • #5
          also could you add this to a source?
          I will credit you in my mod
          Dude,lets party!
          Bring some food and drink.I got Arcane Dimensions 2.666!?!

          Comment


          • #6
            out of topic,but how did you add that code monkey part to your username?
            Dude,lets party!
            Bring some food and drink.I got Arcane Dimensions 2.666!?!

            Comment


            • #7
              If you want to use the map weapons with "spin-ny model" effect, very simple:

              Open items.qc and do this for every weapon_* function:

              Copy each weapon_* "precache_model ();" to "void() worldspawn" in world.wc:

              Code:
              void() worldspawn =
              {
              // rest of worldspawn code
              
              	precache_model ("progs/g_shot.mdl");
              	precache_model ("progs/g_nail.mdl");
              	precache_model ("progs/g_nail2.mdl");
              	precache_model ("progs/g_rock.mdl");
              	precache_model ("progs/g_rock2.mdl");
              	precache_model ("progs/g_light.mdl");
              
              };
              If a weapon is not loaded on a map, it wont be precached - so copy all those to worldspawn. Then:

              Code:
              void() weapon_supershotgun =
              {
              	// precache_model ("progs/g_shot.mdl");
              // rest of spawn code
              };
              Comment out each and EVERY precache you copied.
              Because the engine does not like precache calls after worldspawn, where you now precache all weapon map models.

              New function (in items.qc if you like):

              Code:
              void(void() wcall, string cln) drop_wep =
              {
              	newmis = self;		// use this existing global to save self
              	self = spawn();		// take over monster "self"
              	wcall();		// make the weapon
              	self.classname = cln;	// for touch fn
              
              // these calls kill velocity and drop to floor
              // the reason I set origin twice - first so drop to floor doesnt remove the item if it falls out, second for the "bounce" origin
              	setorigin(self, newmis.origin + '0 0 16');
              	StartItem();
              	PlaceItem();		// shortcut start code thinks so we can set do the next bit
              
              // now I borrow a bit of R00k's code since he did the leg work:
              	setorigin(self, newmis.origin + '0 0 16');
              	self.velocity 	= aim(newmis, 16);
              	self.velocity 	= self.velocity * 320;
              	self.movetype 	= MOVETYPE_BOUNCE;		// can be MOVETYPE_TOSS if you want it not to fall too far.
              
              	self.think 	= SUB_Remove;			// this function will be called if the weapon is not picked up
              	self.nextthink 	= time + 20;
              };
              Now, near the end of any monster death frames:
              (I use ogre here as an example.)

              Code:
              // you can put this prototype in defs.qc:
              void(void() wcall, string cln) drop_wep;
              
              void()	ogre_die13	=[	$death13,	ogre_die14	]
              {
              	drop_wep(weapon_grenadelauncher, "weapon_grenadelauncher");
              };
              I think I'll even throw this in and test it.
              Last edited by numbersix; 01-18-2017, 04:35 PM.
              numbersix - Mod DB [_] Six Gaming

              Support free code and get credit! - Hint "Pledge 24" comes with extra releases.

              Comment


              • #8
                You have to set the weapon classname so the touch function works.
                I'll edit the example to do that.

                Works now, in my test.

                Thought I'm not certain that velocity code works - I have some issue with my monster code
                right now, where once they see the player, they get stuck, so '0 0 0' velocity.

                I should also note some monsters (like the ogre) have more than one death animation.
                So if you only change the one frame as in the example, ogre wont always drop a GL.
                Last edited by numbersix; 01-18-2017, 04:35 PM.
                numbersix - Mod DB [_] Six Gaming

                Support free code and get credit! - Hint "Pledge 24" comes with extra releases.

                Comment


                • #9
                  Some source repository:

                  If you want to enable all the hipnotic ents:

                  Hipnotic quake-c release

                  Base v1.06 qc:

                  quake-c version 1.06

                  Theres a ton of others - those are the basic sets with all the warnings fixed.
                  (But perhaps not all the bugs. I've fixed an number of bugs since I released those.)

                  You might also notice the "Recoded v1.06" release.
                  Its a good bit more complex, and the default compile is for darkplaces.
                  I didnt include the link as it may not be the best code for learning.
                  numbersix - Mod DB [_] Six Gaming

                  Support free code and get credit! - Hint "Pledge 24" comes with extra releases.

                  Comment


                  • #10
                    also how do i make a version of quoth's hammer replacement thing?
                    I want to replace my shotgun with an upgradeed one later in the game.
                    same with the axe(i mean sword) to a chainsaw.
                    also i want a seperate axe weapon for my second class.I will use rubicon2.s IT_NO_WEAPON.
                    Dude,lets party!
                    Bring some food and drink.I got Arcane Dimensions 2.666!?!

                    Comment


                    • #11
                      Originally posted by ijazz View Post
                      So I thought of an idea for my mod.
                      Monsters like Grunts,Enforcers and Ogres would drop weapons and a certain spawnflags would make them drop backpacks instead.
                      I need the exact steps,directions and what to enter here as the Inside QC tuts made my mod unplayable once.Please help?
                      You don't need QuakeC to do custom item drops when a monster dies. A fair number of them are possible without any QuakeC at all.

                      There are a number of tricks in this thread that require no QuakeC, many of them are documented in the following thread:

                      Func_Msgboard: Teaching Old Progs.dat New Tricks.

                      I mean you can do it with QuakeC if you want, but you can make a grunt drop a rocket launcher if you wanted.
                      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

                      Working...
                      X