Here's the pulse of my rain COG, the code that actually fires the rain templates. But it's acting a bit funny. It's supposed to scan the sector, count the number of raindrops, and if that number is fewer than the specified amount (based on a user specified density and area of the surface) it will create rain. If not, it won't. It's supposed to make it so rain is evenly distributed no matter what the size of the surface. If you have a rainDensity of 10, it shouldn't be dropping 10 drops at a time from a surface whose area is 0.2. It should only be dropping 2. But for some reason I'm getting as many as 9 or 10 drops from a small sky opening when, infact there should be no more than 2 in the sector at any given time. What's going on?
Oh, and don't worry about the code block after if(numDropsInSector < heapGet(numSkySurfaces + i)). That part works fine. I'm having trouble regulating the amount of rain however.
Oh, and don't worry about the code block after if(numDropsInSector < heapGet(numSkySurfaces + i)). That part works fine. I'm having trouble regulating the amount of rain however.
Code:
pulse: // Loop through all our stored sky surfaces using the loop index 'i' and // heapGet(). for(i = 0; i < numSkySurfaces; i = i + 1) { temp = firstThingInSector(getSurfaceSector(i)); numDropsInSector = 0; // Add up all the things in the sector which are raindrops. for(j = 0; j < getSectorThingCount(getSurfaceSector(i)); j = j + 1) { if(getThingTemplate(temp + j) == raindropTpl) numDropsInSector = numDropsInSector + 1; } // Only create rain if the current number of raindrops in the sector // is less than the number it should have. if(numDropsInSector < heapGet(numSkySurfaces + i)) { surface = heapGet(i); temp = heapGet(numSkySurfaces * 2 + i) * rand(); testPoint = heapGet(numSkySurfaces * 4 + numMaxTestPoints * i + temp); testPoint = vectorSet(vectorX(testPoint), vectorY(testPoint), vectorZ(testPoint) - 0.05); ghostObj = createThingAtPos(ghostTpl, getSurfaceSector(surface), testPoint, '-90 0 0'); proj = fireProjectile(ghostObj, raindropTpl, -1, -1, '0 0 0', '0 0 0', 0, 0x0, 0, 0); destroyThing(ghostObj); } } return;
Bassoon, n. A brazen instrument into which a fool blows out his brains.