Will this snippet work as is with tba ?

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago - 3 years 10 months ago #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 ?
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: 3 years 10 months ago by JTP.

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

More
3 years 10 months ago #5734 by thomas
Replied by thomas on topic Will this snippet work as is with tba ?
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.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago - 3 years 10 months ago #5737 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
And it'll "just work" Means ? :)
Last edit: 3 years 10 months ago by JTP.

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

More
3 years 10 months ago #5738 by thomas
Replied by thomas on topic Will this snippet work as is with tba ?
Have you tried it?

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago #5739 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
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
3 years 10 months ago #5740 by thomas
Replied by thomas on topic Will this snippet work as is with tba ?
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.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago #5741 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
Ok thanks alot..usually when people use "" its not a good thing haha

Just finished redoing all the send_to_char in Clan.c

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago - 3 years 10 months ago #5742 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
From the snippet:
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

In tba, would that just be:
clan.o  : clan.c conf.h sysdep.h structs.h utils.h comm.h db.h interpreter.h handler.h screen.h

I depend ??

Or will i need to do more ?
Last edit: 3 years 10 months ago by JTP.

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

More
3 years 10 months ago #5743 by thomas
Replied by thomas on topic Will this snippet work as is with tba ?
You don't actually need to change the Makefile anymore. It autodetects all *.c files and creates a new depend file for you if you compile with "make clean", then "make" as usual.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 10 months ago #5745 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
Bunch of errors:
clan.c: In function ‘do_clan’:
clan.c:96: error: too few arguments to function ‘get_char_room_vis’
clan.c: In function ‘do_clan_who’:
clan.c:143: error: ‘buf’ undeclared (first use in this function)
clan.c:143: error: (Each undeclared identifier is reported only once
clan.c:143: error: for each function it appears in.)
clan.c:145: warning: passing argument 2 of ‘send_to_char’ from incompatible pointer type
clan.c:157: warning: passing argument 2 of ‘send_to_char’ from incompatible pointer type
clan.c: In function ‘do_clan_tell’:
clan.c:183: error: ‘buf’ undeclared (first use in this function)
clan.c:189: warning: passing argument 2 of ‘send_to_char’ from incompatible pointer type
clan.c:196: warning: passing argument 2 of ‘send_to_char’ from incompatible pointer type
clan.c: In function ‘do_assign’:
clan.c:303: error: too few arguments to function ‘get_char_room_vis’
clan.c:320: error: ‘buf’ undeclared (first use in this function)
clan.c:321: warning: passing argument 2 of ‘send_to_char’ from incompatible pointer type
make[1]: *** [clan.o] Error 1

Also problems in the parts from act.informative.c and act.wizard.c, but i remmed them out to get this far.

So whats wrong ?

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

More
3 years 9 months ago #5842 by rudeboyrave
Replied by rudeboyrave on topic Will this snippet work as is with tba ?
what you need to do for these easy errors is define what a buf is. here is an example of what you need to do for any buf errors you get similar to these.
ACMD(do_whatever)
{
+    char buf[MAX_STRING_LENGTH];

for your send_to_char error... just look at any other send_to_char in your code and see what is different.. my guess is that the ch is in the wrong spot?

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 9 months ago - 3 years 9 months ago #5843 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
I moved all the ch to send_to_char(ch, "
So its not that.

Alot of errors in that patch, also the to few arguments: if ( !(victim = get_char_room_vis( ch, arg2 )))


Definately not a clean patch haha
Last edit: 3 years 9 months ago by JTP.

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

More
3 years 9 months ago - 3 years 9 months ago #5876 by rudeboyrave
Replied by rudeboyrave on topic Will this snippet work as is with tba ?
Here is a freshly minted clan patch. I have made the changes needed to get it to work on a stock TBAMUD 3.67 release.

download the patch, place it in your src directory (be sure to backup the directory first for safety)
and run with

patch -u < clans-tba367.patch


if all goes well you will now have clans. I have tested on a fresh copy!

the patch can be found here since i cant upload here?
www.filedropper.com/clans-tba367

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.
Last edit: 3 years 9 months ago by rudeboyrave. Reason: cant upload patch???
The following user(s) said Thank You: WhiskyTest

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 9 months ago #5878 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
Thats good news...big thanks!

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 8 months ago - 3 years 8 months ago #5911 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
Just tested it, it Works great !

Only one minor thing, impl must be in the same room as the one he wanna assign a Clan to.

And then leader also needs to be in the same room as the people he wanna enlist.


And

ct or Clan tell with no text send a tell with nothing, maybe it needs a check like tell playername with no text.


And clan names can only be small letters.

But other then that, it works very good. If you update your patch, to handle some of this. Pls let me know.
Last edit: 3 years 8 months ago by JTP.

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

More
2 years 1 month ago #7296 by Sascha
Replied by Sascha on topic Will this snippet work as is with tba ?
Does anyone have this patch? The link is no longer active. Thanks in advance!

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

More
2 years 1 month ago #7297 by rudeboyrave
Replied by rudeboyrave on topic Will this snippet work as is with tba ?
here is an updated link. there are a few warnings when compiling but should work the same as it did on 367. the issues JTP mentioned above this post persist and will need to be fixed if its an issue!

drive.google.com/open?id=1mW0tDCDPu_j9Mxou5vZmwLeGJ_jhBYy2

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.
The following user(s) said Thank You: Sascha

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

More
2 years 1 month ago #7298 by Sascha
Replied by Sascha on topic Will this snippet work as is with tba ?
Thanks so much for the quick response! I'm looking forward to tinkering with this. :)

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
2 years 1 month ago #7302 by JTP
Replied by JTP on topic Will this snippet work as is with tba ?
Anyone knows How to get it to use caps in the clan name ?

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

More
2 years 1 month ago #7315 by Sascha
Replied by Sascha on topic Will this snippet work as is with tba ?
I've been able to patch this into 3.68. So far so good! No crashing...!

First of all, this is cool. Thank you so much for sharing the updated file. Here are my observations/questions:

-=-=-=-=-=-=-

Yes, as mentioned there are warnings when compiling but they are beyond my current skill level to address. It would be nice if the clan name could be capitalized. That would be cosmetically spiffy for sure.

I've noticed that my test player sees that she's in a clan, etc. and so forth but when an Imm pulls the who list there's no mention of it, only brackets. This is what it looks like from the player with the command 'clan who':

seafolk clan members online
====/=====================-
Mariana

And this is how it looks to the Imms when we do a 'who':

Mortals
[50 Ch] Mariana is testing clans. []

2 characters displayed.

Those brackets at the end should have the clan name in it, right? So did I do something wrong?

-=-=-=-=-=-=-

Here's my wishlist of what would be great to do with this, if anyone has the time and inclination to make these changes. If this already exists then please point me to it, because I haven't found it yet. :)

1) Documentation please! For those of us who are not primarily coders, something that tells us what to do and how to do it would be great. I was able to read through the code and get enough clues to start figuring out how to use this.

2) Allow a mob to be the clan leader if needed as a default.

3) Allow all players to pull up a list of possible clans to apply to/participate in. Maybe a "view clans" or "clan list" command?

4) Allow further customizations for different clans in regards to rank names. For example, if I "assign seafolk (playername)", that creates the seafolk clan and makes (playername) the leader. The ranks for the seafolk clan are the same as the heartguard clan, as I understand it from reading the code. (Please correct me if I'm wrong.) I'd like to see an in-game editor that would let me name the clan, set up the rank names, assign the leader, and assign a cost system (gold and/or quest point levels) to the ranks (which would make qps spendable right there instead of having to script that up).

This would allow things to be set up a little bit easier, perhaps, and also gain some in-game traction for players who might pull up a list and see clan names. The goal would be "Hey! What is this Heartguard clan, and how do I get into it?" Sure, there can be chatter on game forums, but having it be game-inclusive would be optimum.

So, is anyone inclined to take this on as an improvement request for 3.68?

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

Time to create page: 0.396 seconds