[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Question regarding CHAR_DATA's

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Question regarding CHAR_DATA's
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Sat 11 Dec 2004 01:12 PM (UTC)  quote  ]
Message
I changed those things, and it is working fine now :)
Thanks alot =)
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 11 Dec 2004 12:48 PM (UTC)  quote  ]
Message
That's because argument is null... this is a timer function, remember . . . you don't always have data in the char*argument to the function! you have to retrieve victim from those temporary pointers you created, or, from the who_fighting call.

Besides... your argument handling in do_handseal is wrong. Look at what you do with arg2 and argument, and think about what the value of 'argument' is as you pass it in to the do_chidori function...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Sat 11 Dec 2004 12:21 PM (UTC)  quote  ]
Message
Ok, here's the full code as it is right now. Right now, I only get the 'They aren't here' messages, because the victim is NULL.

void do_chidori( CHAR_DATA *ch, char *argument/*, CHAR_DATA *victim*/)
{
	CHAR_DATA *victim = ch->victim_ptr;
//	CHAR_DATA *victim;
	switch (ch->substate)
	{
	default:
		if (ch->level <= 50)
		{
		send_to_char("You cannot perform Chidori\n\r", ch);
		return;
		}
		if ( (victim = get_char_world( ch, argument ) ) == NULL )
		{
			send_to_char( "They aren't here.\n\r", ch );
			return;
		}
		if ( argument[0] == '\0' && (victim = who_fighting(ch)) == NULL )
		{
        ch_printf( ch, "You can't seem to focus for Chidori.\n\r" );
        return;
		}
		else if ( argument[0] != '\0' && (victim = get_char_room(ch, argument)) == NULL )
		{
        send_to_char( "You can't seem to focus for Chidori.\n\r", ch );
        return;
		}
		if ( ch == victim)
		{
		ch_printf( ch, "Using Chidori on yourself? Are you suicidal?\n\r");
		return;
		}
		act(AT_WHITE, "You quickly do some handseals for your jitsu.&R", ch, victim, NULL, TO_CHAR);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 1 );
		return;
	case 1:
		act( AT_RED, "\n\rYou raise your hand out infront of yourself and focus your chakra.", ch, NULL, victim, TO_CHAR);
		act( AT_RED, "\n\r$n raises $s hands and focuses $s chakra.", ch, NULL, victim, TO_CANSEE);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 2 );
		return;
	case 2:
		act( AT_RED, "\n\rYour chakra flows all over your body. &YCHIDORI&r!!! victim $N", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\r$n's chakra flows all over $s body. &YCHIDORI&r!!!", ch, NULL, victim, TO_CANSEE);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 3);
		return;
	case 3:
		damage( ch, victim, 150, TYPE_LIGHTNING );
		ch->mana -= 75;
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 4);
		return;
	case 4:
		act( AT_WHITE, "&wYou lower your hand." , ch, NULL, victim, TO_CHAR);
		act( AT_WHITE, "&w$n lowers $s hand." , ch, NULL, victim, TO_CANSEE);
		return;
	}
	return;
}

void do_handseal( CHAR_DATA *ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];

argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );

CHAR_DATA *victim;
victim = who_fighting(ch);

//victim = ch->victim;
    if ( arg1[0] == '\0' && (xIS_SET(ch->affected_by, AFF_SHARINGAN) ) )
    {
		send_to_char("You place your palms together.\n\r&WYour eyes return to normal as you stop using Sharingan.\n\r", ch);
		act(AT_GREEN, "$n places $s palms together.\n\r$n's chakra fades as $e stops using sharingan", ch, NULL, NULL,TO_CANSEE );
		xREMOVE_BIT(ch->affected_by, AFF_SHARINGAN);
		ch->mod_str = 0;
		ch->mod_dex = 0;
		ch->mod_lck = 0;
		ch->mod_wis = 0;
		ch->mod_int = 0;
		ch->mod_con = 0;
		return;
    }
    else if ( arg1[0] == '\0' )
    {
		send_to_char("&YWhat would u like to perform?\n\r", ch);
		return;
    }
	if ( !str_cmp( arg1, "mfotb" ) )
    {
		do_sharingan(ch, argument);
		return;
    }

	else if ( !str_cmp( arg1, "mfbtobs" ) )
    {
		ch->victim_ptr = victim;
		do_chidori(ch, argument);
		return;
    }
}
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 11 Dec 2004 10:00 AM (UTC)  quote  ]
Message
If you're going to paste code, you should probably paste all of it so that we don't have to play guessing games with what you left out. :-) If you omit stuff, who knows if it might be doing something wrong that we should know about as we read your code?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Sat 11 Dec 2004 09:41 AM (UTC)  quote  ]
Message
Yea, it misses a small part. I removed it because it took up quite a few lines, but doesn't affect the call to do_chidori. All it did was remove some affects if you had them on you
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Sat 11 Dec 2004 02:09 AM (UTC)  quote  ]

Amended on Sat 11 Dec 2004 02:13 AM (UTC) by Greven

Message
Very true, I was simply refering to this
void do_handseal( CHAR_DATA *ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
//char arg2[MAX_INPUT_LENGTH];

argument = one_argument( argument, arg1 );
//argument = one_argument( argument, arg2 );

CHAR_DATA *victim;
victim = ch;

    if ( arg1[0] == '\0' )
    {
		send_to_char("&YWhat would u like to perform?\n\r", ch);
		return;
    }
    if ( !str_cmp( arg1, "mfbtobs" ) )
    {
		ch->victim_ptr = victim;
		do_chidori(ch, argument);
		return;
    }
}
All I meant was to get this to work would be to initialize(with the appropraite checks, of course) victim to who_fighting(ch) instead of ch. Though setting up ch->victim_ptr to who_fighting(ch) would be pointless here, and should just be done and checked in do_chidori anyways.


As to how the other was working... yeah, your right, it shouldn't have been. Looks like these are not full functions anyways, as the one above really does very little anyways except call do_chidori. I would assume, possibly erroneously, that there is more that is not posted.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 11 Dec 2004 02:00 AM (UTC)  quote  ]

Amended on Sat 11 Dec 2004 02:01 AM (UTC) by David Haley

Message
The error I pointed out is one of syntax, not semantics:

void do_handseal( CHAR_DATA *ch, char *argument)
{
     char arg1[MAX_INPUT_LENGTH];
     // char arg2[MAX_INPUT_LENGTH];

     argument = one_argument( argument, arg1 );
     // argument = one_argument( argument, arg2 );

     CHAR_DATA *victim;
     victim = ch;

     // Where is the opening if statement here?
     else if ( arg1[0] == '\0' )
     {
          send_to_char("&YWhat would u like to perform?\n\r", ch);
          return;
     }
     ...
It shouldn't have even compiled to begin with.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Sat 11 Dec 2004 01:29 AM (UTC)  quote  ]
Message
The reason that it was working before and not now was this part
victim = who_fighting(ch)
This was reseting victim to the proper setting. You can put something like that back in.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 11 Dec 2004 12:20 AM (UTC)  quote  ]
Message
I don't see how the 'old code' could work in the first place because it starts out with an else if - but where's the if?

It does have a victim = ch at the top, but if you look carefully you'll see that victim gets changed right afterwards - the victim = ch seems to be a useless statement.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Fri 10 Dec 2004 11:52 PM (UTC)  quote  ]

Amended on Sat 11 Dec 2004 12:06 AM (UTC) by DjNiVeK

Message
Ahh, now I see what went wrong, lol. I'll try coding it in tomorrow, but I think you're right.
ty :)

Edit: hmm, didn't seem to solve the problem.
The old code was posted 1 post above the new code. The old 'code' was the old version of handseal, and it also had that victim = ch; in it.
But that didn't seem to make a difference, because the attack still hit the 'real' victim instead of ch.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Fri 10 Dec 2004 11:38 PM (UTC)  quote  ]
Message
Quote:


void do_handseal( CHAR_DATA *ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
//char arg2[MAX_INPUT_LENGTH];

argument = one_argument( argument, arg1 );
//argument = one_argument( argument, arg2 );

CHAR_DATA *victim;
victim = ch;

    if ( arg1[0] == '\0' )
    {
		send_to_char("&YWhat would u like to perform?\n\r", ch);
		return;
    }
    if ( !str_cmp( arg1, "mfbtobs" ) )
    {
		ch->victim_ptr = victim;
		do_chidori(ch, argument);
		return;
    }
}



I have a concern. You do victim = ch;, but then later you do ch->victim_ptr = victim. Thus, arent you pointing to your own structure? As in, ch->victim_ptr->name would be the same as ch->name? Seems rather pointless to point to yourself.

Also, what exactly is the "old" code? What you should do, is when they specify the name of the victim, do something like,

if ( (victim = get_char_world( ch, arg2 ) ) == NULL )
{
  send_to_char( "They aren't here.\n\r", ch );
  return;
}


This will then give a pointer to the correct person, and if that person isn't found it will tell you "They aren't here."

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Fri 10 Dec 2004 11:12 PM (UTC)  quote  ]
Message
The problem is the fact that the CHAR_DATA *victim contains the same information as CHAR_DATA *ch.
Which is understandable because in the beginning of the handseal function, there is a 'victim = ch;'
I'm wondering why the old code is able to attack the victim, even with that 'victim = ch;' part.
So my question kinda is: "Why does the old code have a good 'victim' and the new code doesn't, as it has about the same code."
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 10 Dec 2004 10:38 PM (UTC)  quote  ]
Message
What exactly is the problem, and what are you asking me to look at?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Fri 10 Dec 2004 09:16 PM (UTC)  quote  ]
Message
New Code:

void do_chidori( CHAR_DATA *ch, char *argument/*, CHAR_DATA *victim*/)
{
	CHAR_DATA *victim = ch->victim_ptr;
	switch (ch->substate)
	{
	default:
		if (ch->level <= 50)
		{
		send_to_char("You cannot perform Chidori\n\r", ch);
		return;
		}
		if ( argument[0] == '\0' && (victim = who_fighting(ch)) == NULL )
		{
        ch_printf( ch, "You can't seem to focus for Chidori.\n\r" );
        return;
		}
		else if ( argument[0] != '\0' && (victim = get_char_room(ch, argument)) == NULL )
		{
        send_to_char( "You can't seem to focus for Chidori.\n\r", ch );
        return;
		}
		if ( ch == victim)
		{
		ch_printf( ch, "Using Chidori on yourself? Are you suicidal?\n\r");
		return;
		}
		act(AT_WHITE, "You quickly do some handseals for your jitsu.&R", ch, victim, NULL, TO_CHAR);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 1 );
		return;
	case 1:
		act( AT_RED, "\n\rYou raise your hand out infront of yourself and focus your chakra.", ch, NULL, victim, TO_CHAR);
		act( AT_RED, "\n\r$n raises $s hands and focuses $s chakra.", ch, NULL, victim, TO_CANSEE);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 2 );
		return;
	case 2:
		act( AT_RED, "\n\rYour chakra flows all over your body. &YCHIDORI&r!!! victim $N", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\r$n's chakra flows all over $s body. &YCHIDORI&r!!!", ch, NULL, victim, TO_CANSEE);
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 3);
		return;
	case 3:
		damage( ch, victim, 150, TYPE_LIGHTNING );
		ch->mana -= 75;
		add_timer( ch, TIMER_DO_FUN, 1, do_chidori, 4);
		return;
	case 4:
		act( AT_WHITE, "&wYou lower your hand." , ch, NULL, victim, TO_CHAR);
		act( AT_WHITE, "&w$n lowers $s hand." , ch, NULL, victim, TO_CANSEE);
		return;
	}
	return;
}

void do_handseal( CHAR_DATA *ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
//char arg2[MAX_INPUT_LENGTH];

argument = one_argument( argument, arg1 );
//argument = one_argument( argument, arg2 );

CHAR_DATA *victim;
victim = ch;

    if ( arg1[0] == '\0' )
    {
		send_to_char("&YWhat would u like to perform?\n\r", ch);
		return;
    }
    if ( !str_cmp( arg1, "mfbtobs" ) )
    {
		ch->victim_ptr = victim;
		do_chidori(ch, argument);
		return;
    }
}
[Go to top] top

Posted by DjNiVeK   (48 posts)  [Biography] bio
Date Fri 10 Dec 2004 09:15 PM (UTC)  quote  ]
Message
Ok, I made a new pointer (victim_ptr), and I can get CHAR_DATA's to the new function now. But it seems like there is no way to get the char data of the victim passed on. I don't know why, because in the old function, it didn't have anything extra, but it did target the victim.
I didn't change anything in the code (so didn't remove the messages and all)
Old Code:

void do_handseal( CHAR_DATA *ch, char *argument)
{
char arg1[MAX_INPUT_LENGTH];
// char arg2[MAX_INPUT_LENGTH];

argument = one_argument( argument, arg1 );
// argument = one_argument( argument, arg2 );

CHAR_DATA *victim;
victim = ch;

     else if ( arg1[0] == '\0' )
     {
      send_to_char("&YWhat would u like to perform?\n\r", ch);
      return;
     }
     if ( !str_cmp( arg1, "mfbtobs" ) )
     {
     if (ch->level <= 50)
      {
       send_to_char("You cannot perform Chidori\n\r", ch);
       return;
      }
    if ( argument[0] == '\0' && (victim = who_fighting(ch)) == NULL )
    {
        ch_printf( ch, "You can't seem to focus for Chidori.\n\r" );
        global_retcode = damage( ch, ch, random_int(1, 1), TYPE_LIGHTNING );
        return;
    }
    else if ( argument[0] != '\0' && (victim = get_char_room(ch, argument)) == NULL )
    {
        send_to_char( "You can't seem to focus for Chidori.\n\r", ch );
        global_retcode = damage( ch, ch, random_int(1, 1), TYPE_LIGHTNING );
        return;
    }

//        if(ch->position == POS_STANDING )
//        {
//        send_to_char("You can't do that when your not fighting\n\r", ch);
//        return;
//        }
        if (can_use_skill(ch, number_percent(), gsn_lightning_bolt ))
        {
        act(AT_WHITE, "You quickly do some handseals for your jitsu.&R", ch, victim, NULL, TO_CHAR);
        act( AT_RED, "\n\r$n raises his hand out in front of $mself and focuses $s chakra.", victim, NULL, ch, TO_CHAR);
        act( AT_RED, "\n\r$n's chakra flows all over $s body. &YCHIDORI&r!!!", victim, NULL, ch, TO_CHAR);
        act( AT_RED, "\n\rYou raise your hand out infront of yourself and focus your chakra.", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\rYour chakra flows all over your body. &YCHIDORI&r!!! Victim: $N", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\r$N raises $s hands and focuses $s chakra.", ch, NULL, victim, TO_NOTVICT);
        act( AT_RED, "\n\r$N's chakra flows all over $s body. &YCHIDORI&r!!!", ch, NULL, victim, TO_NOTVICT);
        one_hit( ch, victim, TYPE_LIGHTNING );
        ch->mana -= 75;
        act( AT_WHITE, "&w$N lowers $S hand." , victim, NULL, ch, TO_CHAR);
        act( AT_WHITE, "&wYou lower your hand." , ch, NULL, victim, TO_CHAR);
        act( AT_WHITE, "&w$N lowers $S hand." , ch, NULL, victim, TO_NOTVICT);
//      learn_from_success( ch, spell_chidori );
        }
        else
        {
        act(AT_WHITE, "You quickly do some handseals for your jitsu.&R", ch, victim, NULL, TO_CHAR);
        act( AT_RED, "\n\r$n raises his hand out in front of $mself and focuses $s chakra.", victim, NULL, ch, TO_CHAR);
        act( AT_RED, "\n\r$n's chakra flows all over $s body. &YCHIDORI&r!!!", victim, NULL, ch, TO_CHAR);
        act( AT_RED, "\n\rYou raise your hand out infront of yourself and focus your chakra.", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\rYour chakra flows all over your body. &YCHIDORI&r!!! Victim: $N", ch, NULL, victim, TO_CHAR);
        act( AT_RED, "\n\r$N raises $s hands and focuses $s chakra.", ch, NULL, victim, TO_NOTVICT);
        act( AT_RED, "\n\r$N's chakra flows all over $s body. &YCHIDORI&r!!!", ch, NULL, victim, TO_NOTVICT);
        damage(ch, victim, 0, TYPE_LIGHTNING);
        ch->mana -= 150;
        act( AT_WHITE, "&w$N lowers $S hand." , victim, NULL, ch, TO_CHAR);
        act( AT_WHITE, "&wYou lower your hand." , ch, NULL, victim, TO_CHAR);
        act( AT_WHITE, "&w$N lowers $S hand." , ch, NULL, victim, TO_NOTVICT);
//      learn_from_failure( ch, spell_chidori );
        return;
                }
        WAIT_STATE( ch, 14 );
                }
        }
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,861 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]