]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_nades.qc
fc1f1d1e7b705890313ce607aeb343c989ebb4a3
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_nades.qc
1 #include "mutator_nades.qh"
2
3 #include "mutator.qh"
4
5 #include "gamemode_keyhunt.qh"
6 #include "gamemode_freezetag.qh"
7 #include "../../common/nades/all.qh"
8 #include "../../common/gamemodes/all.qh"
9 #include "../../common/monsters/spawn.qh"
10 #include "../../common/monsters/sv_monsters.qh"
11 #include "../g_subs.qh"
12
13 REGISTER_MUTATOR(nades, cvar("g_nades"))
14 {
15         MUTATOR_ONADD
16         {
17                 addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer);
18                 addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
19                 addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
20                 addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
21                 addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
22                 addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
23         }
24
25         return false;
26 }
27
28 .float nade_time_primed;
29
30 .entity nade_spawnloc;
31
32 void nade_timer_think()
33 {SELFPARAM();
34         self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
35         self.nextthink = time;
36         if(!self.owner || wasfreed(self.owner))
37                 remove(self);
38 }
39
40 void nade_burn_spawn(entity _nade)
41 {
42         CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true);
43 }
44
45 void nade_spawn(entity _nade)
46 {
47         entity timer = spawn();
48         setmodel(timer, MDL_NADE_TIMER);
49         setattachment(timer, _nade, "");
50         timer.classname = "nade_timer";
51         timer.colormap = _nade.colormap;
52         timer.glowmod = _nade.glowmod;
53         timer.think = nade_timer_think;
54         timer.nextthink = time;
55         timer.wait = _nade.wait;
56         timer.owner = _nade;
57         timer.skin = 10;
58
59         _nade.effects |= EF_LOWPRECISION;
60
61         CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true);
62 }
63
64 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
65 {SELFPARAM();
66         entity e;
67         float d;
68         vector p;
69
70         if ( damage < 0 )
71                 return;
72
73         RandomSelection_Init();
74         for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
75                 if(e.takedamage == DAMAGE_AIM)
76                 if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
77                 if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
78                 if(!e.frozen)
79                 {
80                         p = e.origin;
81                         p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
82                         p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
83                         p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
84                         d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
85                         if(d < dist)
86                         {
87                                 e.fireball_impactvec = p;
88                                 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
89                         }
90                 }
91         if(RandomSelection_chosen_ent)
92         {
93                 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
94                 d = damage + (edgedamage - damage) * (d / dist);
95                 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
96                 //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
97                 Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
98         }
99 }
100
101
102 void napalm_ball_think()
103 {SELFPARAM();
104         if(round_handler_IsActive())
105         if(!round_handler_IsRoundStarted())
106         {
107                 remove(self);
108                 return;
109         }
110
111         if(time > self.pushltime)
112         {
113                 remove(self);
114                 return;
115         }
116
117         vector midpoint = ((self.absmin + self.absmax) * 0.5);
118         if(pointcontents(midpoint) == CONTENT_WATER)
119         {
120                 self.velocity = self.velocity * 0.5;
121
122                 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
123                         { self.velocity_z = 200; }
124         }
125
126         self.angles = vectoangles(self.velocity);
127
128         napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
129                                   autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
130
131         self.nextthink = time + 0.1;
132 }
133
134
135 void nade_napalm_ball()
136 {SELFPARAM();
137         entity proj;
138         vector kick;
139
140         spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
141
142         proj = spawn ();
143         proj.owner = self.owner;
144         proj.realowner = self.realowner;
145         proj.team = self.owner.team;
146         proj.classname = "grenade";
147         proj.bot_dodge = true;
148         proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
149         proj.movetype = MOVETYPE_BOUNCE;
150         proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
151         PROJECTILE_MAKETRIGGER(proj);
152         setmodel(proj, MDL_Null);
153         proj.scale = 1;//0.5;
154         setsize(proj, '-4 -4 -4', '4 4 4');
155         setorigin(proj, self.origin);
156         proj.think = napalm_ball_think;
157         proj.nextthink = time;
158         proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
159         proj.effects = EF_LOWPRECISION | EF_FLAME;
160
161         kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
162         kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
163         kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
164         proj.velocity = kick;
165
166         proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
167
168         proj.angles = vectoangles(proj.velocity);
169         proj.flags = FL_PROJECTILE;
170         proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
171
172         //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
173 }
174
175
176 void napalm_fountain_think()
177 {SELFPARAM();
178
179         if(round_handler_IsActive())
180         if(!round_handler_IsRoundStarted())
181         {
182                 remove(self);
183                 return;
184         }
185
186         if(time >= self.ltime)
187         {
188                 remove(self);
189                 return;
190         }
191
192         vector midpoint = ((self.absmin + self.absmax) * 0.5);
193         if(pointcontents(midpoint) == CONTENT_WATER)
194         {
195                 self.velocity = self.velocity * 0.5;
196
197                 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
198                         { self.velocity_z = 200; }
199
200                 UpdateCSQCProjectile(self);
201         }
202
203         napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
204                 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
205
206         self.nextthink = time + 0.1;
207         if(time >= self.nade_special_time)
208         {
209                 self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
210                 nade_napalm_ball();
211         }
212 }
213
214 void nade_napalm_boom()
215 {SELFPARAM();
216         entity fountain;
217         int c;
218         for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
219                 nade_napalm_ball();
220
221
222         fountain = spawn();
223         fountain.owner = self.owner;
224         fountain.realowner = self.realowner;
225         fountain.origin = self.origin;
226         setorigin(fountain, fountain.origin);
227         fountain.think = napalm_fountain_think;
228         fountain.nextthink = time;
229         fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
230         fountain.pushltime = fountain.ltime;
231         fountain.team = self.team;
232         fountain.movetype = MOVETYPE_TOSS;
233         fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
234         fountain.bot_dodge = true;
235         fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
236         fountain.nade_special_time = time;
237         setsize(fountain, '-16 -16 -16', '16 16 16');
238         CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
239 }
240
241 void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
242 {
243         frost_target.frozen_by = freezefield.realowner;
244         Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
245         Freeze(frost_target, 1/freeze_time, 3, false);
246         if(frost_target.ballcarried)
247         if(g_keepaway) { ka_DropEvent(frost_target); }
248         else { DropBall(frost_target.ballcarried, frost_target.origin, frost_target.velocity);}
249         if(frost_target.flagcarried) { ctf_Handle_Throw(frost_target, world, DROP_THROW); }
250         if(frost_target.nade) { toss_nade(frost_target, '0 0 0', time + 0.05); }
251
252         kh_Key_DropAll(frost_target, false);
253 }
254
255 void nade_ice_think()
256 {SELFPARAM();
257
258         if(round_handler_IsActive())
259         if(!round_handler_IsRoundStarted())
260         {
261                 remove(self);
262                 return;
263         }
264
265         if(time >= self.ltime)
266         {
267                 if ( autocvar_g_nades_ice_explode )
268                 {
269                         entity expef = EFFECT_NADE_EXPLODE(self.realowner.team);
270                         Send_Effect(expef, self.origin + '0 0 1', '0 0 0', 1);
271                         sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
272
273                         RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
274                                 autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
275                         Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
276                                 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
277                 }
278                 remove(self);
279                 return;
280         }
281
282
283         self.nextthink = time+0.1;
284
285         // gaussian
286         float randomr;
287         randomr = random();
288         randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
289         float randomw;
290         randomw = random()*M_PI*2;
291         vector randomp;
292         randomp.x = randomr*cos(randomw);
293         randomp.y = randomr*sin(randomw);
294         randomp.z = 1;
295         Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, self.origin + randomp, '0 0 0', 1);
296
297         if(time >= self.nade_special_time)
298         {
299                 self.nade_special_time = time+0.7;
300
301                 Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
302                 Send_Effect(EFFECT_ICEFIELD, self.origin, '0 0 0', 1);
303         }
304
305
306         float current_freeze_time = self.ltime - time - 0.1;
307
308         entity e;
309         for(e = findradius(self.origin, autocvar_g_nades_nade_radius); e; e = e.chain)
310         if(e != self)
311         if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, self.realowner) || e == self.realowner))
312         if(e.takedamage && e.deadflag == DEAD_NO)
313         if(e.health > 0)
314         if(!e.revival_time || ((time - e.revival_time) >= 1.5))
315         if(!e.frozen)
316         if(current_freeze_time > 0)
317                 nade_ice_freeze(self, e, current_freeze_time);
318 }
319
320 void nade_ice_boom()
321 {SELFPARAM();
322         entity fountain;
323         fountain = spawn();
324         fountain.owner = self.owner;
325         fountain.realowner = self.realowner;
326         fountain.origin = self.origin;
327         setorigin(fountain, fountain.origin);
328         fountain.think = nade_ice_think;
329         fountain.nextthink = time;
330         fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
331         fountain.pushltime = fountain.wait = fountain.ltime;
332         fountain.team = self.team;
333         fountain.movetype = MOVETYPE_TOSS;
334         fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
335         fountain.bot_dodge = false;
336         setsize(fountain, '-16 -16 -16', '16 16 16');
337         fountain.nade_special_time = time+0.3;
338         fountain.angles = self.angles;
339
340         if ( autocvar_g_nades_ice_explode )
341         {
342                 setmodel(fountain, MDL_PROJECTILE_GRENADE);
343                 entity timer = spawn();
344                 setmodel(timer, MDL_NADE_TIMER);
345                 setattachment(timer, fountain, "");
346                 timer.classname = "nade_timer";
347                 timer.colormap = self.colormap;
348                 timer.glowmod = self.glowmod;
349                 timer.think = nade_timer_think;
350                 timer.nextthink = time;
351                 timer.wait = fountain.ltime;
352                 timer.owner = fountain;
353                 timer.skin = 10;
354         }
355         else
356                 setmodel(fountain, MDL_Null);
357 }
358
359 void nade_translocate_boom()
360 {SELFPARAM();
361         if(self.realowner.vehicle)
362                 return;
363
364         vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
365         tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
366         locout = trace_endpos;
367
368         makevectors(self.realowner.angles);
369
370         MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
371
372         TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
373 }
374
375 void nade_spawn_boom()
376 {SELFPARAM();
377         entity spawnloc = spawn();
378         setorigin(spawnloc, self.origin);
379         setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
380         spawnloc.movetype = MOVETYPE_NONE;
381         spawnloc.solid = SOLID_NOT;
382         spawnloc.drawonlytoclient = self.realowner;
383         spawnloc.effects = EF_STARDUST;
384         spawnloc.cnt = autocvar_g_nades_spawn_count;
385
386         if(self.realowner.nade_spawnloc)
387         {
388                 remove(self.realowner.nade_spawnloc);
389                 self.realowner.nade_spawnloc = world;
390         }
391
392         self.realowner.nade_spawnloc = spawnloc;
393 }
394
395 void nade_heal_think()
396 {SELFPARAM();
397         if(time >= self.ltime)
398         {
399                 remove(self);
400                 return;
401         }
402
403         self.nextthink = time;
404
405         if(time >= self.nade_special_time)
406         {
407                 self.nade_special_time = time+0.25;
408                 self.nade_show_particles = 1;
409         }
410         else
411                 self.nade_show_particles = 0;
412 }
413
414 void nade_heal_touch()
415 {SELFPARAM();
416         float maxhealth;
417         float health_factor;
418         if(IS_PLAYER(other) || IS_MONSTER(other))
419         if(other.deadflag == DEAD_NO)
420         if(!other.frozen)
421         {
422                 health_factor = autocvar_g_nades_heal_rate*frametime/2;
423                 if ( other != self.realowner )
424                 {
425                         if ( SAME_TEAM(other,self) )
426                                 health_factor *= autocvar_g_nades_heal_friend;
427                         else
428                                 health_factor *= autocvar_g_nades_heal_foe;
429                 }
430                 if ( health_factor > 0 )
431                 {
432                         maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max;
433                         if ( other.health < maxhealth )
434                         {
435                                 if ( self.nade_show_particles )
436                                         Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1);
437                                 other.health = min(other.health+health_factor, maxhealth);
438                         }
439                         other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
440                 }
441                 else if ( health_factor < 0 )
442                 {
443                         Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0');
444                 }
445
446         }
447
448         if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) )
449         {
450                 entity show_red = (IS_VEHICLE(other)) ? other.owner : other;
451                 show_red.stat_healing_orb = time+0.1;
452                 show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime;
453         }
454 }
455
456 void nade_heal_boom()
457 {SELFPARAM();
458         entity healer;
459         healer = spawn();
460         healer.owner = self.owner;
461         healer.realowner = self.realowner;
462         setorigin(healer, self.origin);
463         healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
464         healer.ltime = time + healer.healer_lifetime;
465         healer.team = self.realowner.team;
466         healer.bot_dodge = false;
467         healer.solid = SOLID_TRIGGER;
468         healer.touch = nade_heal_touch;
469
470         setmodel(healer, MDL_NADE_HEAL);
471         healer.healer_radius = autocvar_g_nades_nade_radius;
472         vector size = '1 1 1' * healer.healer_radius / 2;
473         setsize(healer,-size,size);
474
475         Net_LinkEntity(healer, true, 0, healer_send);
476
477         healer.think = nade_heal_think;
478         healer.nextthink = time;
479         healer.SendFlags |= 1;
480 }
481
482 void nade_monster_boom()
483 {SELFPARAM();
484         entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
485
486         if(autocvar_g_nades_pokenade_monster_lifetime > 0)
487                 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
488         e.monster_skill = MONSTER_SKILL_INSANE;
489 }
490
491 void nade_boom()
492 {SELFPARAM();
493         entity expef = NULL;
494         bool nade_blast = true;
495
496         switch ( Nades[self.nade_type] )
497         {
498                 case NADE_TYPE_NAPALM:
499                         nade_blast = autocvar_g_nades_napalm_blast;
500                         expef = EFFECT_EXPLOSION_MEDIUM;
501                         break;
502                 case NADE_TYPE_ICE:
503                         nade_blast = false;
504                         expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
505                         break;
506                 case NADE_TYPE_TRANSLOCATE:
507                         nade_blast = false;
508                         break;
509                 case NADE_TYPE_MONSTER:
510                 case NADE_TYPE_SPAWN:
511                         nade_blast = false;
512                         switch(self.realowner.team)
513                         {
514                                 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
515                                 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
516                                 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
517                                 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
518                                 default: expef = EFFECT_SPAWN_NEUTRAL; break;
519                         }
520                         break;
521                 case NADE_TYPE_HEAL:
522                         nade_blast = false;
523                         expef = EFFECT_SPAWN_RED;
524                         break;
525
526                 default:
527                 case NADE_TYPE_NORMAL:
528                         expef = EFFECT_NADE_EXPLODE(self.realowner.team);
529                         break;
530         }
531
532         if(expef)
533                 Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1);
534
535         sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
536         sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
537
538         self.event_damage = func_null; // prevent somehow calling damage in the next call
539
540         if(nade_blast)
541         {
542                 RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
543                                  autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
544                 Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
545         }
546
547         if(self.takedamage)
548         switch ( Nades[self.nade_type] )
549         {
550                 case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
551                 case NADE_TYPE_ICE: nade_ice_boom(); break;
552                 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
553                 case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
554                 case NADE_TYPE_HEAL: nade_heal_boom(); break;
555                 case NADE_TYPE_MONSTER: nade_monster_boom(); break;
556         }
557
558         entity head;
559         for(head = world; (head = find(head, classname, "grapplinghook")); )
560         if(head.aiment == self)
561                 RemoveGrapplingHook(head.realowner);
562
563         remove(self);
564 }
565
566 void nade_touch()
567 {SELFPARAM();
568         /*float is_weapclip = 0;
569         if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
570         if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
571         if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
572                 is_weapclip = 1;*/
573         if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
574         {
575                 entity head;
576                 for(head = world; (head = find(head, classname, "grapplinghook")); )
577                 if(head.aiment == self)
578                         RemoveGrapplingHook(head.realowner);
579                 remove(self);
580                 return;
581         }
582
583         PROJECTILE_TOUCH;
584
585         //setsize(self, '-2 -2 -2', '2 2 2');
586         //UpdateCSQCProjectile(self);
587         if(self.health == self.max_health)
588         {
589                 spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM);
590                 return;
591         }
592
593         self.enemy = other;
594         nade_boom();
595 }
596
597 void nade_beep()
598 {SELFPARAM();
599         sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
600         self.think = nade_boom;
601         self.nextthink = max(self.wait, time);
602 }
603
604 void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
605 {SELFPARAM();
606         if(ITEM_DAMAGE_NEEDKILL(deathtype))
607         {
608                 self.takedamage = DAMAGE_NO;
609                 nade_boom();
610                 return;
611         }
612
613         if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id)
614                 return;
615
616         if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
617         {
618                 force *= 1.5;
619                 damage = 0;
620         }
621
622         if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
623         {
624                 force *= 0.5; // too much
625                 frag_damage = 0;
626         }
627
628         if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
629         {
630                 force *= 6;
631                 damage = self.max_health * 0.55;
632         }
633
634         if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_HMG))
635                 damage = self.max_health * 0.1;
636
637         if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
638         if(deathtype & HITTYPE_SECONDARY)
639         {
640                 damage = self.max_health * 0.1;
641                 force *= 10;
642         }
643         else
644                 damage = self.max_health * 1.15;
645
646         self.velocity += force;
647         UpdateCSQCProjectile(self);
648
649         if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker)))
650                 return;
651
652         if(self.health == self.max_health)
653         {
654                 sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
655                 self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
656                 self.think = nade_beep;
657         }
658
659         self.health -= damage;
660
661         if ( self.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
662                 self.realowner = attacker;
663
664         if(self.health <= 0)
665                 W_PrepareExplosionByDamage(attacker, nade_boom);
666         else
667                 nade_burn_spawn(self);
668 }
669
670 void toss_nade(entity e, vector _velocity, float _time)
671 {SELFPARAM();
672         if(e.nade == world)
673                 return;
674
675         entity _nade = e.nade;
676         e.nade = world;
677
678         remove(e.fake_nade);
679         e.fake_nade = world;
680
681         makevectors(e.v_angle);
682
683         W_SetupShot(e, false, false, "", CH_WEAPON_A, 0);
684
685         Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
686
687         vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
688                                   + (v_right * autocvar_g_nades_throw_offset.y)
689                                   + (v_up * autocvar_g_nades_throw_offset.z);
690         if(autocvar_g_nades_throw_offset == '0 0 0')
691                 offset = '0 0 0';
692
693         setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
694         //setmodel(_nade, MDL_PROJECTILE_NADE);
695         //setattachment(_nade, world, "");
696         PROJECTILE_MAKETRIGGER(_nade);
697         setsize(_nade, '-16 -16 -16', '16 16 16');
698         _nade.movetype = MOVETYPE_BOUNCE;
699
700         tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
701         if (trace_startsolid)
702                 setorigin(_nade, e.origin);
703
704         if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH)
705                 _nade.velocity = '0 0 100';
706         else if(autocvar_g_nades_nade_newton_style == 1)
707                 _nade.velocity = e.velocity + _velocity;
708         else if(autocvar_g_nades_nade_newton_style == 2)
709                 _nade.velocity = _velocity;
710         else
711                 _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true);
712
713         _nade.touch = nade_touch;
714         _nade.health = autocvar_g_nades_nade_health;
715         _nade.max_health = _nade.health;
716         _nade.takedamage = DAMAGE_AIM;
717         _nade.event_damage = nade_damage;
718         _nade.customizeentityforclient = func_null;
719         _nade.exteriormodeltoclient = world;
720         _nade.traileffectnum = 0;
721         _nade.teleportable = true;
722         _nade.pushable = true;
723         _nade.gravity = 1;
724         _nade.missile_flags = MIF_SPLASH | MIF_ARC;
725         _nade.damagedbycontents = true;
726         _nade.angles = vectoangles(_nade.velocity);
727         _nade.flags = FL_PROJECTILE;
728         _nade.projectiledeathtype = DEATH_NADE.m_id;
729         _nade.toss_time = time;
730         _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
731
732         if(_nade.nade_type == NADE_TYPE_TRANSLOCATE.m_id || _nade.nade_type == NADE_TYPE_SPAWN.m_id)
733                 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
734         else
735                 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
736
737         nade_spawn(_nade);
738
739         if(_time)
740         {
741                 _nade.think = nade_boom;
742                 _nade.nextthink = _time;
743         }
744
745         e.nade_refire = time + autocvar_g_nades_nade_refire;
746         e.nade_timer = 0;
747 }
748
749 void nades_GiveBonus(entity player, float score)
750 {
751         if (autocvar_g_nades)
752         if (autocvar_g_nades_bonus)
753         if (IS_REAL_CLIENT(player))
754         if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
755         if (player.frozen == 0)
756         if (player.deadflag == DEAD_NO)
757         {
758                 if ( player.bonus_nade_score < 1 )
759                         player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
760
761                 if ( player.bonus_nade_score >= 1 )
762                 {
763                         Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
764                         play2(player, SND(KH_ALARM));
765                         player.bonus_nades++;
766                         player.bonus_nade_score -= 1;
767                 }
768         }
769 }
770
771 void nades_RemoveBonus(entity player)
772 {
773         player.bonus_nades = player.bonus_nade_score = 0;
774 }
775
776 float nade_customize()
777 {SELFPARAM();
778         //if(IS_SPEC(other)) { return false; }
779         if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
780         {
781                 // somewhat hide the model, but keep the glow
782                 //self.effects = 0;
783                 if(self.traileffectnum)
784                         self.traileffectnum = 0;
785                 self.alpha = -1;
786         }
787         else
788         {
789                 //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
790                 if(!self.traileffectnum)
791                         self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name);
792                 self.alpha = 1;
793         }
794
795         return true;
796 }
797
798 void nade_prime()
799 {SELFPARAM();
800         if(autocvar_g_nades_bonus_only)
801         if(!self.bonus_nades)
802                 return; // only allow bonus nades
803
804         if(self.nade)
805                 remove(self.nade);
806
807         if(self.fake_nade)
808                 remove(self.fake_nade);
809
810         entity n = spawn(), fn = spawn();
811
812         n.classname = "nade";
813         fn.classname = "fake_nade";
814
815         if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
816                 n.nade_type = self.nade_type;
817         else if (self.bonus_nades >= 1)
818         {
819                 n.nade_type = self.nade_type;
820                 n.pokenade_type = self.pokenade_type;
821                 self.bonus_nades -= 1;
822         }
823         else
824         {
825                 n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
826                 n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
827         }
828
829         n.nade_type = bound(1, n.nade_type, Nades_COUNT);
830
831         setmodel(n, MDL_PROJECTILE_NADE);
832         //setattachment(n, self, "bip01 l hand");
833         n.exteriormodeltoclient = self;
834         n.customizeentityforclient = nade_customize;
835         n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name);
836         n.colormod = Nades[n.nade_type].m_color;
837         n.realowner = self;
838         n.colormap = self.colormap;
839         n.glowmod = self.glowmod;
840         n.wait = time + autocvar_g_nades_nade_lifetime;
841         n.nade_time_primed = time;
842         n.think = nade_beep;
843         n.nextthink = max(n.wait - 3, time);
844         n.projectiledeathtype = DEATH_NADE.m_id;
845
846         setmodel(fn, MDL_NADE_VIEW);
847         setattachment(fn, self.weaponentity, "");
848         fn.realowner = fn.owner = self;
849         fn.colormod = Nades[n.nade_type].m_color;
850         fn.colormap = self.colormap;
851         fn.glowmod = self.glowmod;
852         fn.think = SUB_Remove;
853         fn.nextthink = n.wait;
854
855         self.nade = n;
856         self.fake_nade = fn;
857 }
858
859 float CanThrowNade()
860 {SELFPARAM();
861         if(self.vehicle)
862                 return false;
863
864         if(gameover)
865                 return false;
866
867         if(self.deadflag != DEAD_NO)
868                 return false;
869
870         if (!autocvar_g_nades)
871                 return false; // allow turning them off mid match
872
873         if(forbidWeaponUse(self))
874                 return false;
875
876         if (!IS_PLAYER(self))
877                 return false;
878
879         return true;
880 }
881
882 .bool nade_altbutton;
883
884 void nades_CheckThrow()
885 {SELFPARAM();
886         if(!CanThrowNade())
887                 return;
888
889         entity held_nade = self.nade;
890         if (!held_nade)
891         {
892                 self.nade_altbutton = true;
893                 if(time > self.nade_refire)
894                 {
895                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW);
896                         nade_prime();
897                         self.nade_refire = time + autocvar_g_nades_nade_refire;
898                 }
899         }
900         else
901         {
902                 self.nade_altbutton = false;
903                 if (time >= held_nade.nade_time_primed + 1) {
904                         makevectors(self.v_angle);
905                         float _force = time - held_nade.nade_time_primed;
906                         _force /= autocvar_g_nades_nade_lifetime;
907                         _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
908                         toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
909                 }
910         }
911 }
912
913 void nades_Clear(entity player)
914 {
915         if(player.nade)
916                 remove(player.nade);
917         if(player.fake_nade)
918                 remove(player.fake_nade);
919
920         player.nade = player.fake_nade = world;
921         player.nade_timer = 0;
922 }
923
924 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
925 {
926         if(vh_player.nade)
927                 toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
928
929         return false;
930 }
931
932 CLASS(NadeOffhand, OffhandWeapon)
933     METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
934     {
935         entity held_nade = player.nade;
936                 if (held_nade)
937                 {
938                         player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
939                         // LOG_TRACEF("%d %d\n", player.nade_timer, time - held_nade.nade_time_primed);
940                         makevectors(player.angles);
941                         held_nade.velocity = player.velocity;
942                         setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
943                         held_nade.angles_y = player.angles.y;
944
945                         if (time + 0.1 >= held_nade.wait)
946                                 toss_nade(player, '0 0 0', time + 0.05);
947                 }
948
949         if (!CanThrowNade()) return;
950         if (!(time > player.nade_refire)) return;
951                 if (key_pressed) {
952                         if (!held_nade) {
953                                 nade_prime();
954                                 held_nade = player.nade;
955                         }
956                 } else if (time >= held_nade.nade_time_primed + 1) {
957                         if (held_nade) {
958                                 makevectors(player.v_angle);
959                                 float _force = time - held_nade.nade_time_primed;
960                                 _force /= autocvar_g_nades_nade_lifetime;
961                                 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
962                                 toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
963                         }
964                 }
965     }
966 ENDCLASS(NadeOffhand)
967 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
968
969 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
970 {
971         if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
972                 nades_CheckThrow();
973                 return true;
974         }
975         return false;
976 }
977
978 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
979 {SELFPARAM();
980         if (!IS_PLAYER(self)) { return false; }
981
982         if (self.nade && (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, self, self.nade_altbutton);
983
984         if(IS_PLAYER(self))
985         {
986                 if ( autocvar_g_nades_bonus && autocvar_g_nades )
987                 {
988                         entity key;
989                         float key_count = 0;
990                         FOR_EACH_KH_KEY(key) if(key.owner == self) { ++key_count; }
991
992                         float time_score;
993                         if(self.flagcarried || self.ballcarried) // this player is important
994                                 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
995                         else
996                                 time_score = autocvar_g_nades_bonus_score_time;
997
998                         if(key_count)
999                                 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1000
1001                         if(autocvar_g_nades_bonus_client_select)
1002                         {
1003                                 self.nade_type = self.cvar_cl_nade_type;
1004                                 self.pokenade_type = self.cvar_cl_pokenade_type;
1005                         }
1006                         else
1007                         {
1008                                 self.nade_type = autocvar_g_nades_bonus_type;
1009                                 self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1010                         }
1011
1012                         self.nade_type = bound(1, self.nade_type, Nades_COUNT);
1013
1014                         if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
1015                                 nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max);
1016                 }
1017                 else
1018                 {
1019                         self.bonus_nades = self.bonus_nade_score = 0;
1020                 }
1021         }
1022
1023         float n = 0;
1024         entity o = world;
1025         if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
1026                 n = -1;
1027         else
1028         {
1029                 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1030                 n = 0;
1031                 FOR_EACH_PLAYER(other) if(self != other)
1032                 {
1033                         if(other.deadflag == DEAD_NO)
1034                         if(other.frozen == 0)
1035                         if(SAME_TEAM(other, self))
1036                         if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
1037                         {
1038                                 if(!o)
1039                                         o = other;
1040                                 if(self.frozen == 1)
1041                                         other.reviving = true;
1042                                 ++n;
1043                         }
1044                 }
1045         }
1046
1047         if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
1048         {
1049                 self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1050                 self.health = max(1, self.revive_progress * start_health);
1051
1052                 if(self.revive_progress >= 1)
1053                 {
1054                         Unfreeze(self);
1055
1056                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1057                         Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
1058                 }
1059
1060                 FOR_EACH_PLAYER(other) if(other.reviving)
1061                 {
1062                         other.revive_progress = self.revive_progress;
1063                         other.reviving = false;
1064                 }
1065         }
1066
1067         return false;
1068 }
1069
1070 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1071 {SELFPARAM();
1072         if(autocvar_g_nades_spawn)
1073                 self.nade_refire = time + autocvar_g_spawnshieldtime;
1074         else
1075                 self.nade_refire  = time + autocvar_g_nades_nade_refire;
1076
1077         if(autocvar_g_nades_bonus_client_select)
1078                 self.nade_type = self.cvar_cl_nade_type;
1079
1080         self.nade_timer = 0;
1081
1082         if (!self.offhand) self.offhand = OFFHAND_NADE;
1083
1084         if(self.nade_spawnloc)
1085         {
1086                 setorigin(self, self.nade_spawnloc.origin);
1087                 self.nade_spawnloc.cnt -= 1;
1088
1089                 if(self.nade_spawnloc.cnt <= 0)
1090                 {
1091                         remove(self.nade_spawnloc);
1092                         self.nade_spawnloc = world;
1093                 }
1094         }
1095
1096         return false;
1097 }
1098
1099 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1100 {
1101         if(frag_target.nade)
1102         if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade)
1103                 toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1104
1105         float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
1106
1107         if(IS_PLAYER(frag_attacker))
1108         {
1109                 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1110                         nades_RemoveBonus(frag_attacker);
1111                 else if(frag_target.flagcarried)
1112                         nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1113                 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1114                 {
1115                         #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1116                                 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1117                         switch(frag_attacker.killcount)
1118                         {
1119                                 KILL_SPREE_LIST
1120                                 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1121                         }
1122                         #undef SPREE_ITEM
1123                 }
1124                 else
1125                         nades_GiveBonus(frag_attacker, killcount_bonus);
1126         }
1127
1128         nades_RemoveBonus(frag_target);
1129
1130         return false;
1131 }
1132
1133 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
1134 {
1135         if(frag_target.frozen)
1136         if(autocvar_g_freezetag_revive_nade)
1137         if(frag_attacker == frag_target)
1138         if(frag_deathtype == DEATH_NADE.m_id)
1139         if(time - frag_inflictor.toss_time <= 0.1)
1140         {
1141                 Unfreeze(frag_target);
1142                 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1143                 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1144                 frag_damage = 0;
1145                 frag_force = '0 0 0';
1146                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1147                 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1148         }
1149
1150         return false;
1151 }
1152
1153 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1154 {SELFPARAM();
1155         if(IS_PLAYER(frag_attacker))
1156         if(DIFF_TEAM(frag_attacker, self))
1157         if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
1158                 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1159
1160         return false;
1161 }
1162
1163 bool nades_RemovePlayer()
1164 {SELFPARAM();
1165         nades_Clear(self);
1166         nades_RemoveBonus(self);
1167         return false;
1168 }
1169
1170 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { nades_RemovePlayer(); }
1171 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { nades_RemovePlayer(); }
1172 MUTATOR_HOOKFUNCTION(nades, reset_map_global) { nades_RemovePlayer(); }
1173
1174 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1175 {SELFPARAM();
1176         self.nade_timer = other.nade_timer;
1177         self.nade_type = other.nade_type;
1178         self.pokenade_type = other.pokenade_type;
1179         self.bonus_nades = other.bonus_nades;
1180         self.bonus_nade_score = other.bonus_nade_score;
1181         self.stat_healing_orb = other.stat_healing_orb;
1182         self.stat_healing_orb_alpha = other.stat_healing_orb_alpha;
1183         return false;
1184 }
1185
1186 MUTATOR_HOOKFUNCTION(nades, GetCvars)
1187 {
1188         GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type");
1189         GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type");
1190
1191         return false;
1192 }
1193
1194 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1195 {
1196         ret_string = strcat(ret_string, ":Nades");
1197         return false;
1198 }
1199
1200 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
1201 {
1202         ret_string = strcat(ret_string, ", Nades");
1203         return false;
1204 }