Spell Affects [CASE CLOSED]

Posted by Dark_Trunks on Wed 26 Jun 2002 03:55 PM — 13 posts, 43,250 views.

Australia #0
Hi everyone. I'm back yet again.

This time I'm wondering if anyone can help me with creating new affects for spells/skills.

At first I thought all I'd have to do is add them to mud.h with the rest of them:
typedef enum
{
AFF_BLIND, AFF_INVISIBLE, AFF_DETECT_EVIL, AFF_DETECT_INVIS,....

But that doesnt seem to work, so I guess theres a bit more to it.

So if anyone can give me a hand with this it'd be much appreciated!
USA #1
Adding it to mud.h will only allow you to put it on a player or remove it, but you will actually have to change the code to check if the effect is on. Meaning if you want an affect like blindness, you will have to put before the part of code that displays a room to have a check if(!IS_AFFECTED(ch, AFF_NEWBLIND) then to continue, or whatever the correct check is, I can't be bothered to look it up. The game won't know what to do with an effect unless it is told, so you will also have to go into the code to make the checks if the player is affected or not.

-Mark Calloway
Australia #2
Well thats exactly what I've done, but whenever I make a call to affect_to_char(ch, af) the compiler complains about an incompatible type.

Quote:

misc.c:259: incompatible type for argument 2 of `affect_to_char'
misc.c:272: incompatible type for argument 2 of `affect_remove'


And in case your wondering, I'm pretty sure I've made 'af' properly. (Please correct me if I'm wrong)


    AFFECT_DATA af;
    af.type      = 0;
    af.duration  = 0;
    af.location  = APPLY_NONE;
    af.modifier  = 0;
    af.bitvector = meb(AFF_OOZARU);
Australia Forum Administrator #3
Perhaps post the lines in question that actually cause the error message?
Australia #4
Well before I put them in, the compiler assumed I was sending an int as the second argument. Although it was just a warning, I didn't want to run it with something like that - I've had that warning before and it caused many crashes.
Australia Forum Administrator #5
You still haven't posted the lines that are causing the error. I can't tell what is wrong if I have to guess what your code looks like.
Australia #6
Sorry, I miss read your last post.
Here are the lines in question:

affect_to_char(ch,af);

AND

affect_remove(ch, af);


af is setup exactly as in the previous post.
Amended on Wed 03 Jul 2002 03:16 PM by Dark_Trunks
USA #7
did u add to handler.c in the
char *affect_bit_name( EXT_BV *vector ) ?
Australia #8
Yes I added it to that:

    if ( xIS_SET(*vector, AFF_OOZARU       )) strcat( buf, " oozaru"	    );
USA #9
k not sure if u making this for a spell.. but say if there was a spell 'oozaru' and coded it in ur
ch_ret spell_oozaru( int sn, int level, CHAR_DATA *ch, void *vo )

the af thing should look like

af.type = sn;
af.duration = level * 3;
af.location = APPLY_AFFECT;
af.modifier = 0;
af.bitvector = meb(AFF_OOZARU);
Australia #10
Well technically it's not a spell. Its just an affect that I want applied at a peticular time (ie at night on the 30th of every month). The time isn't the problem though, that works fine its the affect that doesn't work.

So what your're saying is that I should make it sort of like a skill/spell? Well I haven't actually done a spell before but I suppose I could give it a go, it makes sense really: Just make it a spell that can't actually be cast by mortals.

Thanks alot for your help.
Australia #11
Well thanks to everyone for your help. I managed to finally get it to work!
There was actually two parts to the solution:
PART I:
The compile warning messages were fixed by changing af to &af (I don't know enough about C to understand why)

affect_to_char(ch,&af);


And the second part was to assign the affect a skill number while not actually making it a skill. (Sure it sounds confusing, I barely understand it - but it works!)

So thanks again!
Australia Forum Administrator #12
Quote:

The compile warning messages were fixed by changing af to &af (I don't know enough about C to understand why)

affect_to_char(ch,&af);


The function prototype has an asterisk before "paf", see below:


void affect_to_char( CHAR_DATA *ch, AFFECT_DATA *paf )


The asterisk says to pass the address of an AFFECT_DATA. This is what the ampersand does, takes the address of its argument.