Jump to content

Fix for Broken Traders when using WAI Mission System in NAPF Epoch


Recommended Posts

A number of weeks ago I took a break from my own servers to look around for fresh ideas. I ran into the Wicked AI mission system on a few Epoch servers. I'd seen the missions before, long before I started using a mission system myself, and had employed DZMS for my servers, heavily expanding it. Knowing more now than I did before, I found WAI's use of features like fixed HMG emplacements interesting. 

I set out to use WAI MS in conjunction with DZMS ( and DZAI, for patrols, for that matter ), for heavier team missions. That way, the DZAI patrols harass everyone lightly... the DZMS missions allow solo players opportunities to collect loot, and the big WAI team missions play out for heavily armored groups.

I noticed on two servers running WAI Epoch Napf that traders were broken. The pattern was the same -- most Emmem traders simply won't recognize the player. Only the med and clothing traders in Lenzburg work. Most of the traders in Schratten seem OK, but the hero trader at SWAF is broken.

After I got the three systems working happily together -- not as bad an exercise as one might think, simply load them in the order DZAI, DZMS, WAI, and dispense with all the conditionals testing for other systems, and hard-code the side center and hostile and friendly relationships at each major module load init, handling only those sides employed incrementally for each system --  I found that my traders had broken in precisely the same fashion in which they were broken on the two servers I'd tried out the weeks before.

Googling reveals that the WAI Epoch Napf trader breakage is a long-known issue, documented well back into 2014. No one has posted a detailed fix, however.

The issue seems to be that WAI upsets the hostile/neutral/friendly classifications that allow the trader self-action filter to successfully test for a trader in front of the player. The only thing different about WAI I believe is its handling of side RESISTANCE, so I'm guessing -- GUESSING! -- since some traders work and others don't after WAI loads that the issue is that agents -- which seem to be unaligned -- have a somewhat undefined side for the purposes of checking hostility. Since the broken relationships appear to be repeatable, perhaps the hostility has some relationship to the skin. Why it works before there's a RESISTANCE center in the game and before there are hostility relationships between RESISTANCE and others.... I haven't figured out. Like I said, this is partly guesswork.

This, however, fixes it for Epoch Napf running DZAI, DZMS, and WAI...

I added this code to the fn_selfActions.sqf file:

Three variables into the private statement:

private ["_PosPlayer","_CoordX","_CoordY",...

.....

And then changes below -- commenting out the three existing "humanity logic" conditionals and adding new tests based on locations unique to Napf and humanity...

        if (s_player_parts_crtl < 0) then {

//                sleep 1.0;
//                titleText ["SECOND TRADER GATE PASSED.", "PLAIN DOWN", 3];

            // get humanity
            _humanity = player getVariable ["humanity",0];

            _traderMenu = call compile format["menu_%1;",_traderType];

            // diag_log ("TRADER = " + str(_traderMenu));
            
            _low_high = "low";

            _humanity_logic = false;

//            if((_traderMenu select 2) == "friendly") then {
//                _humanity_logic = (_humanity < -5000);
//            };

//            if((_traderMenu select 2) == "hostile") then {
//                _low_high = "high";
//                _humanity_logic = (_humanity > -5000);
//            };

//            if((_traderMenu select 2) == "hero") then {
//                _humanity_logic = (_humanity < 5000);
//            };

            // get the individual player coordinates

            _PosPlayer = getPos player;
            _CoordX = _PosPlayer select 0;
            _CoordY = _PosPlayer select 1;

            // check for being at bandit trader

            if ( ( _CoordX > 10205 ) and ( _CoordX < 10605 ) and ( _CoordY > 8170 ) and ( _CoordY < 8570 ) ) then {
//                sleep 1.0;
//                      titleText ["BANDIT TRADER DETECTED.", "PLAIN DOWN", 3];
                _low_high = "high";
                _humanity_logic = ( _humanity > -5000 );
            };

            // check for being at hero trader

            if ( ( _CoordX > 5050 ) and ( _CoordX < 5250 ) and ( _CoordY > 4850 ) and ( _CoordY < 5050 ) ) then {
//                sleep 1.0;
//                     titleText ["HERO TRADER DETECTED.", "PLAIN DOWN", 3];
                _humanity_logic = ( _humanity < 5000 );
            };

            if ( _humanity_logic ) then {
               
//                sleep 1.0;
//                      titleText ["HUMANITY LOGIC INVOKED.", "PLAIN DOWN", 3];

                _cancel = player addAction [format[localize "STR_EPOCH_ACTIONS_HUMANITY",_low_high], "\z\addons\dayz_code\actions\trade_cancel.sqf",["na"], 0, true, false, "",""];
                s_player_parts set [count s_player_parts,_cancel];

            } else {

//                sleep 1.0;
//                    titleText ["TRYING TO ADD TRADER MENU.", "PLAIN DOWN", 3];
                
                // Static Menu
                {
                    //diag_log format["DEBUG TRADER: %1", _x];
                    _buy = player addAction [format["Trade %1 %2 for %3 %4",(_x select 3),(_x select 5),(_x select 2),(_x select 6)], "\z\addons\dayz_code\actions\trade_items_wo_db.sqf",[(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4),(_x select 5),(_x select 6)], (_x select 7), true, true, "",""];
                    s_player_parts set [count s_player_parts,_buy];
                
                } count (_traderMenu select 1);

                // Database menu
                _buy = player addAction [localize "STR_EPOCH_PLAYER_289", "\z\addons\dayz_code\actions\show_dialog.sqf",(_traderMenu select 0), 999, true, false, "",""];
                s_player_parts set [count s_player_parts,_buy];

            };
            s_player_parts_crtl = 1;
            
        };
    } else {
        {player removeAction _x} count s_player_parts;s_player_parts = [];
        s_player_parts_crtl = -1;
    };
 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...