Comrades in Arms Discussion Board

Full Version: Class Useractions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While, incidentally, I'm registered here I can ask for help.

If I change value (isbooston) on one vehicle it is also change on all other vehicles on map. Any chance to solve it?

It looks like that:
class myboostaction
{
displayName = "[Boost On]";
position = "pos driver";
radius = 3;
condition = "alive this && player in this && !isbooston && getpos this select 2<1";
statement = "isbooston=true";
}
Yes. That's a global variable. However, I'm quite sure it would not be transmitted in online play so it should not cause problems if you check that the player is driver.

My first thought, would be to make an array for multiple vehicles (arrays can't be publicvariable'd btw).

Like, if the vehicle is not in arr, add it like arr = arr + [this, false]. After it is the boolean for its boost, so the array is like [veh1, false, veh2, false, veh3, false]. Then write a small funtion to find at what index the vehicle is in the array. Then you'll have boost for multiple vehicles and you still only use one name in the global variable space (the name of the array).

So, to set in on: arr set [([this,arr] call seekIndex)+1, true]
off: arr set [([this,arr] call seekIndex)+1, false]
Uh, well. I'm not into functions so... However I found, in other addon, that I can use "this animate" and "if this animationphase".
How to create empty animation, just for variable usage ?
Making functions is as easy as myFunction = {1 + 1}. Really handy for any complex tasks, to make something faster and more readable with less writing.

Using an animation is a good idea. Here's how you define an animation (from FDF config):

class Animations
{
class Pilli // Just a dummy animation in the model
{
type="rotation";
animPeriod=0.01
selection="pilli";
axis="osa_pilli";
angle0=0;
angle1=1;
};
};

I'm not sure if you have to have the actual components in the model. Probably yes. I think axis="osa_pilli"; will be two points in the memory LOD and selection="pilli"; a named selection of model vertices.
I copied points from the other addon.
Everything is fine but it doesn't seem to work.
Exactly:

class myboostaction
{
displayName = "[Boost On]";
condition = "this animationphase ""BOOST""==0";
statement = "this animate [""BOOST"", 0.01]";
}
class myboostaction2
{
displayName = "[Boost Off]";
condition = "this animationphase ""BOOST"">0";
statement = "this animate [""BOOST"", 0]";
}

So often it doesn't seem to work->can't change option->I click on "ON" but "OFF" doesn't appear. Often, because later it is working somehow and then again it blocks.

It works on 100% when I click, disembark, embark. Then option is changed.
Try using a larger value than 0.01. Maybe it's stored in a 8 bit floating point value or whatever and it rounds to zero.

class myboostaction
{
displayName = "[Boost On]";
condition = "this animationphase ""BOOST""<0.5";
statement = "this animate [""BOOST"", 1]";
}
class myboostaction2
{
displayName = "[Boost Off]";
condition = "this animationphase ""BOOST"">=0.5";
statement = "this animate [""BOOST"", 0]";
}

How did you define the animation? You could try changing something there too.
>larger value
No, this isn't it.

>How did you
As you wrote.

>try changing
I set angle0=0 and angle1=0 and looks like it's working. But when I get back to editing screen and then preview again it's not working.

I don't get it.
Do you have the named selections for axis and selection in the .p3d model? I don't know what else it could be.

And of course, did you change the animation name from Pilli to boost: Smile

      class Animations
      {
        class BOOST
        {
            type="rotation";
            animPeriod=0.01
            selection="";
            axis="";
            angle0=0;
            angle1=1;
        };
      };
>Do you have the named
You mean that points? Yes

>did you change the animation name
Yes, of course.

Maybe you want to take a look on it? Catch me on ICQ.
Ok. I'm back to that project. I deleted condition "player in this" and changed radius to 3.
So, actions are working when I'm not a driver and not working (or working irregularly) when I'm driver.
Like I said, I click, disembark, and option is changed.
Send it to me on ICQ or email and I'll try to come up with something.
I released that on my website.
StuffSpeeder_add