Jump to content

[RELEASE] IWAC - Autoclaim addon for WAI [v1.3.1]


iben

Recommended Posts

I'm using my own function for mission claim in static missions.
This function is for Mission claiming (show marker and announce), and warn other players who are breaking into the mission. It doesn't check a double claiming.

Spoiler

AIcity_claimMark = { //[markername,[position],text,distance] spawn AIcity_claimMark;
    private ["_title","_pos","_text","_dist","_claimed","_claimids","_mark","_in"];
    _title = _this select 0;
    _pos = _this select 1;
    _text = _this select 2;
    _dist = _this select 3;
    _claimed = false;
    _claimids = [];
    while {true} do {
        //set who claim 
        if (!_claimed) then {
            //range circle
            _mark = createMarker [_title+"_range",_pos];
            _mark setMarkerShape "ELLIPSE";
            _mark setMarkerBrush "Border";
            _mark setMarkerColor "ColorRed";
            _mark setMarkerSize [_dist,_dist];
            //check someone now in range
            sleep 10;
            _in = false;
            {
                //warn claiming
                if((alive _x) && (_x distance _pos <= _dist )) then {
                    _in = true;
                    RemoteMessage = ["IWAC", [getPlayerUID _x,"You are in claiming zone."]];
                    publicVariable "RemoteMessage";
                    diag_log format["[AI city]: %1 in %2 zone",name _x,_text];
                };
            } forEach playableUnits;
            if (_in) exitWith {
                sleep 30;
                {
                    if((alive _x) && (_x distance _pos <= _dist )) exitWith {
                        _claimed = true;
                        {
                            _claimids set [count _claimids,getPlayerUID _x];
                            RemoteMessage = ["IWAC", [getPlayerUID _x,"Your team have claimed the mission."]];
                            publicVariable "RemoteMessage";
                        } forEach (units group _x);
                        if (wai_radio_announce) then {
                            RemoteMessage = ["radio","[RADIO] Someone has claimed an AI city."];
                            publicVariable "RemoteMessage";
                        };
                        diag_log format["[AI city]: %1 has claimed %2",name _x,_text];
                    };
                } forEach playableUnits;
            };
        };
        //check players. in the claiming group or not, or claimed one not in group.
        if (_claimed) then {
            //claim marker
            _mark = createMarker [_title+"_claim",[(_pos select 0) + _dist/2,(_pos select 1) + _dist/2]];
            _mark setMarkerShape "ICON";
            _mark setMarkerText (_text + " Claimed");
            _mark setMarkerType "hd_flag";
            _mark setMarkerColor "ColorBlue";
            _mark setMarkerSize [1, 1];
            
            //player in range in the claiming group or not
            {
                if(!((getPlayerUID _x) in _claimids) && (_x distance _pos <= _dist )) then {
                    //warn
                    RemoteMessage = ["IWAC", [getPlayerUID _x,"You are in an already claimed mission. Ask for permission!"]];
                    publicVariable "RemoteMessage";
                    diag_log format["[AI city]: %1, not in claiming list, is in %2",name _x,_text];
                    sleep 5;
                };
            } forEach playableUnits;
            //player in claiming group in range or not
            _count = {(alive _x) && (_x distance _pos <= _dist ) && ((getPlayerUID _x) in _claimids)} count playableUnits;
            if (_count < 1) then {
                diag_log format["[AI city]: None in %1 now",_text];
                //warn
                {
                    if((alive _x) && ((getPlayerUID _x) in _claimids)) then {
                        RemoteMessage = ["IWAC", [getPlayerUID _x,"You are out of the mission"]];
                        publicVariable "RemoteMessage";
                    };
                } forEach playableUnits;
                //wait
                sleep 100;
                //check
                _count = {(alive _x) && (_x distance _pos <= _dist ) && ((getPlayerUID _x) in _claimids)} count playableUnits;
                if (_count < 1) then {
                    if (wai_radio_announce) then {
                        RemoteMessage = ["radio","[RADIO] The AI city is in peace."];
                        publicVariable "RemoteMessage";
                    };
                    //delete
                    _claimed = false;
                    _claimids = [];
                    diag_log format["[AI city]: %1 has been unclaimed",_text];
                };
            };
            sleep 5;
        };
        deleteMarker _mark;
    };
};

put the code above in the bottom of server_functions.sqf or somewhere, and call it in each mission sqf like:
["sectorC",[2197.9333, 11942.657, 77.671524],"Bandit Sector C",1500] spawn AIcity_claimMark;
https://imgur.com/0KLdgZJ

I haven't tested, but maybe you can use it in mission systems like DZMS or WAI with terminate command like:

Spoiler

//Claim system start
_handle = ["DZMSMajClaim",_coords,_missName,1500] spawn AIcity_claimMark;

//Wait until the player is within 30 meters and also meets the kill req
[_coords,"DZMSUnitsMajor"] call DZMSWaitMissionComp;

//~~~ mission end ~~//

//Finish Claim system
terminate _handle;

//Let the timer know the mission is over
DZMSMajDone = true;

if this one is not working, you'll still be able to use this function by replacing "while {true}" with "while {!DZMSMajDone}" or such.

Link to comment
Share on other sites

49 minutes ago, Petite said:

Is there a way for other players to get a message mission was claimed by X? 

I put 
              if (wai_radio_announce) then {
                RemoteMessage = ["radio",format["[RADIO] %1 has claimed a mission.",(name _ccl)]];
                publicVariable "RemoteMessage";
              };

under 
              RMSG(CML(_cls,1),FSTR2(STRLO("STR_IWAC_CLAIMED"),ACSTR,CMNAME(_mission)));
around line 222 of mission_winorfail.sqf

 

btw, I also wrote
    [nil,_crate,rSAY,"alarm",2000] call RE;
below the same line to call alarm when one claims the mission

Link to comment
Share on other sites

On 12/12/2017 at 10:22 PM, Schalldampfer said:

I put 
              if (wai_radio_announce) then {
                RemoteMessage = ["radio",format["[RADIO] %1 has claimed a mission.",(name _ccl)]];
                publicVariable "RemoteMessage";
              };

under 
              RMSG(CML(_cls,1),FSTR2(STRLO("STR_IWAC_CLAIMED"),ACSTR,CMNAME(_mission)));
around line 222 of mission_winorfail.sqf

 

btw, I also wrote
    [nil,_crate,rSAY,"alarm",2000] call RE;
below the same line to call alarm when one claims the mission

Awesome I will try thanks.

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

getting this error. i don´t change something in mission_init.sqf

 

while {_running} do {

if (ai_show_remaining) then {
_airemain = (w>
  Error position: <ai_show_remaining) then {
_airemain = (w>
  Error Undefined variable in expression: ai_show_remaining
File z\addons\dayz_server\WAI\addons\IWAC\mission_init.sqf, line 77
Error in expression <ing = true;

while {_running} do {

if (ai_show_remaining) then {
_airemain = (w>
  Error position: <ai_show_remaining) then {
_airemain = (w>
  Error Undefined variable in expression: ai_show_remaining
File z\addons\dayz_server\WAI\addons\IWAC\mission_init.sqf, line 77
Error in expression <ing = true;

while {_running} do {

if (ai_show_remaining) then {
_airemain = (w>
  Error position: <ai_show_remaining) then {
_airemain = (w>
  Error Undefined variable in expression: ai_show_remaining
File z\addons\dayz_server\WAI\addons\IWAC\mission_init.sqf, line 77
Error in expression <ing = true;

while {_running} do {

Link to comment
Share on other sites

@Kimarik

This is where IWAC checks for the variable:
https://github.com/damnrelentless/IWAC/blob/d41ae31c610f38383463aee31c845eccf7d3b8a5/%40DayZ_Epoch_Server/addons/dayz_server/WAI/addons/IWAC/mission_init.sqf#L77-L80

It's normally set in the WAI config. Make sure it's in there:
https://github.com/worldwidesorrow/Wicked-Ai-Overpoch/blob/9ae40cfeb2d240423d0093155d1cfe83567d9561/WAI/config.sqf#L20

I guess this was added to WAI pretty late so your problem might just be that you don't have the latest version of WAI installed.

Link to comment
Share on other sites

  • 2 weeks later...
2018/01/11, 18:14:09 "WAI: [Mission:[Hero] Hippy Commune]: Starting... [10306.5,8514.39,0]"
2018/01/11, 18:14:09 Error in expression <sion); 
_car = (_mar select 4);
_cia = (_car select 1);

_type = (_mar select 1)>
2018/01/11, 18:14:09   Error position: <_car select 1);

_type = (_mar select 1)>
2018/01/11, 18:14:09   Error Undefined variable in expression: _car
2018/01/11, 18:14:09 File z\addons\dayz_server\WAI\addons\IWAC\mission_init.sqf, line 85

Getting this error that is spamming-

Thoughts? or how to fix?\

 

 

Also, is there a way to add static missions having this to warn players when others are going to ai compounds

Link to comment
Share on other sites

1 hour ago, DieTanx said:

2018/01/11, 18:14:09 "WAI: [Mission:[Hero] Hippy Commune]: Starting... [10306.5,8514.39,0]"
2018/01/11, 18:14:09 Error in expression <sion); 
_car = (_mar select 4);
_cia = (_car select 1);

_type = (_mar select 1)>
2018/01/11, 18:14:09   Error position: <_car select 1);

_type = (_mar select 1)>
2018/01/11, 18:14:09   Error Undefined variable in expression: _car
2018/01/11, 18:14:09 File z\addons\dayz_server\WAI\addons\IWAC\mission_init.sqf, line 85

Getting this error that is spamming-

Thoughts? or how to fix?\

 

 

Also, is there a way to add static missions having this to warn players when others are going to ai compounds

This was due to my infistar spawning missions- not related to the script-

 

Thanks iben for the help

Link to comment
Share on other sites

  • 3 weeks later...

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
  • Discord

×
×
  • Create New...