I need some help passing a method as a parameter. I did some google searching and the examples given were either confusing or I'm an idiot or a mix of both. So, I will explain the situation and what I need it to do and hopefully someone can just give me the code in my situation that I need and I can learn that way.
I'm writing code for a basic heal spell. However, it and all other spells can be affected by this thing called "glory". Glory will echo the spell cast to all others in the targets group. For example, the code looks something like this…
if( is_affected( ch, gsn_glory ) ) for( gvictim = victim->in_room->first_person; gvictim; gvictim = gvictim->next_in_room ) { if( !is_same_group( victim, gvictim ) ) continue; if( gvictim == victim ) continue; method_passed( ch, gvictim ) – In this case it would be heal_char
Now, I get there are other ways that would require a lot more writing, and then rewriting every time I added a new spell, or I could rewrite the entire spell system to support this. However, this would be a convenient hack to make it work.
If you're using merc/ROM derivative or close too, you can just use SPELL_FUN. It's used as a parameter in a table for spells. You can just use it and pass it that way. If not, the basic idea is to declare a set of function with identical arguments.
The idea is you start with a typedef for your new function.
I'm writing code for a basic heal spell. However, it and all other spells can be affected by this thing called "glory". Glory will echo the spell cast to all others in the targets group. For example, the code looks something like this…
Now, I get there are other ways that would require a lot more writing, and then rewriting every time I added a new spell, or I could rewrite the entire spell system to support this. However, this would be a convenient hack to make it work.
Thanks in advance, Davenge~~~