Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Secound Ac-130 Firing Problem - Debug

  1. #1

    Secound Ac-130 Firing Problem - Debug

    Well, here I am asking for help again.

    My Ac-130 script works in basic form, but I wanted to add some realism.

    So, what has quiet a few smaller numbers, but not a lot of larger ones? I jumped for Exponential. The exp command wouldn't work in Arma 2, I found out after a lot of time trying to get it to work. Next best thing.

    I picked Binary. The script is a bit complicated, but experianced coders will make easy sence of it.

    Problem is, this script wont fire. At all. The logic seems right, everything goes just fine. With a bit of tweaking, it now only fires on the spot of the target. You'll see if you run it.

    Its meant to spread out around the target. Binary adds the proberbility of the number being smaller, as more shots would hit closer to the target than not.
    Heres the script, you can try it yourself.

    I started with the IED script by Jeevz, as that gave me the idea. But now, it looks nothing like it. I was going to finish off coments ect once i'd finished the work.

    Code:
    ; ****************************************************************
    ; Script file for Armed Assault
    ; Created by: TODO: Author Name
    ; ****************************************************************
    
    ; AC-130 Gunship Script
    ; By Niel
    ; Adapted Jeevz IED script
    ; v0.1 12/13/06
    
    
    ; This script will simulate a Ac-130 gunship attack.
    ; It creates an explosion of a
    ; selected size on any object when called
    ; The arguments are [objectName, Size of Ammo]
    ; Explosion Power will be 1 of 3 choices
    ; 25mm - Gatling Gun - 15 shots -Good for Anti-Personnel use
    ; 40mm - Will usually disable a Humvee without killing the occupants
    ; 125mm - Will usually destroy a passing humvee and kill or severly injure all occupants, will disable the tracks and possibly engine on M1A1
    ; Huge - Nothing will survive, I mean... it's HUGE :-)
    
    
    ; Example script call --> [theCar, "Small"] exec "IED.sqs"
    
    ;start script
    
    _theObject = _this select 0
    _theExplosion = _this select 1
    
    ;locate the Object to be blown up
    _bombLoc = GetPos _theObject
    _bombLocX = _bombLoc select 0
    _bombLocY = _bombLoc select 1
    _bombLocZ = _bombLoc select 2
    
    ;Reset Shots Fired, binary and Shots
    
    _ShotsFired = 0
    _binaryX = 1
    _binaryY = 1
    _count1=0
    _count2=0
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    ; Deterimine the ordinance used to create the explosion
    ? (_theExplosion == "25mm") : _ammoType = "B_25mm_HE"
    ? (_theExplosion == "40mm") : _ammoType = "R_57mm_HE"
    ? (_theExplosion == "125mm") : _ammoType = "Sh_125_HE"
    AirAttack sidechat "AC-130 Firing"
    
    
    ; Deterimine the shots used to create the explosion
    ? (_theExplosion == "25mm") : _ShotsNeeded = (random 10)
    ? (_theExplosion == "40mm") : _ShotsNeeded = (random 5)
    ? (_theExplosion == "125mm") : _ShotsNeeded = 1
    
    ;Make Small Explosion Shots Fired Random
    
    ? (_theExplosion == "25mm") : _ShotsNeeded = _ShotsNeeded+30
    
    ;Kept if needed
    
    ? (_theExplosion == "40mm") : _ShotsNeeded+0
    ? (_theExplosion == "125mm") : _ShotsNeeded+0
    
    ;Use Different Spreads
    
    ? (_theExplosion == "25mm") : _Spread = 10
    ? (_theExplosion == "40mm") : _Spread = 7.5
    ? (_theExplosion == "125mm") : _Spread = 5
    
    ;Repeating Fire
    
    #loop
    
    Goto "Binary"
    
    #Shot1
    
    _ammoType createVehicle[_bombLocX + _spreadx, _bombLocY + _spreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired=_ShotsFired+1
    
    _shot1=1
    
    ? _ShotsFired>=_ShotsNeeded : goto "End"
    
    Goto "Binary"
    
    #Shot2
    
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY + _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot2=1
    ? _ShotsFired = _ShotsNeeded: Goto "End"
    
    Goto "Binary"
    
    #Shot3
    
    _ammoType createVehicle[_bombLocX + _spreadX, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot3=1
    
    ? _ShotsFired = _ShotsNeeded : Goto "End"
    
    Goto "Binary"
    
    #Shot4
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot4=1
    
    ? _ShotsFired = _ShotsNeeded : Goto "End"
    
    Goto "loop"
    
    #Binary
    
    ;Spread Logic
    
    ;? (_theExplosion == "25mm") : _count1 = (random 10)
    ;? (_theExplosion == "40mm") : _count1 = (random 10)
    ;? (_theExplosion == "125mm") : _count1 = (random 10)
    ;? (_theExplosion == "25mm") : _count2 = (random 10)
    ;? (_theExplosion == "40mm") : _count2 = (random 10)
    ;? (_theExplosion == "125mm") : _count2 = (random 10)
    
    _count1 = 10
    _count2 = 10
    
    ;_count1 = round(random 10)
    ;_count2 = round(random 10)
    
    ;Binary Based Random Spread
    
    while "_count1 > 0" do {_binaryX=2*_binaryX _count1=_count1-1}
    while "_count2 > 0" do {_binaryY=2*_binaryY _count2=_count2-1}
    _spreadx =(_Binaryx / 1000 *_spread)
    ;_Binaryx =_Binaryx * _spread
    _spready =(_BinaryY / 1000*_spread)
    ;_BinaryY =_BinaryY * _spread
    ;_spreadx = _Binaryx
    ;_spreadY = _BinaryY
    
    ? (_shot1 = 0) : goto "Shot1"
    ? (_shot1 = 1) : goto "Shot2"
    ? (_shot2 = 1) : goto "Shot3"
    ? (_shot3 = 1) : goto "Shot4"
    ? (_shot4 = 1) : goto "Reset"
    
    #Reset
    
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    Goto "Shot1"
    
    #End
    
    exit
    EDIT:

    This script seems scruffy because of the ways I tried to get this to work. A lot of stuff is commented out, after checking it did nothing to help. Once the problem is solved, the randomness will be added back in.

    Thanks, any help would be great.
    Last edited by Coronel_Niel; Aug 16 2009 at 19:26.

  2. #2
    It's now working up to the when statement, I'm not sure what your trying to achieve here? looks like your trying to lay down some random fire a round an area

    Most of the errors were = or lack of.





    Code:
    ; ****************************************************************
    ; Script file for Armed Assault
    ; Created by: TODO: Author Name
    ; ****************************************************************
    
    ; ****************************************************************
    ; Script file for Armed Assault
    ; Created by: TODO: Author Name
    ; ****************************************************************
    
    ; AC-130 Gunship Script
    ; By Niel
    ; Adapted Jeevz IED script
    ; v0.1 12/13/06
    
    
    ; This script will simulate a Ac-130 gunship attack.
    ; It creates an explosion of a
    ; selected size on any object when called
    ; The arguments are [objectName, Size of Ammo]
    ; Explosion Power will be 1 of 3 choices
    ; 25mm - Gatling Gun - 15 shots -Good for Anti-Personnel use
    ; 40mm - Will usually disable a Humvee without killing the occupants
    ; 125mm - Will usually destroy a passing humvee and kill or severly injure all occupants, will disable the tracks and possibly engine on M1A1
    ; Huge - Nothing will survive, I mean... it's HUGE :-)
    
    
    ; Example script call --> [theCar, "Small"] exec "IED.sqs"
    
    ;start script
    
    _theObject = _this select 0
    _theExplosion = _this select 1
    
    ;locate the Object to be blown up
    _bombLoc = GetPos _theObject
    _bombLocX = _bombLoc select 0
    _bombLocY = _bombLoc select 1
    _bombLocZ = _bombLoc select 2
    
    ;Reset Shots Fired, binary and Shots
    
    _ShotsFired = 0
    _ShotsNeeded = 0
    _binaryX = 1
    _binaryY = 1
    _count1=0
    _count2=0
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    ; Deterimine the ordinance used to create the explosion
    ? (_theExplosion == "25mm") : _ammoType = "B_25mm_HE"
    ? (_theExplosion == "40mm") : _ammoType = "R_57mm_HE"
    ? (_theExplosion == "125mm") : _ammoType = "Sh_125_HE"
    ; AirAttack sidechat "AC-130 Firing"
    
    
    ; Deterimine the shots used to create the explosion
    ? (_theExplosion == "25mm") : _ShotsNeeded = (random 10)
    ? (_theExplosion == "40mm") : _ShotsNeeded = (random 5)
    ? (_theExplosion == "125mm") : _ShotsNeeded = 1
    
    ;Make Small Explosion Shots Fired Random
    
    ? (_theExplosion == "25mm") : _ShotsNeeded = _ShotsNeeded+30
    
    ;Kept if needed
    
    ? (_theExplosion == "40mm") : _ShotsNeeded+0
    ? (_theExplosion == "125mm") : _ShotsNeeded+0
    
    ;Use Different Spreads
    
    ? (_theExplosion == "25mm") : _Spread = 10
    ? (_theExplosion == "40mm") : _Spread = 7.5
    ? (_theExplosion == "125mm") : _Spread = 5
    ;Repeating Fire
    
    #loop
    
    Goto "Binary"
    
    #Shot1
    
    _ammoType createVehicle[_bombLocX + _spreadx, _bombLocY + _spreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired=_ShotsFired+1
    
    _shot1 = 1
    
    ? (_ShotsFired >=_ShotsNeeded) : goto "End"
    
    Goto "Binary"
    
    #Shot2
    
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY + _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot2 = 1
    ? (_ShotsFired == _ShotsNeeded) : Goto "End"
    
    Goto "Binary"
    
    #Shot3
    
    _ammoType createVehicle[_bombLocX + _spreadX, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot3 = 1
    
    ? (_ShotsFired == _ShotsNeeded) : Goto "End"
    
    Goto "Binary"
    
    #Shot4
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot4 = 1
    
    ? (_ShotsFired == _ShotsNeeded) : Goto "End"
    
    Goto "loop"
    
    #Binary
    
    ;Spread Logic
    
    ;? (_theExplosion == "25mm") : _count1 = (random 10)
    ;? (_theExplosion == "40mm") : _count1 = (random 10)
    ;? (_theExplosion == "125mm") : _count1 = (random 10)
    ;? (_theExplosion == "25mm") : _count2 = (random 10)
    ;? (_theExplosion == "40mm") : _count2 = (random 10)
    ;? (_theExplosion == "125mm") : _count2 = (random 10)
    
    _count1 = 10
    _count2 = 10
    
    ;_count1 = round(random 10)
    ;_count2 = round(random 10)
    
    ;Binary Based Random Spread
    
    while {_count1 > 0} do {_binaryX=2*_binaryX _count1=_count1-1}
    while {_count2 > 0} do {_binaryY=2*_binaryY _count2=_count2-1}
    _spreadx =(_Binaryx / 1000 *_spread)
    ;_Binaryx =_Binaryx * _spread
    _spready =(_BinaryY / 1000*_spread)
    ;_BinaryY =_BinaryY * _spread
    ;_spreadx = _Binaryx
    ;_spreadY = _BinaryY
    
    ? (_shot1 == 0) : goto "Shot1"
    ? (_shot1 == 1) : goto "Shot2"
    ? (_shot2 == 1) : goto "Shot3"
    ? (_shot3 == 1) : goto "Shot4"
    ? (_shot4 == 1) : goto "Reset"
    
    #Reset
    
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    Goto "Shot1"
    
    #End
    
    
    
    exit

  3. #3
    Staff Sergeant
    Join Date
    Aug 31 2007
    Location
    United States of America
    Posts
    279
    So the script works now or.... I am confused lol.
    -Being stupid is a talent, you don't grow up saying that you want to be stupid. Your born with the natural talent of it, so use it.

  4. #4
    It does work but not as it should. Also to call the script it's not "small" it's one of the ammo sizes "25mm"

  5. #5
    Staff Sergeant
    Join Date
    Aug 31 2007
    Location
    United States of America
    Posts
    279
    So what exactly is wrong with it? (I'm sorry if im being a noob) but just curious

  6. #6
    The basic problem is it's old script and a bit messy.

    I've gave up and wrote something else it may do what your after as it's much the same thing.

    It's just firing a number of shots around a vehicle or object.

    Note it's now in sqf format so save the file as AC130.sqf


    Code:
    //////////////////////////////////////////////////////////////////
    // call the code using the following 
    // null=[target,"25mm"]  execVM "AC130.sqf";
    // null=[target,"40mm"]  execVM "AC130.sqf";
    // null=[target,"125mm"] execVM "AC130.sqf";
    /////////////////////////////////////////////////////////////////
    
    _theObject = _this select 0;
    _theExplosion = _this select 1;
    
    //locate the Object to be blown up
    _bombLoc = GetPos _theObject;
    _bombLocX = _bombLoc select 0;
    _bombLocY = _bombLoc select 1;
    _bombLocZ = _bombLoc select 2;
    
    
    _ShotsFired = 0;
    _ShotsNeeded = 0;
    _ammoType ="";
    _Spread = 0;
    
    // Deterimine the ordinance used to create the explosion
    
    if (_theExplosion == "25mm") then { 
           _ammoType = "B_25mm_HE";
            _ShotsNeeded = round(random 40)+20;// No of rounds 
             _Spread = 10;// accuracy 
    };
    
    if (_theExplosion == "40mm") then { 
          _ammoType = "R_57mm_HE";
            _ShotsNeeded = round(random 10)+5;// No of rounds
              _Spread = 7.5;// accuracy
    };
    
    if (_theExplosion == "125mm") then {
    	 _ammoType = "Sh_125_HE";
    	   _ShotsNeeded = 1;// No of rounds
               _Spread = 2; // accuracy
    };
    
    // AirAttack sidechat "AC-130 Firing"
    
    for [{_p = 0},{_p < _ShotsNeeded},{_p = _p + 1}] do
    {
     _bomb = _ammoType createVehicle[(_bombLocX + random _spread)-_spread/2, (_bombLocY + random _spread)-_spread/2,0];
       sleep 0.1;
      
    };
    Last edited by F2k Sel; Aug 17 2009 at 01:39.

  7. #7
    It works, but this is V3 of the script. The coments are messy, the work is too, and yes, ive created a script that just shoots rounds, how many shots are needed, and the spread.

    The reason it fires for times, is once in each quadrent. So its + +, - +, + -, - -.

    Binary is 1 x 2, then the answer x2, then that answer x2. So that while is meant to do x*2 and the count is the spread. So it will get 1024.

    Then its meant to /1000, to get 1.024
    Then its meant to * that by your spread
    So, it can get anything from 2 - 1024

    Theirs a lot more smaller numbers than bigger ones, and a AC-130 gunner would be more accurate than not.

    It calls the binary script, makes a random spread, then goes back to shot1. When shot1 is fired, shot1 = 1.
    When it runs binary again, it see's shot 1 is fired and goes to shot 2.
    Reset just resets all the values and goes to shot 1.

    It also randoms the X and Y Spread, hence count 1 and 2, for totaly random shots.
    Last edited by Coronel_Niel; Aug 17 2009 at 08:25.

  8. #8
    That's what was confusing me I couldn't see what it was trying to do, when I ran it it just seemed to go on on for such a long time I started to get quite a bit of slowdown.

    My maths isn't up to sorting that bit out, is the while working?

    I thought it had to be while {code} do and not while "code" do but as I don't use sqs maybe it's fine.

  9. #9
    This could be a very interesting addon!

  10. #10
    ive got it to get to:


    Code:
    ; ****************************************************************
    ; Script file for Armed Assault
    ; Created by: TODO: Author Name
    ; ****************************************************************
    
    ; AC-130 Gunship Script
    ; By Niel
    ; Adapted Jeevz IED script
    ; v0.1 12/13/06
    
    
    ; This script will simulate a Ac-130 gunship attack.
    ; It creates an explosion of a
    ; selected size on any object when called
    ; The arguments are [objectName, Size of Ammo]
    ; Explosion Power will be 1 of 3 choices
    ; 25mm - Gatling Gun - 15 shots -Good for Anti-Personnel use
    ; 40mm - Will usually disable a Humvee without killing the occupants
    ; 125mm - Will usually destroy a passing humvee and kill or severly injure all occupants, will disable the tracks and possibly engine on M1A1
    ; Huge - Nothing will survive, I mean... it's HUGE :-)
    
    
    ; Example script call --> [theCar, "Small"] exec "IED.sqs"
    
    ;start script
    
    _theObject = _this select 0
    _theExplosion = _this select 1
    
    ;locate the Object to be blown up
    _bombLoc = GetPos _theObject
    _bombLocX = _bombLoc select 0
    _bombLocY = _bombLoc select 1
    _bombLocZ = _bombLoc select 2
    
    ;Reset Shots Fired, binary and Shots
    
    _ShotsFired = 0
    _binaryX = 1
    _binaryY = 1
    _count1=0
    _count2=0
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    ; Deterimine the ordinance used to create the explosion
    ? (_theExplosion == "25mm") : _ammoType = "B_25mm_HE"
    ? (_theExplosion == "40mm") : _ammoType = "R_57mm_HE"
    ? (_theExplosion == "125mm") : _ammoType = "Sh_125_HE"
    AirAttack sidechat "AC-130 Firing"
    
    
    ; Deterimine the shots used to create the explosion
    ? (_theExplosion == "25mm") : _ShotsNeeded = (random 10)
    ? (_theExplosion == "40mm") : _ShotsNeeded = (random 5)
    ? (_theExplosion == "125mm") : _ShotsNeeded = 1
    
    ;Make Small Explosion Shots Fired Random
    
    ? (_theExplosion == "25mm") : _ShotsNeeded = _ShotsNeeded+30
    
    ;Kept if needed
    
    ? (_theExplosion == "40mm") : _ShotsNeeded+0
    ? (_theExplosion == "125mm") : _ShotsNeeded+0
    
    ;Use Different Spreads
    
    ? (_theExplosion == "25mm") : _Spread = 10
    ? (_theExplosion == "40mm") : _Spread = 7.5
    ? (_theExplosion == "125mm") : _Spread = 5
    
    ;Repeating Fire
    
    #loop
    
    Goto "Binary"
    
    #Shot1
    
    _ammoType createVehicle[_bombLocX + _spreadx, _bombLocY + _spreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired + 1
    
    _shot1 = _shot1 + 1
    
    ? _ShotsFired>=_ShotsNeeded : goto "End"
    
    Goto "Binary"
    
    #Shot2
    
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY + _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot2=1
    ? _ShotsFired = _ShotsNeeded: Goto "End"
    
    Goto "Binary"
    
    #Shot3
    
    _ammoType createVehicle[_bombLocX + _spreadX, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot3=1
    
    ? _ShotsFired = _ShotsNeeded : Goto "End"
    
    Goto "Binary"
    
    #Shot4
    
    _ammoType createVehicle[_bombLocX - _spreadx, _bombLocY - _SpreadY, _bombLocZ]
    ~0.1
    
    _ShotsFired = _ShotsFired+1
    
    _shot4=1
    
    ? _ShotsFired = _ShotsNeeded : Goto "End"
    
    Goto "loop"
    
    #Binary
    
    ;Spread Logic
    
    ;? (_theExplosion == "25mm") : _count1 = (random 10)
    ;? (_theExplosion == "40mm") : _count1 = (random 10)
    ;? (_theExplosion == "125mm") : _count1 = (random 10)
    ;? (_theExplosion == "25mm") : _count2 = (random 10)
    ;? (_theExplosion == "40mm") : _count2 = (random 10)
    ;? (_theExplosion == "125mm") : _count2 = (random 10)
    
    _count1 = 10
    _count2 = 10
    
    ;_count1 = round(random 10)
    ;_count2 = round(random 10)
    
    ;Binary Based Random Spread
    
    #Count3
    
    ? _count1 == 0 : goto "count4"
    _binaryX = _binaryX * 2
    _count1 = _count1 - 1
    
    Goto "Count3"
    
    #Count4
    
    ? _count2 == 0 : goto "Binary2"
    _binaryy = _binaryy * 2
    _count2 = _count2 - 1
    
    Goto "Count4"
     
    #Binary2
     
    _spreadx =(_Binaryx / 1000 * _spread)
    ;_Binaryx =_Binaryx * _spread
    _spready =(_BinaryY / 1000 * _spread)
    ;_BinaryY =_BinaryY * _spread
    ;_spreadx = _Binaryx
    ;_spreadY = _BinaryY
    
    ? (_shot1 == 0) : goto "Shot1"
    ? (_shot1 == 1) : goto "Shot2"
    ? (_shot2 == 1) : goto "Shot3"
    ? (_shot3 == 1) : goto "Shot4"
    ? (_shot4 == 1) : goto "Reset"
    
    #Reset
    
    _shot1 = 0
    _shot2 = 0
    _shot3 = 0
    _shot4 = 0
    
    Goto "Shot1"
    
    #End
    
    exit
    Still doesnt work, but it should I think.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •