Issue adding a new affect

Posted by Sypher-Z on Fri 22 Aug 2008 03:08 PM — 7 posts, 21,468 views.

#0
Hello. I'm relatively new to coding in C++, and though I've some knowledge of VBA, I do not believe it is enough for the problem I'm facing.

I recently added a new affect. I've defined it in various places, such as mud.h, handler.c, and build.c.

The issue I encounter, is that when I set myself with the affect, it's giving me a different affect in mstat. It's actually giving me dead affects that are embedded in the code, but not used in the MUD itself. There isn't even a way to mset these affects, yet all of a sudden they appear out of the blue with this new affect I've added.

I'm not sure if it has to do with the order I've placed the code for the affect in each individual file, or if it's that I forgot to define it in another file altogether.

Anyway, if any more information is needed, just let me know. I appreciate any assistance offered, and I thank you for your time.

Sypher
USA #1
Could you show what you did to add the effect? The details of what it does in terms of gameplay aren't terribly important for now.
#2
Sure,

**In the handlers, I noticed I needed to define a new aff_, so I went ahead and defined aff_bl and proceeded to add:

aff_bl = IS_AFFECTED( ch, AFF_THORNS );

*Further down in the handler file, I added:

if( aff_bl)
xSET_BIT( ch->affected_by, AFF_THORNS );

*As well as:

if ( xIS_SET(*vector, AFF_THORNS ))
strcat( buf, " thorns" );


**In mud.h, I added the AFF_THORNS in the affected_by_types table.

**In act_info.c I added the flag for the affect.

if( IS_AFFECTED( victim, AFF_THORNS ) )
ch_printf( ch, " &P*&G%s is covered in dangerous thorns.\n\r", name );

**In build.c I added this in *const a_flags[] as the last one.

..., "thorns"
};

Those are all the changes that I made to add the affect. I'm not sure why it's rolling over to different affects.

Let me know if I'm missing anything, please. Thanks for looking.
USA #3
Quote:
**In mud.h, I added the AFF_THORNS in the affected_by_types table.

Could you show how you did this please?

Effects are implemented with bitvectors, and if the bitvectors are not set up correctly, then setting a flag can set other things. So, if the value is not exactly correct, or the flag data structure isn't set up correctly, things can go wrong.
#4
I had a feeling it was that. I had moved the affect in mud.h to another spot and it was reflecting a different affect.

At the moment, I don't really know where to put it. I wouldn't want to mess up anything that would..say..change all the mobs affects due to another of these "roll-overs".

mud.h is a little whacky at the moment. It looks like some of these affects were crammed in there, mainly the useless ones.

I'm not sure of how much of this you'd like to see, but here's the final few lines.. The final 4 to be exact. I'll label each line with an asterisk.

*AFF_SUPER_OOZARU, AFF_NOSHADOW, AFF_SERAPHIM, AFF_MECHAFIGHTER,
*AFF_APPMAGE, AFF_MASTERMAGE, AFF_ARCHMAGE, AFF_SHADOWMAGE, AFF_SEMIMORT, AFF_GESPETITE, AFF_MALACHITE, AFF_EMERALD, AFF_THORNS,
*MAX_AFFECTED_BY,
*} affected_by_types;

I'm now sure if you can decipher this with such little data, but the piece that I added in handler.c:

*if ( xIS_SET(*vector, AFF_THORNS )) strcat( buf, " thorns" );

This piece was put at the end of the list. So I figured thorns should be at the end of the list. I guess I was wrong, heh. Newbie luck = 0. :P

Let me know if you need any more info in particular.

Edit:
I was wondering if it's necessary to add these effects in ibuild.c. If so, I've no clue how to deal with the fourth number in the individial MENU_DATA sequences. But I'm not worried about that for now. Just figured I'd ask if it's necessary at all.
Amended on Fri 22 Aug 2008 06:56 PM by Sypher-Z
#5
I'm not sure if it's against the forum policy to double post or anything, but...believe it or not, I found the fix.

Now...remember this is like..SMAUG. >.>

I had to go in build.c where I added thorns and, since there are dead affects in the MUD from unused races, I had to add "", before thorns in the char *const a_flags[].

Took me a while to figure this one out. I basically moved the code up and down a notch in multiple files until I caught the one that was actually affecting it. Like I said, I'm relatively new. At least I know more or less how computers work, heheh.

Thank you for all the help. I really appreciate you taking the time. I'll definitely come back if I have any other issue that I can't figure out. I know how SMAUG can be tricky. Lol.

Sypher
USA #6
Glad to hear you figured it out. :-) The SMAUG code is indeed persnickety and doesn't always make it easy to figure out how to add things like this. Sometimes you just need to know the right arcane incantation to do the trick...