#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "tables.h"
Include dependency graph for flags.c:

Go to the source code of this file.
Functions | |
| int flag_lookup | args ((const char *name, const struct flag_type *flag_table)) |
| void | do_flag (CHAR_DATA *ch, char *argument) |
|
|
|
|
||||||||||||
|
Definition at line 44 of file flags.c. References char_data::act, act_flags, affect_flags, char_data::affected_by, comm_flags, flag_lookup(), form_flags, get_char_world(), imm_flags, char_data::imm_flags, IS_NPC, IS_SET, MAX_INPUT_LENGTH, NO_FLAG, one_argument(), part_flags, plr_flags, REMOVE_BIT, char_data::res_flags, send_to_char(), SET_BIT, str_prefix(), char_data::vuln_flags, and char_data::zone. 00045 {
00046 char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH],
00047 arg3[MAX_INPUT_LENGTH];
00048 char word[MAX_INPUT_LENGTH];
00049 CHAR_DATA *victim;
00050 long *flag, old = 0, new = 0, marked = 0, pos;
00051 char type;
00052 const struct flag_type *flag_table;
00053
00054 argument = one_argument (argument, arg1);
00055 argument = one_argument (argument, arg2);
00056 argument = one_argument (argument, arg3);
00057
00058 type = argument[0];
00059
00060 if (type == '=' || type == '-' || type == '+')
00061 argument = one_argument (argument, word);
00062
00063 if (arg1[0] == '\0')
00064 {
00065 send_to_char ("Syntax:\n\r", ch);
00066 send_to_char (" flag mob <name> <field> <flags>\n\r", ch);
00067 send_to_char (" flag char <name> <field> <flags>\n\r", ch);
00068 send_to_char (" mob flags: act,aff,off,imm,res,vuln,form,part\n\r",
00069 ch);
00070 send_to_char (" char flags: plr,comm,aff,imm,res,vuln,\n\r", ch);
00071 send_to_char (" +: add flag, -: remove flag, = set equal to\n\r",
00072 ch);
00073 send_to_char (" otherwise flag toggles the flags listed.\n\r", ch);
00074 return;
00075 }
00076
00077 if (arg2[0] == '\0')
00078 {
00079 send_to_char ("What do you wish to set flags on?\n\r", ch);
00080 return;
00081 }
00082
00083 if (arg3[0] == '\0')
00084 {
00085 send_to_char ("You need to specify a flag to set.\n\r", ch);
00086 return;
00087 }
00088
00089 if (argument[0] == '\0')
00090 {
00091 send_to_char ("Which flags do you wish to change?\n\r", ch);
00092 return;
00093 }
00094
00095 if (!str_prefix (arg1, "mob") || !str_prefix (arg1, "char"))
00096 {
00097 victim = get_char_world (ch, arg2);
00098 if (victim == NULL)
00099 {
00100 send_to_char ("You can't find them.\n\r", ch);
00101 return;
00102 }
00103
00104 /* select a flag to set */
00105 if (!str_prefix (arg3, "act"))
00106 {
00107 if (!IS_NPC (victim))
00108 {
00109 send_to_char ("Use plr for PCs.\n\r", ch);
00110 return;
00111 }
00112
00113 flag = &victim->act;
00114 flag_table = act_flags;
00115 }
00116
00117 else if (!str_prefix (arg3, "plr"))
00118 {
00119 if (IS_NPC (victim))
00120 {
00121 send_to_char ("Use act for NPCs.\n\r", ch);
00122 return;
00123 }
00124
00125 flag = &victim->act;
00126 flag_table = plr_flags;
00127 }
00128
00129 else if (!str_prefix (arg3, "aff"))
00130 {
00131 flag = &victim->affected_by;
00132 flag_table = affect_flags;
00133 }
00134
00135 else if (!str_prefix (arg3, "immunity"))
00136 {
00137 flag = &victim->imm_flags;
00138 flag_table = imm_flags;
00139 }
00140
00141 else if (!str_prefix (arg3, "resist"))
00142 {
00143 flag = &victim->res_flags;
00144 flag_table = imm_flags;
00145 }
00146
00147 else if (!str_prefix (arg3, "vuln"))
00148 {
00149 flag = &victim->vuln_flags;
00150 flag_table = imm_flags;
00151 }
00152
00153 else if (!str_prefix (arg3, "form"))
00154 {
00155 if (!IS_NPC (victim))
00156 {
00157 send_to_char ("Form can't be set on PCs.\n\r", ch);
00158 return;
00159 }
00160
00161 flag = &victim->form;
00162 flag_table = form_flags;
00163 }
00164
00165 else if (!str_prefix (arg3, "parts"))
00166 {
00167 if (!IS_NPC (victim))
00168 {
00169 send_to_char ("Parts can't be set on PCs.\n\r", ch);
00170 return;
00171 }
00172
00173 flag = &victim->parts;
00174 flag_table = part_flags;
00175 }
00176
00177 else if (!str_prefix (arg3, "comm"))
00178 {
00179 if (IS_NPC (victim))
00180 {
00181 send_to_char ("Comm can't be set on NPCs.\n\r", ch);
00182 return;
00183 }
00184
00185 flag = &victim->comm;
00186 flag_table = comm_flags;
00187 }
00188
00189 else
00190 {
00191 send_to_char ("That's not an acceptable flag.\n\r", ch);
00192 return;
00193 }
00194
00195 old = *flag;
00196 victim->zone = NULL;
00197
00198 if (type != '=')
00199 new = old;
00200
00201 /* mark the words */
00202 for (;;)
00203 {
00204 argument = one_argument (argument, word);
00205
00206 if (word[0] == '\0')
00207 break;
00208
00209 pos = flag_lookup (word, flag_table);
00210
00211 if (pos == NO_FLAG)
00212 {
00213 send_to_char ("That flag doesn't exist!\n\r", ch);
00214 return;
00215 }
00216 else
00217 SET_BIT (marked, pos);
00218 }
00219
00220 for (pos = 0; flag_table[pos].name != NULL; pos++)
00221 {
00222 if (!flag_table[pos].settable
00223 && IS_SET (old, flag_table[pos].bit))
00224 {
00225 SET_BIT (new, flag_table[pos].bit);
00226 continue;
00227 }
00228
00229 if (IS_SET (marked, flag_table[pos].bit))
00230 {
00231 switch (type)
00232 {
00233 case '=':
00234 case '+':
00235 SET_BIT (new, flag_table[pos].bit);
00236 break;
00237 case '-':
00238 REMOVE_BIT (new, flag_table[pos].bit);
00239 break;
00240 default:
00241 if (IS_SET (new, flag_table[pos].bit))
00242 REMOVE_BIT (new, flag_table[pos].bit);
00243 else
00244 SET_BIT (new, flag_table[pos].bit);
00245 }
00246 }
00247 }
00248 *flag = new;
00249 return;
00250 }
00251 }
|
Here is the call graph for this function:

1.4.0