ciao ho letto il msg beh ho dovuto disabilitare quella funzione per far si che il comando clan crea funzionasse pero ora ho un altro problema che quando creo il clan quando voglio aggiungere altri membri al clan non mi fa fare niente ed in piu quando riavvio il mud con il commando shutdown il clan che avevo creato non ci sta piu ma cmq ora posto il file sorgente del clan
=================================================================
/**************************************************************************
* # # # ## # # ### ## ## ###
http://www.lyonesse.it *
* # # # # # ## # # # # # *
* # # # # # ## ## # # ## ## ## # # ## *
* # # # # # ## # # # # # # # # # # # *
* ### # ## # # ### ## ## ### # # #### ## Ver. 1.0 *
* *
* -Based on CircleMud & Smaug- Copyright (c) 2001-2002 by Mithrandir *
* *
* ********************************************************************** */
/**************************************************************************
* File: clan.h Part of CircleMUD *
* *
* All rights reserved. See license.doc for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
typedef struct clan_data CLAN_DATA;
typedef struct politics_data_type CLAN_POLITIC_DATA;
#define MAX_CLANS 50
#define MIN_CLAN_MEMBERS 3
#define MAX_CLAN_MEMBERS 50
#define RANK_INVITED 0
#define RANK_APPLIER 1
#define RANK_MEMBER_FIRST 2
#define MAX_RANK_ADVANCE 6
#define RANK_PRIVILEGES 8
#define RANK_DIPLOMAT 7
#define RANK_MAGISTRATE 8
#define RANK_HERO 9
#define RANK_LEADER 10
#define RANK_PATRON 11
#define LVL_CLAN_GOD LVL_GOD
#define DEFAULT_APP_LVL 8
#define CLAN_NAME_L 128
#define MAX_CLAN_OBJ 3
#define GET_RANK_NAME(ch) (clan_rank_table[GET_CLAN_RANK(ch)].title_of_rank[GET_SEX(ch)])
#define CM_DUES 1
#define CM_APPFEE 2
#define CB_DEPOSIT 1
#define CB_WITHDRAW 2
/* Clan class restrictions: used in clan_data.anti_class */
#define CLAN_ANTI_MAGE (1 << 0)
#define CLAN_ANTI_CLERIC (1 << 1)
#define CLAN_ANTI_THIEF (1 << 2)
#define CLAN_ANTI_WARRIOR (1 << 3)
#define CLAN_ANTI_SORCERER (1 << 4)
/* Clan race restrictions: used in clan_data.anti_race */
#define CLAN_ANTI_HUMAN (1 << 0)
#define CLAN_ANTI_ELF (1 << 1)
#define CLAN_ANTI_DWARF (1 << 2)
/* Clan others restrictions: used in clan_data.anti_other */
#define CLAN_ANTI_GOOD (1 << 0)
#define CLAN_ANTI_NEUTRAL (1 << 1)
#define CLAN_ANTI_EVIL (1 << 2)
#define CLAN_ANTI_PK (1 << 3) /* no Player Killer in the clan */
#define CLAN_ANTI_PT (1 << 4) /* no Player Thief in the clan */
#define CLAN_ONLY_PK (1 << 5) /* only Player Killer in the clan */
#define CLAN_ONLY_PT (1 << 6) /* only Player Thief in the clan */
#define CLAN_ANTI_MALE (1 << 7)
#define CLAN_ANTI_FEMALE (1 << 8)
/* Clan status: used in clan_data.status */
#define CLAN_FORMING (1 << 0) /* less than MIN_CLAN_MEMBERS clannies */
#define CLAN_ACTIVE (1 << 1) /* normal status of a clan */
#define CLAN_INACTIVE (1 << 2) /* reached the MAX_CLAN_MEMBERS number */
#define CLAN_DISBANDING (1 << 3) /* a clan that's going to die */
#define CLAN_DEAD (1 << 4) /* a dead clan */
/* Clan types: used in clan_data.ctype */
#define CLAN_NORMAL (1 << 0)
#define CLAN_PRIVATE (1 << 1) /* a clan that does not accept new members freely */
#define CLAN_SECRET (1 << 2) /* clan segreto */
struct clan_data
{
CLAN_DATA *next;
char *name; /* nome del clan */
char *abbr; /* abbrevazione (MASSIMO 5 CARATTERI) */
char *leader; /* nome del leader clan */
char *godname; /* name of the sponsor god */
char *motto; /* il motto del clan */
char *warcry; /* il grido di guerra del clan */
sh_int id; /* unique number of the clan */
sh_int members; /* numeri dei membri del clan */
sh_int magistrates; /* number of magistrates in the clan */
sh_int ambassadors; /* number of diplomats in the clan */
sh_int heroes; /* numero degli eroi del clan */
sh_int app_level; /* min level to join the clan */
sh_int max_level; /* max level to be member of the clan */
sh_int status; /* stato del clan */
sh_int ctype; /* tipo di clan */
int anti_class;
int anti_race;
int anti_other;
int power; /* potenza military del clan */
int influence; /* political influence of the clan */
int treasure; /* ricchezza del clan */
int app_fee; /* gold required to join the clan */
int dues; /* quota mensile */
int hall; /* vnum of main clan building */
obj_vnum objs[MAX_CLAN_OBJ]; /* vnum of personalized clan objs */
time_t birth; /* data di formazione del clan */
};
struct politics_data_type
{
sh_int diplomacy[MAX_CLANS][MAX_CLANS];
bool daily_negotiate_table[MAX_CLANS][MAX_CLANS];
bool end_current_state[MAX_CLANS][MAX_CLANS];
};
struct clan_titles
{
char *title_of_rank[3];
};
/* functions */
void save_clans(void);
void init_clans(void);
CLAN_DATA *get_clan(int clan_id);
CLAN_DATA *find_clan(char *name);
----------------------------------------------------------------------------------
/**************************************************************************
* # # # ## # # ### ## ## ###
http://www.lyonesse.it *
* # # # # # ## # # # # # *
* # # # # # ## ## # # ## ## ## # # ## *
* # # # # # ## # # # # # # # # # # # *
* ### # ## # # ### ## ## ### # # #### ## Ver. 1.0 *
* *
* -Based on CircleMud & Smaug- Copyright (c) 2001-2002 by Mithrandir *
* *
* ********************************************************************** */
/**************************************************************************
* File: clan.c Intended to be used with CircleMUD *
* Usage: This is the code for clans *
* By Mehdi Keddache (Heritsun on Eclipse of Fate eclipse.argy.com 7777) *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
* CircleMUD (C) 1993, 94 by the Trustees of the Johns Hopkins University *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "db.h"
#include "interpreter.h"
#include "spells.h"
#include "handler.h"
#include "clan.h"
extern const char *pc_class_types[];
extern const char *pc_race_types[];
/* extern functions */
void smash_tilde(char *str);
void create_building( CHAR_DATA *ch, char *arg, int clan );
/* local functions */
ACMD(do_negotiate);
ACMD(do_clan);
ACMD(do_cset);
ACMD(do_politics);
char *get_diplo_name(sh_int value);
bool check_membership(CHAR_DATA *vict, CLAN_DATA *pClanan);
int num_of_vis_clans(void);
void save_clan_table(void);
void send_clan_format(CHAR_DATA *ch);
void do_clan_create(CHAR_DATA *ch, char *arg);
void do_clan_disband(CHAR_DATA *ch);
void do_clan_revive(CHAR_DATA *ch);
void do_clan_enroll(CHAR_DATA *ch, char *arg);
void do_clan_expel(CHAR_DATA *ch, char *arg);
void do_clan_demote(CHAR_DATA *ch, char *arg);
void do_clan_promote(CHAR_DATA *ch, char *arg);
void do_clan_invite(CHAR_DATA *ch, char *arg);
void do_clan_bank(CHAR_DATA *ch, char *arg, int action);
void do_clan_who(CHAR_DATA *ch);
void do_clan_status(CHAR_DATA *ch);
void do_clan_info(CHAR_DATA *ch, char *arg);
void do_clan_money(CHAR_DATA *ch, char *arg, int action);
void do_clan_application(CHAR_DATA *ch, char *arg);
void do_clan_diplomat(CHAR_DATA *ch, char *arg);
void do_clan_magistrate(CHAR_DATA *ch, char *arg);
void do_clan_hero(CHAR_DATA *ch, char *arg);
void do_clan_apply(CHAR_DATA *ch, char *arg);
void do_clan_set(CHAR_DATA *ch, char *arg);
/* global vars & structs */
int num_of_clans;
CLAN_DATA *clans_table;
CLAN_POLITIC_DATA politics_data;
/* tables */
const char *clan_status_table[] =
{
"Formazione",
"Attivo",
"Inattivo",
"Disabilitato",
"morto",
"\n"
};
const char *clan_types_table[] =
{
"Normale",
"Privato",
"Segreto",
"\n"
};
const char *clan_anti_table[] =
{
"No buono",
"No Neutrale"
"No cattivo",
"No Pkiller",
"No Pthieves",
"Only Pkiller",
"Only Pthieves",
"No Maschi",
"No Femmine",
"\n"
};
const struct clan_titles clan_rank_table[] =
{
{ {"<Invita>", "<Invita>", "<Invita>"} }, /* Invita */
{ {"<Applier>", "<Applier>", "<Applier>"} }, /* Applied */
{ {"<Recruit>", "<Recruit>", "<Recruit>"} },
{ {"<Adept>", "<Adept>", "<Adept>"} },
{ {"<Officer>", "<Officer>", "<Officer>"} },
{ {"<Lieutenant>","<Lieutenant>", "<Lieutenant>"} },
{ {"<Vassal>", "<Vassal>", "<Vassal>"} }, /* 6 */ /* MAX ADVANCE */
{ {"<Ambassador>","<Ambassador>", "<Ambassadress>"} }, /* SPECIAL */
{ {"<Magistrate>","<Magistrate>", "<Magistrate>"} }, /* SPECIAL */
{ {"<Lord>", "<Lord>", "<Lady>"} }, /* SPECIAL */
{ {"<Leader>", "<Leader>", "<Leader>"} }, /* 10 */
{ {"<Patron>", "<Patron>", "<Patron>"} }, /* God creator */
{ { NULL, NULL, NULL } }
};
/* === Clan Utilities Functions =========================== */
CLAN_DATA *get_clan(int idnum)
{
CLAN_DATA *pClan;
if (idnum == -1)
return (NULL);
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (pClan->id == idnum)
break;
}
return (pClan);
}
CLAN_DATA *find_clan(char *name)
{
CLAN_DATA *pClan;
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (!str_cmp(pClan->name, name))
break;
}
return (pClan);
}
/*
* return the number of visible (non-secret) clans
*/
int num_of_vis_clans(void)
{
CLAN_DATA *pClan;
int num = 0;
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (!IS_SET(pClan->ctype, CLAN_SECRET))
num++;
}
return (num);
}
/* === Clan Files handling Functions =========================== */
void fwrite_clan(CLAN_DATA *pClan)
{
FILE *fp;
char fname[128];
sprintf(fname, "%s%d.clan", LIB_CLANS, pClan->id );
if ( !(fp = fopen(fname, "w") ) )
{
log( "SYSERR: unable to create clan file %s.", fname );
return;
}
fprintf( fp, "#CLAN\n" );
fprintf( fp, "ClanID %hd\n", pClan->id );
fprintf( fp, "Nome %s~\n", pClan->name );
fprintf( fp, "Abbr %s\n", pClan->abbr );
fprintf( fp, "Fondatore %s\n", pClan->leader );
fprintf( fp, "Godname %s\n", pClan->godname );
if ( pClan->motto )
fprintf( fp, "Motto %s~\n", pClan->motto );
if ( pClan->warcry )
fprintf( fp, "Warcry %s~\n", pClan->warcry );
fprintf( fp, "Membri %hd\n", pClan->members );
fprintf( fp, "Magistrato %hd\n", pClan->magistrates );
fprintf( fp, "Ambassstore %hd\n", pClan->ambassadors );
fprintf( fp, "Eroi %hd\n", pClan->heroes );
fprintf( fp, "AppLivelli %hd\n", pClan->app_level );
fprintf( fp, "MaxLivelli %hd\n", pClan->max_level );
fprintf( fp, "Status %hd\n", pClan->status );
fprintf( fp, "ClanTipo %hd\n", pClan->ctype );
fprintf( fp, "AntiClasse %d\n", pClan->anti_class );
fprintf( fp, "AntiOther %d\n", pClan->anti_other );
fprintf( fp, "Power %d\n", pClan->power );
fprintf( fp, "Influente %d\n", pClan->influence );
fprintf( fp, "Treasure %d\n", pClan->treasure );
fprintf( fp, "Appfee %d\n", pClan->app_fee );
fprintf( fp, "Dues %d\n", pClan->dues );
fprintf( fp, "Hall %d\n", pClan->hall );
fprintf( fp, "Birth %d\n", pClan->birth );
fprintf( fp, "Oggetti %d %d %d\n",
pClan->objs[0], pClan->objs[1], pClan->objs[2] );
fprintf( fp, "Fine\n" );
fclose(fp);
}
/* Save clan structure to disk */
void save_clans()
{
CLAN_DATA *pClan;
log( "Salvataggio clan" );
for (pClan = clans_table; pClan; pClan = pClan->next)
fwrite_clan(pClan);
}
/*
* Save clan politics structure to disk
*/
void save_clan_table(void)
{
FILE *fl;
if (!(fl = fopen(CLAN_DIP_FILE, "wb")))
{
log("SYSERR: Unable to open clandata file");
return;
}
fwrite(&politics_data, sizeof(CLAN_POLITIC_DATA), 1, fl);
fclose(fl);
}
#if defined(KEY)
#undef KEY
#endif
#define KEY( literal, field, value ) \
if ( !strcmp( word, literal ) ) \
{ \
field = value; \
fMatch = TRUE; \
break; \
}
CLAN_DATA *fread_clan(FILE *fp)
{
CLAN_DATA *pClan;
char *word;
bool fMatch;
CREATE(pClan, CLAN_DATA, 1);
pClan->name = NULL;
pClan->abbr = NULL;
pClan->leader = NULL;
pClan->godname = NULL;
pClan->motto = NULL;
pClan->warcry = NULL;
for ( ; ; )
{
word = feof( fp ) ? "Fine" : fread_word( fp );
fMatch = FALSE;
switch (UPPER(word[0]))
{
case '*':
case '#':
fMatch = TRUE;
fread_to_eol( fp );
break;
case 'A':
KEY("Abbr", pClan->abbr, str_dup(fread_word(fp)));
KEY("Ambassatore", pClan->ambassadors, fread_number(fp));
KEY("AntiClassi", pClan->anti_class, fread_number(fp));
KEY("AntiOther", pClan->anti_other, fread_number(fp));
KEY("AppLevel", pClan->app_level, fread_number(fp));
KEY("Appfee", pClan->app_fee, fread_number(fp));
break;
case 'B':
KEY("Birth", pClan->birth, fread_number(fp));
break;
case 'C':
KEY("ClanID", pClan->id, fread_number(fp));
KEY("ClanTipo", pClan->ctype, fread_number(fp));
break;
case 'D':
KEY("Dues", pClan->dues, fread_number(fp));
break;
case 'E':
if (!strcmp(word, "Fine"))
return (pClan);
break;
case 'G':
KEY("Godname", pClan->godname, str_dup(fread_word(fp)));
break;
case 'H':
KEY("Hall", pClan->hall, fread_number(fp));
KEY("Eroi", pClan->heroes, fread_number(fp));
break;
case 'I':
KEY("Influente", pClan->influence, fread_number(fp));
break;
case 'L':
KEY("Leader", pClan->leader, str_dup(fread_word(fp)));
break;
case 'M':
KEY("Magistr", pClan->magistrates, fread_number(fp));
KEY("MaxLevel", pClan->max_level, fread_number(fp));
KEY("Members", pClan->members, fread_number(fp));
KEY("Motto", pClan->motto, fread_string_nospace(fp));
break;
case 'N':
KEY("Name", pClan->name, fread_string_nospace(fp));
break;
case 'O':
if (!strcmp(word, "Obj"))
{
pClan->objs[0] = fread_number(fp);
pClan->objs[1] = fread_number(fp);
pClan->objs[2] = fread_number(fp);
fMatch = TRUE;
break;
}
break;
case 'P':
KEY("Potenza", pClan->power, fread_number(fp));
break;
case 'S':
KEY("Status", pClan->status, fread_number(fp));
break;
case 'T':
KEY("Treasure", pClan->treasure, fread_number(fp));
break;
case 'W':
KEY("Warcry", pClan->warcry, fread_string_nospace(fp));
break;
}
if (!fMatch)
log("fread_clan: clan file has no match: %s", word);
}
}
/*
* Boot up initialization of clan & clan politics structure
*/
void init_clans(void)
{
FILE *fp;
CLAN_DATA *pClan;
char fname[128];
int i = 0;
num_of_clans = 0;
clans_table = NULL;
for (i = 1; i < MAX_CLANS; i++)
{
sprintf(fname, "%s%d.clan", LIB_CLANS, i);
if ((fp = fopen(fname, "r")))
{
pClan = fread_clan(fp);
fclose(fp);
if (!pClan)
{
log("SYSERR: init_clans() - error reading clan %d.", i);
continue;
}
num_of_clans++;
// add to the list
pClan->next = clans_table;
clans_table = pClan;
}
}
log(" %d clan caricati.", num_of_clans);
if (!(fp = fopen(CLAN_DIP_FILE, "rb")))
{
log(" Clandata file does not exist. Will create a new one");
save_clan_table();
return;
}
fread(&politics_data, sizeof(CLAN_POLITIC_DATA), 1, fp);
fclose(fp);
log( " politica data per clan caricati." );
log( "Clan -- NESSUNO");
}
/*
* Check clan requisite for new members allowance
*/
bool check_membership(CHAR_DATA *vict, CLAN_DATA *pClan )
{
/* ANTI_CLASS check */
if (pClan->anti_class)
{
if ((IS_SET(pClan->anti_class, CLAN_ANTI_MAGE) && GET_CLASS(vict) == CLASS_MAGIC_USER) ||
(IS_SET(pClan->anti_class, CLAN_ANTI_CLERIC) && GET_CLASS(vict) == CLASS_CLERIC) ||
(IS_SET(pClan->anti_class, CLAN_ANTI_THIEF) && GET_CLASS(vict) == CLASS_THIEF) ||
(IS_SET(pClan->anti_class, CLAN_ANTI_SORCERER) && GET_CLASS(vict) == CLASS_SORCERER) ||
(IS_SET(pClan->anti_class, CLAN_ANTI_WARRIOR) && GET_CLASS(vict) == CLASS_WARRIOR))
return (FALSE);
}
/* ANTI_RACE check */
/*if (pClan->anti_race)
{
if ((IS_SET(pClan->anti_race, CLAN_ANTI_UMANO) && GET_RACE(vict) == RACE_UMANO) ||
(IS_SET(pClan->anti_race, CLAN_ANTI_ELFO) && GET_RACE(vict) == RACE_ELFO) ||
(IS_SET(pClan->anti_race, CLAN_ANTI_NANO) && GET_RACE(vict) == RACE_NANO))
return (FALSE);
}*/
/* ANTI_OTHER check */
if (pClan->anti_other)
{
if ((IS_SET(pClan->anti_other, CLAN_ANTI_GOOD) && IS_GOOD(vict)) ||
(IS_SET(pClan->anti_other, CLAN_ANTI_NEUTRAL) && IS_NEUTRAL(vict)) ||
(IS_SET(pClan->anti_other, CLAN_ANTI_EVIL) && IS_EVIL(vict)) ||
(IS_SET(pClan->anti_other, CLAN_ANTI_MALE) && GET_SEX(vict) == SEX_MALE) ||
(IS_SET(pClan->anti_other, CLAN_ANTI_FEMALE) && GET_SEX(vict) == SEX_FEMALE))
return (FALSE);
}
/* aggiungere check x PK, PT */
return (TRUE);
}
/* === Clan User Functions =========================================== */
void send_clan_format(CHAR_DATA *ch)
{
send_to_char("Comandi clan dispoibile a te:\n\r"
" clan info <clan>\r\n",ch);
if (GET_LEVEL(ch) >= LVL_CLAN_GOD)
{
send_to_char(
" clan create <fondatore> <clan tipo> <clan abbrev> 'clan nome'\r\n"
" clan disband\r\n"
" clan arruola <player>\r\n"
" clan espelli <player>\r\n"
" clan promuovi <player>\r\n"
" clan degrada <player>\r\n"
" clan invite <player>\r\n"
" clan diplomazia <player>\r\n"
" clan magistrate <player>\r\n"
" clan hero <player>\r\n"
" clan preleva <amount>\r\n"
" clan deposita <amount>\r\n"
" clan set appfee <amount>\r\n"
" clan set dues <amount>\r\n"
" clan set applev <level>\r\n", ch);
}
else
{
if (GET_CLAN(ch) == -1)
send_to_char(" clan apply <clan>\r\n",ch);
else if (GET_CLAN_RANK(ch) <= RANK_APPLIER)
return;
else
{
int r = GET_CLAN_RANK(ch);
send_to_char(" clan deposita <amount>\r\n",ch);
send_to_char(" clan who\r\n",ch);
send_to_char(" clan status\r\n",ch);
if (r <= MAX_RANK_ADVANCE)
send_to_char(" clan resign\r\n", ch);
if (r >= RANK_PRIVILEGES)
{
send_to_char(" clan preleva <amount>\r\n", ch);
send_to_char(" clan arruola <player>\r\n", ch);
send_to_char(" clan espelli <player>\r\n", ch);
send_to_char(" clan promuovi <player>\r\n", ch);
send_to_char(" clan degrada <player>\r\n", ch);
send_to_char(" clan invita <player>\r\n", ch);
send_to_char(" clan set applev <livel>\r\n", ch);
send_to_char(" clan set appfee <amount>\r\n", ch);
send_to_char(" clan set dues <amount>\r\n", ch);
send_to_char(" clan diplomatico<player>\r\n", ch);
send_to_char(" clan magistrato <player>\r\n", ch);
send_to_char(" clan eroe <player>\r\n", ch);
}
}
}
}
/* create a new clan */
void do_clan_create(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan, *pCl;
CHAR_DATA *leader = NULL;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], arg3[MAX_INPUT_LENGTH];
char *clanname;
int i;
if (!*arg)
{
send_to_char("clan create <leader> <clan tipo> <clan abbrev> 'clan nome'\r\n", ch);
return;
}
if (GET_LEVEL(ch) < LVL_CLAN_GOD)
{
send_to_char("Non sei abbastanza Immortale per creare nuovi clans!\r\n", ch);
return;
}
if (GET_CLAN(ch) != -1 && GET_LEVEL(ch) < LVL_GRGOD)
{
send_to_char("You already are a clan patron.\r\n", ch);
return;
}
if (num_of_clans >= MAX_CLANS - 1)
{
send_to_char("Raggiunto il Massimo dei Regni. WOW!\r\n",ch);
return;
}
arg = two_arguments(arg, arg1, arg2);
arg = one_argument(arg, arg3);
clanname = get_spell_name(arg);
if (clanname == NULL)
{
send_to_char("You need to specify a clan name.\r\n", ch);
return;
}
if (!(*arg2))
{
send_to_char("You need to specify the type of the clan, <normal/private/secret>.\r\n", ch);
return;
}
if (!(*arg3))
{
send_to_char("You need to specify a clan abbreviation of 5 characters.\r\n", ch);
return;
}
if (!(leader = get_char_vis(ch, arg1, NULL, FIND_CHAR_ROOM)))
{
send_to_char("Il leader del nuovo clan deve essere presente.\r\n",ch);
return;
}
if (strlen(arg3) > 5)
{
send_to_char("Clan abbreviation too long! (5 characters max)\r\n", ch);
return;
}
if (strlen(clanname) > CLAN_NAME_L)
{
ch_printf(ch, "Clan name too long! (%d characters max)\r\n", CLAN_NAME_L);
return;
}
if (GET_LEVEL(leader) >= LVL_IMMORT)
{
send_to_char("Non puoi mettere un Immortale a capo di un Clan.\r\n",ch);
return;
}
if (GET_LEVEL(leader) < DEFAULT_APP_LVL)
{
ch_printf(ch, "%s is not mighty enough to be a clan leader.\r\n", GET_NAME(leader));
return;
}
/*
if (GET_CLAN(leader) != -1)
{
send_to_char("The leader already belongs to a clan!\r\n",ch);
return;
}
*/
if ( find_clan(clanname) )
{
send_to_char("That clan name alread exists!\r\n",ch);
return;
}
CREATE(pClan, CLAN_DATA, 1);
pClan->id = num_of_clans;
pClan->abbr = str_dup( CAP((char *)arg3) );
pClan->name = str_dup( CAP((char *)clanname) );
pClan->leader = str_dup( GET_NAME(leader) );
pClan->godname = str_dup( GET_NAME(ch) );
pClan->motto = str_dup( "Lunga vita al clan!" );
pClan->warcry = str_dup( "Per la gloria del clan!" );
pClan->birth = time(0);
pClan->members = 10;
pClan->ambassadors = 0;
pClan->heroes = 0;
pClan->magistrates = 0;
pClan->power = GET_LEVEL(leader) * 2;
pClan->influence = GET_LEVEL(leader);
pClan->treasure = 0;
pClan->hall = NOWHERE;
pClan->app_fee = 0;
pClan->dues = 0;
pClan->app_level = DEFAULT_APP_LVL;
pClan->max_level = LVL_IMMORT - 1;
pClan->anti_class = 0;
pClan->anti_other = 0;
pClan->anti_race = 0;
for (i = 0; i < MAX_CLAN_OBJ; i++)
pClan->objs[i] = NOTHING;
SET_BIT(pClan->status, CLAN_FORMING);
if (is_abbrev(arg2, "privato"))
SET_BIT(pClan->ctype, CLAN_PRIVATE);
else if (is_abbrev(arg2, "secret"))
SET_BIT(pClan->ctype, CLAN_SECRET);
else
SET_BIT(pClan->ctype, CLAN_NORMAL);
/* set up politics */
for (pCl = clans_table; pCl; pCl = pCl->next)
{
politics_data.diplomacy[pClan->id][pCl->id] = 100;
politics_data.diplomacy[pCl->id][pClan->id] = 100;
}
/* save the new clan */
fwrite_clan(pClan);
/* setup the clan god */
if (GET_LEVEL(ch) < LVL_GRGOD)
{
GET_CLAN(ch) = pClan->id;
GET_CLAN_RANK(ch) = RANK_PATRON;
}
send_to_char("Clan creato.\r\n", ch);
GET_CLAN(leader) = pClan->id;
GET_CLAN_RANK(leader) = RANK_LEADER;
save_char(leader, NULL);
ch_printf(leader, "Ora sei il leader della nuovo clan creato '%s'.\r\n", pClan->name);
/* add to the list */
pClan->next = clans_table;
clans_table = pClan;
num_of_clans++;
log("CLAN: nuovo clan, '%s', creato da %s.", pClan->name, GET_NAME(ch));
}
/*
* functions to disband and revive a clan (Only PATRON)
*
*/
void do_clan_disband(CHAR_DATA *ch)
{
CLAN_DATA *pClan;
if (!(pClan = get_clan(GET_CLAN(ch))))
{
send_to_char("Problemi con tuo clan... \r\n", ch);
return;
}
if (IS_SET(pClan->status, CLAN_DISBANDING))
{
send_to_char("Your clan is already in the disbandig status.\r\n", ch);
return;
}
SET_BIT(pClan->status, CLAN_DISBANDING);
send_to_char("You have initiated the disband of your clan.\r\n", ch);
log("CLAN: Clan %s (%d) set to disbanding status.", pClan->name, pClan->id);
fwrite_clan( pClan );
}
void do_clan_revive(CHAR_DATA *ch)
{
CLAN_DATA *pClan;
if (!(pClan = get_clan(GET_CLAN(ch))))
{
send_to_char("Problemi con tuo clan... \r\n", ch);
return;
}
if (!IS_SET(pClan->status, CLAN_DISBANDING))
{
send_to_char("Your clan is alive.\r\n", ch);
return;
}
REMOVE_BIT(pClan->status, CLAN_DISBANDING);
send_to_char("You have revived your clan form disbanding.\r\n", ch);
log("CLAN: Clan %s (%d) revived from disbanding status.", pClan->name, pClan->id);
fwrite_clan( pClan );
}
/* ---------------------------------------------------------------------- *
* Funzioni per arruolare, invitare, promuovere, retrocedere e cacciare *
* pg dal clan *
* ---------------------------------------------------------------------- */
/*
* Enroll characters that have applied to the clan
*/
void do_clan_enroll(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
int immcom = 0;
if (!(*arg))
{
send_clan_format(ch);
return;
}
if (GET_LEVEL(vict) >= LVL_IMMORT)
{
send_to_char("Non puoi arruolare immortali nel clan.\r\n",ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("E, Chi ??\r\n",ch);
return;
}
if (GET_CLAN(vict) != GET_CLAN(ch))
{
send_to_char("They didn't request to join your clan.\r\n",ch);
return;
}
if (GET_CLAN_RANK(vict) != RANK_APPLIER)
{
act("$N has not applied for membership.", FALSE, ch, NULL, vict, TO_CHAR);
return;
}
if (GET_LEVEL(vict) < pClan->app_level)
{
act("$N doesn't have enough experience to be a member of your clan.", FALSE, ch, NULL, vict, TO_CHAR);
return;
}
if (GET_LEVEL(vict) > pClan->max_level)
{
act("$N è troppo potente per essere un membro della vostra clan.", FALSE, ch, NULL, vict, TO_CHAR);
return;
}
if (!check_membership(vict, pClan))
{
act("Sorry, but $N cannot be a member of the clan.", FALSE, ch, NULL, vict, TO_CHAR);
return;
}
/* all right, now enroll lui/lei */
GET_CLAN_RANK(vict) = RANK_MEMBER_FIRST;
save_char(vict, NULL);
pClan->power += GET_LEVEL(vict);
pClan->members++;
if ( pClan->members >= MIN_CLAN_MEMBERS && IS_SET(pClan->status, CLAN_FORMING) )
{
REMOVE_BIT(pClan->status, CLAN_FORMING);
SET_BIT(pClan->status, CLAN_ACTIVE);
send_to_char("Your clan has reached the minimum number of members allowed.\r\n"
"From now the clan can act as normal.\r\n", ch);
log( " '%s' (%d) clan is now active.", pClan->name, pClan->id );
}
if ( pClan->members == MAX_CLAN_MEMBERS )
{
REMOVE_BIT(pClan->status, CLAN_ACTIVE);
SET_BIT(pClan->status, CLAN_INACTIVE);
send_to_char("Your clan has reached the maximum number of members allowed.\r\n", ch);
}
sprintf(buf, "You've been enrolled in '%s' clan!\r\n", pClan->name );
send_to_char(buf, vict);
send_to_char("Done.\r\n", ch);
}
/*
* Kick off from the clan unwanted members
*/
void do_clan_expel(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
int immcom = 0;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan( GET_CLAN(ch) );
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("E, chi ??\r\n", ch);
return;
}
if (GET_CLAN(vict) != pClan->id)
{
send_to_char("They're not in your clan.\r\n",ch);
return;
}
if (GET_CLAN_RANK(vict) >= GET_CLAN_RANK(ch))
{
send_to_char("You cannot kick out that person.\r\n",ch);
return;
}
GET_CLAN(vict) = -1;
GET_CLAN_RANK(vict) = -1;
save_char(vict, NULL);
pClan->power -= GET_LEVEL(vict);
pClan->members--;
if (pClan->members < MIN_CLAN_MEMBERS)
{
REMOVE_BIT(pClan->status, CLAN_ACTIVE);
SET_BIT(pClan->status, CLAN_FORMING);
}
if (IS_SET(pClan->status, CLAN_INACTIVE))
{
REMOVE_BIT(pClan->status, CLAN_INACTIVE);
SET_BIT(pClan->status, CLAN_ACTIVE);
}
send_to_char("You've been kicked out of your clan!\r\n", vict);
send_to_char("Done.\r\n", ch);
}
/*
* Demote a clannie
*/
void do_clan_demote(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
int immcom = 0;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("Er, chi ??\r\n", ch);
return;
}
if (GET_CLAN(vict) != pClan->id)
{
send_to_char("They're not in your clan.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) == 0 || GET_CLAN_RANK(vict) == RANK_INVITED)
{
send_to_char("They're not enrolled yet.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) == RANK_MEMBER_FIRST)
{
send_to_char("They can't be demoted any further, use expel now.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) >= GET_CLAN_RANK(ch))
{
send_to_char("You cannot demote a person of this rank!\r\n", ch);
return;
}
/* hanlde those special ranks above 6 */
if (GET_CLAN_RANK(vict) > MAX_RANK_ADVANCE)
{
if (GET_CLAN_RANK(vict) == RANK_HERO)
pClan->heroes--;
else if (GET_CLAN_RANK(vict) == RANK_MAGISTRATE)
pClan->magistrates--;
else if (GET_CLAN_RANK(vict) == RANK_DIPLOMAT)
pClan->ambassadors--;
else
{
send_to_char("Leader o Patrone non possono essere retrocessi\r\n", ch);
return;
}
GET_CLAN_RANK(vict) = MAX_RANK_ADVANCE;
}
else
GET_CLAN_RANK(vict)--;
save_char(vict, NULL);
send_to_char("You've demoted within your clan!\r\n", vict);
send_to_char("Done.\r\n", ch);
}
/*
* Promote a clannie
*/
void do_clan_promote(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("E, chi ??\r\n", ch);
return;
}
if (GET_CLAN(vict) != pClan->id)
{
send_to_char("They're not in your clan.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) == 0 || GET_CLAN_RANK(vict) == RANK_INVITED)
{
send_to_char("They're not enrolled yet.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) >= GET_CLAN_RANK(ch))
{
send_to_char("You cannot promote that person over your rank!\r\n",ch);
return;
}
if (GET_CLAN_RANK(vict) == MAX_RANK_ADVANCE)
{
send_to_char("You cannot promote someone over the top reachable rank!\r\n",ch);
return;
}
GET_CLAN_RANK(vict)++;
save_char(vict, NULL);
send_to_char("You've been promoted within your clan!\r\n", vict);
send_to_char("Done.\r\n", ch);
}
/*
* Invite someone in your clan
*/
void do_clan_invite(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("E, chi ??\r\n", ch);
return;
}
if (GET_CLAN(vict) > 0)
{
sprintf(buf, "%s appartiene già a un clan.\r\n", GET_NAME(vict));
send_to_char(buf, ch);
return;
}
if (!check_membership(vict, pClan))
{
sprintf(buf, "Ci dispiace, ma % s non può essere un membro del vostro clan .\r\n", GET_NAME(vict));
send_to_char(buf, ch);
return;
}
GET_CLAN(vict) = GET_CLAN(ch);
GET_CLAN_RANK(vict) = RANK_INVITED;
save_char(vict, NULL);
sprintf(buf, "Sei stato invitato da %s to apply to '%s' clan!\r\n", GET_NAME(ch), pClan->name);
send_to_char(buf, vict);
send_to_char("Fatto.\r\n", ch);
}
/*
* build a building for the clan
*/
void do_clan_build(CHAR_DATA *ch, char *arg)
{
if ( !*arg )
{
send_to_char("What do you want to build for your clan?\r\n", ch);
return;
}
create_building(ch, arg, GET_CLAN(ch));
}
/* ---------------------------------------------------------------------- */
/*
* Handling money of the clan
*/
void do_clan_bank(CHAR_DATA *ch, char *arg, int action)
{
CLAN_DATA *pClan;
int amount = 0;
if (!(*arg))
{
send_clan_format(ch);
return;
}
if (GET_CLAN_RANK(ch) < RANK_PRIVILEGES || GET_CLAN_RANK(ch) > RANK_PATRON)
{
if (action == CB_WITHDRAW)
{
send_to_char("You're not influent enough in the clan to do that!\r\n",ch);
return;
}
}
pClan = get_clan(GET_CLAN(ch));
if (!(*arg))
{
if ( action == CB_DEPOSIT )
send_to_char("Quante monete vuoi depositare?\r\n",ch);
else
send_to_char("Quante monete vuoi ritirare?\r\n",ch);
return;
}
if (!is_number(arg))
{
send_to_char("That's not a monetary amount!\r\n",ch);
return;
}
amount = atoi(arg);
if (action == CB_DEPOSIT && get_gold(ch) < amount)
{
send_to_char("You do not have that kind of money!\r\n", ch);
return;
}
if (action == CB_WITHDRAW && pClan->treasure < amount)
{
send_to_char("Il clan non è abbastanza ricco per le vostre esigenze!\r\n", ch);
return;
}
switch (action)
{
case CB_WITHDRAW:
create_amount(amount, ch, NULL, NULL, NULL, FALSE);
pClan->treasure -= amount;
send_to_char("Tu ritiri del tesoro dal clan.\r\n", ch);
break;
case CB_DEPOSIT:
sub_gold(ch, amount);
pClan->treasure += amount;
send_to_char("Si aggiunge al tesoro del clan.\r\n", ch);
break;
default:
send_to_char("Problem in command, please report.\r\n", ch);
break;
}
save_char(ch, NULL);
fwrite_clan(pClan);
}
/* ---------------------------------------------------------------------- */
/*
* Which members of the clan are playing?
*/
void do_clan_who(CHAR_DATA *ch)
{
DESCRIPTOR_DATA *d;
CHAR_DATA *tch;
char line_disp[MAX_STRING_LENGTH];
if (GET_CLAN_RANK(ch) == 0 || GET_CLAN_RANK(ch) == RANK_INVITED)
{
send_to_char("Tu non sei accettato dal clan, ma.\r\n", ch);
return;
}
send_to_char("\r\n&b&4-===========&b&1}&b&3****&b&1(&b&3O &b&7Informazioni sulla citta'(Membri) &b&3O&b&1)&b&3****&b&1{&b&4============-&b&7\r\n", ch);
send_to_char("-------------------------\r\n", ch);
for (d = descriptor_list; d; d = d->next)
{
if (d->connected)
continue;
if ((tch = d->character))
{
if (GET_CLAN(tch) == GET_CLAN(ch) && GET_CLAN_RANK(tch) > 0)
{
sprintf(line_disp,"(%20s) %s\r\n", GET_RANK_NAME(tch), GET_NAME(tch));
send_to_char(line_disp,ch);
}
}
}
}
/*
* clannie's status
*/
void do_clan_status(CHAR_DATA *ch)
{
CLAN_DATA *pClan;
char line_disp[MAX_STRING_LENGTH];
if (IS_IMMORTAL(ch))
{
send_to_char("Tu sei un immortale e non puoi unirti a nessun clan!\r\n", ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (GET_CLAN_RANK(ch) == 0)
sprintf(line_disp, "È stato applicato a '%s'\r\n", pClan->name);
else if (GET_CLAN_RANK(ch) == RANK_INVITED)
sprintf(line_disp, "Sei stato invitato a applicare al '%s'\r\n", pClan->name);
else
sprintf(line_disp, "Tu sei &b&1%s &b&3[&b&7Rango %d&b&3] di '%s' (ID %d)\r\n",
GET_RANK_NAME(ch), GET_CLAN_RANK(ch), pClan->name, pClan->id);
send_to_char(line_disp, ch);
}
/*
* List of clans (no args) or detailed infos about the clan
*/
void do_clan_info(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
int i = 0;
char buf9[10];
char ctypes[128], cstat[128], cant1[128], cant2[128], cant3[128];
if (num_of_clans == 0)
{
send_to_char("No clans have formed yet.\r\n",ch);
return;
}
strcpy(buf, "&b&4-===========&b&1}&b&3****&b&1(&b&3O &b&7Associazioni di The Gate &b&3O&b&1)&b&3****&b&1{&b&4============-&b&7\r\n");
if (!(*arg))
{
for (pClan = clans_table; pClan; pClan = pClan->next)
{
strcpy(buf9, " ");
if (IS_SET(pClan->ctype, CLAN_SECRET))
{
if (GET_LEVEL(ch) < LVL_GRGOD && GET_CLAN(ch) != pClan->id)
continue;
else
strcpy(buf9, "(S)");
}
if (IS_SET(pClan->ctype, CLAN_PRIVATE))
strcpy(buf9, "(P)");
sprintf(buf + strlen(buf),
"[%-2d] %s &b&3%-35s &b&7[&b&1%-5s&b&7] Membri: %3d Potenza: %5d Appfee: %d\r\n",
pClan->id, buf9, pClan->name, pClan->abbr, pClan->members,
pClan->power, pClan->app_fee);
}
page_string(ch->desc,buf, 1);
return;
}
else
{
if ( !(pClan = find_clan(arg) ) )
{
send_to_char("Clan sconosciuto.\r\n", ch);
return;
}
}
if (IS_SET(pClan->ctype, CLAN_SECRET) && GET_LEVEL(ch) < LVL_GRGOD &&
GET_CLAN(ch) != pClan->id )
{
send_to_char("Clan sconosciuto.\r\n", ch);
return;
}
if ( pClan->ctype )
sprintbit( pClan->ctype, clan_types_table, ctypes );
else
strcpy( ctypes, "None");
if ( pClan->status )
sprintbit( pClan->status, clan_status_table, cstat );
else
strcpy( cstat, "None");
if ( pClan->anti_class )
sprintbit( pClan->anti_class, pc_class_types, cant1 );
else
strcpy( cant1, "None");
if ( pClan->anti_race )
sprintbit( pClan->anti_race, pc_race_types, cant2 );
else
strcpy( cant2, "None");
if ( pClan->anti_other )
sprintbit( pClan->anti_other, clan_anti_table, cant3 );
else
strcpy( cant3, "None");
sprintf(buf,
"\r\n&b&7Info per clan&0 <<&b&3%s&0>>:\r\n\r\n"
"Abbreviation : %s\r\n"
"Leader : %s\r\n"
"Membri : %d\r\n"
"Potenza : %d\r\n"
"Tesoro : %d\r\n"
"Application fee : %d monete d'oro\r\n"
"Monthly Dues : %d monete d'oro\r\n"
"Application level : %d\r\n"
"Max level : %d\r\n"
"Clan Tipo : %s\r\n"
"Clan Status : %s\r\n"
"Classe restrictions: %s\r\n"
"Razza restrictions : %s\r\n"
"Other restrictions : %s\r\n",
pClan->name, pClan->abbr, pClan->leader,
pClan->members, pClan->power, pClan->treasure,
pClan->app_fee, pClan->dues, pClan->app_level,
pClan->max_level, ctypes, cstat, cant1, cant2, cant3
);
send_to_char(buf, ch);
}
/* ---------------------------------------------------------------------- */
/* Funzioni chiamate da Set */
/* ---------------------------------------------------------------------- */
/*
* Set the application fee and the monthly dues
*/
void do_clan_money(CHAR_DATA *ch, char *arg, int action)
{
CLAN_DATA *pClan;
int amount = 0;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(*arg))
{
send_to_char("Set it to how much?\r\n", ch);
return;
}
if (!is_number(arg))
{
send_to_char("Set it to what?\r\n", ch);
return;
}
amount = atoi(arg);
switch (action)
{
case CM_APPFEE:
pClan->app_fee = amount;
send_to_char("È possibile modificare la quota di iscrizione.\r\n", ch);
break;
case CM_DUES:
pClan->dues = amount;
send_to_char("È possibile modificare le quote mensili.\r\n", ch);
break;
default:
send_to_char("Problem in command, please report.\r\n", ch);
break;
}
fwrite_clan( pClan );
}
/*
* Set the minimum application level to the clan
*/
void do_clan_application(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
int applevel;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(*arg))
{
send_to_char("Set to which level?\r\n", ch);
return;
}
if (!is_number(arg))
{
send_to_char("Set the application level to what?\r\n", ch);
return;
}
applevel = atoi(arg);
if (applevel < 1 || applevel > (LVL_IMMORT - 1))// 2
{
sprintf(buf, "Il livello di applicazione può andare da 1 a %d.\r\n", (LVL_IMMORT - 1));// 2
send_to_char(buf, ch);
return;
}
pClan->app_level = applevel;
fwrite_clan( pClan );
}
/*
* Nomina ad uno dei rank speciali:
*
* - diplomatico (gestisce le relazioni con altri clan)
* - magistrato (amministratore del clan)
* - eroe (comandante in guerra)
*/
void do_clan_specialrank(CHAR_DATA *ch, char *rank, char *arg)
{
CLAN_DATA *pClan;
CHAR_DATA *vict = NULL;
if (!(*arg))
{
send_clan_format(ch);
return;
}
pClan = get_clan(GET_CLAN(ch));
if (!(vict = get_char_room_vis(ch, arg, NULL)))
{
send_to_char("E, chi ??\r\n", ch);
return;
}
if (GET_CLAN(vict) != pClan->id)
{
send_to_char("Non sono nel tuo clan.\r\n", ch);
return;
}
if (GET_CLAN_RANK(vict) < RANK_MEMBER_FIRST)
{
send_to_char("Non sono ancora iscritto.\r\n", ch);
return;
}
if ( !isname( rank, "diplomatico magistrato eroe" ) )
{
log( "SYSERR: clan_specialrank() : unknown special rank %s", rank );
sprintf( buf, "%s: Rango sconosciuto.\r\n", rank );
}
else
{
if ( isname( rank, "diplomatico") )
{
GET_CLAN_RANK(vict) = RANK_DIPLOMAT;
pClan->ambassadors++;
sprintf(buf, "%s è oggi un diplomatico del vostro clan.\r\n", GET_NAME(vict));
send_to_char("Ora sei un diplomatico del vostro clan.\r\n", vict);
}
else if ( isname( rank, "magistrato" ) )
{
GET_CLAN_RANK(vict) = RANK_MAGISTRATE;
pClan->magistrates++;
sprintf(buf, "%s ora è un magistrato del vostro clan.\r\n", GET_NAME(vict));
send_to_char("Ora sei un magistrato del vostro clan.\r\n", vict);
}
else if ( isname( rank, "eroe" ) )
{
GET_CLAN_RANK(vict) = RANK_HERO;
pClan->heroes++;
sprintf(buf, "%s ora e un erore del vostro clan.\r\n", GET_NAME(vict));
send_to_char("Ora sei un eroe del vostro clan.\r\n", vict);
}
save_char(vict, NULL);
fwrite_clan( pClan );
}
send_to_char(buf, ch);
}
/*
* solo per diplomatici
*/
ACMD(do_negotiate)
{
CLAN_DATA *chclan, *tclan;
char buf[MAX_STRING_LENGTH];
char arg1[MAX_STRING_LENGTH];
char arg2[MAX_STRING_LENGTH];
sh_int target_clan;
argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);
if (IS_NPC(ch) || GET_CLAN_RANK(ch) != RANK_DIPLOMAT)
{
send_to_char( "Questo comando serve solo per i clan diplomatici.\r\n", ch );
return;
}
if (!is_number(arg1) || !(*arg2))
{
send_to_char( "Syntax: Negotiate <numero clan> <pace/guerra/fine>\r\n", ch );
return;
}
target_clan = atoi(arg1);
if ((target_clan < 1) || (target_clan > (MAX_CLANS - 1)))
{
send_to_char("Questo non è un clan!\r\n", ch);
return;
}
if (target_clan == GET_CLAN(ch))
{
send_to_char("Well, that will accomplish a lot.. you must be of two minds about the whole thing!\r\n", ch );
return;
}
if ( !(tclan = get_clan(target_clan) ) )
{
send_to_char("Questo clan non esiste!\r\n", ch);
return;
}
if (IS_SET(tclan->ctype, CLAN_SECRET))
{
send_to_char("Questo clan non esiste!\r\n", ch);
return;
}
chclan = get_clan(GET_CLAN(ch));
if (IS_SET(chclan->ctype, CLAN_SECRET))
{
send_to_char("Il vostro è un clan segreto! Non ci sono esigenze di negoziati.\r\n", ch);
return;
}
if (politics_data.daily_negotiate_table[chclan->id][tclan->id])
{
sprintf(buf, "Il clan ha già negoziato con %s today.\r\n", tclan->name);
send_to_char(buf, ch);
return;
}
/* P A C E */
if (!str_cmp(arg2, "pace"))
{
if (politics_data.diplomacy[chclan->id][tclan->id] < -450)
{
if (politics_data.end_current_state[chclan->id][tclan->id] &&
politics_data.end_current_state[tclan->id][chclan->id])
{
politics_data.diplomacy[chclan->id][tclan->id] = -425;
politics_data.diplomacy[tclan->id][chclan->id] = -425;
send_to_char("È stato negoziato una fine a questa guerra di clan temuto. ottimo lavoro!!\r\n", ch);
sprintf(buf, "CLAN: The war between %s and %s has ended. They may no longer PKILL each other!!\r\n",
chclan->name, tclan->name);
send_to_all(buf);
politics_data.end_current_state[chclan->id][tclan->id] = FALSE;
politics_data.end_current_state[tclan->id][chclan->id] = FALSE;
}
else
{
sprintf(buf, "You are currently at WAR with %s."
"Both clans must negotiate an end to the war first.\r\n",
tclan->name);
send_to_char(buf, ch);
return;
}
}
else
{
politics_data.diplomacy[chclan->id][tclan->id] += 25;
politics_data.diplomacy[tclan->id][chclan->id] += 25;
sprintf(buf, "You are requesting a more peaceful state of affairs with %s.\r\n",
tclan->name );
send_to_char(buf, ch);
}
}
/* W A R */
else if (!str_cmp(arg2, "war"))
{
if ((politics_data.diplomacy[chclan->id][tclan->id] - 50) < -450)
{
sprintf(buf, "You have started a WAR with %s! Watch out!.\r\n", tclan->name);
send_to_char(buf, ch);
sprintf(buf, "CLAN: A war has started between %s and %s. They may now PKILL each other!!\r\n",
chclan->name, tclan->name);
send_to_all(buf);
politics_data.diplomacy[chclan->id][tclan->id] = -460;
politics_data.diplomacy[tclan->id][chclan->id] = -460;
politics_data.end_current_state[chclan->id][tclan->id] = FALSE;
politics_data.end_current_state[tclan->id][chclan->id] = FALSE;
}
else
{
politics_data.diplomacy[chclan->id][tclan->id] -= 50;
politics_data.diplomacy[tclan->id][chclan->id] -= 50;
sprintf(buf, "You are requesting a more aggressive state of affairs with %s.\r\n", tclan->name);
send_to_char(buf, ch);
}
}
/* E N D */
else if (!str_cmp(arg2, "end"))
{
if (politics_data.diplomacy[chclan->id][tclan->id] > 450 )
{
send_to_char("You are negotiating an end to your alliance.\r\n", ch);
politics_data.end_current_state[chclan->id][tclan->id] = FALSE;
politics_data.end_current_state[tclan->id][chclan->id] = FALSE;
politics_data.diplomacy[chclan->id][tclan->id] = 100;
politics_data.diplomacy[tclan->id][chclan->id] = 100;
}
if (politics_data.diplomacy[chclan->id][tclan->id] < -450 )
{
politics_data.end_current_state[chclan->id][tclan->id] = TRUE;
if (politics_data.end_current_state[chclan->id][tclan->id] &&
politics_data.end_current_state[tclan->id][chclan->id])
send_to_char("Both clans have successfully negotiated and end to the war. Negotiate peace to seal your treaty!\r\n", ch);
else
send_to_char("You have requested an end to this dreaded war, but the other clan has not yet agreed.\r\n", ch);
}
else
{
send_to_char("You must be either at war or in an alliance with a clan before you can END it.\r\n", ch);
return;
}
}
else
{
send_to_char( "That is not a legal diplomatic negotiation!\n\r", ch );
return;
}
politics_data.daily_negotiate_table[chclan->id][tclan->id] = TRUE;
/* save table to file here */
save_clan_table();
}
/*
* Character ask to be allowed to be members of the clan
*/
void do_clan_apply(CHAR_DATA *ch, char *arg)
{
CLAN_DATA *pClan;
if (!(*arg))
{
send_clan_format(ch);
return;
}
if (GET_LEVEL(ch) >= LVL_IMMORT)
{
send_to_char("Gods cannot apply for any clan.\r\n", ch);
return;
}
if (GET_CLAN(ch) != -1)
{
send_to_char("You already belong to a clan!\r\n",ch);
return;
}
if (!(pClan = find_clan(arg)))
{
send_to_char("Unknown clan.\r\n", ch);
return;
}
if (IS_SET(pClan->ctype, CLAN_SECRET) && GET_CLAN_RANK(ch) != RANK_INVITED)
{
send_to_char("Unknown clan.\r\n", ch);
return;
}
if (IS_SET(pClan->status, CLAN_INACTIVE) || IS_SET(pClan->status, CLAN_DISBANDING))
{
send_to_char("Sorry, but the clan does not accept new members at the moment.\r\n", ch);
return;
}
if (IS_SET(pClan->ctype, CLAN_PRIVATE) && GET_CLAN_RANK(ch) != RANK_INVITED)
{
send_to_char("Sorry, but you have to be invited to join the clan before apply.\r\n", ch);
return;
}
if (GET_LEVEL(ch) < pClan->app_level)
{
send_to_char("You are not mighty enough to apply to this clan.\r\n",ch);
return;
}
if (GET_LEVEL(ch) > pClan->max_level)
{
send_to_char("Sei troppo potente da apply a questo clan.\r\n",ch);
return;
}
if (!check_membership(ch, pClan))
{
send_to_char("Sorry, but you cannot be a member of this clan.\r\n", ch);
return;
}
if ( get_gold(ch) < pClan->app_fee)
{
send_to_char("You cannot afford the application fee!\r\n", ch);
return;
}
sub_gold(ch, pClan->app_fee);
pClan->treasure += pClan->app_fee;
fwrite_clan(pClan);
GET_CLAN(ch) = pClan->id;
GET_CLAN_RANK(ch) = RANK_APPLIER;
save_char(ch, NULL);
send_to_char("ti sei iscritto al clan!\r\n",ch);
}
/* core of clan command */
void do_clan_set(CHAR_DATA *ch, char *arg)
{
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
half_chop(arg, arg1, arg2);
if (is_abbrev(arg1, "dues" )) { do_clan_money(ch, arg2, CM_DUES); return ;}
if (is_abbrev(arg1, "appfee" )) { do_clan_money(ch, arg2, CM_APPFEE); return ;}
if (is_abbrev(arg1, "applev" )) { do_clan_application(ch, arg2); return ;}
send_clan_format(ch);
}
ACMD(do_clan)
{
char arg1[MAX_INPUT_LENGTH], *arg2;
arg2 = one_argument(argument, arg1);
skip_spaces(&arg2);
if (is_abbrev(arg1, "apply" )) { do_clan_apply(ch, arg2); return; }
if (is_abbrev(arg1, "info" )) { do_clan_info(ch, arg2); return; }
// no clan member.. handle gods that wanna create a clan
if (GET_CLAN(ch) == -1 || !get_clan(GET_CLAN(ch)))
{
if (GET_LEVEL(ch) >= LVL_CLAN_GOD && isname(arg1, "create"))
do_clan_create(ch, arg2);
else
{
send_to_char("You do not belong to a clan!\r\n",ch);
send_clan_format(ch);
}
return;
}
// unranked ppl exit here..
if (GET_CLAN_RANK(ch) <= RANK_APPLIER)
return;
/* some checks to see if he can use that command */
if (isname(arg1, "disband revive magistrate hero") && GET_CLAN_RANK(ch) < RANK_LEADER)
{
send_to_char("You're not influent enough in the clan to do that!\r\n", ch);
return;
}
if (isname(arg1, "build enroll expel demote promote invite set diplomat") &&
GET_CLAN_RANK(ch) < RANK_PRIVILEGES)
{
send_to_char("You're not influent enough in the clan to do that!\r\n", ch);
return;
}
/* Gods or God Patron only */
if (is_abbrev(arg1, "create" )) { do_clan_create(ch, arg2); return; }
if (is_abbrev(arg1, "disband" )) { do_clan_disband(ch); return; }
if (is_abbrev(arg1, "revive" )) { do_clan_revive(ch); return; }
/* Privileged members only */
if (is_abbrev(arg1, "build" )) { do_clan_build(ch, arg2); return; }
if (is_abbrev(arg1, "demote" )) { do_clan_demote(ch, arg2); return; }
if (is_abbrev(arg1, "enroll" )) { do_clan_enroll(ch, arg2); return; }
if (is_abbrev(arg1, "expel" )) { do_clan_expel(ch, arg2); return; }
if (is_abbrev(arg1, "invita" )) { do_clan_invite(ch, arg2); return; }
if (is_abbrev(arg1, "promote" )) { do_clan_promote(ch, arg2); return; }
if (is_abbrev(arg1, "set" )) { do_clan_set(ch, arg2); return; }
if (isname(arg1, "diplomat magistrate hero"))
{
do_clan_specialrank(ch, arg1, arg2);
return;
}
if (is_abbrev(arg1, "preleva" )) { do_clan_bank(ch, arg2, CB_WITHDRAW); return ;}
if (is_abbrev(arg1, "deposita" )) { do_clan_bank(ch, arg2, CB_DEPOSIT); return ;}
/* all members */
if (is_abbrev(arg1, "who" )) { do_clan_who(ch); return ;}
if (is_abbrev(arg1, "status" )) { do_clan_status(ch); return ;}
send_clan_format(ch);
}
/*
* commands for everyone
*/
/* show what's going on in politic field */
char *get_diplo_name(sh_int value)
{
char *name = '\0';
if ( value < -450 ) name = " WAR ";
else if ( value < -300 ) name = "HATRED ";
else if ( value < -150 ) name = "DISLIKE";
else if ( value < 150 ) name = "NEUTRAL";
else if ( value < 300 ) name = "RESPECT";
else if ( value < 450 ) name = " TRUST ";
else name = " ALLY ";
return (name);
}
ACMD(do_politics)
{
CLAN_DATA *pClan, *pClan2;
char buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
if (IS_NPC(ch))
{
send_to_char("Not for Npcs.\r\n", ch);
return;
}
send_to_char("Current Politics of Lyonesse Mud\r\n\r\n", ch);
if (num_of_vis_clans() < 2)
{
send_to_char("Too few clans to have politics, sorry.\r\n", ch);
return;
}
buf[0] = '\0';
buf2[0] = '\0';
sprintf(buf, " ");
strcat(buf2, buf);
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (IS_SET(pClan->ctype, CLAN_SECRET))
continue;
sprintf(buf, " %-5s ", pClan->abbr);
strcat(buf2, buf);
}
buf[0] = '\0';
sprintf(buf, "\r\n\r\n");
strcat(buf2, buf);
send_to_char(buf2 , ch);
for (pClan = clans_table; pClan; pClan = pClan->next)
{
/* clan symbol here */
buf[0] = '\0';
buf2[0] = '\0';
if (IS_SET(pClan->ctype, CLAN_SECRET) && GET_LEVEL(ch) < LVL_GRGOD)
continue;
sprintf(buf,"%1i %-5s ", pClan->id, pClan->abbr);
strcat(buf2, buf);
for (pClan2 = clans_table; pClan2; pClan2 = pClan2->next)
{
buf[0] = '\0';
if (IS_SET(pClan2->ctype, CLAN_SECRET) && GET_LEVEL(ch) < LVL_GRGOD)
continue;
if (pClan->id != pClan2->id)
sprintf(buf, "%-7s ", get_diplo_name(politics_data.diplomacy[pClan->id][pClan2->id]));
else
sprintf(buf, " ");
strcat(buf2, buf);
}
sprintf(buf, "\n\r\n\r");
strcat(buf2, buf);
send_to_char( buf2, ch );
}
if (GET_CLAN_RANK(ch) == RANK_DIPLOMAT)
{
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (politics_data.end_current_state[GET_CLAN(ch)][pClan->id])
{
sprintf(buf, "%s has requested an end to your current state of affairs", pClan->name);
send_to_char(buf, ch);
}
}
}
}
void show_clan_politic( CHAR_DATA *ch, int idnum )
{
CLAN_DATA *pClan;
if ( !ch || !get_clan(idnum) )
return;
for (pClan = clans_table; pClan; pClan = pClan->next)
{
if (pClan->id == idnum)
continue;
if (IS_SET(pClan->ctype, CLAN_SECRET) && GET_LEVEL(ch) < LVL_GRGOD)
continue;
ch_printf(ch, "Clan (%d) %s: --> %s <--\r\n",
pClan->id, pClan->name,
get_diplo_name(politics_data.diplomacy[idnum][pClan->id]) );
}
}
===============================================================
questi sono i due file che riguardano i clan sinceramente non so quale il problema mah speriamo che si posso risolvere sto problemino attendo risposte se e possibile nel fra tempo buona serata;)