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



Exploding Barrel - KingCrimson - 07-15-2012

Well, on a Custom Story (The Attic - Chapter 2) there was a map where the barrels exploded as you walked near them. I wanted to do a effect like that on my custom story. But when i enter the map it says:

"main (171, 6) :ERR : Expected "("

In case i had copied wrong the script area and barrel's name, i changed them to the names they have on the tutorial at the wiki (Area: explode_scare)(Barrel: pot_explode (since the tutorial explains how to do it with a pot).

Here's my map script:

Quote:////////////////////////////
// Run when the map starts
void OnStart()
{
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);

SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("bot1", "func1", true);
SetEntityPlayerInteractCallback("bot2", "func2", true);
SetEntityPlayerInteractCallback("bot3", "func3", true);
SetEntityPlayerInteractCallback("bot4", "func4", true);

AddUseItemCallback("", "secret1", "door3", "unlock", true);

AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);

AddUseItemCallback("", "crowbar1", "crowdoor", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar2", "area1", "CollideAreaBreakDoor", true, 1);

AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);

SetEntityActive("crowbar_broken", true);

AddEntityCollideCallback("Player", "KillTheLights", "LightsOut", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar1");
}


void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar2", true);
}

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("crowdoor", false, true);
AddPropImpulse("crowdoor", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("crowdoor", true);
SetSwingDoorClosed("crowdoor", false, false);
SetMoveObjectState("crowdoor", 1);
PlaySoundAtEntity("","break_wood_metal", "area2", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "area2", false);
SetEntityActive("crowbar2", false);
SetLocalVarInt("Door", 1);
}

void lockedoor(string &in entity)

{
if(GetSwingDoorLocked("locked1") == true)
{

SetMessage("Messages", "Broken", 1);

}
}

void LightsOut(string &in asParent, string &in asChild, int alState)
{
SetLampLit("light_1", false, true);
AddTimer("", 2, "Out2");
}


void Out2(string &in asTimer)
{
SetLampLit("light_2", false, true);
AddTimer("", 2, "Out3");
}


void Out3(string &in asTimer)
{
SetLampLit("light_3", false, true);
AddTimer("", 2, "Out4");
}


void Out4(string &in asTimer)
{
SetLampLit("light_4", false, true);
AddTimer("", 2, "Out5");
}


void Out5(string &in asTimer)
{
SetLampLit("light_5", false, true);
AddTimer("", 2, "Out6");
}


void Out6(string &in asTimer)
{
SetLampLit("light_6", false, true);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
}
void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func4(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetSwingDoorLocked("button1", false, false);
PlaySoundAtEntity("", "unlock_door.snt", "door1", 0.5f, false);
}

void Explode(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("barrilexplosivo", 0);
}


}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
The scripts of this event are marked in RED


PS: I don't think the problem is that i'm using a barrel, since i tried with a pot and it says the same error.

Thanks in advance


RE: Exploding Barrel - Statyk - 07-15-2012

You didn't close off "void func5()" above "void Explode"

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetSwingDoorLocked("button1", false, false);
PlaySoundAtEntity("", "unlock_door.snt", "door1", 0.5f, false);
}
}



RE: Exploding Barrel - KingCrimson - 07-15-2012

Worked! Thank you!