new spell

Posted by Ithildin on Thu 08 Jul 2004 04:57 PM — 3 posts, 14,805 views.

USA #0
i made a new spell for my mud called vitality. what it does is this: you cast it on yourself or another, you get a 33% increase in hp for a limited time. so far i have most of it figured out. i just can't get their hitpoints that they have to go up along with max hitpoints. example:

if someone has 1200/1200 hp, then casted vitality they would end up with 1200/1600 hp. i want their regular hitpoints to go up as well. here's my code so far.


ch_ret spell_vitality( int sn, int level, CHAR_DATA *ch, void *vo )
{
	CHAR_DATA *victim = (CHAR_DATA *) vo;
	SKILLTYPE *skill = get_skilltype(sn);
	AFFECT_DATA af;

	int vch;
	int vvh;

	if (target_name[0] == '\0')
	victim = ch;
    else
	victim = get_char_room(ch, target_name);

	if ( IS_SET( victim->immune, RIS_MAGIC ) ) 
	{
      immune_casting( skill, ch, victim, NULL );
      return rSPELL_FAILED;
    }
	if ( IS_AFFECTED(victim, AFF_VITALITY) )
    {
	failed_casting( skill, ch, victim, NULL );
	return rSPELL_FAILED;
    }

    act( AT_MAGIC, "&WYou complete your spell", ch, NULL, NULL, TO_CHAR );
	
	af.type      = gsn_vitality;
    af.duration  = 120;
    af.location  = APPLY_HIT;
    af.modifier  = (victim->max_hit*.33);
    af.bitvector = meb(AFF_VITALITY);
    affect_to_char( victim, &af );
	vch = (victim->max_hit*.33); <-- i tried these
	vvh = victim->hit + vch;  <-- but it doesn't work
	victim->hit = vvh;   <-- i get more regular hp than max
    act( AT_MAGIC, "&WYou feel vitalized!", victim, NULL, NULL, TO_CHAR );
    return rNONE;
}

USA #1
i did this:


	vch = (victim->max_hit*.33);
	
	af.type      = gsn_vitality;
    af.duration  = 120;
    af.location  = APPLY_HIT;
    af.modifier  = vch;
    af.bitvector = meb(AFF_VITALITY);
    affect_to_char( victim, &af );
	vvh = victim->hit + vch;
	victim->hit = vvh;


and it worked, but now my only problem is, when i dispel myself my regular hp stays the vited hp. example:

my character has 1200/1200, vited, 1596/1596, dispelled, 1596/1200

how would i go about getting that back down to his old regular hp?
Canada #2
Well, you could always code in an affect that affects hit instead of max hit, and just add a second affect through the spell for the same amount and same duration. You could also put a check in the code that removes the affects that if hit > max hit, set hit to max > hit.

[EDIT] You'll want to look in affect_modify that is (eventually) where things go to get removed.