Error: divide by zero

Capture

This is a new error that seems to have started happening with the latest update. Don’t remember seeing it before.

Any idea what that error may be from?

Can you post the script?

1 Like

Pretty sure it was this?

switch (Random(2))
{
case 0: oObject = CreateObject(OBJECT_TYPE_PLACEABLE, “chest001”, GetLocation(oWaypoint)); break;
case 1: oObject = CreateObject(OBJECT_TYPE_CREATURE, “boss001”, GetLocation(oWaypoint)); break;
}

AssignCommand(oObject, DetermineCombatRound(oPC));

The chest didn’t know how to attack the player, so I changed it to this and am testing now…

switch (Random(2))
{
case 0: oObject = CreateObject(OBJECT_TYPE_PLACEABLE, “chest001”, GetLocation(oWaypoint)); break;
case 1: oObjectx = CreateObject(OBJECT_TYPE_CREATURE, “boss001”, GetLocation(oWaypoint)); break;
}

AssignCommand(oObjectx, DetermineCombatRound(oPC));

Well, that’s what you get for trying to make a placeable perform an attack. Only creatures can attack. And DetermineCombatRound does not check if OBJECT_SELF is a creature. Classic BioWare scripting.

Same happens in 1.69. You are not noticing it always because of Random.


  1. In nw_i0_generic
  2. DetermineCombatRound calls chooseTactics
  3. chooseTactics calls DetermineClassToUse
  4. DetermineClassToUse divides something by GetHitDice(OBJECT_SELF)
  5. … which is 0 for placeables
  6. QED
2 Likes

CEP has a chest creature that will attack just fine.