Advertisement
Heracles421

config.cpp

Apr 2nd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.26 KB | None | 0 0
  1. /* This is a sample of a house with two stage destruction (a damaged version and a ruin), two destructible parts, five doors and eight windows */
  2. #include "cfgPatches.hpp"
  3.  
  4. class CfgVehicles
  5. {
  6.     // Parent class declarations
  7.     class House {};
  8.     class House_F: House {};
  9.  
  10.     // Class of the house in good state
  11.     class Hunters_Cabin: House_F
  12.     {
  13.         scope = 2; // 2 = public = shown in editor
  14.         displayName = "Hunters Cabin"; // Name in editor
  15.         model = \Builds\Hunters_Cabin.p3d; // Path to model
  16.         icon = "iconStaticObject";
  17.        
  18.         vehicleClass = Structures; // category in editor; "Structures" value is a class defined in CfgVehicleClasses
  19.         mapSize = 20.27; // Scale of icon in editor
  20.         cost = 40000; // Score penalty for destroying the house
  21.  
  22.         class AnimationSources
  23.         {
  24.             // Animation sources for doors
  25.             class Door_1_rot
  26.             {
  27.                 source = user; // "user" = custom source = not controlled by some engine value
  28.                 initPhase = 0; // Initial value of animations based on this source
  29.                 animPeriod = 1; // Coefficient for duration of change of this animation
  30.                 sound = "GenericDoorsSound"; /// Selects sound class from CfgAnimationSourceSounds that is going to be used for sounds of doors
  31.             };
  32.         };
  33.        
  34.         // This section defined custom actions for action menu. Each class defined here represent one action. Here we have Open+Close pairs of action for each door (1-5)
  35.         class UserActions
  36.         {
  37.             class OpenDoor_1
  38.             {
  39.                 displayNameDefault = "<img image='\A3\Ui_f\data\IGUI\Cfg\Actions\open_door_ca.paa' size='2.5' />"; // This is displayed in the center of the screen just below crosshair. In this case it's an icon, not a text.
  40.                 displayName = "Open Door"; // Label of the action used in the action menu itself.
  41.                 position = Door_1_trigger; // Point in Memory lod in p3d around which the action is available.
  42.                 priority = 0.4; // Priority coefficient used for sorting action in the action menu.
  43.                 radius = 1.5; // Range around the above defined point in which you need to be to access the action.
  44.                 onlyForPlayer = false; // Defines if the action is available only to players or AI as well.
  45.                 condition = ((this animationPhase 'Door_1_rot') < 0.5); // Condition for showing the action in action menu. In this case it checks if the door is closed and if the part of the house in which the door is located hasn't been destroyed yet).
  46.                 statement = ([this, 'Door_1_rot'] execVM "\Builds\scripts\fnc_DoorNoHandleOpen.sqf"); // Action taken when this action is selected in the action menu. In this case it calls a function that opens the door.
  47.             };
  48.             class CloseDoor_1: OpenDoor_1
  49.             {
  50.                 displayName = "Close Door";
  51.                 priority = 0.2;
  52.                 condition = ((this animationPhase 'Door_1_rot') >= 0.5); // Checks if the door is currently open and not destroyed.
  53.                 statement = ([this, 'Door_1_rot'] execVM "\Builds\scripts\fnc_DoorNoHandleClose.sqf");
  54.             };
  55.         };
  56.         // Here are references binding specific positions in Path lod in p3d to specific actions from "class UserActions" for AI to know when to use which doors. The actionBegin# and ActionEnd# is a hardcoded naming system.
  57.         actionBegin1 = OpenDoor_1;
  58.         actionEnd1 = OpenDoor_1;
  59.         // Amount of doors of this house; a parameter for easy processing of all doors on different houses by scripts.
  60.         numberOfDoors = 1;
  61.     };
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement