problem with variables in one_hit

Posted by RyueOkami on Mon 08 Dec 2003 08:46 AM — 7 posts, 24,707 views.

#0
I have a small problem with the smaug engine:
I have 2 sh_int variables (combat,fighting) stored
in the character.


for the one_hit, I use those two to calculate a to hit number (called offensiv and is from type int).

offensiv, combat and fighting are 0 each.

but when I say

offensiv=ch->combat+ch->fighting;

offensiv gets a real high value (12753 or so).

can someone say me what to do?
USA #1
Looks like you didn't actually initialize your variable. They don't default to 0 when you declare them; you have to manually set them to 0 when the character object is created.


Read this post for some more information on uninitialized variables:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3532
#2
nö hab es initialisiert und mir die jeweiligen Variablenwerte einzeln ausgeben lassen (dann passt es, aber sobald ich die zuweisung mache, dann passt es nimma)

OBJ_DATA *wield;
int diceroll=0;
int Offensiv=0;
int Defensiv=0;
int Damage_Reduction=0;
int Damage_Done=0;
int Critical=0;
ch_ret retcode = rNONE;
static bool dual_flip = FALSE;

Offensiv=((int) (ch->DBZ_combat))+((int)(ch->DBZ_Fighting)); //Ab hier hat Offensiv den seltsamen Wert
Damage_Done=ch->DBZ_physical+ch->DBZ_Fighting;
Defensiv=victim->DBZ_combat+ch->DBZ_Evade;
Damage_Reduction=victim->DBZ_Defense;




dann eines noch, die DBZ_physical und so setz ich in der load_mobile....muss ich die sonst noch wo setzen? (die Werte gehen irgendwo verloren)
#3
Correction the Offensiv is now set right....only thing is, that he doesn't remember the values set in load_mobiles to one_hit
Australia Forum Administrator #4
You need to put the calculated values back. eg.

ch->DBZ_combat = (something);
USA #5
RyueOkami, if you could post that message again in English, that'd be nice... I know German enough to get the general idea of what you're saying but it would be nice to be more precise about things. :)
#6
Upsi sry overlooked that I wrote it in german *g*.

The problem with the value of offensive is solved.
(tnx).

The translation is
(with some additions ;) ): I set the variable DBZ_physical
in load_mobiles. But it seems the value I set it to
is forgotten when I get to one_hit. Must I set the
value again somewhere else too?