Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

kingdom.c File Reference

#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"
#include "lookup.h"

Include dependency graph for kingdom.c:

Go to the source code of this file.

Functions

void do_kingdom_guild (CHAR_DATA *ch, char *argument)
void do_kingdom_recruiter (CHAR_DATA *ch, char *argument)
void do_kingdom_set_rank (CHAR_DATA *ch, char *argument)
void do_kingdom_status (CHAR_DATA *ch, char *argument)
void do_who_kingdom (CHAR_DATA *ch, char *argument)


Function Documentation

void do_kingdom_guild CHAR_DATA ch,
char *  argument
 

Definition at line 18 of file kingdom.c.

References char_data::clan, get_char_world(), IS_NPC, IS_SET, kingdom_type::join_string, char_data::king, KING_RECRUITER, kingdom_data, kingdom_lookup(), kingdom_table, MAX_STRING_LENGTH, kingdom_data_1::member_count, char_data::name, kingdom_type::name, save_kingdom_data(), send_to_all(), and send_to_char().

00019 {
00020     char buf[MAX_STRING_LENGTH];
00021     CHAR_DATA *victim;
00022     
00023     if (argument[0] == '\0')
00024     {
00025         send_to_char ("Syntax - Kguild <person>\n\r",ch);
00026         return;
00027     }
00028         
00029     /*if ((victim = get_char_world(ch, argument)) == NULL)
00030     {*/
00031         if (ch->level > 51  && (kingdom_lookup(argument) !=0 ))
00032         {
00033             sprintf(buf, "You are now a member of %s\n\r", kingdom_table[kingdom_lookup(argument)].name);
00034             send_to_char(buf,ch);
00035             if (ch->king != 0)
00036                 kingdom_data[ch->king].member_count--;
00037             
00038             ch->king = kingdom_lookup(argument);
00039 
00040             kingdom_data[ch->king].member_count++;
00041             return;
00042         }
00043     if ((victim = get_char_world(ch,argument)) == NULL)
00044     {   
00045         send_to_char ("They are not here.\n\r",ch);
00046         return;
00047     }
00048     if (IS_NPC(victim))
00049     {
00050         send_to_char("They are not here.\n\r",ch);
00051         return;
00052     }
00053 
00054     if (victim->king > 0)
00055     {
00056         send_to_char ("They are already part of a kingdom!\n\r",ch);
00057         return;
00058     }
00059     if (!IS_SET(ch->kking, KING_RECRUITER))
00060     {
00061         if (ch->level > 51)
00062         {
00063         }
00064         else
00065         {
00066         send_to_char("You are not a recruiter.\n\r",ch);
00067         return;
00068     }
00069     }
00070     if (ch->king == 0)
00071     {
00072         send_to_char("How can you make them part of your [non-existant] kingdom?\n\r",ch);
00073         return;
00074     }
00075 
00076     if (victim->clan > 0 && !(ch->level > 51))
00077     {
00078         send_to_char("They are part of a clan!\n\r",ch);
00079         return;
00080     }
00081     if (victim == ch)
00082     {
00083         send_to_char ("heh..funny\n\r",ch);
00084         return;
00085     }
00086 
00087     sprintf(buf, "You have been guilded into %s by %s\n\r", kingdom_table[ch->king].name, ch->name);
00088     send_to_char(buf,victim);
00089     sprintf(buf, "%s %s\n\r",victim->name,kingdom_table[ch->king].join_string);
00090     send_to_all("",buf);
00091     victim->king = ch->king;
00092     kingdom_data[ch->king].member_count++;
00093     save_kingdom_data();
00094 
00095 
00096     
00097 }

Here is the call graph for this function:

void do_kingdom_recruiter CHAR_DATA ch,
char *  argument
 

Definition at line 101 of file kingdom.c.

References get_char_world(), IS_NPC, IS_SET, char_data::king, KING_GUARDIAN, KING_LEADER, KING_RECRUITER, kingdom_table, char_data::kking, MAX_STRING_LENGTH, char_data::name, one_argument(), send_to_char(), SET_BIT, and str_cmp().

00102 {
00103     char buf[MAX_STRING_LENGTH];
00104     CHAR_DATA *victim;
00105     char arg[MAX_STRING_LENGTH];
00106     argument = one_argument(argument,arg);
00107     
00108     if (arg[0] == '\0')
00109     {
00110         if (ch->level > 51)
00111         {
00112             send_to_char("Syntax - kset [recruiter/guardian/leader] <person>\n\r",ch);
00113             return;
00114         }
00115         
00116         send_to_char("Syntax - kset [recruiter/guardian] <person>\n\r",ch);
00117         return;
00118     }
00119     if (ch->king == 0)
00120     {
00121         send_to_char ("You are not in a kingdom.\n\r",ch);
00122         return;
00123     }
00124     if (!IS_SET(ch->kking, KING_LEADER) && ch->level < 52)
00125     {
00126         send_to_char("You are not a kingdom leader.\n\r",ch);
00127         return;
00128     }
00129     if (!str_cmp(arg, "recruiter"))
00130     {
00131         if (argument[0] == '\0')
00132         {
00133             send_to_char ("Syntax - kset recruiter <person>\n\r",ch);
00134             return;
00135         }
00136         if ((victim = get_char_world(ch, argument)) == NULL)
00137         {
00138             send_to_char("They are not here.\n\r",ch);
00139             return;
00140         }
00141         if (IS_NPC(victim))
00142         {
00143             send_to_char("They are not here.\n\r",ch);
00144             return;
00145         }
00146         if (victim->king != ch->king)
00147         {
00148             send_to_char ("They are not a member of your kingdom.\n\r",ch);
00149             return;
00150         }
00151         sprintf(buf, "%s is now set to recruit in your kingdom.\n\r", victim->name);
00152         send_to_char(buf,ch);
00153         sprintf(buf, "You are now a recruiter of %s", kingdom_table[victim->king].name);
00154         send_to_char(buf,victim);
00155         SET_BIT(victim->kking, KING_RECRUITER);
00156         return;
00157     }
00158     if (!str_cmp(arg, "guardian"))
00159     {
00160         if (argument[0] == '\0')
00161         {
00162             send_to_char("Syntax - kset guardian <person>\n\r",ch);
00163             return;
00164         }
00165         if ((victim = get_char_world(ch,argument)) == NULL)
00166         {
00167             send_to_char("They are not here.\n\r",ch);
00168             return;
00169         }
00170         if (IS_NPC(victim))
00171         {
00172             send_to_char("They are not here.\n\r",ch);
00173             return;
00174         }
00175         if (victim->king != ch->king)
00176         {
00177             send_to_char("They are not a member of your kingdom.\n\r",ch);
00178             return;
00179         }
00180         sprintf(buf, "%s is now a guardian over your kingdom.\n\r", victim->name);
00181         send_to_char(buf,ch);
00182         sprintf(buf, "You are now a guardian of the kingdom of %s\n\r",kingdom_table[victim->king].name);
00183         send_to_char(buf,victim);
00184         SET_BIT(victim->kking, KING_GUARDIAN);
00185         return;
00186     }
00187     if (!str_cmp(arg, "leader") && ch->level > 51)
00188     {
00189         if (argument[0] == '\0')
00190         {
00191             send_to_char ("Syntax - kset leader <person>",ch);
00192             return;
00193         }
00194         if ((victim = get_char_world(ch, argument)) == NULL)
00195         {
00196             send_to_char("They are not here.\n\r",ch);
00197             return;
00198         }
00199         if (IS_NPC(victim))
00200         {
00201             send_to_char("They are not here.\n\r",ch);
00202             return;
00203         }
00204         if (victim->king == 0)
00205         {
00206             send_to_char ("They are not in a kingdom!\n\rdo 'kguild <kingdom name>' then 'kguild <person>' THEN kset leader!\n\r",ch);
00207             return;
00208         }
00209         sprintf(buf, "%s is now the leader of %s\n\r", victim->name, kingdom_table[victim->king].name);
00210         send_to_char(buf,ch);
00211         sprintf(buf, "You are now the leader of %s\n\r", kingdom_table[victim->king].name);
00212         send_to_char(buf,victim);
00213         SET_BIT(victim->kking, KING_LEADER);
00214         SET_BIT(victim->kking, KING_RECRUITER);
00215         return;
00216     }
00217     send_to_char("Syntax - kset [recruiter/guardian] <person>\n\r",ch);
00218     return;
00219     
00220     
00221         
00222     
00223 }

Here is the call graph for this function:

void do_kingdom_set_rank CHAR_DATA ch,
char *  argument
 

Definition at line 367 of file kingdom.c.

References IS_IMMORTAL, IS_SET, KING_LEADER, kingdom_data, MSL, one_argument(), kingdom_data_1::rank, save_kingdom_data(), send_to_char(), and str_dup().

00368 {
00369     char buf[MSL];
00370     char arg1[MSL];
00371 
00372     argument = one_argument(argument,arg1);
00373 
00374     if (ch->king <=0)
00375     {
00376         send_to_char("You are not in a kingdom.\n\r",ch);
00377         return;
00378     }
00379     else if (IS_IMMORTAL(ch) && ch->king <=0)
00380     {
00381         send_to_char("Please set yourself into a kingdom first.\n\r",ch);
00382         return;
00383     }
00384 
00385     if (!IS_SET(ch->kking, KING_LEADER))
00386     {
00387         send_to_char("You are not the leader of your kingdom.\n\r",ch);
00388         return;
00389     }
00390 
00391     if (argument[0] == '\0' || arg1[0] == '\0')
00392     {
00393         send_to_char ("Syntax - krank <number> <rank>\n\r",ch);
00394         return;
00395     }
00396 
00397     if (atoi(arg1) > 10)
00398     {
00399         send_to_char("You may not have more or than 10 ranks.\n\r",ch);
00400         return;
00401     }
00402     
00403     if (atoi(arg1) < 1)
00404     {
00405         send_to_char("Invalid rank number. Ranks may only go one through ten.\n\r",ch);
00406         return;
00407     }
00408 
00409     if (strlen(argument) > 15)
00410     {
00411         send_to_char("Rank name too long.\n\r",ch);
00412         return;
00413     }
00414 
00415     sprintf(buf, "Rank %d assigned as %s.\n\r", atoi(arg1), argument);
00416     send_to_char(buf,ch);
00417 
00418     kingdom_data[ch->king].rank[atoi(arg1)-1] = str_dup(argument);
00419     save_kingdom_data();
00420 
00421     return;
00422 }

Here is the call graph for this function:

void do_kingdom_status CHAR_DATA ch,
char *  argument
 

Definition at line 325 of file kingdom.c.

References add_buf(), buf_string(), free_buf(), IS_SET, KING_LEADER, kingdom_data, kingdom_data_1::leader, kingdom_data_1::member_count, MSL, new_buf(), kingdom_data_1::rank, send_to_char(), and kingdom_data_1::tithe.

00326 {
00327     char buf[MSL];
00328     BUFFER *buffer;
00329     int runner=0;
00330     int col=0;
00331 
00332     if (ch->king <= 0)
00333     {
00334         send_to_char("You are not in a kingdom.\n\r",ch);
00335         return;
00336     }
00337     
00338     if (!IS_SET(ch->kking, KING_LEADER))
00339     {
00340         send_to_char("You are not the leader of your kingdom.\n\r",ch);
00341         return;
00342     }
00343     buffer = new_buf();
00344 
00345     sprintf(buf, "{cLeader{x: {W%-14s{x {cMember's{x: {W%d{x\n\r\n\r", kingdom_data[ch->king].leader, 
00346             kingdom_data[ch->king].member_count);
00347     add_buf(buffer, buf);
00348 
00349     for (runner=0;runner<=9;runner++)
00350     {
00351         sprintf(buf, "{cRank {C%-2d{x {W%-15s", runner+1, kingdom_data[ch->king].rank[runner]);
00352         add_buf(buffer,buf);
00353         if (++col % 2 == 0)
00354             add_buf(buffer, "\n\r");
00355     }
00356     add_buf(buffer, "\n\r");
00357     if (kingdom_data[ch->king].tithe == 0)
00358         sprintf(buf, "{cTithe{x: None.\n\r");
00359     else
00360         sprintf(buf, "{cTithe{x:{W %f%% {x\n\r", kingdom_data[ch->king].tithe);
00361     add_buf(buffer, buf);
00362 
00363     send_to_char(buf_string(buffer), ch);
00364     free_buf(buffer);
00365 }

Here is the call graph for this function:

void do_who_kingdom CHAR_DATA ch,
char *  argument
 

Definition at line 224 of file kingdom.c.

References add_buf(), buf_string(), can_see(), descriptor_data::character, CON_PLAYING, descriptor_data::connected, descriptor_list, FALSE, free_buf(), is_number(), IS_SET, char_data::king, KING_GUARDIAN, KING_LEADER, KING_RECRUITER, kingdom_lookup(), kingdom_table, char_data::kking, char_data::level, MAX_KINGDOM, MAX_LEVEL, MAX_PC_RACE, MAX_STRING_LENGTH, char_data::name, new_buf(), descriptor_data::next, one_argument(), descriptor_data::original, page_to_char(), pc_race_table, char_data::race, send_to_char(), str_prefix(), and TRUE.

00225 {
00226     DESCRIPTOR_DATA *d;
00227         char buf[MAX_STRING_LENGTH];
00228         char buf2[MAX_STRING_LENGTH];
00229         CHAR_DATA *victim;
00230         BUFFER *buffer;
00231         int numchar;
00232         bool rgfKing[MAX_KINGDOM];
00233         register int iKing;
00234         bool fKingRestrict = FALSE;
00235         int nNumber;
00236         int iLevelLower;
00237         int iLevelUpper;
00238         bool fLeader;
00239         bool fRecruiter;
00240         int king;
00241         int space;
00242         iLevelLower    = 0;
00243         iLevelUpper    = MAX_LEVEL;
00244         fLeader = FALSE;
00245         fRecruiter = FALSE;
00246         for (iKing = 0; iKing < MAX_KINGDOM; iKing++)
00247             rgfKing[iKing] = FALSE;
00248         nNumber = 0;
00249             for ( ;; )
00250         {
00251                 char arg[MAX_STRING_LENGTH];
00252             argument = one_argument( argument, arg );
00253                     if ( arg[0] == '\0' )
00254                     break;
00255 
00256                 if ( is_number( arg ) )
00257                 {
00258                     switch ( ++nNumber )
00259                         {
00260                         case 1: iLevelLower = atoi( arg ); break;
00261                         case 2: iLevelUpper = atoi( arg ); break;
00262                         default:
00263                         send_to_char( "Only two level numbers allowed.\n\r", ch );
00264                         return;
00265                     }
00266                     }
00267             else
00268             {
00269                 if (!str_prefix(arg,"leader"))
00270                     fLeader = TRUE;
00271                 else if (!str_prefix(arg, "recruiter"))
00272                     fRecruiter = TRUE;
00273                 else
00274                 {
00275                     iKing = kingdom_lookup(arg);
00276                     if (iKing)
00277                     {
00278                         fKingRestrict = TRUE;
00279                          rgfKing[iKing] = TRUE;
00280                     }
00281                     else
00282                     {
00283                         send_to_char("That's not a valid race, class, clan, or kingdom.\n\r",ch);
00284                         return;
00285                     }
00286                 }
00287             }
00288         }
00289         buffer = new_buf();
00290         numchar=0;
00291         for (d=descriptor_list;d;d=d->next)
00292         {
00293             if ( d->connected != CON_PLAYING || !can_see( ch, d->character ) )
00294                     continue;
00295             victim   = ( d->original != NULL ) ? d->original : d->character;
00296             if (victim->king == 0)
00297             {
00298                 continue;
00299             }
00300             king = victim->king;
00301             buf[0] = '\0';
00302                         buf2[0] = '\0';
00303             sprintf(buf, "[%2d %6s] ",victim->level,victim->race < MAX_PC_RACE ?pc_race_table[victim->race].who_name: "");
00304             sprintf(buf2,"%-16s",kingdom_table[victim->king].who_name);
00305             space = (20 - strlen(buf2));
00306             for( ; space > 0;space--)
00307             {
00308                 strcat(buf2, " ");
00309             }
00310             strcat(buf,buf2);
00311             sprintf(buf2,"%-11s %-9s%-9s%-9s\n\r",victim->name, IS_SET (victim->kking, KING_LEADER) ? "({WLEADER{x) " : "",
00312                     IS_SET (victim->kking, KING_RECRUITER) ? "({WRECRUITER{x) " : "", IS_SET(victim->kking,
00313                         KING_GUARDIAN) ? "({WGUARDIAN{x)" : "");
00314             strcat(buf,buf2);
00315             add_buf(buffer,buf);
00316             numchar++;
00317         }
00318         sprintf(buf, "Total: %d.\n\r",numchar);
00319         add_buf(buffer,buf);
00320         page_to_char(buf_string(buffer),ch);
00321         free_buf(buffer);
00322          return;
00323 }

Here is the call graph for this function:


Generated on Thu Jan 13 22:01:09 2005 for Beyond the Shadows by  doxygen 1.4.0