Jump to content
Haymaker

Dynamic Spawning Script Debugging

Recommended Posts

                // Determine nearestBuilding
                _nearestBuilding = nearestBuilding _position; 
                
                // Create the warlord group
                _group = createGroup East;
				
				// Issue occurs somewhere within the nested if
                if (player distance _position > 400) then{

                    // Determine whether to spawn station in a building or outside
                    if (_nearestBuilding distance _position < 400) then {
                    
                        // Spawn a station in the nearestBuilding
                        _spawnFlag = createVehicle [_flag, _nearestBuilding buildingPos 1, [], 0, "NONE"];
                                                                  
                        // Spawn a cache in the nearestBuilding
                        _spawnCache = createVehicle [_cache, _nearestBuilding buildingPos 1, [], 0, "NONE"];
                                                                  
                    } else {
                                                                  
                        _cache = "CUP_TKVehicleBox_EP1";
                        _spawnflag = createVehicle [_flag, _position, [], 0, "NONE"];
                        _spawncache = createVehicle [_cache, _position, [], 0, "NONE"];
                        _spawntent = createVehicle ["Land_TentA_F", _position, [], 0, "NONE"];
                                                                  
                    };
                                                                  
                    _spawnVehicleStation = createVehicle [_vehicleStation, _position, [], 0, "NONE"];
                    _warlord createUnit [_position, _group];
                };

No I did not include the entire script because it isn't necessary, the problem that is occurring is occurring somewhere within this excerpt - so assume all undeclared variables have been declared.

 

So I've been working on some dynamic spawning scripts for some insurgent objects. I added a nested if to determine whether to spawn some of the assets inside a building or outside. Now this works about half of the time, the other half of the time it only spawns "_warlord" and "_vehicleStation" in the location, and throws "_cache" and "_flag" to the origin. I'm assuming that this could be because it doesn't recognize certain buildings as enterable with positions, in which case I will just have to prepare an array of buildings to look for. 

 

Any help or opinions are much appreciated. Thank you.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×