Announcement

Collapse
No announcement yet.

My mortar shoots nothing?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • My mortar shoots nothing?

    Greetings.

    My issue is that I have got a mortar battery in a mission of mine, that fires nothing. It fires, but the ins_mortar getVariable "ARTY_AMMO" doesn't show anything, and no rounds ever impact. Doing removeAllWeapons on the mortar, and adding a ARTY_8Rnd_82mmHE_2B14 magazine didn't help either.

    I've got an Insurgent mortar (mortar1) synced to an artillery logic (ins_mortar).
    The fire mission is declared as fireMission = ["IMMEDIATE", "HE", 0, 1]; and _mortarTgtPos is the getPosASL coordinates of a unit.

    All debug messages shows, the marker is correctly placed on target, the mortar does fire, but the ammo used never shows up, no round ever impacts, no error messages. What have I done wrong?

    fireArty.sqf
    Code:
    #define __debug true
    
    _mortarTgtPos = _this select 0;
    
    if (__debug) then { player sideChat "Executing fireArty.sqf" };
    
    if ([ins_mortar, _mortarTgtPos, fireMission select 1] call BIS_ARTY_F_PosInRange) then
    {
    	[ins_mortar, _mortarTgtPos, fireMission] spawn BIS_ARTY_F_ExecuteTemplateMission;
    	hint "mortar1: Firing.";
    	_mrk = createMarker ["MortarTarget", _mortarTgtPos];
    	_mrk setMarkerColor "ColorBlack";
    	_mrk setMarkerShape "ICON";
    	_mrk setMarkerType "mil_objective";
    	
    	waitUntil {ins_mortar getVariable "ARTY_ONMISSION"};
    	if (__debug) then { player sideChat "mortar1 is on a mission" };
    	if (__debug) then { player sideChat format["ammo used:", ins_mortar getVariable "ARTY_AMMO"] };
    	waitUntil {ins_mortar getVariable "ARTY_COMPLETE"};
    	if (__debug) then { player sideChat "mortar1 has finished fire mission" };
    	waitUntil {ins_mortar getVariable "ARTY_SPLASH"};
    	if (__debug) then { player sideChat "mortar1 about to splash!" };
    	
    	sleep 10;
    	
    	deleteMarker _mrk;
    }
    else
    {
    	hint "mortar1: Target out of range";
    };
    
    if (__debug) then { player sideChat "Exiting fireArty.sqf" };




  • #2
    Re: My mortar shoots nothing?

    ammo used will not show because you don't have a "specifier" that links to the variable.

    Code:
    if (__debug) then { player sideChat format["ammo used:", ins_mortar getVariable "ARTY_AMMO"] };
    you should have a "specifier" (%1) after "ammo used:". In regards of the shell not impacting, I have no idea why it wouldn't. Double check your fire mission template.


    IN GAME ARMA: |TG-Irr| Lq.Snake

    Comment


    • #3
      Re: My mortar shoots nothing?

      Gah. Doh. Nice syntax miss by me. :P

      Thanks, let's see if it gives anything useful this time.


      Okido, syntax corrected and now it shows the ARTY_AMMO as "HE", so at least that's one less problem. Still can't figure out why it doesn't hit though. Bleh, will have to look more at it tomorrow.



      Comment


      • #4
        Re: My mortar shoots nothing?

        Just as a curiosity, where and how did you define the variable ARTY_AMMO? Did you just assign the string "HE" to that variable or does it actually return the type of ammo used?


        IN GAME ARMA: |TG-Irr| Lq.Snake

        Comment


        • #5
          Re: My mortar shoots nothing?

          See this to see in detail what ARTY_AMMO is. Briefly put it is an artillery module-specific variable with which I can inqurie a battery about what ammunition type it is using for a fire mission.



          Comment


          • #6
            Re: My mortar shoots nothing?

            I see. Makes more sense now. Thanks, Inkompetent.

            Try removing that magazine manually instead of using removeAllWeapons command. So,

            Code:
            this removeMagazines "ARTY_8Rnd_82mmHE_2B14";
            and then re-adding it:
            Code:
            this addMagazine "ARTY_8Rnd_82mmHE_2B14";
            Probably won't do anything but doesn't hurt to try.


            IN GAME ARMA: |TG-Irr| Lq.Snake

            Comment


            • #7
              Re: My mortar shoots nothing?

              Another thing, it might also be because the artillery logic hasn't initialized yet?

              Code:
              //* Waits until the arty logic has loaded properly *//
              waitUntil { !isNil { ins_mortar getVariable "initDone"} };
              waitUntil { ins_mortar getVariable "initDone" };


              IN GAME ARMA: |TG-Irr| Lq.Snake

              Comment


              • #8
                Re: My mortar shoots nothing?

                Actually the base script aimArty.sqf is executed from the artillery logic, which can't happen until it is initialized, so I got that covered :)



                Comment


                • #9
                  Re: My mortar shoots nothing?

                  I see. Might just be some sort of glitch the arty has? I'm really not sure what's causing it not to impact. That is very strange. The mortars are controlled by AIs, correct? Have you tried using the virtual arty logic and see what happens? Perhaps you should use spawn mode for the shells. It might just be because there's a hill in the way and the shell keeps hitting it.


                  IN GAME ARMA: |TG-Irr| Lq.Snake

                  Comment


                  • #10
                    Re: My mortar shoots nothing?

                    Clear path from the artillery to target, but yeah. I probably should try a virtual battery and/or spawned shells just to see what happens.



                    Comment


                    • #11
                      Re: My mortar shoots nothing?

                      Ah, well. Tried to just execute my fireArty.sqf script and it works like a charm. Somehow it goes wrong in the aimArty.sqf script, or on the way between the two scripts.

                      Odd, since it does make a proper marker positioning and all, but at least I can rule out one part of the system. Starting to think it can be stuff like pointers and existing/non-existing variables... It's not the scopes though, that I know. Got all variables privated just to make sure that wasn't the case.



                      Comment


                      • #12
                        Re: My mortar shoots nothing?

                        Do you mind if I take a look at your aimArty.sqf? Very odd that it would do that... have you tried setting the shells to spawn mode? If so, what was the result?


                        IN GAME ARMA: |TG-Irr| Lq.Snake

                        Comment


                        • #13
                          Re: My mortar shoots nothing?

                          Here it is. My guess right now is that the trigger listing of units is somehow messed up, and I'm experimenting with that at the moment.
                          I've used debug messages to control that it listed the right units, and at that point all seemed right though. It's moments like this I'd like to have better control over the allocated memory and pointers...

                          Edit: All the shots this far have been done with the random aiming.

                          aimArty.sqf
                          Code:
                          #define __debug true
                          sleep .1;
                          
                          private ["_bluforCount",
                          	"_bluforTgt",
                          	"_canFire",
                          	"_doFire",
                          	"_knowsAbout",
                          	"_mortar",
                          	"_mortarTgt",
                          	"_mortarTgtPos",
                          	"_spotter",
                          	"_spotterDispersion",
                          	"_spotterRange",
                          	"_spread",
                          	"_trg"];
                          
                          if (__debug) then { player sideChat "Executing aimArty.sqf" };
                          
                          _spotter = _this select 0;
                          _mortar = _this select 1;
                          
                          if !(local _spotter) exitWith{};
                          
                          _spotterDispersion = false;
                          _canFire = true;
                          _mortarTgt = nil;
                          
                          //sleep (60  + (random 60));
                          
                          while {_canFire} do
                          {	
                          	// List BLUFOR units
                          	_trg = createTrigger ["EmptyDetector", position _mortar];
                          	_trg setTriggerArea [5000, 5000, 0, false];
                          	_trg setTriggerActivation ["WEST", "PRESENT", false];
                          	_trg setTriggerType "NONE";
                          	_trg setTriggerStatements ["this", "bluforList = thisList", ""];
                          	sleep 10;
                          	deleteVehicle _trg;
                          	
                          	if ((alive _spotter) && spotterDetect) then
                          	{
                          		if (__debug) then { player sideChat "Spotter-assisted aiming" };
                          		
                          		_knowsAbout = 0;
                          		{	// Check for most known about target
                          			if ((_spotter knowsAbout _x) > _knowsAbout) then
                          			{
                          				_knowsAbout = _spotter knowsAbout _x;
                          				_mortarTgt = _x;
                          			};
                          		} forEach bluforList;
                          		
                          		if !(_spotterDispersion) then
                          		{
                          			_spread = _spotter distance _mortarTgt;
                          			[ins_mortar, _range] call BIS_ARTY_F_SetDispersion;
                          			_spotterDispersion = true;
                          		};
                          		sleep (35 + (random 30)); // reduced 10 seconds due to pause by trigger
                          	}
                          	else
                          	{	// Pick a random target
                          		if (__debug) then { player sideChat "Random aiming" };
                          		_bluforCount = count bluforList;
                          		_bluforTgt = floor (random _bluforCount);
                          		_mortarTgt = bluforList select _bluforTgt;
                          		
                          		if (_spotterDispersion) then
                          		{
                          			_spotterDispersion = false;
                          		};
                          		_spread = (_mortar distance _mortarTgt)/2;
                          		[ins_mortar, _range] call BIS_ARTY_F_SetDispersion;
                          		sleep (50 + (random 60)); // reduced 10 seconds due to pause by trigger
                          	};
                          	
                          	// distance between spotter and targets
                          	_spotterRange = if !(alive _spotter) then {1000} else {_spotter distance _mortarTgt};
                          		
                          	// check if targets are too close to mortar or spotter
                          	if !((_spotterRange < 100) || ((_mortar distance _mortarTgt) < 100)) then
                          	{
                          		_doFire = if (__debug) then {1} else {floor (random 2)};
                          		if (_doFire == 1) then
                          		{	// Fire
                          			if (__debug) then { player sideChat format["mortartgt is: %1", _mortarTgt] };
                          			
                          			if ([ins_mortar, fireMission] call BIS_ARTY_F_StillViable) then
                          			{
                          				if (__debug) then { player sideChat "ins_mortar is viable." };
                          				_mortarTgtPos = getPosASL _mortarTgt;
                          				if (__debug) then { player sideChat format["Target X: %1, Y: %2, Z: %3", _mortarTgtPos select 0, _mortarTgtPos select 1, _mortarTgtPos select 2] };
                          				nul = [_mortarTgtPos] spawn s_fireArty;
                          			}
                          			else
                          			{
                          				if (__debug) then { player sideChat "ins_mortar is no longer viable" };
                          				_canFire = false;
                          			};
                          		};
                          	};
                          };



                          Comment


                          • #14
                            Re: My mortar shoots nothing?

                            Tried replacing the script-created trigger with a looping, editor-placed one, but same issue. Still the bluforList variable looks fine though. Counts 13 as it should, and the unit names look correct.



                            Comment


                            • #15
                              Re: My mortar shoots nothing?

                              Okay, something is *seriously* bugged, because even if I hard-code the script-call in aimArty.sqf to:

                              nul = [getPosASL alpha3_2] execVM "s\fireArty.sqf";

                              ...it fails to end with impacting grenades. Doesn't matter if I use execVM or spawn, or if I rename the script handle. Same result. Giving aimArty.sqf a unique handle doesn't help either.

                              However if I do the exact same execution from a radio trigger it works like a charm.



                              Comment

                              Connect

                              Collapse

                              TeamSpeak 3 Server

                              Collapse

                              Advertisement

                              Collapse

                              Twitter Feed

                              Collapse

                              Working...
                              X