Well, I figured out how to add smoke to the game but I was at a loss when trying to remove the "blocking" objects when removing smoke.
I did, however, solve my problem but there has to be a better approach.
I spent hours trying to write scripts using all the object related functions, and I just couldn't get them to work correctly.
The biggest problem is that object ID's are not constant across game runs (as you know).
The ID's start at 0 and end at the last object placed, which can be in the hundreds.
I discovered that if you delete an object, that ID is now available and will be reused if you place another object.
I'm trying to retreive the ID of an object on the map ... but to no avail.
Below is the script that I'm using to currently remove the smoke "blocking" objects. You'll note that I'm just running a loop to look for ID's from 40-100. I set this range of values because I know that I have ~46 objects on the map. This technique works great, and it's very fast compared to running a loop across the map to look for objects. When I tried using other functions to run loops across the map it took 5-10 seconds to run it ... perhaps it was bad code because I never could get that to work right!
Also, you'll note that I'm calling the function ... SetObjectPosition(id, x, y) ... before I deleted the smoke object. Believe it or not, moving the object to the "trash can" at X/Y coordinates 0,0 was necessary to update the LOS at the beginning of the turn. Without this move, the game engine (LOS) would still think an object is on the tile, despite being physically removed.
Anyway ... can you think of a better approach (script wise) that I can use to locate and remove an object on the map?
Thanks!
Code: Select all
FUNCTION StartTurn(side)
{
int id ;
int x ;
int y ;
int i ;
if( side == 0 )
{
for (id=40; id<=100;id++)
{
if( IsObjectName(id, "smoke_allied") == 1 )
{
SetObjectPosition(id, 0, 0) ;
DeleteObject(id) ;
}
}
AddVizFunctionCall("HideEffectMarker", -9000) ;
}
}


