Jump to content
RizlaUK

Parameter in Description.ext

Recommended Posts

Hi,

 

I have the below parameter in my Description.ext that deals with a percentage of enemies left before a mission completes;

 

class EnemyLeftThreshhold {
            title = "Enemy Left Threshold";
            values[] = {0.50, 0.40, 0.30, 0.20, 0.15, 0.10, 0.05};
            texts[] = {"50%", "40%", "30%", "20%", "15%", "10%", "5%"};
            default = 0.10;
        };

 

Is it possible to make it a range, rather than an exact value? For exmaple;

 

 class EnemyLeftThreshhold {
            title = "Enemy Left Threshold";
            values[] = {0.50-0.41, 0.40-0.31, 0.30-0.21, 0.20-0.11, 0.10-0.05};
            texts[] = {"50%" - 41%, "40% - 31%", "30% - 21%", "20% - 11%", "10% - 5%"};
            default = 0.10-0.05;
        };

 

Would this work?

 

Thanks

 

Rizla

Share this post


Link to post
Share on other sites

first of all. i don't think float values will work in the mission parameters, i think the linked wiki page says so too.

 

for the range stuff. it won't work like that. you will need to use integers there too and then handle the range part inside the script. here's an example:

 

//////////////////////////////
/////description.ext//////////
//////////////////////////////

class EnemyLeftThreshhold 
{
    title = "Enemy Left Threshold";
    values[] = {1, 2};
    texts[] = {"50% - 100%", "0% - 50%"};
    default = 1;
}; 

//////////////////////////////
///////////script/////////////
//////////////////////////////

_enmth = 0;

switch (paramsArray select 0) do
{
	case 1:
	{
		_enmth = 0.5 + random 0.5;
	};
	case 2:
	{
		_enmth = random 0.5;
	};
};

 

Share this post


Link to post
Share on other sites
2 hours ago, bad benson said:

first of all. i don't think float values will work in the mission parameters, i think the linked wiki page says so too.

 

for the range stuff. it won't work like that. you will need to use integers there too and then handle the range part inside the script. here's an example:

 


//////////////////////////////
/////description.ext//////////
//////////////////////////////

class EnemyLeftThreshhold 
{
    title = "Enemy Left Threshold";
    values[] = {1, 2};
    texts[] = {"50% - 100%", "0% - 50%"};
    default = 1;
}; 

//////////////////////////////
///////////script/////////////
//////////////////////////////

_enmth = 0;

switch (paramsArray select 0) do
{
	case 1:
	{
		_enmth = 0.5 + random 0.5;
	};
	case 2:
	{
		_enmth = random 0.5;
	};
};

 

 

Thanks for the example. Forgive me for asking, but for the script part would i need to make that a function and define it in cfgfunctions.hpp?

 

Cheers

 

Rizla

Share this post


Link to post
Share on other sites

I think there is param in params that will execute script or function when you select param

Share this post


Link to post
Share on other sites
17 hours ago, RizlaUK said:

 

Thanks for the example. Forgive me for asking, but for the script part would i need to make that a function and define it in cfgfunctions.hpp?

 

Cheers

 

Rizla

 

you don't have to do it like that. the game will automatically fill the reserved global variable "paramsArray" with your parameters. so it can be accessed in any script. i usually use the mission parameters to set things into global variables so i can easily change it while the mission is running. that example i gave you uses a local variable (_enmth aka enemy threshold). it would be inside the script where you do whatever you plan to do with those values. it's just a pseudo code example though.

 

you can of course use cfgFunctions and add your function in the "function" parameter in your mission parameters class. i haven't done it like that before so if you want to do it like that, wait for someone else to comment or find a working example. all i'm saying is you don't HAVE to do it like that.

 

from here on out it would be good, if you test stuff out and come back with more code. it's kind of hard to try to explain stuff in a general matter without being confusing. at least for me :dummy:

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×