Frictional Games Forum (read-only)
[SCRIPT] Need help with hazards - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Need help with hazards (/thread-18450.html)



Need help with hazards - ooadrianoo - 09-22-2012

This is my first contacts with hazards.
There are 5 barrels. The barrels should be spawn randomly, and should removed randomly.
Here is my script:
PHP Code:
void OnStart()
{
int iBarrel RandFloat(16);



AddTimer("remove_barrel"2"Remove_Barrel_Timer");

AddTimer("barrel"1"BarrelTimer");
}

void BarrelTimer(string &in asTimer)
{
SetEntityActive("barrel_" +iBarrel true);
AddTimer("barrel"3"BarrelTimer");
}



void Remove_Barrel_Timer(string &in asTimer)
{
if (
GetEntityExists("barrel_" +iBarrel) == true)
{
SetEntityActive("barrel_" +iBarrelfalse);
AddTimer("remove_barrel"5"Remove_Barrel_Timer");
}


Can anyone tell me, that I have done false?


RE: Need help with hazards - Adny - 09-22-2012

Try RandInt instead of RandFloat; The game is generating a random decimal between 1 & 6, but I'm assuming the names of the barrels in the level editor (that you're trying to set active) are just integers (i.e. "barrel_1", not "barrel_1.241")

Scripting isn't my cup of tea, but I hope that helped!


RE: Need help with hazards - Your Computer - 09-22-2012

You declared iBarrel locally, but tried to access it as if it were declared in the global scope.


RE: Need help with hazards - ooadrianoo - 09-22-2012

Please can you post a right script?

I come from Germany so I can't understand everything you write.


RE: Need help with hazards - Your Computer - 09-22-2012

You don't explain much in what exactly you're trying to achieve, nor does your code allow me to make safe assumptions. Nevertheless, i'd rewrite your code like so:

PHP Code:
void OnStart()
{
    
AddTimer("barrel_"+RandInt(16), 1"ActivateBarrel");
}

void ActivateBarrel(string &in barrel)
{
    
SetEntityActive(barreltrue);
    
AddTimer(barrel2"RemoveBarrel");
}

void RemoveBarrel(string &in barrel)
{
    
SetEntityActive(barrelfalse);




RE: Need help with hazards - ooadrianoo - 09-22-2012

(09-22-2012, 02:16 AM)Your Computer Wrote: You don't explain much in what exactly you're trying to achieve, nor does your code allow me to make safe assumptions. Nevertheless, i'd rewrite your code like so:

PHP Code:
void OnStart()
{
    
AddTimer("barrel_"+RandInt(16), 1"ActivateBarrel");
}

void ActivateBarrel(string &in barrel)
{
    
SetEntityActive(barreltrue);
    
AddTimer(barrel2"RemoveBarrel");
}

void RemoveBarrel(string &in barrel)
{
    
SetEntityActive(barrelfalse);



I just wanted to set random barrels active. So if they is a barrel active (checked by GetEntityExists), then this barrel should be deactivated in a few seconds.

This process should not stop.



RE: Need help with hazards - WALP - 09-22-2012

barrels?, I sense a pewdiepie themed custom story here.
just saying