RCalPistol: initial media commit
authorRudolf Polzer <rpolzer@nb-04.(none)>
Mon, 1 Feb 2010 13:40:45 +0000 (14:40 +0100)
committerRudolf Polzer <rpolzer@nb-04.(none)>
Thu, 4 Feb 2010 14:07:42 +0000 (15:07 +0100)
data/models/weapons/g_rcalpistol.md3 [new file with mode: 0644]
data/models/weapons/h_rcalpistol.dpm [new file with mode: 0644]
data/models/weapons/h_rcalpistol.dpm.framegroups [new file with mode: 0644]
data/models/weapons/v_rcalpistol.md3 [new file with mode: 0644]
data/qcsrc/server/w_rcalpistol.qc [new file with mode: 0644]
data/textures/somepistol.png [new file with mode: 0644]
misc/mediasource/w_rcalpistol/somepistol.xcf [new file with mode: 0644]
misc/mediasource/w_rcalpistol/somepistol_scaled.blend [new file with mode: 0644]
misc/mediasource/w_rcalpistol/somepistol_scaled_norm.blend [new file with mode: 0644]

diff --git a/data/models/weapons/g_rcalpistol.md3 b/data/models/weapons/g_rcalpistol.md3
new file mode 100644 (file)
index 0000000..d77a702
Binary files /dev/null and b/data/models/weapons/g_rcalpistol.md3 differ
diff --git a/data/models/weapons/h_rcalpistol.dpm b/data/models/weapons/h_rcalpistol.dpm
new file mode 100644 (file)
index 0000000..0184e66
Binary files /dev/null and b/data/models/weapons/h_rcalpistol.dpm differ
diff --git a/data/models/weapons/h_rcalpistol.dpm.framegroups b/data/models/weapons/h_rcalpistol.dpm.framegroups
new file mode 100644 (file)
index 0000000..474f093
--- /dev/null
@@ -0,0 +1,4 @@
+1 8 20 0 // fire
+9 5 20 0 // fire2
+15 200 20 1 // idle
+215 39 20 0 // reload
diff --git a/data/models/weapons/v_rcalpistol.md3 b/data/models/weapons/v_rcalpistol.md3
new file mode 100644 (file)
index 0000000..0c3e257
Binary files /dev/null and b/data/models/weapons/v_rcalpistol.md3 differ
diff --git a/data/qcsrc/server/w_rcalpistol.qc b/data/qcsrc/server/w_rcalpistol.qc
new file mode 100644 (file)
index 0000000..b7c4db4
--- /dev/null
@@ -0,0 +1,250 @@
+#ifdef REGISTER_WEAPON
+REGISTER_WEAPON(RCALPISTOL, w_rcalpistol, IT_NAILS, 3, WEP_FLAG_NORMAL | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_LOW, "rcalpistol", "rcalpistol", "Rifle Caliber Pistol");
+#else
+//Rifle Caliber Pistol Primary mode: semi automatic fire, Secondary: Toggle laser pointer (about .75 of an inch below the barrel)**
+//Uses the same type of rifle ammo as the rifle, should be the same amount (RCALPISTOL uses 10 of the bullet ammo, this probably should too)
+//This does not fire "regular" pistol bullets like a regular pistol or submachine gun shoots. If you'd like a pistol like that please make a new one :)
+
+.float rcalpistol_release;
+.float rcalpistol_accumulator;
+.float rcalpistol_bulletcounter; //Added because even though this is in defs.qc, that doesn't seem to matter;
+
+float W_RCalPistol_CheckMaxBullets(float checkammo)
+{
+       float maxbulls;
+       maxbulls = cvar("g_balance_rcalpistol_magazinecapacity");
+       if(!maxbulls)
+               maxbulls = 6; // Small magazine
+       if(checkammo)
+               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+                       maxbulls = min(maxbulls, floor(self.ammo_nails / min(cvar("g_balance_rcalpistol_primary_ammo"), cvar("g_balance_rcalpistol_secondary_ammo"))));
+       if(self.rcalpistol_bulletcounter > maxbulls || !cvar("g_balance_rcalpistol_magazinecapacity"))
+               self.rcalpistol_bulletcounter = maxbulls;
+       return (self.rcalpistol_bulletcounter == maxbulls);
+}
+
+void W_RCalPistol_ReloadedAndReady()
+{
+       float t;
+       self.rcalpistol_bulletcounter = cvar("g_balance_rcalpistol_magazinecapacity");
+       W_RCalPistol_CheckMaxBullets(TRUE);
+       t = ATTACK_FINISHED(self) - cvar("g_balance_rcalpistol_reloadtime") - 1;
+       ATTACK_FINISHED(self) = t;
+       w_ready();
+}
+
+void W_RCalPistol_Reload()
+{
+       float t;
+
+       W_RCalPistol_CheckMaxBullets(TRUE);
+       if (self.rcalpistol_bulletcounter >= cvar("g_balance_rcalpistol_magazinecapacity"))
+               return;
+
+       if(self.ammo_nails < min(cvar("g_balance_rcalpistol_primary_ammo"), cvar("g_balance_rcalpistol_secondary_ammo")))
+       {
+               self.rcalpistol_bulletcounter = -1; // reload later
+               return;
+       }
+       
+       if (self.weaponentity)
+       {
+               if (self.weaponentity.wframe == WFRAME_RELOAD)
+                       return;
+
+               // allow to switch away while reloading, but this will cause a new reload!
+               self.weaponentity.state = WS_READY;
+       }
+
+       sound (self, CHAN_WEAPON2, "weapons/rcalpistol_reload.wav", VOL_BASE, ATTN_NORM);
+
+       t = max(time, ATTACK_FINISHED(self)) + cvar("g_balance_rcalpistol_reloadtime") + 1;
+       ATTACK_FINISHED(self) = t;
+
+       weapon_thinkf(WFRAME_RELOAD, cvar("g_balance_rcalpistol_reloadtime"), W_RCalPistol_ReloadedAndReady);
+
+       self.rcalpistol_bulletcounter = -1;
+}
+
+void W_RCalPistol_CheckReloadAndReady()
+{
+       w_ready();
+       if (self.rcalpistol_bulletcounter <= 0)
+               W_RCalPistol_Reload();
+       else
+               w_ready();
+}
+
+void W_RCalPistol_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
+{
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+               self.ammo_nails -= pAmmo;
+
+       if(deathtype & HITTYPE_SECONDARY)
+               W_SetupShot (self, cvar("g_antilag_bullets") && pSpeed >= cvar("g_antilag_bullets"), 2, "weapons/rcalpistol_fire2.wav", cvar("g_balance_rcalpistol_secondary_damage"));
+       else
+               W_SetupShot (self, cvar("g_antilag_bullets") && pSpeed >= cvar("g_antilag_bullets"), 2, "weapons/rcalpistol_fire.wav", cvar("g_balance_rcalpistol_primary_damage"));
+
+       pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 2000, 1);
+
+       if(self.BUTTON_ZOOM) // if zoomed, shoot from the eye
+       {
+               w_shotdir = v_forward;
+               w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward;
+       }
+
+       fireBallisticBullet(w_shotorg, w_shotdir, pSpread, pSpeed, pLifetime, pDamage, pHeadshotAddedDamage / pDamage, pForce, deathtype, (cvar("g_balance_rcalpistol_tracer") ? EF_RED : EF_BLUE), 1, pBulletConstant);
+       endFireBallisticBullet();
+
+       if (cvar("g_casings") >= 2)
+               SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
+       
+       self.rcalpistol_bulletcounter = self.rcalpistol_bulletcounter - 1;
+       W_RCalPistol_CheckMaxBullets(TRUE);
+}
+
+void W_RCalPistol_Attack()
+{
+       W_RCalPistol_FireBullet(cvar("g_balance_rcalpistol_primary_spread"), cvar("g_balance_rcalpistol_primary_damage"), cvar("g_balance_rcalpistol_primary_headshotaddeddamage"), cvar("g_balance_rcalpistol_primary_force"), cvar("g_balance_rcalpistol_primary_speed"), cvar("g_balance_rcalpistol_primary_lifetime"), cvar("g_balance_rcalpistol_primary_ammo"), WEP_RCALPISTOL, cvar("g_balance_rcalpistol_primary_bulletconstant"));
+}
+
+void W_RCalPistol_Attack2()
+{
+       W_RCalPistol_FireBullet(cvar("g_balance_rcalpistol_secondary_spread"), cvar("g_balance_rcalpistol_secondary_damage"), cvar("g_balance_rcalpistol_secondary_headshotaddeddamage"), cvar("g_balance_rcalpistol_secondary_force"), cvar("g_balance_rcalpistol_secondary_speed"), cvar("g_balance_rcalpistol_secondary_lifetime"), cvar("g_balance_rcalpistol_secondary_ammo"), WEP_RCALPISTOL | HITTYPE_SECONDARY, cvar("g_balance_rcalpistol_secondary_bulletconstant"));
+}
+
+void spawnfunc_weapon_rcalpistol (void)
+{
+       weapon_defaultspawnfunc(WEP_RCALPISTOL);
+}
+
+.float bot_secondary_rcalpistolmooth;
+float w_rcalpistol(float req)
+{
+       float full;
+       if (req == WR_AIM)
+       {
+               self.BUTTON_ATCK=FALSE;
+               self.BUTTON_ATCK2=FALSE;
+               if(vlen(self.origin-self.enemy.origin) > 1000)
+                       self.bot_secondary_rcalpistolmooth = 0;
+               if(self.bot_secondary_rcalpistolmooth == 0)
+               {
+                       if(bot_aim(cvar("g_balance_rcalpistol_primary_speed"), 0, cvar("g_balance_rcalpistol_primary_lifetime"), TRUE))
+                       {
+                               self.BUTTON_ATCK = TRUE;
+                               if(random() < 0.01) self.bot_secondary_rcalpistolmooth = 1;
+                       }
+               }
+               else
+               {
+                       if(bot_aim(cvar("g_balance_rcalpistol_secondary_speed"), 0, cvar("g_balance_rcalpistol_secondary_lifetime"), TRUE))
+                       {
+                               self.BUTTON_ATCK2 = TRUE;
+                               if(random() < 0.03) self.bot_secondary_rcalpistolmooth = 0;
+                       }
+               }
+       }
+       else if (req == WR_THINK)
+       {
+               if(self.rcalpistol_bulletcounter < 0) // forced reload (e.g. because interrupted)
+               {
+                       if(self.switchweapon == self.weapon)
+                       if(self.weaponentity.state == WS_READY)
+                               W_RCalPistol_Reload();
+               }
+               else
+               {
+                       self.rcalpistol_accumulator = bound(time - cvar("g_balance_rcalpistol_bursttime"), self.rcalpistol_accumulator, time);
+                       if(self.rcalpistol_release)
+                       {
+                               if (self.BUTTON_ATCK)
+                               if (time >= self.rcalpistol_accumulator + cvar("g_balance_rcalpistol_primary_burstcost"))
+                               if (weapon_prepareattack(0, cvar("g_balance_rcalpistol_primary_refire")))
+                               {
+                                       W_RCalPistol_Attack();
+                                       weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_rcalpistol_primary_animtime"), W_RCalPistol_CheckReloadAndReady);
+                                       self.rcalpistol_accumulator += cvar("g_balance_rcalpistol_primary_burstcost");
+                                       self.rcalpistol_release = 0;
+                               }
+                               if (self.BUTTON_ATCK2)
+                               if (time >= self.rcalpistol_accumulator + cvar("g_balance_rcalpistol_secondary_burstcost"))
+                               if (weapon_prepareattack(1, cvar("g_balance_rcalpistol_secondary_refire")))
+                               {
+                                       W_RCalPistol_Attack2();
+                                       weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_rcalpistol_secondary_animtime"), W_RCalPistol_CheckReloadAndReady);
+                                       self.rcalpistol_accumulator += cvar("g_balance_rcalpistol_secondary_burstcost");
+                                       self.rcalpistol_release = 0;
+                               }
+                       }
+                       if not(self.BUTTON_ATCK || self.BUTTON_ATCK2)
+                               self.rcalpistol_release = 1;
+               }
+       }
+       else if (req == WR_PRECACHE)
+       {               
+               precache_model ("models/weapons/g_rcalpistol.md3");
+               precache_model ("models/weapons/v_rcalpistol.md3");
+               precache_model ("models/weapons/h_rcalpistol.dpm");
+               precache_sound ("weapons/campingrifle_reload.wav");
+               precache_sound ("weapons/campingrifle_fire.wav");
+               precache_sound ("weapons/campingrifle_fire2.wav");
+       }
+       else if (req == WR_SETUP)
+       {
+               weapon_setup(WEP_RCALPISTOL);
+
+               full = W_RCalPistol_CheckMaxBullets(TRUE);
+               if(cvar("g_balance_rcalpistol_auto_reload_after_changing_weapons"))
+                       if(!full)
+                               self.rcalpistol_bulletcounter = -1;
+       }
+       else if (req == WR_CHECKAMMO1)
+               return self.ammo_nails >= cvar("g_balance_rcalpistol_primary_ammo");
+       else if (req == WR_CHECKAMMO2)
+               return self.ammo_nails >= cvar("g_balance_rcalpistol_secondary_ammo");
+       else if (req == WR_SUICIDEMESSAGE)
+       {
+               if(w_deathtype & HITTYPE_SECONDARY)
+                       w_deathtypestring = "shot themself automatically";
+               else
+                       w_deathtypestring = "sniped themself somehow";
+       }
+       else if (req == WR_KILLMESSAGE)
+       {
+               if(w_deathtype & HITTYPE_SECONDARY)
+               {
+                       if(w_deathtype & HITTYPE_BOUNCE)
+                               w_deathtypestring = "failed to hide from #'s bullet hail";
+                       else
+                               w_deathtypestring = "died in #'s bullet hail";
+               }
+               else
+               {
+                       if(w_deathtype & HITTYPE_BOUNCE)
+                       {
+                               // TODO special headshot message here too?
+                               w_deathtypestring = "failed to hide from #'s pistol";
+                       }
+                       else
+                       {
+                               if(w_deathtype & HITTYPE_HEADSHOT)
+                                       w_deathtypestring = "was executed by #";
+                               else
+                                       w_deathtypestring = "was shot down by #";
+                       }
+               }
+       }
+       else if (req == WR_RELOAD)
+       {
+               W_RCalPistol_Reload();
+       }
+       else if (req == WR_RESETPLAYER)
+       {
+               self.rcalpistol_accumulator = time - cvar("g_balance_rcalpistol_bursttime");
+               self.rcalpistol_bulletcounter = cvar("g_balance_rcalpistol_magazinecapacity");
+               W_RCalPistol_CheckMaxBullets(FALSE);
+       }
+       return TRUE;
+};
+#endif
diff --git a/data/textures/somepistol.png b/data/textures/somepistol.png
new file mode 100644 (file)
index 0000000..2db3128
Binary files /dev/null and b/data/textures/somepistol.png differ
diff --git a/misc/mediasource/w_rcalpistol/somepistol.xcf b/misc/mediasource/w_rcalpistol/somepistol.xcf
new file mode 100644 (file)
index 0000000..1196f7d
Binary files /dev/null and b/misc/mediasource/w_rcalpistol/somepistol.xcf differ
diff --git a/misc/mediasource/w_rcalpistol/somepistol_scaled.blend b/misc/mediasource/w_rcalpistol/somepistol_scaled.blend
new file mode 100644 (file)
index 0000000..7ac5418
Binary files /dev/null and b/misc/mediasource/w_rcalpistol/somepistol_scaled.blend differ
diff --git a/misc/mediasource/w_rcalpistol/somepistol_scaled_norm.blend b/misc/mediasource/w_rcalpistol/somepistol_scaled_norm.blend
new file mode 100644 (file)
index 0000000..6cd0a1b
Binary files /dev/null and b/misc/mediasource/w_rcalpistol/somepistol_scaled_norm.blend differ