Frictional Games Forum (read-only)
[SCRIPT] Random Exploding Barrel - 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] Random Exploding Barrel (/thread-15039.html)



Random Exploding Barrel - overscore - 04-23-2012

Code:
void badbarrel(string &in asEntity)
{    
int iBarrel = RandInt(1, 3);    
if(iBarrel == 3)    
{    
SetPropHealth("badbarrel", 0);    
}
}


This is the code I have now that has a 1 in 3 chance of the barrel exploding when the player picks it up.

The thing is once it has chosen the random number it may not blow up until you load the map again.

I want it to choose a random number every time the barrel is picked up and check if int == 3 to see if it should explode.

What am I missing here? A For loop?



RE: Random Exploding Barrel - DRedshot - 04-24-2012

try this

void badbarrel(string &in asEntity)
{

if(RandInt(1, 3) == 3)
{
SetPropHealth("badbarrel", 0);
}

}

only a minor change, but it should work this way, that's how I've used it anyhow, and it works Tongue
Edit: Actually, when is the 'badbarrel' function called? Have you made sure its callback isn't disabled after one use?


RE: Random Exploding Barrel - overscore - 04-24-2012

Heh.

Actually it was disabled. Works fine now!

Derp.