Home   Help Search Login Register  

Author Topic: MP Parameters Example (Accepted)  (Read 10492 times)

0 Members and 1 Guest are viewing this topic.

Offline Shuko

  • Members
  • *
Re: MP Parameters Example (Accepted)
« Reply #15 on: 22 Sep 2009, 11:55:40 »
Well, the idea is that you wouldn't need to worry about remember which element a certain parameter is in the paramsarray. Example:

Code: [Select]
class Params
{
  class Hour {
    title = "Hour";
    values[] = {0,2,4,6,8,10,12,14,16,18,20,22};
    texts[] = {"0000","0200","0400","0600","0800","1000","1200","1400","1600","1800","2000","2200"};
    default = 6;
  };
  class Rain {
    title = "Rain";
    values[] = {0,1,2,3};
    texts[] = {"None","Light","Moderate","Heavy"};
    default = 0;
  };
  class Fog {
    title = "Fog";
    values[] = {0,1,2,3};
    texts[] = {"None","Light","Moderate","Heavy"};
    default = 0;
  };
  class Viewdistance {
    title = "Viewdistance";
    values[] = {0,1,1000,1500,2000,2500,3000,3500,4000,5000,6000};
    texts[] = {"Dynamic","User defined","1000", "1500", "2000", "2500", "3000","3500","4000","5000","6000"};
    default = 0;
  };
  class Targets {
    title = "Targets";
    values[] = {4,6,8,10,0};
    texts[] = {"4","6","8","10","Random 4-10"};
    default = 6;
  };
  class AISkill {
    title = "Difficulty: AI Skill";
    values[] = {1,3,5,7};
    texts[] = {"Easy","Normal","Moderate","Hard"};
    default = 3;
  };
  class AIAmount {
    title = "Difficulty: Amount of AI";
    values[] = {1,2,3,4};
    texts[] = {"Few","Normal","Moderate","Many"};
    default = 2;
  };
  class AA {
    title = "Difficulty: AA (ZU-23)";
    values[] = {0,1,2,3};
    texts[] = {"None","Few","Moderate","Many"};
    default = 1;
  };
  class Planes {
    title = "Planes available";
    values[] = {0,1,2};
    texts[] = {"F35B","AV-8B Harrier","Both"};
    default = 2;
  };
  class ObjectiveDistance {
    title = "Objective distance";
    values[] = {0,1,2};
    texts[] = {"Close","Medium","Any"};
    default = 2;
  };
};

Instead of having to edit the processParams.sqf for each mission, you would automatically get the vars created for each parameter (in this example elements 3-9) by going through all the class names in desc.ext.


Code: [Select]
skiptime (((paramsArray select 0) - daytime + 24) % 24);

switch (paramsArray select 1) do {
  case 0: { 0 setOvercast 0; 0 setRain 0; };
  case 1: { 0 setOvercast 0.8; 0 setRain 0.3; };
  case 2: { 0 setOvercast 0.9; 0 setRain 0.6; };
  case 3: { 0 setOvercast 1; 0 setRain 1; };
};

switch (paramsArray select 2) do {
  case 0: { 0 setFog 0; };
  case 1: { 0 setFog 0.3; };
  case 2: { 0 setFog 0.6; };
  case 3: { 0 setFog 1; };
};

SHK_PARAMS_ViewDistance = paramsArray select 3;
SHK_PARAMS_Targets = paramsArray select 4;
SHK_PARAMS_AISkill = paramsArray select 5;
SHK_PARAMS_AIAmount = paramsArray select 6;
SHK_PARAMS_AA = paramsArray select 7;
SHK_PARAMS_Planes = paramsArray select 8;
SHK_PARAMS_ObjectiveDistance = paramsArray select 9;


Called from init.sqf:
Code: [Select]
execvm "processParams.sqf" spawn {
  waituntil {scriptdone _this};
  if (isserver) then {
  } else {
  };
};

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: MP Parameters Example (Accepted)
« Reply #16 on: 22 Sep 2009, 14:05:32 »
I was thinking of something similar, but different. What I was thinking about is to store code in the param class, and in your setMissionConditions.sqf file you just loop through every param, get the value and the code that's in the class, and then execute the code with the value as an argument.

I haven't really explored this at all due to lack of time, but if it can be made like this we never ever again have to use pre-defined indices in the paramsArray ever again.

Offline Shuko

  • Members
  • *
Re: MP Parameters Example (Accepted)
« Reply #17 on: 24 Sep 2009, 20:42:35 »
Stolen from mikey's thread, with minor modification. Answer to my question:

Code: [Select]
for [{_i = 0},{_i < count(paramsArray)},{_i = _i + 1}] do {
call compile format ["PARAMS_%1 = %2",(configName ((missionConfigFile >> "Params") select _i)),(paramsArray select _i)];
};

Offline MRO204

  • Members
  • *
  • I'm a llama!
Re: MP Parameters Example (Accepted)
« Reply #18 on: 28 Sep 2009, 21:45:21 »
back in the day we could use this in a vehilces condition field. How does it work now with the new system??

param1==1

param2==1 && param1==1
etc

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: MP Parameters Example (Accepted)
« Reply #19 on: 28 Sep 2009, 23:30:33 »
(paramsArray select 0) == 1

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: MP Parameters Example (Accepted)
« Reply #20 on: 07 Dec 2009, 12:10:21 »
Hoz can you please fix the demo mission.

http://www.ofpec.com/tutorials/index.php?action=view&id=212
says paramsArray[2] is the first item in the new class params
This is correct from I understand.

The demo mission instead has:
Code: [Select]
class Params
{
        class DayTime
        {
                //paramsArray[0]
                title = "Time Of Day";

Even more the init.sqf seems wrong to me:

skiptime (paramsArray select 2);
[(paramsArray select 2), "false"] execvm "Grass_Changer\grass_changer.sqf";

vs the class params:
http://pastebin.jonasscholz.de/309

skiptime is 2, yet grass should select 4.

Cheers.
« Last Edit: 08 Dec 2009, 14:40:53 by kju »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: MP Parameters Example (Accepted)
« Reply #21 on: 07 Dec 2009, 15:41:52 »
Done and thanks!
Xbox Rocks

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: MP Parameters Example (Accepted)
« Reply #22 on: 08 Dec 2009, 14:41:06 »
Cheers.  :good: