One thing I just remembered is the different durations also, if you have
some affects that are set for permanent, but some that are set for a
certain # of hours (if you've fixed this in your mud) you'll want to
either specify a variable to hold the total of those values also, or an
average of them, or the highest of all of them, or whatever, and change
the original affect in the chain's ->duration field to that value...

Richard Lindsey
Network Administrator
INTERA, Inc.
9111A Research Blvd.
Austin, TX  78758
(512) 425-2006
[EMAIL PROTECTED]
 

-----Original Message-----
From: Richard Lindsey 
Sent: Thursday, April 15, 2004 12:28 PM
To: [EMAIL PROTECTED]; [email protected]
Subject: RE: Combining Affects

It's something you'd have to write yourself, but you can do something
like this...

int total, apply;
AFFECT_DATA *paf, *paf_next, *paf_next2;

for ( paf = obj->affected; paf != NULL; paf = paf->next )
{
   apply = paf->location;
   total = paf->modifier;
   for ( paf_next = paf->next; paf_next != NULL; paf_next =
paf_next->next )
   {
        paf_next2 = paf_next->next;

        if ( paf_next == paf->next && paf_next->location ==
paf->location )
        {
           total += paf_next->modifier;
           paf->next = paf_next2;
           free_affect(paf_next);
        }

        if ( paf_next2->location == paf->location )
        {
           total += paf_next->modifier;
           paf_next->next = paf_next2->next;
           free_affect(paf_next2);
        }
   }
   paf->modifier = total;
}

I think that should work, in theory anyway, it'll cycle through the
affect list, starting with the first, it'll record that apply number and
check the rest of the list for duplicates... any duplicates it finds
it'll add the modifier to total and destroy that affect, then loop on to
(the newly assigned) next affect in the chain until it hits the end, the
go to the 2nd element in the list and check from there on in the same
way... feel free to point out any bugs you see in this (anyone) as I
kind of thought it up on the fly but would like to put it into mine also
:D

Richard Lindsey 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 15, 2004 12:12 PM
To: [email protected]
Subject: Combining Affects

I want to combine the affects on 2 items.
For example - Item 1 has an 'addaffect' of +100 hp, and Item 2 has an
'addaffect' of +20 hp. When 'combined' by the player, the new item will
have
+120 hp. Is there something in the ROM code that I am missing that does
this,
or I have to write one myself? If so, any help would be good.
Thanks



-- 
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom

-- 
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom

Reply via email to