]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/gamec/w_crylink.c
add g_navnodeedit
[divverent/nexuiz.git] / data / qcsrc / gamec / w_crylink.c
1 void() crylink_ready_01;
2 void() crylink_fire1_01;
3 void() crylink_deselect_01;
4 void() crylink_select_01;
5
6 .float gravity;
7
8 float() crylink_check =
9 {
10         if (self.ammo_cells >= 1)
11                 return TRUE;
12         return FALSE;
13 };
14
15 void(float req) w_crylink =
16 {
17         if (req == WR_IDLE)
18                 crylink_ready_01();
19         else if (req == WR_FIRE1 || req == WR_FIRE2)
20                 weapon_prepareattack(crylink_check, crylink_check, crylink_fire1_01, cvar("g_balance_crylink_refire"));
21         else if (req == WR_RAISE)
22                 crylink_select_01();
23         else if (req == WR_UPDATECOUNTS)
24                 self.currentammo = self.ammo_cells;
25         else if (req == WR_DROP)
26                 crylink_deselect_01();
27         else if (req == WR_SETUP)
28                 weapon_setup(WEP_CRYLINK, "w_crylink.zym", IT_CELLS);
29         else if (req == WR_CHECKAMMO)
30                 weapon_hasammo = crylink_check();
31 };
32
33 .entity realowner;
34 void W_Crylink_Touch (void)
35 {
36         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_damage"), cvar("g_balance_crylink_edgedamage"), cvar("g_balance_crylink_radius"), world, cvar("g_balance_crylink_force"), IT_CRYLINK);
37         //te_smallflash(self.origin);
38         if (other.takedamage == DAMAGE_AIM)
39         {
40                 remove (self);
41                 return;
42         }
43         self.owner = world;
44         self.touch = SUB_Null;
45         setmodel (self, "models/plasma.mdl");
46         setsize (self, '0 0 0', '0 0 0');
47         self.gravity = 1;
48         self.glow_size = 0;
49         self.glow_color = 0;
50         self.think = SUB_Remove;
51         self.movetype = MOVETYPE_NONE;
52         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
53         SUB_SetFade(self, time, 1);
54         //remove (self);
55 }
56
57 void W_Crylink_Attack (void)
58 {
59         local float counter, shots;
60         local vector org;
61         local entity proj;
62         
63         local vector trueaim;
64         trueaim = W_TrueAim();
65
66         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
67         if (self.items & IT_STRENGTH) {
68                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
69         }
70         
71         if (cvar("g_use_ammunition"))
72                 self.ammo_cells = self.ammo_cells - 1;
73         self.punchangle_x = -2;
74         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
75         te_smallflash(org);
76
77         shots = cvar("g_balance_crylink_shots");
78         if (!shots)
79                 shots = 5;
80         while (counter < shots)
81         {
82                 proj = spawn ();
83                 proj.realowner = proj.owner = self;
84                 proj.classname = "spike";
85
86                 proj.movetype = MOVETYPE_BOUNCE;
87                 proj.solid = SOLID_BBOX;
88                 proj.gravity = 0.001;
89
90                 setmodel (proj, "models/plasmatrail.mdl");
91                 setsize (proj, '0 0 0', '0 0 0');
92                 setorigin (proj, org);
93
94                 if (self.button3)
95                         proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_spread")) * cvar("g_balance_crylink_speed");
96                 else
97                         proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_spread")) * cvar("g_balance_crylink_speed");
98                 proj.touch = W_Crylink_Touch;
99                 proj.think = SUB_Remove;
100                 proj.nextthink = time + 9;
101
102                 proj.angles = vectoangles (proj.velocity);
103
104                 //proj.glow_size = 20;
105
106                 proj.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
107                 counter = counter + 1;
108         }
109 }
110
111
112 // weapon frames
113 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
114 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
115 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
116 void()  crylink_fire1_01 =
117 {
118         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
119         weapon_thinkf(WFRAME_FIRE1, 0.15, crylink_ready_01);
120 };
121