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