int damagecalc(aclass a, aclass b, anotherclass m)//Calculates damage done with one attack
int ret_damage; //Final damage
float damage; //Net Damage done
float level; //Level of the attacker
float attack; //Attack stat of the attacker
float defense; //Defense stat of the attacked
float base; //Base damage of the attack
float modifier; //Formula as below
float stab; //Same Type Attack Bonus
float type; //Type Effectiveness
float critical; //Critical Ratio
float other; //Accounts for held items
float randomnum; //A number from 0.85 to 1.00
//Critical calcs go here, but for now,
modifier=stab*type*critical*rand; //Formula for modifier
//Formula (It's harder than it looks) (That's what she said)
return ret_damage; //Returns net damage
So, I'm getting an error: invalid operands of types `float' and `int ()()' to binary `operator*'
and it highlights this line modifier=stab*type*critical*rand;
(this line has been underlined above)
So, what am I doing wrong? All definitions outside of this section of the code are okay. I'm pretty sure that the problem is float multiplication.
Well, any help would be very appreciated.
Edit: Just a quick note. The components of the formula themselves can have a decimal point (hence the use of float), but the final result is rounded off and returned as an integer.
Edit 2: Just a side question. Is it possible to manually round off a float downwards to an integer? For eg, 2.112 becomes 2, 2.9999 also becomes 2.
In fact, rand is defined in stdlib.h (or cstdlib) as a function which returns an int and requires no parameter.
Essentially, it has type int ()();
(Yes, it's a type. Yes, functions have types. Yes, you can store a pointer to a function as you would with a normal variable)