Home   Help Search Login Register  

Author Topic: Rank function - Help needed  (Read 2525 times)

0 Members and 1 Guest are viewing this topic.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #15 on: 18 Sep 2004, 14:42:23 »
Are these problems still with manned vehicles placed in the editor?

I'm not sure the crew exist (in the usual OFP sense) when placed this way. To see what I mean, place a manned tank in the editor, call it V1 then call the following code via a radio trigger:

Code: [Select]
(Gunner V1) SwitchCamera "EXTERNAL"
The view you get looks like that of a seagull, hanging around position [0,0,0]. The same applies if you place a soldier in the editor, then get him to board a cargo position. Call the radio trigger again, and you get a view of the outside on the vehicle. If that vehicle has a move waypoint, you watch it drive away with your AI's body in the back seat. It's as though AI become disembodied when they enter certain positions in a vehicle.

I dont know if this is the cause, but it must have some effect?

It certainly explains some odd things I've noticed in CTI games. Under heavy lag, if the position where your AI board a vehicle is bombed, your AI can die even though there are no longer in the vicinity.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #16 on: 18 Sep 2004, 15:37:40 »
Quote
Are these problems still with manned vehicles placed in the editor?
Yeah...
I tried an empty vehicle in which I moveInCargoed a soldier, and that didn't help either...

Altough, if you use a sqs loop for the group that's in a vehicle you get some results. but the ranks are wrong (usually one step higher than they should)...

But, as of now, the code won't most likely even consider the cargo as it takes the first element from the crew array and uses it...

Found something 'interesting' about the crew.
If used on a tank, it returns the crew in this order [driver,commander,gunner] and if used on car it returns [driver,gunner]...

Quote
'm not sure the crew exist (in the usual OFP sense) when placed this way
Yeah, I've noticed this too...

Quote
If that vehicle has a move waypoint, you watch it drive away with your AI's body in the back seat. It's as though AI become disembodied when they enter certain positions in a vehicle.
;D ;D
I knew it!
We had philosophy, now there's metaphysics too ;D

The OFP game engine is so 'retarded' in a way... Much stuff left half finished...

Quote
I dont know if this is the cause, but it must have some effect?
Most likely it does...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #17 on: 18 Sep 2004, 16:03:22 »
Quote
We had philosophy, now there's metaphysics too

LOL

At a push, could you pop each guy out with setpos [0,0,0], get his rank then move him back in?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #18 on: 18 Sep 2004, 17:55:31 »
Quote
At a push, could you pop each guy out with setpos [0,0,0], get his rank then move him back in?
That actually was my initial thought on how to make this, but I just was convinced that there was some more elegant way :P

Well, needs to test that then...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #19 on: 19 Sep 2004, 16:30:07 »
Yeah not an ideal solution. But your just runing this once at the start of the mission? What about guys you place in the editor, and set as "In Cargo", do they suffer from the same problem?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #20 on: 19 Sep 2004, 17:32:29 »
The 'mark' stuff runs once in the beginning (or whenever wanted for that matter)...
And yeah, the In Cargo troops suffer the same problem...

The setPos [0,0,0] stuff ain't actually that easy, and would look horrid on the player... :(
You'd need to store the position of the unit (position in the vehicle, driver, commander, gunner or cargo), then setPos him to [0,0,0] and then moveInxxxxx back to the vehicle in the units correct position... :(

But I have another idea, yet it will fail like all the others probably... :-\
The idea is this:

Code: [Select]
_crw = crew _unit;
_i = 0;
_done = false;
       _ind = call {while {!(_done) && _i < (count _crw)}
              do
           {
            if (_unit == (_crw select _i))
             then {_done = true}
               else {_i = _i + 1};
           };
         if (!(_done))
          then {_i = -1};
         _i
            };
That's a modified version of G Barrons 'indexOf', and it's not functional, but I quoted it there to... ..erm... for some reason I already forgot... ;D ::)

What I need to do is to get the index of the unit in crew/cargo of a vehicle...
But, with indexOf I need to compare the vehicle's crew to itself and that's where I hit the wall... ::)
Because as you would expect
Code: [Select]
(_crw select _i == _crw select _i)returns always true ::)

So I would need to loop through the crew array and check if the unit whose rank is wanted is in the crew array, then get the index of that 'place' in the crew array and use that index to pick up the right element from the crew array to be used with the actual rank return process... *takes a breath*  :P

Anyone? ::) :P
« Last Edit: 19 Sep 2004, 17:35:07 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #21 on: 20 Sep 2004, 04:08:51 »
I'm not sure what the problem is, I ran this function from a trigger, passing ThisList as the parameter:

Code: [Select]
_Result=_This Select 0;

_Rank=[];

{{_Rank=_Rank+[Rating _x]} ForEach (Crew _x)} ForEach _Result;

Hint Format ["Result %1 %2",_Rank];

_DRating=Rating (Driver (_Result Select 0));
_CRating=Rating (Commander (_Result Select 0));
_GRating=Rating (gunner (_Result Select 0));

Player SideChat Format ["Result %1 %2 %3",_DRating,_CRating,_GRating];

Everything looked ok, each soldiers rating corresponded to the values you use in your function. And was correct for there rank. I tried a MG Jeep and an M2A2.

I noticed that if it's just a driver and gunner (MG Jeep), the driver gets the rank set in the editor, and the gunner one less.

But if it has a commander, gunner and driver, the commander gets 2 ranks higher than the rank set in the editor. The gunner gets one rank higher and the driver has the same rank thats set in the editor. The logic changes slightly when you set the rank at either private or colonel, to accomodate for the two extremes.

If you just have a gunner (M2 Machine Gun), he automaticaly gets his rank raised by one. If you set him to Major in the editor, he becomes a Colonel in the game.

A gunner and Commander used in artillery, behave the same as any other vehicle.

With the exception of the MG jeep, it appears straight forward. You can have options in the config for Cargo as Co driver. Perhaps this is what make the MG Jeep different?




Kammak

  • Guest
Re:Rank function - Help needed
« Reply #22 on: 20 Sep 2004, 18:12:26 »
I don't know if this is still an issue, but a real simple way to find out if a unit is a vehicle or not, is this check:

"man" countType [_unit]==1

where _unit is the item being checked.

So, for example,

if ("man" countType[_unit]==1) then [person code here, or goto]
if ("man" countType[_unit]==0) then [vehicle code here, or goto]



Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #23 on: 20 Sep 2004, 19:00:47 »
Quote
Everything looked ok, each soldiers rating corresponded to the values you use in your function.
Yes, I know, I run a test mission with sideChat debug that does exactly same, it returns all the stuff I need to see whether the function works ok...
So, rating returns the correct value, BUT my function somehow doesn't work...
It's either the marking routine that doesn't work (altough I've confirmed that it at least runs, and it's much more 'complicated' than your example, and does not work with forEach for some reason...), or the process of getting the unit from inside a vehicle and then getting the below decimal stuff from the rating doesn't work...

The problem here is that when a unit is inside a vehicle it actually is not in the thisList array...
So, the mark routine checks if the selected unit in the array is a vehicle and then 'goes inside' it and marks all the units in it (at least it should...)

Then, when the rank process is called it needs to be checked whether the passed unit is in a vehicle... And this is actually where I have the problem now... First, I need to determine if the units is in a vehicle, and that's easy...
Then I need the crew array of the vehicle the passed unit is in, then the 'position' (index) of the unit (element) in the crew array in order to get the 'actual unit' (well, the pointer...) from the crew array for the process of getting the below decimal value from that units rating...

But, as usual, I may be thinking this way too complicately... ::)
And doing many other things aside of this, I'm starting to have troubles keeping up myself :P

Quote
I noticed that if it's just a driver and gunner (MG Jeep), the driver gets the rank set in the editor, and the gunner one less [.....
Yeah, like I said, the vehicle rank given in the editor goes to the driver and so on... (of course, if there is a driver in that vehicle...)

Quote
If you just have a gunner (M2 Machine Gun), he automaticaly gets his rank raised by one. If you set him to Major in the editor, he becomes a Colonel in the game.
Noticed this too.
And there's a process now in the function to 'correct' this...

I actually fail to see the BIS logic behind this one...
Wth is the gunners rating being raised like that...??

Quote
With the exception of the MG jeep, it appears straight forward. You can have options in the config for Cargo as Co driver. Perhaps this is what make the MG Jeep different?
Never tested anything with cargoIsCodriver, so won't know what effect it has...

@Kammak:
Yeah, I'm aware of that but that's no longer an issue...
I used that method in some version of this function, but is has some downsides, as  the function deals with the crew of a vehicle, not the actual vehicle itself, the typeOf "man" would always return true...
Meaning, the if ("man" countType[_unit]==1) then {person code here, or goto} would always cause the then part to run...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #24 on: 20 Sep 2004, 20:08:26 »
Quote
I actually fail to see the BIS logic behind this one...
Wth is the gunners rating being raised like that...??

I just assumed it was for simplicity. All vehicles, at the most will have Gunner, Driver and Commander. Its easier to treat a one man M2 in the same way you would an M2A2, rather than having to make an exception for all the different configurations. Although it looks like they had to in the end, with the MG jeep.

Quote
But, as usual, I may be thinking this way too complicately...
And doing many other things aside of this, I'm starting to have troubles keeping up myself

I must admit I find it hard to follow the code. Putting the rating stuff, into seperate functions would be easier to read.

I'm not sure why you need the indexof?

If you have a three functions MyGetRating,MyCalcRank and MySetRating. Then work sequentialy through the crew array, cant you just get the rating, calculate the rank, then set the new rating all within a ForEach loop.

If you call those three functions from another function, MySetRank. You could have:

MySetRank.sqf:

Code: [Select]
private ["_rank","_unit","_rating"];
_Unit=_This Select 0;

_Rank=0;
_Rating=0;

_Rating=[_Unit] Call MyGetRating;
_Rank=[_Rating] Call MycalcRank;
[_Rank,_Unit] Call MySetRating;

And another function, MyIsVehicle. Ok, so I like functions :)

MyIsVehicle.sqf:

Code: [Select]
private ["_Unit"];
_Unit=_This Select 0;
(((Crew _Unit) Select 0)!=Vehicle ((Crew _Unit) Select 0))

Then the function the user calls should just be:

Code: [Select]
private ["_triggerlist"];
_TriggerList=_This Select 0;

{If ([_x] Call MyIsVehicle) Then {{[_x] Call MySetRank} ForEach (Crew _x)} Else {[_x] Call MySetRank}} Foreach _TriggerList;

I did not get as far as trying to set a crew members rating, so If I'm missing one of those little OFP foibles. My apology. But at least it should be easier to debug?
« Last Edit: 20 Sep 2004, 20:09:28 by Unnamed »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #25 on: 20 Sep 2004, 20:36:58 »
Quote
I must admit I find it hard to follow the code
;D
And you wrote the FO stuff from which I don't understand dick... ::)

Quote
Putting the rating stuff, into seperate functions would be easier to read
Yeah, but I want this to be a 'real' function, not bundle of them...

Quote
If you have a three functions MyGetRating,MyCalcRank and MySetRating. Then work sequentialy through the crew array, cant you just get the rating, calculate the rank, then set the new rating all within a ForEach loop
Why use more files as you can have all these functions within one??
And actually this wouldn't change anything...
The same problems would still be there (I think...)...

Quote
I'm not sure why you need the indexof?
Because you can't pick anything from an array by using it's 'name', like _array select _unit... _unit being the vehicle/man/whatever in question...
Or can you??

But you may be right... I'm actually started questioning the necessity of indexOf myself... dunno...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Rank function - Help needed
« Reply #26 on: 20 Sep 2004, 21:03:07 »
Quote
Why use more files as you can have all these functions within one??

It's just easier to debug, does not help when the forum messes up the code formatting either. Difficult to follow all those if thens.

You can always bundle them back up once your happy they work. And they dont have to be files, each function could be a string.

Quote
Because you can't pick anything from an array by using it's 'name', like _array select _unit... _unit being the vehicle/man/whatever in question...

You dont have to when you use the foreach command. You just start at the begining and work your way though. But again, I might have missed something regarding how you determine rank. I assume it's based puerly on each units rating and not there position?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Rank function - Help needed
« Reply #27 on: 22 Sep 2004, 20:47:32 »
Ended up using that forEach...
But it only works in the rank routine, the mark stuff it can't handle...
But that's no biggy, the stuff works...

To a certain extent... ::)
Now as the function works on vehicles it stopped working on troops :P
Huge troubles over a function no-one will ever use ... ::) :P

Ended up having helluva lot of different 'if-this-is-so-then-this-must-be * 2-but-if-like-this-then-not' because OFP is a mental case of ratings when it comes to vehicles...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.