Welcome to the Builder Academy

Question Will this snippet work as is with tba ?

More
08 Apr 2016 13:13 - 08 Apr 2016 13:25 #5730 by JTP
Will this work as is, and just change the send_to_char to match tba ? Or what more needs to be changed ??

Or do any of you have a Clan patch that Works with tba ?
Code:
in structs.h: #define CLAN_RANK_INITIATE 1 #define CLAN_RANK_APPRENTICE 2 #define CLAN_RANK_MEMBER 3 #define CLAN_RANK_MASTER 4 #define CLAN_RANK_LEADER 5 #define GET_CLAN_NAME(ch) ((ch)->player_specials->saved.clan_name) #define GET_CLAN_RANK(ch) ((ch)->player_specials->saved.clan_rank) #define MAX_CLAN_LENGTH 8 ----------------------------------------------------------------------- in structs.h, struct player_special_data_saved: char clan_name[MAX_CLAN_LENGTH+1]; /* clan info to be saved, taerin 5/30/99 */ int clan_rank; /* rank within the clan */ ----------------------------------------------------------------------- Save it in db.c, int load_char: strcpy(psds->clan_name, ""); /* taerin: initializing clan names */ psds->clan_rank = 0; /* taerin: initializing clan ranks */ ----------------------------------------------------------------------- in db.c, int load_char, case 'C': else if ( !strcmp(tag, "ClaN") ) strcpy( psds->clan_name, line ); else if ( !strcmp(tag, "ClaR") ) psds->clan_rank = num; ----------------------------------------------------------------------- in db.c, void save_char: if ( psds->clan_name ) fprintf( outfile, "ClaN: %s\n", GET_CLAN_NAME(ch) ); if ( psds->clan_rank ) fprintf( outfile, "ClaR: %d\n", (int)psds->clan_rank ); ----------------------------------------------------------------------- in act.informative.c, ACMD(do_score): char *get_rank_name(int rank); /* clan segment */ if ( GET_CLAN_RANK(ch) > 0 ) { sprintf( buf, "%s %sYou are a member (%s) of the %s clan.%s\r\n\r\n", buf, CCCYN(ch, C_NRM) ,get_rank_name(GET_CLAN_RANK(ch)), GET_CLAN_NAME(ch), CCNRM(ch, C_NRM) ); } ----------------------------------------------------------------------- in act.informative.c, do_who: if ( GET_CLAN_RANK(wch) > 0 ) { strcat( buf, CCCYN(ch, C_NRM) ); strcat( buf, " [" ); strcat( buf, GET_CLAN_NAME(wch) ); strcat( buf, "]" ); strcat( buf, CCNRM(ch, C_NRM) ); } ----------------------------------------------------------------------- in act.wizard.c, void do_stat_character: sprintf( buf, "Clan: [%s], Rank: [%s]\r\n", GET_CLAN_NAME(k), get_rank_name(GET_CLAN_RANK(k)) ); send_to_char(buf, ch); ----------------------------------------------------------------------- in interpreter.c: ACMD(do_assign) ACMD(do_clan); ACMD(do_ctell); ACMD(do_clan_tell); { "assign" , POS_RESTING , do_assign , LVL_IMPL, 0 }, { "clan" , POS_SLEEPING, do_clan , 0, 0 }, { "ctell" , POS_SLEEPING, do_clan_tell, 0, 0 }, ----------------------------------------------------------------------- in Makefile: OBJFILES list, add clan.o CXREF_FILES list, add clan.c clan.o : clan.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h handler.h screen.h $(CC) -c $(CFLAGS) clan.c ----------------------------------------------------------------------- and a new file, clan.c: /* clan.c wintermute mud circlemud 3.0bpl12 ascii pfile system taerin and riverwind 5/29/99 */ #include "conf.h" #include "sysdep.h" #include "structs.h" #include "utils.h" #include "comm.h" #include "db.h" #include "interpreter.h" #include "handler.h" #include "screen.h" void do_clan_who( struct char_data *ch ); void do_clan_tell( struct char_data *ch, char *msg ); void do_clan_dismiss( struct char_data *ch, struct char_data *victim ); void do_clan_enlist( struct char_data *ch, struct char_data *victim ); void do_clan_promote( struct char_data *ch, struct char_data *victim ); void do_clan_demote( struct char_data *ch, struct char_data *victim ); char *get_rank_name(int rank); extern struct descriptor_data *descriptor_list; /* to set up a new clan, implmentor needs to: assign <clan> <new_leader> */ ACMD(do_clan) { struct char_data *victim = NULL; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; if ( !*GET_CLAN_NAME(ch) ) { send_to_char( "You do not belong to any clan.\r\n", ch ); return; } half_chop( argument, arg1, arg2 ); if ( !*arg1 ) { send_to_char( "Usage: clan [ who | tell | resign ]\r\n", ch ); if ( GET_CLAN_RANK(ch) == CLAN_RANK_LEADER ) { send_to_char( "Also: clan [ enlist | dismiss | promote | demote ] victim\r\n", ch ); } if ( GET_LEVEL(ch) == LVL_IMPL ) { send_to_char( "Assign leaders: assign <clan> <new_leader>\r\n", ch ); } return; } /* perform general level functions first */ if ( is_abbrev( arg1, "who" ) ) { do_clan_who( ch ); return ; } if ( is_abbrev( arg1, "tell" ) ) { do_clan_tell( ch, arg2 ); return ; } if ( is_abbrev( arg1, "resign" ) ) { do_clan_dismiss( ch, ch ); return ; } /* now perform privileged functions */ if ( GET_CLAN_RANK(ch) != CLAN_RANK_LEADER ) { send_to_char( "You do not have the authority to reorganize the clan.\r\n", ch ); return; } if ( !(victim = get_char_room_vis( ch, arg2 )) ) { send_to_char( "That person is not available.\r\n", ch ); return; } if ( GET_LEVEL(victim) > (LVL_IMMORT - 1) ) { send_to_char( "Immortals cannot join clans!\r\n", ch ); return; } if ( is_abbrev( arg1, "enlist" ) ) { do_clan_enlist( ch, victim ); return ; } if ( strcmp(GET_CLAN_NAME(victim), GET_CLAN_NAME(ch)) ) { send_to_char( "That person is not in your clan!\r\n", ch ); return; } if ( is_abbrev( arg1, "dismiss" ) ) { do_clan_dismiss( ch, victim ); return ; } if ( is_abbrev( arg1, "promote" ) ) { do_clan_promote( ch, victim ); return ; } if ( is_abbrev( arg1, "demote" ) ) { do_clan_demote( ch, victim ); return ; } } void do_clan_who( struct char_data *ch ) { struct descriptor_data *d; sprintf( buf, "\r\n%s%s clan members online\r\n====/=====================-%s\r\n", CCBLU(ch, C_NRM), GET_CLAN_NAME(ch), CCNRM(ch, C_NRM) ); send_to_char( buf, ch ); for ( d = descriptor_list; d; d = d->next ) { if (d->connected) { continue; } if ( !strcmp(GET_CLAN_NAME(d->character), GET_CLAN_NAME(ch)) ) { sprintf( buf, "%s\r\n", GET_NAME(d->character) ); send_to_char( buf, ch ); } } return; } void do_clan_tell( struct char_data *ch, char *msg ) { struct descriptor_data *d; if ( GET_CLAN_RANK( ch ) < 1 ) { send_to_char( "You need to be an initiate or higher in a clan.\r\n", ch ); return; } for ( d = descriptor_list; d; d = d->next ) { if (d->connected) { continue; } if ( !strcmp(GET_CLAN_NAME(d->character), GET_CLAN_NAME(ch)) ) { *buf = '\0'; if ( GET_NAME(d->character) == GET_NAME(ch) ) { sprintf( buf, "%sYou tell the clan, ' %s '%s\r\n", CCCYN(ch, C_NRM), msg, CCNRM(ch, C_NRM) ); send_to_char( buf, d->character ); } else { sprintf( buf, "%s%s tells the clan, ' %s '%s\r\n", CCCYN(ch, C_NRM), GET_NAME(ch), msg, CCNRM(ch, C_NRM) ); send_to_char( buf, d->character ); } } } return; } void do_clan_enlist( struct char_data *ch, struct char_data *victim ) { char lbuf[1024]; if ( !GET_CLAN_RANK(victim) ) { strcpy(GET_CLAN_NAME(victim), GET_CLAN_NAME(ch)); GET_CLAN_RANK(victim) = CLAN_RANK_INITIATE; *lbuf = '\0'; sprintf( lbuf, "%sWelcome the newest intitiate of %s, %s!%s", CCRED(ch, C_NRM), GET_CLAN_NAME(ch), GET_NAME(victim), CCNRM(ch, C_NRM) ); do_clan_tell(ch, lbuf); } else { send_to_char( "That person already belongs to a clan..\r\n", ch ); } return; } void do_clan_dismiss( struct char_data *ch, struct char_data *victim ) { char lbuf[1024]; *lbuf = '\0'; sprintf( lbuf, "%s%s has been dismissed from the clan!%s", CCRED(ch, C_NRM), GET_NAME(victim), CCNRM(ch, C_NRM) ); do_clan_tell(ch, lbuf); strcpy(GET_CLAN_NAME(victim), ""); GET_CLAN_RANK(victim) = 0; return; } void do_clan_promote( struct char_data *ch, struct char_data *victim ) { char lbuf[1024]; if ( GET_CLAN_RANK(victim) < CLAN_RANK_MASTER ) { GET_CLAN_RANK(victim)++; *lbuf = '\0'; sprintf( lbuf, "%s%s has been promoted in rank to %s!%s", CCRED(ch, C_NRM), GET_NAME(victim), get_rank_name(GET_CLAN_RANK(victim)), CCNRM(ch, C_NRM) ); do_clan_tell(ch, lbuf); } else { send_to_char( "You can not promote this person any further.\r\n", ch ); } return; } void do_clan_demote( struct char_data *ch, struct char_data *victim ) { char lbuf[1024]; if ( GET_CLAN_RANK(victim) > CLAN_RANK_INITIATE ) { GET_CLAN_RANK(victim)--; *lbuf = '\0'; sprintf( lbuf, "%s%s has been demoted in rank to %s!%s", CCRED(ch, C_NRM), GET_NAME(victim), get_rank_name(GET_CLAN_RANK(victim)), CCNRM(ch, C_NRM) ); do_clan_tell(ch, lbuf); } else { send_to_char( "You can not demote this person any further!\r\n", ch ); } return; } /* reserved for the implementor only */ ACMD(do_assign) { struct char_data *victim = NULL; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; half_chop( argument, arg1, arg2 ); if ( !*arg1 || !*arg2 ) { send_to_char( "Usage: assign <clan> <leader>\r\n", ch); return; } if ( !(victim = get_char_room_vis( ch, arg2 )) ) { send_to_char( "That person is not available.\r\n", ch ); return; } if ( GET_CLAN_RANK(victim) ) { send_to_char( "Can not designate someone already in a clan!\r\n", ch); return; } if ( strlen(arg1) < (MAX_CLAN_LENGTH + 1) ) { strcpy(GET_CLAN_NAME(victim), arg1); GET_CLAN_RANK(victim) = 5; sprintf( buf, "Assigning clan %s to %s.\r\n", GET_CLAN_NAME(victim), GET_NAME(victim) ); send_to_char( buf, ch ); } else { send_to_char( "That clan name exceeds the maximum length allowed.\r\n", ch ); } } char *get_rank_name(int rank) { switch (rank) { case 1: return "Initiate"; break; case 2: return "Apprentice"; break; case 3: return "Member"; break; case 4: return "Master"; break; case 5: return "Leader"; break; default: return "Uninitiated"; break; } }
Last edit: 08 Apr 2016 13:25 by JTP.

Please Log in or Create an account to join the conversation.

More
08 Apr 2016 20:11 #5734 by thomas
On first look, it'll "just work". Try it out, get back to us here if it didn't.

Please Log in or Create an account to join the conversation.

More
08 Apr 2016 21:12 - 08 Apr 2016 21:31 #5737 by JTP
And it'll "just work" Means ? :)
Last edit: 08 Apr 2016 21:31 by JTP.

Please Log in or Create an account to join the conversation.

More
08 Apr 2016 21:41 #5738 by thomas
Have you tried it?

Please Log in or Create an account to join the conversation.

More
08 Apr 2016 21:43 #5739 by JTP
I will try it in an hour..but it'll "just Work" didnt sound very good, so was wondering what you mean by it.

It you already now see its a bad snippet, i could look for another.

Please Log in or Create an account to join the conversation.

More
08 Apr 2016 22:27 #5740 by thomas
I actually meant that it looked about right, and you should be able to make it work relatively easy. So no worries :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.284 seconds