RogerBacon
King
- Joined
- Nov 16, 2003
- Messages
- 649
I have the following code which is supposed to get two random numbers between 0 and unit's strength -1. Similar code works fine in Python but this one is in C++ and it isn't working exactly right.
The defender in my test is a galley (combat strength 2). Even with it's tile defense bonus the currCombatStrFloat should return a max of 2.2, which means 2 after taking (int). However, I'm getting rolls as high as 68. Anyone have any idea why?
Here's, basically, the same code in Python and it is working fine.
Roger Bacon
Code:
attackerDamageRoll = GC.getGameINLINE().getSorenRandNum((int)(currCombatStrFloat(this->plot(),this)+0.5), "attackerDamageRoll");
defenderDefenseRoll = GC.getGameINLINE().getSorenRandNum((int)(currCombatStrFloat(pPlot,pLoopUnit)+0.5), "defenderDefenseRoll");
The defender in my test is a galley (combat strength 2). Even with it's tile defense bonus the currCombatStrFloat should return a max of 2.2, which means 2 after taking (int). However, I'm getting rolls as high as 68. Anyone have any idea why?
Here's, basically, the same code in Python and it is working fine.
Code:
casterPower = caster.currCombatStrFloat(CyMap().plot(caster.getX(), caster.getY()), caster)+0.5
targetPower = targetPlot.getUnit(i).currCombatStrFloat(targetPlot, targetPlot.getUnit(i))+0.5
casterRoll = gc.getGame().getMapRand().get(int(casterPower*amount), "Spell Atack roll")
targetRoll = gc.getGame().getMapRand().get(int(targetPower), "Spell Atack roll")
Roger Bacon