Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Saving pets with spells affecting them

Saving pets with spells affecting them

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Darwin   USA  (125 posts)  Bio
Date Sun 17 Feb 2008 02:09 AM (UTC)
Message
[Smaug 1.4a, Linux (Ubuntu 7.10)]
I've added the following code into fwrite_mobile in save.c in an attempt to save pets with spells affecting them and allowing them to be loaded back in the same state.
  for ( paf = mob->first_affect; paf; paf = paf->next )
    {
	if ( paf->type >= 0 && (skill=get_skilltype(paf->type)) == NULL )
	    continue;

	if ( paf->type >= 0 && paf->type < TYPE_PERSONAL )
	  fprintf( fp, "AffectData   '%s' %3d %3d %3d %s\n",
	    skill->name,
	    paf->duration,
	    paf->modifier,
	    paf->location,
	    print_bitvector(&paf->bitvector)
	    );
	else
	  fprintf( fp, "Affect       %3d %3d %3d %3d %s\n",
	    paf->type,
	    paf->duration,
	    paf->modifier,
	    paf->location,
	    print_bitvector(&paf->bitvector)
	    );
    }

And I've added the following code to fread_mobile also in save.c
    case 'A':
	    if ( !strcmp( word, "Affect" ) || !strcmp( word, "AffectData" ) )
	    {
		AFFECT_DATA *paf;

		CREATE( paf, AFFECT_DATA, 1 );
		if ( !strcmp( word, "Affect" ) )
		{
		    paf->type	= fread_number( fp );
		}
		else
		{
		    int sn;
		    char *sname = fread_word(fp);

		    if ( (sn=skill_lookup(sname)) < 0 )
		    {
			if ( (sn=herb_lookup(sname)) < 0 )
			    bug( "Fread_mobile: unknown skill.", 0 );
			else
			    sn += TYPE_HERB;
		    }
		    paf->type = sn;
		}

		paf->duration	= fread_number( fp );
		paf->modifier	= fread_number( fp );
		paf->location	= fread_number( fp );
		if ( paf->location == APPLY_WEAPONSPELL
		||   paf->location == APPLY_WEARSPELL
		||   paf->location == APPLY_REMOVESPELL
		||   paf->location == APPLY_STRIPSN
		||   paf->location == APPLY_RECURRINGSPELL )
		  paf->modifier	= slot_lookup( paf->modifier );
		paf->bitvector	= fread_bitvector( fp );
        paf->caster     = mob->short_descr;
		LINK(paf, mob->first_affect, mob->last_affect, next, prev );
		fMatch = TRUE;
		break;
	    }

This does have the desired effect of saving the data to file, reading it back and applying it to the mob, however, the mob does not act as if it is affected by the spells. For instance, when I cast any of the shields (fire/ice/shockshield) on a pet, save and quit, when I log back in the pet (with mstat) will show that it has the affect on it, but it does not show on the actual mob when seeing it in the room, nor does it affect anything while it is fighting.

Is there something I'm missing?
Top

Posted by Darwin   USA  (125 posts)  Bio
Date Reply #1 on Sun 17 Feb 2008 02:16 AM (UTC)
Message
Arg. Nevermind. I had forgotten to save the affected_by data. After adding that, everything saved and loaded as desired.
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.


9,665 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.