]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/buffs.qh
Merge branch 'master' into sev/luma
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / buffs.qh
1 entity Buff_Type_first;
2 entity Buff_Type_last;
3 .entity enemy; // internal next pointer
4
5 var float BUFF_LAST = 1;
6
7 .float items; // buff ID
8 .string netname; // buff name
9 .string message; // human readable name
10 .vector colormod; // buff color
11 .string model2; // buff sprite
12 .float skin; // buff skin
13
14 #define REGISTER_BUFF(hname,sname,NAME,bskin,bcolor) \
15         var float BUFF_##NAME; \
16         var entity Buff_Type##sname; \
17         void RegisterBuffs_##sname() \
18         { \
19                 BUFF_##NAME = BUFF_LAST * 2; \
20                 BUFF_LAST = BUFF_##NAME; \
21                 Buff_Type##sname = spawn(); \
22                 Buff_Type##sname.items = BUFF_##NAME; \
23                 Buff_Type##sname.netname = #sname; \
24                 Buff_Type##sname.message = hname; \
25                 Buff_Type##sname.skin = bskin; \
26                 Buff_Type##sname.colormod = bcolor; \
27                 Buff_Type##sname.model2 = strzone(strcat("buff-", #sname)); \
28                 if(!Buff_Type_first) \
29                         Buff_Type_first = Buff_Type##sname; \
30                 if(Buff_Type_last) \
31                         Buff_Type_last.enemy = Buff_Type##sname; \
32                 Buff_Type_last = Buff_Type##sname; \
33         } \
34         ACCUMULATE_FUNCTION(RegisterBuffs, RegisterBuffs_##sname)
35
36 REGISTER_BUFF(_("Ammo"),ammo,AMMO,3,'0.2 1 0.2');
37 REGISTER_BUFF(_("Resistance"),resistance,RESISTANCE,0,'0.3 0.2 1');
38 REGISTER_BUFF(_("Speed"),speed,SPEED,9,'1 1 0.2');
39 REGISTER_BUFF(_("Medic"),medic,MEDIC,1,'1 0.3 1');
40 REGISTER_BUFF(_("Bash"),bash,BASH,5,'1 0.4 0');
41 REGISTER_BUFF(_("Vampire"),vampire,VAMPIRE,2,'1 0.15 0');
42 REGISTER_BUFF(_("Disability"),disability,DISABILITY,7,'0.66 0.66 0.73');
43 REGISTER_BUFF(_("Vengeance"),vengeance,VENGEANCE,15,'0.55 0.5 1');
44 REGISTER_BUFF(_("Jump"),jump,JUMP,10,'0.7 0.2 1');
45 REGISTER_BUFF(_("Flight"),flight,FLIGHT,11,'1 0.2 0.5');
46 REGISTER_BUFF(_("Invisible"),invisible,INVISIBLE,12,'0.9 0.9 0.9');
47 #undef REGISTER_BUFF
48
49 #ifdef SVQC
50 .float buffs;
51 void buff_Init(entity ent);
52 void buff_Init_Compat(entity ent, float replacement);
53
54 #define BUFF_SPAWNFUNC(e,b,t) void spawnfunc_item_buff_##e() { self.buffs = b; self.team = t; buff_Init(self); }
55 #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o,r) void spawnfunc_item_##o() { buff_Init_Compat(self,r); }
56 #define BUFF_SPAWNFUNCS(e,b)                         \
57         BUFF_SPAWNFUNC(e,           b,  0)           \
58         BUFF_SPAWNFUNC(e##_team1,   b,  NUM_TEAM_1) \
59         BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
60         BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
61         BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4) 
62
63 BUFF_SPAWNFUNCS(resistance,             BUFF_RESISTANCE)
64 BUFF_SPAWNFUNCS(ammo,                   BUFF_AMMO)
65 BUFF_SPAWNFUNCS(speed,                  BUFF_SPEED)
66 BUFF_SPAWNFUNCS(medic,                  BUFF_MEDIC)
67 BUFF_SPAWNFUNCS(bash,                   BUFF_BASH)
68 BUFF_SPAWNFUNCS(vampire,                BUFF_VAMPIRE)
69 BUFF_SPAWNFUNCS(disability,             BUFF_DISABILITY)
70 BUFF_SPAWNFUNCS(vengeance,              BUFF_VENGEANCE)
71 BUFF_SPAWNFUNCS(jump,                   BUFF_JUMP)
72 BUFF_SPAWNFUNCS(flight,                 BUFF_FLIGHT)
73 BUFF_SPAWNFUNCS(invisible,              BUFF_INVISIBLE)
74 BUFF_SPAWNFUNCS(random,                 0)
75
76 BUFF_SPAWNFUNC_Q3TA_COMPAT(doubler,    BUFF_MEDIC)
77 BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance,  BUFF_RESISTANCE)
78 BUFF_SPAWNFUNC_Q3TA_COMPAT(scout,      BUFF_SPEED)
79 BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen,  BUFF_AMMO)
80
81 // actually Q3
82 BUFF_SPAWNFUNC_Q3TA_COMPAT(haste,       BUFF_SPEED)
83 BUFF_SPAWNFUNC_Q3TA_COMPAT(invis,       BUFF_INVISIBLE)
84 BUFF_SPAWNFUNC_Q3TA_COMPAT(medic,       BUFF_MEDIC)
85 #endif
86
87 vector Buff_Color(float buff_id);
88 string Buff_PrettyName(float buff_id);
89 string Buff_Name(float buff_id);
90 float Buff_Type_FromName(string buff_name);
91 float Buff_Type_FromSprite(string buff_sprite);
92 float Buff_Skin(float buff_id);
93 string Buff_Sprite(float buff_id);