Originally Posted by
ATAG_Oskar
Bombs create craters without any need for code.
There are reasons why you might want to create a crater programatically though, I know we did for SoW although with the architecture we used it worked a little differently to the OP's requirement.
Our code is here, we use mass much the same as you do so can't see why there's a math problem. What is the precise error thrown?
We only record craters on airfields, and put them into the database for addition to the mission file which is compiled dynamically on run by our server "template manager" software.
Code:
public void AtBombExplosion(string title, double mass, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
{
Debug.DebugOutput("BombExplosion", 3);
int objectiveid = ObjectiveHandling.CheckAreaTargetBombExplosion(mass, pos);
if (objectiveid != 0)
{
Objective obj = ObjectiveHandling.ReturnObjectiveFromID(objectiveid);
obj.SetBombWeightTaken(mass);
ObjectiveHandling.CheckForNewObjectiveRequired(obj.ID);
if (obj.Type == "Airfield" && mass>50)
{
stats.AddCraterToTable(objectiveid, pos);
}
Sortie s = PilotsHandling.FindSortie(initiator.Actor.Name());
if (s != null)
{
string _event = "Dropped Bomb on Objective";
string EventLabel1 = obj.Name;
string EventLabel2 = mass.ToString();
string EventLabel3 = " ";
string EventLabel4 = Battle.THIS.GamePlay.gpSectorName(obj.Location.x, obj.Location.y);
stats.AddEventToTable(_event, s.SortieID, EventLabel1, EventLabel2, EventLabel3, EventLabel4);
}
}
}
once the crater is in the table, the mission file creates a row but used the object
Code:
buildings.House$BombCrater_100_kg
Bookmarks