OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RT-SuperTron on 03 Jun 2003, 04:27:11

Title: Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 03 Jun 2003, 04:27:11
Well wow, now my head wonÂ't stop spinning...so here we go.

1. Is it possible to get the total number of Object IDÂ's on a map..say kolgujev.

2. I have found it much easier and more fun to make WP based on object IDÂ's, but I cant figure out how to make a bunch of numbers work in an Aray to avoid typing multiple lines in a script, exmpl. [2214,3072,735,1456,2483]

I need some help with a sick little script. I am gettin a little tired of using gamelogics and stuff for RND WPÂ's, since i as the composer allways no in which area the "sniper/patrol" can be. So therefor my plan is to make the AI/computer choose a random OBJECT ID number, and that is why it would be nice to have the smallest/largest ID number on the map(or as close to as possible).

Features should be something like this:

. Random ID number
. "Sentry" - so that he/they will choose a new when it gets to hot.
. "Fire/Engage at will"
. "check ammo status" - when he/they are ammo low, I want the unit/units to rearm at one/more ammocrate which is allso randmoly placed. The choise of which ammocrate to use could be based on either (random choise or distance).

Ofcourse you people dont have to make the entire script for me (allthough you are welcome to), all I need is some help on how to do the different things above, so I can piece them together.
I think such a thing would go very well in hand with the AI1-1 or GrouplinkII scripts over at the editors depot.

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 03 Jun 2003, 11:13:13
1. we tried it but it ctd wen u use objects dat r not dere  :(

2. wat do u exactly meen here ? ::)

u want script dat make a unit move 2 dese places ?

like dat ?

Code: [Select]
_man = _this select 0
_array = _this sekect 1
_i = 0
#loop
_num = _array select _i
_man move (object _num)
~5
@ _man distance (object _num) < 5
_i=_i+1
?  _i < count _array : goto "loop"
exit

exec - [manname,[arrayofIDs]] exec "scriptname.sqs"

3.
- random ID num
 make array of all da IDs u want da comp 2 choose from nd do
 arrayname select (random (count arrayname))
-"Sentry" - so that he/they will choose a new when it gets to hot.
 u meen dat he wil run away wen enemy is close or somin like dat ?
 make arry of all enemies
 nd da next line 2 check if its becomin hot
 "if (_X distance ManName < 100) then {_close=_close+[_X]}" foreach arrayOfEnemies
 now da array named close wil tel u how meny enemies r close 2 him (u can also play w/ da distance ;))
- "Fire/Engage at will"
 unitname setcombatmode "red" 4 engage @ wil (check da online comm ref in da ED)
-"check ammo status"
 make array of ammocrates
 nd da next code 2 know hos da nearest
 _i = 0
 _Dis = _10000000
 #loop
 _create = arrayName select _I
 ? _man distance _create <_dis : _cr = _create; _dis = _man distance _create
 _i=_i+1
 ? _i < count _arrayname : goto "loop"
 now _cr is da nearest create ;)

:cheers:

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: macguba on 03 Jun 2003, 14:07:59
I use island-sized placement radii on both the unit and his waypoints, so you have no idea where he is.     If you have several it doesn't even matter if part of the radii are in the sea, since that just makes things even more uncertain.   I assume you are using probability of presence anyway.

In two minutues looking at Kolgujev I found numbers 0,1,2,3,4 and 5.    The highest was 69,948.
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 03 Jun 2003, 15:09:17
Quote
0,1,2,3,4 and 5.    The highest was 69,948.

u meen objects IDs ? right ?

dats actualy not a prob as u can alwayz setpos urself on da 1st objects ;) :P

bout da last thing - guess u could try setposin uself on da next num nd check if its dere - but wat we (sui n me) were tryin 2 do is 2 put all object IDs w/o lookin 4 da highest n testin ;) :P

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: macguba on 03 Jun 2003, 17:43:56
Object IDs, yes.   The fun part was that I thought I'd look for 0 and found it almost straight away.  

For the highest, you would have to find a scripted solution - just by looking at the map you could never be sure you'd found the highest.

If anybody does find the highest, repeat the exercise for each island and post the both the method (so folk can use it on custom islands) and the results for the official islands in the Ed Depot, they'll come in handy for somebody.    
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 03 Jun 2003, 18:31:22
Yeah guys you have got the basic idea. The thing is that I want the computer to play "pick a number" between example (0 and 69900) instead of pick a number in my array. The array gives the computer the choice of selecting between the 4-10-20 or 50 numbers you have put in your array, but letting the computer choose a random number between 0 and 69900 actually gives the AI the choice 69900 places to go, and it dosnt push your processor at all. Think about it...the mother you are hunting could be about 70000 other places than where you are right now...you better keep track of the NME.

Gonna look into it tonight...Thanks guys.

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 03 Jun 2003, 20:32:16
prety easy actualy ;) :P

i think da next line shud work ;)

object (random  69900)

LCD OUT

Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 05 Jun 2003, 00:20:46
Yeah shure enough.

Xnum = (random 69900)

it will pick a number between 0 and 69900. The problem here is that it is not a "round" or "hole" number. When ever you use the above metode it will pick a number like 531.356 or 87.404.

I no that a year ago or so, there was a syntax or line some where in the EdDepot, which made it possible to round of numbers to 4,7,500,87 or what ever number where closest.
But where is it now?? The only thing I remeber about it was that the math syntax "Mod" was implemented in the Line somwhere.

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: macguba on 05 Jun 2003, 00:58:45
It's in this FAQ item. (http://www.ofpec.com/editors/faq_view.php?id=101)
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 05 Jun 2003, 01:20:04
*Amn I have been searching all over for this thing, and you just present it for like that..

Thanks a million times.

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 05 Jun 2003, 01:32:19
dd u try it ?

im prety sure it works w/o dis function ;)

didnt try it tho - but i know dat in da command arrayName select (random num) - it doesnt care if its not round num - so u can check it mebe itll save som system usage ;)

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: macguba on 05 Jun 2003, 11:19:17
lol it didn't take more than 30 seconds to find .... I just searched the FAQ on mod and looked down the list.

Btw LCD I'm here for the rest of this week, but leaving on Sunday or Monday I hope ... and then you'll have a clear month to regain your rightful place as top poster.  ;D  
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 05 Jun 2003, 11:21:17
tank u v. much  ;D ;)

well miss ya ;D

were ya goin ?

(dis post shud prooly b IM ut i need 2 regain ma rightful place as top poster ;D)

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: macguba on 05 Jun 2003, 14:04:52
lol don't worry m8, I'm happy to lend you my crown while I'm away, it won't take very long to get it back when I return heheheheheh

I'm going to the Scottish Highlands (where I'm from) in my shiny new car to climb mountains and camp on beaches.   Will be gone for about a month from Sunday.     (That's assuming I don't just stay there, of course  ::))
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 05 Jun 2003, 14:43:26
u crown stealer

*starts runin after maca

* gets in da sea while hes runin

* remembers dat maca is very far

arghhh my clothes r runied  :o  ::)

dont stay dere :P - nd if u do make sure u have internet conection  ;)  8)  :P

i wil b goin somwere also - but 4 a week ;D campin on da beach but its in da last of da next month  8)

* puts a virtual crown on his head ;D

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 05 Jun 2003, 22:11:45
It works fine thanx.  ;)

#Pick and Show
Xnum = 0
Xnum =(Random 69900)
Xnum = Xnum - (Xnum Mod 1)

Hint Format ["Object choosen is:\n%1",Xnum]

I can even assign the hole squad to move allong with him. BUT!! I have tried million combinations or so, and I cant for the living ....hmmm figure out how to make a check on the leader of the group and the distance to the object.. hence making it loop back and pick a new object.
I now the following line is very incorrect but if you have any idea how to solve it (I now it can be done) then please let me know..

?(Leader Group _This Distance Object Xnum > 10) : Goto "Pick and Show"

When this little riddle get solved, the there is more to come.. ;)

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 05 Jun 2003, 23:44:48
(leader (group _this)) distance (object Xnum) > 10 : Goto "PickandShow"

shud b workin

xeot mebe () prob nd dat u can put space as name of place in script (nd refere 2 it in da boto command)

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 06 Jun 2003, 04:16:54
Hmmm.. still a silent battle between me, and whatever OFP thinks im alowed to type.

Next Question..I have noticed that when you let different leaders or single units start the script with - [This] Exec "TestId.sqs" - in there init field, they will all select the same Number...?? Now how do I make it so they cant do that.
It has got to be something like : Xnum == Xnum : Goto "PickNewOne"

A million thanks for your help so far...

[RT]SuperTron
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: LCD on 06 Jun 2003, 04:22:10
cuz Xnum in ur script is global variable - so it changes 4 every1 - if u want it 2 b privte vari - put _Xnum instead ;D

LCD OUT
Title: Re:Object & Rnd quest for sniper and patrol script
Post by: RT-SuperTron on 07 Jun 2003, 00:47:56
 ::) :beat: (knocking my self silly)...Of course, maybe i should try doing this during the day instead of the night..mannn...

Thankx again..

[RT]SuperTron