6 #define _SSMAGIX "SUPERSPEC_OPTIONSFILE_V1" 7 #define _ISLOCAL(ent) ((edict_num(1) == (ent)) ? true : false) 38 string fn =
"superspec-local.options";
46 fn = sprintf(
"superspec-%s.options", uri_escape(this.
crypto_idfp));
52 LOG_TRACE(
"^1ERROR: ^7 superspec can not open ", fn,
" for writing.");
68 void superspec_msg(
string _center_title,
string _con_title,
entity _to,
string _msg,
float _spamlevel)
72 if(_to.superspec_flags & SSF_SILENT)
76 if (!(_to.superspec_flags & SSF_VERBOSE))
86 if(_for.superspec_itemfilter ==
"")
89 if(_for.superspec_itemfilter ==
"")
93 for(i = 0; i < l; ++i)
95 if(
argv(i) == _item.classname)
110 if(it.superspec_flags & SSF_ITEMMSG)
113 if(it.superspec_flags & SSF_VERBOSE)
114 superspec_msg(
"",
"", it, sprintf(
"Player %s^7 just picked up ^3%s\n", toucher.netname, item.netname), 1);
116 superspec_msg(
"",
"", it, sprintf(
"Player %s^7 just picked up ^3%s\n^8(%s^8)\n", toucher.netname, item.netname, item.classname), 1);
117 if((it.autospec_flags & ASF_SSIM) && it.enemy != toucher)
119 superspec_Spectate(it, toucher);
120 return MUT_ITEMTOUCH_CONTINUE;
124 if(((it.autospec_flags & ASF_SHIELD) && item.invincible_finished) ||
125 ((it.autospec_flags & ASF_STRENGTH) && item.strength_finished) ||
126 ((it.autospec_flags & ASF_MEGA_AR) && item.itemdef == ITEM_ArmorMega) ||
127 ((it.autospec_flags & ASF_MEGA_HP) && item.itemdef == ITEM_HealthMega) ||
128 ((it.autospec_flags & ASF_FLAG_GRAB) && item.classname ==
"item_flag_team"))
131 if((it.enemy != toucher) || IS_OBSERVER(it))
133 if((it.autospec_flags & ASF_OBSERVER_ONLY) && !IS_OBSERVER(it))
135 if(it.superspec_flags & SSF_VERBOSE)
136 superspec_msg(
"",
"", it, sprintf(
"^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", toucher.netname, item.netname), 2);
140 if(it.autospec_flags & ASF_SHOWWHAT)
141 superspec_msg(
"",
"", it, sprintf(
"^7Following %s^7 due to picking up %s\n", toucher.netname, item.netname), 2);
143 superspec_Spectate(it, toucher);
154 #define OPTIONINFO(flag,var,test,text,long,short) \ 155 var = strcat(var, ((flag & test) ? "^2[ON] ^7" : "^1[OFF] ^7")); \ 156 var = strcat(var, text," ^7(^3 ", long, "^7 | ^3", short, " ^7)\n") 168 if(cmd_name ==
"superspec_itemfilter")
170 if(
argv(1) ==
"help")
173 _aspeco =
"^7 superspec_itemfilter ^3\"item_classname1 item_classname2\"^7 only show thise items when ^2superspec ^3item_message^7 is on\n";
174 _aspeco =
strcat(_aspeco,
"^3 clear^7 Remove the filter (show all pickups)\n");
175 _aspeco =
strcat(_aspeco,
"^3 show ^7 Display current filter\n");
176 superspec_msg(
"^3superspec_itemfilter help:\n\n\n",
"\n^3superspec_itemfilter help:\n", player, _aspeco, 1);
178 else if(
argv(1) ==
"clear")
180 if(player.superspec_itemfilter !=
"")
183 player.superspec_itemfilter =
"";
185 else if(
argv(1) ==
"show" ||
argv(1) ==
"")
187 if(player.superspec_itemfilter ==
"")
189 superspec_msg(
"^3superspec_itemfilter^7 is ^1not^7 set",
"\n^3superspec_itemfilter^7 is ^1not^7 set\n", player,
"", 1);
195 for(i = 0; i < l; ++i)
201 superspec_msg(
"^3superspec_itemfilter is:\n\n\n",
"\n^3superspec_itemfilter is:\n", player, _msg, 1);
205 if(player.superspec_itemfilter !=
"")
214 if(cmd_name ==
"superspec")
220 float i, _bits = 0, _start = 1;
221 if(
argv(1) ==
"help")
223 _aspeco =
"use cmd superspec [option] [on|off] to set options\n\n";
224 _aspeco =
strcat(_aspeco,
"^3 silent ^7(short^5 si^7) supresses ALL messages from superspectate.\n");
225 _aspeco =
strcat(_aspeco,
"^3 verbose ^7(short^5 ve^7) makes superspectate print some additional information.\n");
226 _aspeco =
strcat(_aspeco,
"^3 item_message ^7(short^5 im^7) makes superspectate print items that were picked up.\n");
227 _aspeco =
strcat(_aspeco,
"^7 Use cmd superspec_itemfilter \"item_class1 item_class2\" to set up a filter of what to show with ^3item_message.\n");
228 superspec_msg(
"^2Available Super Spectate ^3options:\n\n\n",
"\n^2Available Super Spectate ^3options:\n", player, _aspeco, 1);
232 if(
argv(1) ==
"clear")
234 player.superspec_flags = 0;
240 if(
argv(i) ==
"on" ||
argv(i) ==
"1")
242 player.superspec_flags |= _bits;
245 else if(
argv(i) ==
"off" ||
argv(i) ==
"0")
248 player.superspec_flags &= ~_bits;
264 OPTIONINFO(player.superspec_flags, _aspeco,
SSF_ITEMMSG,
"Item pickup messages",
"item_message",
"im");
266 superspec_msg(
"^3Current Super Spectate options are:\n\n\n\n\n",
"\n^3Current Super Spectate options are:\n", player, _aspeco, 1);
273 if(cmd_name ==
"autospec")
278 if(
argv(1) ==
"help")
280 _aspeco =
"use cmd autospec [option] [on|off] to set options\n\n";
281 _aspeco =
strcat(_aspeco,
"^3 strength ^7(short^5 st^7) for automatic spectate on strength powerup\n");
282 _aspeco =
strcat(_aspeco,
"^3 shield ^7(short^5 sh^7) for automatic spectate on shield powerup\n");
283 _aspeco =
strcat(_aspeco,
"^3 mega_health ^7(short^5 mh^7) for automatic spectate on mega health\n");
284 _aspeco =
strcat(_aspeco,
"^3 mega_armor ^7(short^5 ma^7) for automatic spectate on mega armor\n");
285 _aspeco =
strcat(_aspeco,
"^3 flag_grab ^7(short^5 fg^7) for automatic spectate on CTF flag grab\n");
286 _aspeco =
strcat(_aspeco,
"^3 observer_only ^7(short^5 oo^7) for automatic spectate only if in observer mode\n");
287 _aspeco =
strcat(_aspeco,
"^3 show_what ^7(short^5 sw^7) to display what event triggered autospectate\n");
288 _aspeco =
strcat(_aspeco,
"^3 item_msg ^7(short^5 im^7) to autospec when item_message in superspectate is triggered\n");
289 _aspeco =
strcat(_aspeco,
"^3 followkiller ^7(short ^5fk^7) to autospec the killer/off\n");
290 _aspeco =
strcat(_aspeco,
"^3 all ^7(short ^5aa^7) to turn everything on/off\n");
291 superspec_msg(
"^2Available Auto Spectate ^3options:\n\n\n",
"\n^2Available Auto Spectate ^3options:\n", player, _aspeco, 1);
295 float i, _bits = 0, _start = 1;
296 if(
argv(1) ==
"clear")
298 player.autospec_flags = 0;
304 if(
argv(i) ==
"on" ||
argv(i) ==
"1")
306 player.autospec_flags |= _bits;
309 else if(
argv(i) ==
"off" ||
argv(i) ==
"0")
312 player.autospec_flags &= ~_bits;
339 OPTIONINFO(player.autospec_flags, _aspeco,
ASF_SHOWWHAT,
"Show what item triggered spectate",
"show_what",
"sw");
340 OPTIONINFO(player.autospec_flags, _aspeco,
ASF_SSIM,
"Switch on superspec item message",
"item_msg",
"im");
343 superspec_msg(
"^3Current auto spectate options are:\n\n\n\n\n",
"\n^3Current auto spectate options are:\n", player, _aspeco, 1);
347 if(cmd_name ==
"followpowerup")
356 if(cmd_name ==
"followstrength")
364 if(cmd_name ==
"followshield")
386 if(this.
enemy.crypto_idfp ==
"")
387 Send_Notification(NOTIF_ONE_ONLY, this.
enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
399 string fn =
"superspec-local.options";
403 player.superspec_itemfilter =
"";
406 _hello.enemy = player;
408 _hello.nextthink =
time + 5;
412 if(player.crypto_idfp ==
"")
415 fn = sprintf(
"superspec-%s.options", uri_escape(player.crypto_idfp));
421 LOG_TRACE(
"^1ERROR: ^7 superspec can not open ", fn,
" for reading.");
425 string _magic =
fgets(fh);
428 LOG_TRACE(
"^1ERROR^7 While reading superspec options file: unknown magic");
433 player.superspec_flags =
stof(
fgets(fh));
448 if(it.autospec_flags & ASF_SHOWWHAT)
449 superspec_msg(
"",
"", it, sprintf(
"^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
451 superspec_Spectate(it, frag_attacker);
void ClientConnect(entity this)
ClientConnect
void superspec_hello(entity this)
string autocvar_g_superspectate
#define FOREACH_CLIENT(cond, body)
bool Spectate(entity this, entity pl)
float superspec_filteritem(entity _for, entity _item)
REGISTER_MUTATOR(superspec, expr_evaluate(autocvar_g_superspectate))
#define IS_REAL_CLIENT(v)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
void SV_ParseClientCommand(entity this, string command)
const float ASF_FLAG_GRAB
bool superspec_Spectate(entity this, entity targ)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
void superspec_save_client_conf(entity this)
const float ASF_OBSERVER_ONLY
#define MUTATOR_RETURNVALUE
MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
#define new_pure(class)
purely logical entities (.origin doesn't work)
#define OPTIONINFO(flag, var, test, text, long, short)
string superspec_itemfilter
void superspec_msg(string _center_title, string _con_title, entity _to, string _msg, float _spamlevel)
const float ASF_FOLLOWKILLER
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...