Home   Help Search Login Register  

Author Topic: Custom actions and scripts  (Read 909 times)

0 Members and 1 Guest are viewing this topic.

Offline KTottE

  • Former Staff
  • ****
Custom actions and scripts
« on: 17 Jul 2003, 14:54:17 »
Well now, lets say I make a weapon, and every time my guy has the weapon in his hands he gets an action. And this action executes a script.

So, how do I fix this in the config.cpp?

And it's nothing to do with animations or anything, it just fires a normal script.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Rubble_Maker

  • Guest
Re:Custom actions and scripts
« Reply #1 on: 18 Jul 2003, 10:45:42 »
class UserActions
{
   class TEST
   {
      displayName="bla";
      position="???";
      radius=18100;
      condition="player hasWeapon ""blablabla""";
      statement="this exec ""myscript.sqs""";
   };
}

Offline KTottE

  • Former Staff
  • ****
Re:Custom actions and scripts
« Reply #2 on: 18 Jul 2003, 20:23:29 »
Thanks a million mate, only two questions:

What's position do?
What form is radius in and what does it do?
I guess radius is how far out the action is to be available?
If so, is it in meters, centimeters, ofp-units or sunshine units :)

"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Rubble_Maker

  • Guest
Re:Custom actions and scripts
« Reply #3 on: 18 Jul 2003, 21:51:41 »
Well I never added a user action to a soldier, so I dunno which is a valid position, but maybe check out the commented config.cpp's and see which position BIS choose. The position is the name of some model section which will be the center of the action, i.e. the distance will be measured from there. This really doesn't make sense for a soldier, I know, but imagine you have a huge airplane, and you want to add an action "open door" to its cargo door. Then you'd like to make the option pop up only when the player is close to the cargo door, and not when he's, say, close to the cockpit. Thats what it is good for ;)

radius is the maximum distance from where some other player would be able to trigger this action. Make this as small as possible! I noticed the BAS delta's option to lower the googles sometimes pops up when a soldier gets really close to the player. Setting a very small radius will probably avoid this.

Oh, and ofp usually measures stuff metrically, i.e. meters, seconds, kilograms.

Offline KTottE

  • Former Staff
  • ****
Re:Custom actions and scripts
« Reply #4 on: 19 Jul 2003, 11:18:08 »
ok, figured as much. Hm, you could probably just name a selection and have the position as that, right?
Then I can name a part of the gun "tehuberl33tpos" and just have position set as that ;D
And as for radius, it'll be smaaaaall. Because I also hate the fact that you can fire other people's goggles with the BAS units.

edit

I'd be happy if it weren't for the fact that it's not working :(

Code: [Select]
class UserActions
   {
      class switchScope
      {  
        displayName="Switch optics";
        position="zbran";
        radius=1;
        condition="player hasWeapon ""KTE_M4Bi_AC""";
        statement="[this] exec ""switchBiScope.sqs""";
      };
  };

That's what I have now, KTE_M4Bi_AC is a valid weapon, and this action is supposed to be attached to it, problem: Nothing shows up in the action menu. I've tried with replacing the double quotes with { and }, I've tried setting condition to nothing (empty) and true. Could it be my "position" that's farking things up?
Or maybe the radius is too small?

edit2

Right, found out that OFP doesn't like you adding actions to weapons, so I had to do a unit-addon as well.
Anyway, now I've got another problem.
Everything works 100%, except when I select one of the weapons, I get two actions. I've checked through the config.cpp, and there's only one entry for this, so I'm wondering what could cause it.
« Last Edit: 20 Jul 2003, 21:52:47 by KTottE »
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"