Home   Help Search Login Register  

Author Topic: Sniper Range  (Read 1232 times)

0 Members and 1 Guest are viewing this topic.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Sniper Range
« on: 02 Jan 2003, 01:41:42 »
heres an interesting one...

so i have a training mission and i want to create a sniper range... with a difference...

now - what i want is 6 targets (Target E) to randomly pop up from behind sandbags and then pop down again after 2 secs - there should be a gap between them popping up of 2 secs.

now - i have made a vague start, with help from Sefe before - but the version i have now keeps on saying there is an error - it says the bit where the target is moved to the posistion is type number, expected array

Code: [Select]
;Thanks to Sefe for major help with this script :o)

_PopUpUnits = [sniper1, sniper2, sniper3, sniper4, sniper5, sniper6]

_UnitCoordinates = [10357.09,12685.92,0.05], [10352.26,12695.23,0.05], [10352.42,12679.24,0.05], [10356.93,12689.01,0.05], [10354.49,12682.38,0.05], [10354.50,12692.35,0.05]

#Loop

? (Count _PopUpUnits) == 0 : goto "Skip"

_UnitNumber = Random (Count _PopUpUnits)
? _UnitNumber >= (Count _PopUpUnits) : _UnitNumber = (Count _PopUpUnits) - 1

_CurrentUnit = _PopUpUnits Select _UnitNumber

_CurrentCoordinates = _UnitCoordinates Select _UnitNumber

_CurrentUnit setpos _CurrentCoordinates

~(1 + (Random 3))

if (not (Alive _CurrentUnit)) then {Hint "You have killed a target"; _PopUpUnits = _PopUpUnits - [_CurrentUnit]; _UnitCoordinates = _UnitCoordinates - [_CurrentCoordinates]}

_Currentunit setpos (getpos gamelogic1)

~(1 + (Random 5))

Goto "Loop"

#Skip

Hint "You have killed the last target"

so - some help on that bit...

now, also, instead of it just appearing - could it be possible to make the targets move upwards by changing the height - it should be quite rapid, lasting about 1 sec.

hope you can help.

cheers.
Proud Member of the Volunteer Commando Battalion

Liquid_Silence

  • Guest
Re:Sniper Range
« Reply #1 on: 02 Jan 2003, 03:58:39 »
Code: [Select]
_UnitCoordinates = [10357.09,12685.92,0.05], [10352.26,12695.23,0.05], [10352.42,12679.24,0.05], [10356.93,12689.01,0.05], [10354.49,12682.38,0.05], [10354.50,12692.35,0.05]

should be :
Code: [Select]
_UnitCoordinates = [[10357.09,12685.92,0.05], [10352.26,12695.23,0.05], [10352.42,12679.24,0.05], [10356.93,12689.01,0.05], [10354.49,12682.38,0.05], [10354.50,12692.35,0.05]]


in answer to your second question...yes:

here it is:
Code: [Select]
;Thanks to Sefe for major help with this script :o)

_PopUpUnits = [sniper1, sniper2, sniper3, sniper4, sniper5, sniper6]

_UnitCoordinates = [[10357.09,12685.92,-0.95], [10352.26,12695.23,-0.95], [10352.42,12679.24,-0.95], [10356.93,12689.01,-0.95], [10354.49,12682.38,-0.95], [10354.50,12692.35,-0.95]]

_i = 0

#setup
(_popUpUnits select _i) setPos (_unitCoordinates select _i)
?(!_i == count _popUpunits): goto "setup"

#Loop

? (Count _PopUpUnits) == 0 : goto "Skip"

_UnitNumber = Random (Count _PopUpUnits)
? _UnitNumber >= (Count _PopUpUnits) : _UnitNumber = (Count _PopUpUnits) - 1

_CurrentUnit = _PopUpUnits Select _UnitNumber

_CurrentCoordinates = _UnitCoordinates Select _UnitNumber

_i = 0

;rises over half a second
#upLoop
_i + 0.02
_CurrentUnit setpos [_CurrentCoordinates select 0, _CurrentCoordinates select 1, (_CurrentCoordinates select 2) + _i]
~0.01
?(!_i == 1):goto "upLoop"

~(Random 3)


;falls over half a second
#downLoop
_i = _i - 0.02
_CurrentUnit setpos [_CurrentCoordinates select 0, _CurrentCoordinates select 1, (_CurrentCoordinates select 2) + _i]
~0.01
?(!_i == 0):goto "downLoop"

if (not (Alive _CurrentUnit)) then {Hint "You have killed a target"; _PopUpUnits = _PopUpUnits - [_CurrentUnit]; _UnitCoordinates = _UnitCoordinates - [_CurrentCoordinates]}

~(1 + (Random 5))

Goto "Loop"

#Skip

Hint "You have killed the last target"

also has the advantage that if you walked behind the rocks, you would actually see the targets... :)

If it's buggy (I'm away from a computer with ofp, so I can't test it :( ) just post again...

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:Sniper Range
« Reply #2 on: 02 Jan 2003, 04:22:20 »
lol great minds think alike
i just thought of the same idea while thinking about america's army

try using a loop that moves it up a little bit at a time within a short amount of time

mine just does it instantly, less work

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Sniper Range
« Reply #3 on: 02 Jan 2003, 12:13:02 »
aaaah - great - will test later 2nite

cheers lads :thumbsup:
Proud Member of the Volunteer Commando Battalion

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Sniper Range
« Reply #4 on: 02 Jan 2003, 13:13:58 »
so.... tested it

has an error:

(!_i == 1): Error !: type Number, expected bool

hope that makes some sense - also, the targets, im going for they have to start off underground - how much by?
Proud Member of the Volunteer Commando Battalion

Bremmer

  • Guest
Re:Sniper Range
« Reply #5 on: 02 Jan 2003, 14:50:04 »
Heres a firing range script I wrote a while ago (v1.46) I think it should still work:


Code: [Select]
_targets = [tag_1,tag_2,tag_3,tag_4,tag_5,tag_6]
"_x setpos [getpos _x select 0, getpos _x select 1, -2]" foreach _targets

#select
? count _targets == 0 : Hint "All Targets destroyed"; exit
_random = random (count _targets)
_random = _random - _random % 1
_target = _targets select _random

_pos = getpos _target
_x = _pos select 0
_y = _pos select 1
_z = _pos select 2

_delta = 2
_increment = 0

#up
~0.01
_target setpos [_x,_y,_z + _increment]
_increment = _increment + 0.05
? getpos _target select 2 < _z + _delta : goto "up"

~(random 2) + 2

#down
~0.01
_target setpos [_x,_y,_z + _increment]
_increment = _increment - 0.05
? getpos _target select 2 > _z : goto "down"

? getdammage _target > 0.9 : _targets = _targets - [_target]
~(random 2) + 2

goto "select"

 :)

Liquid_Silence

  • Guest
Re:Sniper Range
« Reply #6 on: 02 Jan 2003, 15:57:20 »
Whoops :-[

um, this works (if you didn't use Bremmer's :) )

(I finally got back to my computer so I could test it :) ...)

This raises them quite high, so you might want to reduce the height (just change the "?(_i < 1):goto "upLoop" " line...)

Code: [Select]
;Thanks to Sefe for major help with this script :o)

_PopUpUnits = [sniper1, sniper2, sniper3, sniper4, sniper5, sniper6]
_UnitCoordinates = [[10357.09,12685.92,-0.95], [10352.26,12695.23,-0.95], [10352.42,12679.24,-0.95], [10356.93,12689.01,-0.95], [10354.49,12682.38,-0.95], [10354.50,12692.35,-0.95]]

_i = 0

#setup

(_popUpUnits select _i) setPos (_unitCoordinates select _i)
_i = _i + 1
?(_i < count _popUpunits): goto "setup"

#Loop

? (Count _PopUpUnits) == 0 : goto "Skip"

_UnitNumber = Random (Count _PopUpUnits)
_rem = _unitNumber % 1
_unitNumber = _unitNumber - _rem

? _UnitNumber >= (Count _PopUpUnits): _UnitNumber = (Count _PopUpUnits) - 1

_currentUnit = _popUpUnits select _unitNumber
_CurrentCoordinates = getpos _currentUnit

_i = 0

#upLoop
_i = _i + 0.04
_CurrentUnit setpos [_CurrentCoordinates select 0, _CurrentCoordinates select 1, (_CurrentCoordinates select 2) + _i]
~0.01
?(_i < 1):goto "upLoop"

~(Random 3)


#downLoop
_i = _i - 0.04
_CurrentUnit setpos [_CurrentCoordinates select 0, _CurrentCoordinates select 1, (_CurrentCoordinates select 2) + _i]
~0.01
?(_i > 0): goto "downLoop"

if (not (Alive _CurrentUnit)) then {Hint "You have killed a target"; _PopUpUnits = _PopUpUnits - [_CurrentUnit]; _UnitCoordinates = _UnitCoordinates - [_CurrentCoordinates]}

~(1 + (Random 5))

Goto "Loop"

#Skip

Hint "You have killed the last target"

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Sniper Range
« Reply #7 on: 02 Jan 2003, 16:11:12 »
bremmer's worked - but had the same problem as my original one (the one well before sefe's one)

when moving them up and down the targets move forward slightly each time.... not a big problem really, but noticable since they are behind sandbags at one time, and then in fron a bit later...

would it be possible, to add a little, move them backwards (west in my case) a small amount, say 0.1 i think.

cheers.
Proud Member of the Volunteer Commando Battalion

Liquid_Silence

  • Guest
Re:Sniper Range
« Reply #8 on: 04 Jan 2003, 02:41:48 »
to move them backwards you'd have to use trig...

Um, this is really weird, 'cause there is no changing of the x,y variables, so why should it move on the horizontal plane? Um, does mine have the same problem? (it probably does, but it's worth a try...)

Pandoz

  • Guest
Re:Sniper Range
« Reply #9 on: 06 Jan 2003, 04:57:58 »
the only thing that i can think of is when they swing up they have slight momentum that carries them forward slightly on their rotation point. Then when u shoot them down and they fall they stay in that spot...and repeat once they come back up...that is the only thing i can think of for the scooting thing