Comrades in Arms Discussion Board
Class Useractions - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: Class Useractions (/showthread.php?tid=1353)



Class Useractions - faguss - 05-13-2008

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";
}


Re: Class Useractions - Pulverizer - 05-14-2008

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]


Re: Class Useractions - faguss - 05-14-2008

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 ?


Re: Class Useractions - Pulverizer - 05-14-2008

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.


Re: Class Useractions - faguss - 05-15-2008

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.


Re: Class Useractions - Pulverizer - 05-15-2008

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.


Re: Class Useractions - faguss - 05-15-2008

>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.


Re: Class Useractions - Pulverizer - 05-16-2008

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;
        };
      };



Re: Class Useractions - faguss - 05-16-2008

>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.


Re: Class Useractions - faguss - 06-10-2008

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.


Re: Class Useractions - Pulverizer - 06-13-2008

Send it to me on ICQ or email and I'll try to come up with something.


Re: Class Useractions - faguss - 06-13-2008

I released that on my website.
StuffSpeeder_add