Home   Help Search Login Register  

Author Topic: Set a type of global dispersion... help!  (Read 667 times)

0 Members and 1 Guest are viewing this topic.

Offline pexmo

  • Members
  • *
  • I'm a llama!
Set a type of global dispersion... help!
« on: 12 Jan 2005, 10:14:43 »
Hola again, im rearanging the workings of our coop campaign as it has entered phase two. So im posting quite alot at the moment :)

What i wanna do is:

Im using GeneralCoders ol fire dispersion script that i found in the beta section. This is the code:


Quote
_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]

?(_shooter == player): goto exit
?((_this select 2) == "throw"): goto exit

_vel = velocity _projectile
_speed = speed _projectile

_disp = (_speed * (0.016    - (skill _shooter)/100) )
_dispX2 = _disp*2

_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]

),(_vel select 2) - _disp + Random(_dispX2)]

What i wanna do is add that if the unit is a sniper (or is the unit with the name sniper) the it exits but if the unit is any other player it goes past the ai dispersion in this script to a new section named for example #playerdisp.

#playerdisp uses the same code as the rest of the script but has a different diespersion setting.

How do i do this?

I got it working so i can use a diffrent disp for ALL players but it added to the ais disp i think. this is the code i used for that (my first ever attemt on any scripting):


Quote
_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]

?(_shooter == player): goto #playerdisp
?((_this select 2) == "throw"): goto exit

_vel = velocity _projectile
_speed = speed _projectile

_disp = (_speed * (0.016    - (skill _shooter)/100) )
_dispX2 = _disp*2

_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]

),(_vel select 2) - _disp + Random(_dispX2)]

exit

#playerdisp


_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]

?(_shooter == player): goto exit
?((_this select 2) == "throw"): goto exit

_vel = velocity _projectile
_speed = speed _projectile

_disp = (_speed * (0.016    - (skill _shooter)/100) )
_dispX2 = _disp*2

_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]

),(_vel select 2) - _disp + Random(_dispX2)]

exit

Dubieman

  • Guest
Re:Set a type of global dispersion... help!
« Reply #1 on: 12 Jan 2005, 19:22:18 »
Well I dunno how to exactly do this, but depending on what side you're playing, you want to find any and all snipers. So you might be able to find the type of unit (ex.: SoldierWB).

So then find out what the soldier type is, and then go from there. Well, actually I have a strong feeling that something like that can't be done. :-\

Then the other way would be to name the snipers and not include them in the script using their names, or incorporating them into their own array like:

[sniper1, sniper2, sniper3] = thislist

But again I'm not totally sure. I haven't used arrays much. :P

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:Set a type of global dispersion... help!
« Reply #2 on: 12 Jan 2005, 19:51:52 »
Well i only want this to work with ONE sniper so as long as i can enter in a name and have that name goto exit or its own separate # in the script im satisfied.

know how i enter a units name (name in the editor under the name line) into the script as in the lines checking if player?

Dubieman

  • Guest
Re:Set a type of global dispersion... help!
« Reply #3 on: 12 Jan 2005, 20:01:05 »
So you don't want this script to work on this one sniper.

You'd have to put him into his own array and then in the script, I think you'd have some code to check if its being run on the units in "thislist". Sorry, but I really don't have any idea on how to actually work that out, again, haven't used arrays much if at all. :P :-\


Edit: Or actually I was thinking you could put everyone else into an array and just run the script on each unit of the array. Bah, sorry, can't help you here either.  >:( :P

« Last Edit: 12 Jan 2005, 20:02:29 by GuiltyRoachKillar »

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Set a type of global dispersion... help!
« Reply #4 on: 13 Jan 2005, 02:03:50 »
Hey pexmo!

If you want a certain unit to not have the dispersion apply to him, then I believe that you can just use his name (sniper) in the script as an if/then statement as so:

Code: [Select]
?(_shooter == sniper): exit
Try it and let us know if it worked.


                                                                 Wadmann

Check out my Camouflage Collection! New items added 31 July 2005.

Dubieman

  • Guest
Re:Set a type of global dispersion... help!
« Reply #5 on: 13 Jan 2005, 02:13:42 »
Gaaa,

if the answer is that simple I'll take an umbrella and put it up my ___ and open it! >:( :P :beat:

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Set a type of global dispersion... help!
« Reply #6 on: 13 Jan 2005, 03:23:59 »
get ready to wear some diapers thens cause you won't be able to hold anything in with an ___hole that wide. lol

Dubieman

  • Guest
Re:Set a type of global dispersion... help!
« Reply #7 on: 13 Jan 2005, 05:29:14 »
Time to take some OFPEC sick days. "Doc, whadda ya do when..." :D

Getting off topic. Maybe I should read up on arrays when the php code lowers its defensive m134 minigun system. :o 8)
« Last Edit: 13 Jan 2005, 05:29:36 by GuiltyRoachKillar »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Set a type of global dispersion... help!
« Reply #8 on: 13 Jan 2005, 05:32:17 »
whats to learn?
it a list.

Dubieman

  • Guest
Re:Set a type of global dispersion... help!
« Reply #9 on: 13 Jan 2005, 05:34:22 »
I've only used that stuff once or twice, plus I've never done coding before, so I wanna try to learn everything. Though I know I won't ever learn everything. ::)

The fruitless search for knowledge, good and bad, and time for me to bow out of the thread. ::) :P

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:Set a type of global dispersion... help!
« Reply #10 on: 13 Jan 2005, 14:52:22 »
Quote
_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]

?(_shooter == player): goto exit
?((_this select 2) == "throw"): goto exit

_vel = velocity _projectile
_speed = speed _projectile

_disp = (_speed * (0.016    - (skill _shooter)/100) )
_dispX2 = _disp*2

_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]

),(_vel select 2) - _disp + Random(_dispX2)]



Ok i used that as the script for the ai. And its set of by a anybody present once trigger that triggs this script:

Quote
_list = _this
_count = count _list
_i=0
#loop

(_list select _i) addEventHandler ["fired",{_this exec "fired.sqs"}]

_i = _i + 1
?(_i < _count ):goto"loop"

Thats for the ai.

Then i used this for the players units:

For the sniper i made a script called sniperdisp.sqs and its executed by this line in the units init field:

this addEventHandler ["fired",{_this exec "sniperdisp.sqs"}];

and the sniperdisp uses the same code as the fired script (ai disp) but with another setting for the disp.

Does this work?

Its seems wierd as sometimes i do have the disp but next time i preview the mish i dont and the ai seems to do the same. It always works on my test ai but not on the units in my mission area. The trigger is covering them all so thats not it.

What should i change.

And if anyone else have a better solution to add a global value to dispersion for the ai, a sniper player and one for the rest of the players ( i dont wanna go in and edit every darn weapon) please post how you would do this.

edit: the sniperdisp script dont have he player goto exit line, should i have a ai exit line though? (not player exit?)
« Last Edit: 13 Jan 2005, 14:53:43 by pexmo »

Offline pexmo

  • Members
  • *
  • I'm a llama!
Re:Set a type of global dispersion... help!
« Reply #11 on: 17 Jan 2005, 09:14:18 »
Im using the above script but as i stated before: Im not sure it works all the time.

A example:

I place me infront of a enemy ai infantery unit and use the script. Now he fires like hell and cant hit me that good. BUT when i play the mission i tested him in the ai seems to ignore this dispersion, at least sometimes. Anyone know if its the script that just dont work sometimes or if its the script itslef thats not that good at doing its job?

And if so is there some other dipersion scripts out there? I dont want to use HD jam units.

EDIT': i guess the "sometimes not working effect" is caused by the RANDOM thingy in the script. Any way to bypass this?
« Last Edit: 17 Jan 2005, 10:51:31 by pexmo »