f3cuk / WICKED-AI

Wicked AI missions for your server
30 stars 59 forks source link

Proposed changes #46

Closed SJossy closed 10 years ago

SJossy commented 10 years ago

Found a few bugs, typos, and completely changed the vehicle spawn and save methods which made mission files a little easier to understand

f3cuk commented 10 years ago

Nice work Sjossy,

There were two reason why i moved the custom_publish after the mission gets cleared.

  1. Easy way to ensure nothing gets written to the database before the mission gets cleared
  2. Sometimes when vehicles get published they "glitch and die", at times even resulting in killing everyone at the mission. This does not fix the glitching, but atleast you are in the area and chances are you are able to prevent the vehicle from blowing up. At least, that was my theory behind it.
SJossy commented 10 years ago

If I understand correctly, the glitch and die you are referring to was because they clip into the terrain or an object and bounce around? If that's the case I can stop that happening by moving the createVehicle into the vehicle publish code and make a safepos check easy enough, also I added the surfacenormal check to set the vehicle aligned to the terrain instead of clipping through hills and such so that may prevent most of the glitching that's occuring.

In regards to the vehicles going into the db before the mission gets cleared, I can prevent that again if you want

rockeumel commented 10 years ago

i add a GetIn Eventhandler to all my spawned missionvehicles, if a player gets in the vehicle, then it will be published.

f3cuk commented 10 years ago

@SJossy: The glitch happened when a vehicle got published. Before that it just kinda floats at the position it's placed at.

I think the vehicle part might need some rethinking. Right now its a lot of redundant code in most of the mission files. When actually all users really should need to input is a vehicle class, position and possibly a facing direction

Something like this would be awesome

_vehicle = [_vehclass, _position] call custom_vehicle_publish; // Publish the vehicle in a safe place near the position
_c130 = ["C130",[123.45,123.45,3],true,140] // Publish the vehicle in a fixed position with a fixed direction.

Then in custom publish

_vehclass = _this select 0;
_position = _this select 1;
_count = count _this;

if(_count > 2) {
    _position_fixed = _this select 2;
    if(_count > 3) {
        _direction = _this select 3;
    } else {
        _direction = floor(round(random 360)) BIS_fnc_selectRandom;
    };
} else {
    _position_fixed = false;
    _direction = floor(round(random 360)) BIS_fnc_selectRandom;
};

@rockeumel: I think SJossy added that in our Testbranch yesterday.

rockeumel commented 10 years ago

//Armed Land Vehicle _veh = createVehicle [_vehclass,_position, [], 0, "CAN_COLLIDE"];

_veh = createVehicle [_vehclass,_position, [], 10, "FORM"];

if you spawn a vehicle with the special "FORM" it should not glitch in any other object.

SJossy commented 10 years ago

Ah good to know, yeah I already revamped the vehicle spawn to only publish once someone gets in, I'm using findEmptyPosition if a position is not set as static but I will use FORM also as a double check thanks!

rockeumel commented 10 years ago

i like isflatempty https://community.bistudio.com/wiki/isFlatEmpty

_newpos = _testpos isflatempty [ (sizeof typeof _object) / 2, //--- Minimal distance from another object 0, //--- If 0, just check position. If >0, select new one 0.3, //--- Max gradient (sizeof typeof _object), //--- Gradient area 0, //--- 0 for restricted water, 2 for required water, false, //--- True if some water can be in 25m radius _object //--- Ignored object ];

SJossy commented 10 years ago

would that go something like this?

if (!_position_fixed) then {
    _isFlat = [];
    _attempt = 0;
    while {count _isFlat == 0} do {
        _attempt = _attempt + 1;
        _isFlat = _position isFlatEmpty [
            (sizeof typeof _vehicle) / 2,   //--- Minimal distance from another object
            0,                              //--- If 0, just check position. If >0, select new one
            0.6,                            //--- Max gradient
            (sizeof typeof _vehicle),       //--- Gradient area
            0,                              //--- 0 for restricted water, 2 for required water,
            false,                          //--- True if some water can be in 25m radius
            _vehicle                        //--- Ignored object
        ];
        if (_attempt == 50) exitWith { diag_log("Failed to find suitable position for " +str(_class)); };
    };
};
rockeumel commented 10 years ago

Maybe like that: for loop is faster then while

if (!_position_fixed) then { _isFlat = []; for "_i" from 1 to 50 do { _isFlat = _position isFlatEmpty [ (sizeof typeof _vehicle) / 2, //--- Minimal distance from another object 0, //--- If 0, just check position. If >0, select new one 0.6, //--- Max gradient (sizeof typeof _vehicle), //--- Gradient area 0, //--- 0 for restricted water, 2 for required water, false, //--- True if some water can be in 25m radius _vehicle //--- Ignored object ]; if (count _isFlat >1) exitwith {}; }; if (count _isFlat == 0) exitWith { diag_log("Failed to find suitable position for " +str(_class)); }; };

SJossy commented 10 years ago

Good point, I'm too tired to be doing this right now :zzz:

SJossy commented 10 years ago

I wasn't able to get isFlatEmpty functioning correctly but I ended up getting good test results with findEmptyPosition, the ikea mission with 3 vehicles spreads them around the box evenly, so this should be ready to merge, let me know what you think

f3cuk commented 10 years ago

Hey man,

Great work, really glad you decided to join us! Until the weekend i wont have much time to code or review or testing. Judging by the other stuff you have already done i'm gonna go ahead and merge this.

SJossy commented 10 years ago

ok cool, I can start some work on other areas if you'd like, it looks like the weapon array's could use some love, I already have a script that determine's what magazines to add from an array if you want me to integrate it. It also handles magazines and backpacks in the same array so it makes for easy config

Or I'm happy to work on another area all together if you want :)