Home   Help Search Login Register  

Author Topic: sniper target range  (Read 1390 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 target range
« on: 20 Oct 2002, 12:44:53 »
now heres an idea ive been toying with, but i just cant get it started with my scripting knowledge (which isnt bad, but just happens to be not good enuff  ;) )

now my idea is to have a random target range for snipers - so 4-5 targets are hidden behind a sandbag fence and are raised using the getpos command into view (so they start off underground to be hidden) - they stay in view for 2 seconds or so, and then drop back down again... this i would like to be fairly random, so the player doesnt know what target will be next - and of course, as soon as a target is killed the hint comes up and when all targets are killed the script stops - and now thinking about it, when one of the targets is killed, it would be good to remove it from the script so it doesnt go up and down when its fallen over.

i reckon this could be a fun script... any help? :help:

and maybe add some sound onto it - maybe editor sounds (like fire, and cease fire - they must be in game somewhere, since you can order people to fire and also units will say 'cease fire' if u hit them)

be kinda cool.

: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 target range
« Reply #1 on: 21 Oct 2002, 00:51:21 »
ok, im back - no help so far i see.

i worked a bit on the script but have gotten no where fast - got the targets pretty much moving up and down but i cant give them a delay till they go up - and i dunno how to make it random or remove them from the script when dead..

pleeeeeeease help :help:
Proud Member of the Volunteer Commando Battalion

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:sniper target range
« Reply #2 on: 22 Oct 2002, 00:01:41 »
try this script (without having tested it):

_PopUpUnits = [Unit1, Unit2, ..., UnitN]

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

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

_CurrentUnit = _PopUpUnits Select _UnitNumber

;Add the code to make the unit _UrrentUnit pop up here

~(1 + (Random 3))

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

;Add the code to make the unit disappear here

~(1 + (Random 5))
Goto "Loop"
#Skip

Hint "You have killed the last target"
« Last Edit: 22 Oct 2002, 00:06:25 by Sefe »

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:sniper target range
« Reply #3 on: 22 Oct 2002, 01:11:59 »
aaah brilliant stuff - i'll add it to my current script and see what happens... hopefull this should be the stuff i need

thanks sefe - you're a great help.  ;)
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 target range
« Reply #4 on: 22 Oct 2002, 20:39:48 »
ok, some problems with the script...

the script has no errors as such, but the target moves forward instead of up, and it always seems to be the same target, sniper6

heres the script:

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

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

#Loop

_height == 0
_height2 == 0

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

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

_CurrentUnit = _PopUpUnits Select _UnitNumber

#loop2

_CurrentUnit setpos [getpos _CurrentUnit select 0, getpos _CurrentUnit select 1,

(getpos _CurrentUnit select 2) +0.01]

~0.1

_height = _height +1

? _height == 200 : goto "carryon"

goto "loop2"

#carryon

~(1 + (Random 3))

if (not (Alive _CurrentUnit)) then {Hint "You have killed a target"; _PopUpUnits =

_PopUpUnits - [_CurrentUnit]}

#loop3

_CurrentUnit setpos [getpos _CurrentUnit select 0, getpos _CurrentUnit select 1,

(getpos _CurrentUnit select 2) -0.01]

~0.1

_height2 = _height2 +1

? _height2 == 200 : goto "carryon2"

goto "loop3"

#carryon2

~(1 + (Random 5))

Goto "Loop"

#Skip

Hint "You have killed the last target"

now - the traget is 2m under ground and i want it to go up 2m - have i got that bit correct? i thought i had, but maybe not - and the random part - is that working? it kept on selecting sniper6.

cheers.
Proud Member of the Volunteer Commando Battalion

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:sniper target range
« Reply #5 on: 22 Oct 2002, 20:49:43 »
for the sniper6 part there seems to be a bug in my script.

Try

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

instead of

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

It's the small things that make the difference ::)

And what about moving the targets away instead of underground?

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:sniper target range
« Reply #6 on: 22 Oct 2002, 21:58:00 »
ok, that works - but they still float forwards - strange.
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 target range
« Reply #7 on: 22 Oct 2002, 22:06:32 »
hmmmm, so i removed the loop that lets it go up slowly - and just replaced it with a  straight move up by 2m...

now, it works, but each time the targets go up and down, they move forward slightly...

sefe, what do you mean by:

Quote
And what about moving the targets away instead of underground?

do you mean teleport them into posistion or camcreate? please explain. cheers
Proud Member of the Volunteer Commando Battalion

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:sniper target range
« Reply #8 on: 22 Oct 2002, 23:05:13 »
I mean teleport them away and back again.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:sniper target range
« Reply #9 on: 23 Oct 2002, 00:34:16 »
ok, sound good - but heres a new prob - they have to appear behind their respective sandbag...

so sniper1 goes with sandbag one.,,

what do i add to the script to make it so when sniper1 is selected then sandbag1 will be chosen for it to be teleported to?

cheers sefe.
Proud Member of the Volunteer Commando Battalion

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:sniper target range
« Reply #10 on: 23 Oct 2002, 01:44:10 »
create a second array with the coordinates of the units at the beginning of the script:

_UnitCoordinates = [[x1, y1], [x2, y2], ... [xn, yn]]

then after the _CurrentUNit = ... bit, write:

_CurrentCoordinates = _UnitCoordinates Select _UnitNumber

then change

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

to

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

Now the variable _CurrentCoordinates will contain the respective coordinates. You can either use them to move your units up without moving forward or just teleport them.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:sniper target range
« Reply #11 on: 23 Oct 2002, 18:53:11 »
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 (getpos _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"

k, thats what i have at the moment...

now it causes error zero divisor on this line:

Code: [Select]
_CurrentCoordinates = _UnitCoordinates Select _UnitNumber
im really gratefull for the help so far sefe - just need this last bit sorted. Thaaaaanx.
Proud Member of the Volunteer Commando Battalion

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:sniper target range
« Reply #12 on: 25 Oct 2002, 15:05:07 »
Try

_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]]

and

_CurrentUnit setpos _CurrentCoordinates