Calling a variable from another function

Posted by Zeno on Fri 12 Sep 2003 09:49 PM — 7 posts, 25,520 views.

USA #0
I made a new function in fight.c, and I want to use the variable dam in it, but I don't want to redefine it. How would I call it from ch_ret one_hit ?
Australia Forum Administrator #1
Pass it as an argument.


eg.

void my_new_function (int dam)
{
// blah blah
}

Then in one_hit:

my_new_function (dam);


You may need to pass other arguments as well to be useful.

eg.

void my_new_function ( CHAR_DATA *ch, CHAR_DATA *victim, int dt, int dam)
{
// blah blah
}


Then in one_hit:

my_new_function (ch, victim, dt, dam);



USA #2
Ok, I think it worked. But, whats dt? I looked in fight.c and couldn't find what it was defined as. I saw "dt = TYPE_HIT;". I'm still looking over stuff right now though.

[EDIT] So far the function is working like I wanted it to. I'd just like to know things when I use them. :)

[EDIT2] Also, damage doesn't seem to be going over 30000, which is sh_int. Whats affecting this? I want damage to go higher, but I'm not sure what dt and stuff has to do.
Amended on Sat 13 Sep 2003 12:05 AM by Zeno
Canada #3
DT is short for damage type, it refers to, depending where, the gsn of the shill that is being used, or sometime the type of weapon for a normal attack. If the damage is not going above 30k, ever, then it being restricted somewhere, you might look in the damage functions to make sure that the variable used for damage is not a sh_int, as well as not coded restrictions.
USA #4
I've looked over fight.c and I'm not sure what to change. There's a lot of damage functions, and I've already changed dam to int, but whenever I do over 31000 damage (I think) It goes to 0, or 1. Its a big list to look over, so I'll keep searching. But if someone could be more specific, it would help.
USA #5
Sounds like there's a variable somewhere that is set to sh_int. That would limit that particular variable to 32767 (for most people anyway). I don't believe anything in one_hit() is set to sh_int but you may have something in your new function that is. If you do happen to have a variable set to sh_int, change it to int and the problem with dam becoming 0 or 1 should go away.
USA #6
Yeah, I know, but the problem is, I don't know what function it is. My new fuction is fine, everything's int or higher. This problem existed before the new fuction was put in. A while back, dam was sh_int, but I already changed that to int.