]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_porto.qc
some weapon system fixes; allow infinite portals to work by anticipating the collision
[divverent/nexuiz.git] / data / qcsrc / server / w_porto.qc
1 .float porto_grenade_id;
2
3 void W_Porto_Explode (void)
4 {
5         remove(self);
6 }
7
8 void W_Porto_Touch1 (void)
9 {
10         if(self.porto_grenade_id == 0)
11         {
12                 self.porto_grenade_id = time;
13                 if(!Portal_SpawnInPortalAtTrace(self.owner, self.velocity, self.porto_grenade_id))
14                 {
15                         self.porto_grenade_id = 0;
16                         remove(self);
17                 }
18         }
19         else
20         {
21                 Portal_SpawnOutPortalAtTrace(self.owner, self.velocity, self.porto_grenade_id);
22                 self.porto_grenade_id = 0;
23                 remove(self);
24         }
25 }
26
27 void W_Porto_Attack (void)
28 {
29         local entity gren;
30
31         if (cvar("g_use_ammunition"))
32                 self.weapons = self.weapons - (self.weapons & WEPBIT_PORTO);
33         W_SetupShot (self, '0 0 0', FALSE, 4, "weapons/grenade_fire.wav");
34
35         //pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
36
37         gren = spawn ();
38         gren.owner = self;
39         gren.classname = "porto";
40         gren.bot_dodge = TRUE;
41         gren.bot_dodgerating = 200;
42         gren.movetype = MOVETYPE_BOUNCEMISSILE;
43         gren.solid = SOLID_BBOX;
44         gren.effects = EF_LOWPRECISION;
45         gren.modelflags = MF_GRENADE;
46         setmodel(gren, "models/grenademodel.md3"); // precision set above
47         setsize(gren, '0 0 0', '0 0 0');
48         setorigin(gren, w_shotorg);
49
50         gren.nextthink = time + cvar("g_balance_porto_primary_lifetime");
51         gren.think = W_Porto_Explode;
52         gren.touch = W_Porto_Touch1;
53         gren.velocity = w_shotdir * cvar("g_balance_porto_primary_speed");
54         W_SetupProjectileVelocity(gren);
55
56         gren.angles = vectoangles (gren.velocity);
57         gren.flags = FL_PROJECTILE;
58 }
59
60 void W_Porto_Attack2 (void)
61 {
62         // nothing yet (maybe find the last one and detonate it?)
63 }
64
65 void spawnfunc_weapon_porto (void)
66 {
67         weapon_defaultspawnfunc(WEP_PORTO, 5000);
68 }
69
70 float w_porto(float req)
71 {
72         if (req == WR_AIM)
73         {
74                 self.BUTTON_ATCK = FALSE;
75                 self.BUTTON_ATCK2 = FALSE;
76                 if(bot_aim(cvar("g_balance_porto_primary_speed"), 0, cvar("g_balance_grenadelauncher_primary_lifetime"), FALSE))
77                         self.BUTTON_ATCK = TRUE;
78         }
79         else if (req == WR_THINK)
80         {
81                 if (self.BUTTON_ATCK)
82                 if (weapon_prepareattack(0, cvar("g_balance_porto_primary_refire")))
83                 {
84                         W_Porto_Attack();
85                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_porto_primary_animtime"), w_ready);
86                 }
87         }
88         else if (req == WR_PRECACHE)
89         {
90                 precache_model ("models/grenademodel.md3");
91                 precache_model ("models/weapons/g_porto.md3");
92                 precache_model ("models/weapons/v_porto.md3");
93                 precache_model ("models/weapons/w_porto.zym");
94                 precache_sound ("weapons/grenade_fire.wav");
95         }
96         else if (req == WR_SETUP)
97                 weapon_setup(WEP_PORTO);
98         else if (req == WR_SUICIDEMESSAGE)
99                 w_deathtypestring = "did the impossible";
100         else if (req == WR_KILLMESSAGE)
101                 w_deathtypestring = "felt # doing the impossible";
102         else if (req == WR_SPAWNFUNC)
103                 spawnfunc_weapon_porto();
104         return TRUE;
105 };