Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script problem, need help please
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
Script problem, need help please

Been having a script problem now for some time and I cannot find the problem. Would you guys mind giving me a hand? Here's the script.

//-----------------------------------------

///////////////////////////////////////////
// CONTROL VARIABLES
////////////////////////////////////////////

//------------------------------------------

float gfTimeToActivateNextWorm = 8.0f;
float gfTimeToActivateRandomRockSounds = RandFloat(8.0f, 15.0f);
float gfTimeToActivateRockShakeBeforeWorm = 4.0f;
float gfTimeToActivateWormItself = 7.0f;

//-----------------------------------------

///////////////////////////////////////////
// WORM HELPERS
////////////////////////////////////////////

//------------------------------------------

//A helper telling where the player is located
void LocatePlayerLocation(bool abActivated)
{
if(GetLocatePlayerLocation()==true)
return;

//There are six areas giving a different local that tells what worm is gonna spawn
int lAreaOne = GetLocalVarInt("AreaOne");
int lAreaTwo = GetLocalVarInt("AreaTwo");
int lAreaThree = GetLocalVarInt("AreaThree");
int lAreaFour = GetLocalVarInt("AreaFour");
int lAreaFive = GetLocalVarInt("AreaFive");
int lAreaSix = GetLocalVarInt("AreaSix");

if(lAreaOne == 1){
StartScreenShake(0.02f, 0.5f, 0.8f, 2.0f);
PlaySoundAtEntity("rumble", "general_rock_rumble_no3d.snt", "Player", 0.5f, true);
}
}
//Each timer for each worm
void TimerInitiateWorm01(string &in asTimer)
{
AddLocalVarInt("Worm01", 1); //What step to play in the event
float fEventSpeed = 0.5f; //The default time between steps in an event

switch(GetLocalVarInt("Worm01")) {
case 1:
SetEntityActive("worm_1", true);

}
//Collide with AreaCheckPlayer, give a certain local
void CollideCheckPlayer01(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaTwo", 0);
SetLocalVarInt("AreaThree", 0);
SetLocalVarInt("AreaFour", 0);
SetLocalVarInt("AreaFive", 0);
SetLocalVarInt("AreaSix", 0);

SetLocalVarInt("AreaOne", 1);
}
void CollideCheckPlayer02(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaOne", 0);
SetLocalVarInt("AreaThree", 0);
SetLocalVarInt("AreaFour", 0);
SetLocalVarInt("AreaFive", 0);
SetLocalVarInt("AreaSix", 0);

SetLocalVarInt("AreaTwo", 1);
}
void CollideCheckPlayer03(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaOne", 0);
SetLocalVarInt("AreaTwo", 0);
SetLocalVarInt("AreaFour", 0);
SetLocalVarInt("AreaFive", 0);
SetLocalVarInt("AreaSix", 0);

SetLocalVarInt("AreaThree", 1);
}
void CollideCheckPlayer04(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaTwo", 0);
SetLocalVarInt("AreaThree", 0);
SetLocalVarInt("AreaOne", 0);
SetLocalVarInt("AreaFive", 0);
SetLocalVarInt("AreaSix", 0);

SetLocalVarInt("AreaFour", 1);
}
void CollideCheckPlayer05(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaOne", 0);
SetLocalVarInt("AreaThree", 0);
SetLocalVarInt("AreaFour", 0);
SetLocalVarInt("AreaTwo", 0);
SetLocalVarInt("AreaSix", 0);

SetLocalVarInt("AreaFive", 1);
}
void CollideCheckPlayer06(string &in asParent, string &in asChild, int alState)
{
//Remove any existing local to avoid multiple worms
SetLocalVarInt("AreaOne", 0);
SetLocalVarInt("AreaTwo", 0);
SetLocalVarInt("AreaFour", 0);
SetLocalVarInt("AreaFive", 0);
SetLocalVarInt("AreaThree", 0);

SetLocalVarInt("AreaSix", 1);
}

//-----------------------------------------

///////////////////////////////////////////
// THE HUNGRY WORM
////////////////////////////////////////////

//------------------------------------------

//Use meat to feed the worm
void UseMeatOnDoor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("fresh_meat_static", true);

PlaySoundAtEntity("meetworm", "worm_distant.snt", "Player", 0.0f, true);
AddTimer("", 5.0f, "TimerWormEatFlesh");
}
//The Worm is hungry
void TimerWormEatFlesh(string &in asTimer)
{
AddLocalVarInt("Worm", 1); //What step to play in the event
float fEventSpeed = 0.5f; //The default time between steps in an event

switch(GetLocalVarInt("Worm")) {
case 1:
PlaySoundAtEntity("meetworm", "worm_distant.snt", "Player", 0.0f, true);
fEventSpeed = 2.0f;
break;
case 2:
SetEntityActive("hungry_worm", true);
//Needed due to that the worm doesn't have any form of animations
PlayPropAnimation("hungry_worm", "character_rockworm_attack.dae", float afFadeTime, false, "");
fEventSpeed = 3.3f;
break;
case 3:
SetEntityActive("hungry_worm", false);
break;
}

if(GetLocalVarInt("Worm") < 3) AddTimer("", fEventSpeed, "TimerWormEatFlesh");
}
//Some stuff to make sure he doesn't go through objects
void CollideBoardWorm(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("wooden_boards_block_1", 0);
}
void CollideBreakDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("fresh_meat_static", false);
SetPropHealth("cellar_wood01_3", 0);
}
//If player feels like standing in the way of the worm
void CollideWormPlayer(string &in asParent, string &in asChild, int alState)
{
FadeOut(0.5f);
AddTimer("", 5.0f, "TimerPlayerEaten");

CheckPoint("", "PlayerStartArea_2", "JustInCase", "Hints", "PlayerEaten");
}
void TimerPlayerEaten(string &in asTimer)
{
//Kill player without making a sound
DisableDeathStartSound();
AddPlayerHealth(-200);
}
void JustInCase(string &in asParent, string &in asChild, int alState)
{
//Not sure if everything works as it should if you die
SetEntityActive("cellar_wood01_3", false);
SetEntityActive("hungry_worm", false);
SetEntityActive("fresh_meat_static", false);
}

//-----------------------------------------

///////////////////////////////////////////
// BOIL ACETONE
////////////////////////////////////////////

//------------------------------------------

void UseAcetoneOnContainer(string &in asItem, string &in asEntity)
{
SetEntityActive("container_1", true);
SetEntityActive("container_2", false);

RemoveItem(asItem);

PlaySoundAtEntity("pl", "puzzle_add_chemical", asEntity, 0.0f, false);

//Delay the boil a bit
AddTimer("BloodInPlace", 1, "TimerBloodInPlace");
}
void UseContainerOnBurner(string &in asItem, string &in asEntity)
{
SetEntityActive("container_2", true);

RemoveItem(asItem);

PlaySoundAtEntity("plss", "puzzle_place_jar", asEntity, 0.0f, false);
}
void UseAcetoneOnBurner(string &in asItem, string &in asEntity)
{
SetMessage("Ch03Lvl18", "UseAcetoneJarOnBurner", 0);
}

void TimerBloodInPlace(string &in asTimer)
{
SetLocalVarInt("AcetoneOnBurner", 1);

//Check if player can now boil acetone
CheckBoilAcetone();
}

//Turn on the burner
void TurnSpecialBurner(string &in asEntity, int alState)
{
if(alState == 1){
PlaySoundAtEntity("bruner_on","26_burner_ignite.snt", "AreaBurner", 0, false);

CreateParticleSystemAtEntity("burnerfire", "ps_fire_lab_burner.ps", "AreaBurner", true);

PlaySoundAtEntity("burnerfire","26_burner_loop.snt", "AreaBurner", 1, true);

AddTimer("burnerfullspeed",2, "TimerBurnerFullSpeed");
}
else if(alState == -1)
{
PlaySoundAtEntity("bruner_off","26_burner_ignite.snt", "AreaBurner", 0.15f, false);

DestroyParticleSystem("burnerfire");
StopSound("burnerfire", 1);

RemoveTimer("burnerfullspeed");

SetLocalVarInt("BurnerReady", 0);
}
}
void TimerBurnerFullSpeed(string &in asTimer)
{
SetLocalVarInt("BurnerReady", 1);

//Check if player can now boil acetone
CheckBoilAcetone();
}
void CheckBoilAcetone()
{
//If the burner is a full speed, acetone is in place and it is not boiled yet, then
if(GetLocalVarInt("BurnerReady")==1 && GetLocalVarInt("AcetoneOnBurner")==1 && GetLocalVarInt("AcetoneBoiled")==0)
{
SetLocalVarInt("AcetoneBoiled", 1);

CreateParticleSystemAtEntity("bloodboil", "ps_glass_container_blood_bubbles.ps", "AreaBloodBoil", false);
PlaySoundAtEntity("bloodboil","puzzle_boil.snt", "AreaBloodBoil", 1, false);

AddTimer("boileffectdone", 3, "TimerBoilEffectDone");
}
}

void TimerBoilEffectDone(string &in asTimer)
{
DestroyParticleSystem("bloodboil");
StopSound("bloodboil",1);

AddTimer("fadeoutblood", 0.3, "TimerBoilEffectFadeOutContainer");
SetPropActiveAndFade("complete_substance", true, 0.5);

PlaySoundAtEntity("boildone","puzzle_acid", "special_burner", 0, false);
}

void TimerBoilEffectFadeOutContainer(string &in asTimer)
{
SetPropActiveAndFade("container_1", false, 0.5);
}

//-----------------------------------------

///////////////////////////////////////////
// ROCK WORM
////////////////////////////////////////////

//------------------------------------------

//When returning, turn on some worms that arrive depending where the player is
void CollideStartWorm(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("meetworm", "worm_distant.snt", "Player", 0.0f, false);
SetPlayerActive(false);
StartPlayerLookAt("Look_1", 2, 5,"");

AddTimer("", 2.0f, "TimerStartWorm);
}
void TimerStartWorm(string &in asTimer)
{
AddLocalVarInt("StartWorm", 1); //What step to play in the event
float fEventSpeed = 0.5f; //The default time between steps in an event

switch(GetLocalVarInt("StartWorm")) {
case 1:
PlaySoundAtEntity("meetworm", "worm_distant.snt", "Player", 0.0f, false);
StartPlayerLookAt("Look_2", 3, 5,"");
fEventSpeed = 1.5f;
break;
case 2:
StartPlayerLookAt("Look_3", 3, 5,"");
PlaySoundAtEntity("meetworm", "worm_distant.snt", "Player", 0.0f, false);
fEventSpeed = 1.0f;
break;
case 3:
StopPlayerLookAt();
SetPlayerActive(true);
GiveSanityDamage(10, false);
break;
case 4:
SetEntityActive("hungry_worm", true);
PlayPropAnimation("hungry_worm", "character_rockworm_attack.dae", float afFadeTime, false, "");
fEventSpeed = 3.3f;
break;
case 5:
SetEntityActive("hungry_worm", false);
LocatePlayerLocation(true);
break;
}

if(GetLocalVarInt("StartWorm") < 5) AddTimer("", fEventSpeed, "TimerStartWorm");
}

//-----------------------------------------

///////////////////////////////////////////
// MISCS
////////////////////////////////////////////

//------------------------------------------
//Pick the note about the worm
void PickWormNote(string &in asEntity, string &in asType)
{
PlayMusic("05_paper_transformation.ogg", false, 0.7f, 0, 10, false);
}
//Interact with machine lever, without having things completed
void InteractTooQuick(string &in asEntity)
{
SetMessage("Ch03Lvl18", "TooQuick", 0);
}

////////////////////////////
// Run first time starting map
void OnStart()
{
SetMapDisplayNameEntry("Ravine");

//Use Item
AddUseItemCallback("", "fresh_meat", "cellar_wood01_3", "UseMeatOnDoor", true);
AddUseItemCallback("", "container", "special_burner", "UseContainerOnBurner", true);

//Collide Callback
AddEntityCollideCallback("Player", "hungry_worm", "CollideWormPlayer", false, 0);
for(int i=1;i<=4; ++i) AddEntityCollideCallback("Player", "rockworm_attack_static_"+i, "CollideWormPlayerExt", false, 0);
AddEntityCollideCallback("hungry_worm", "AreaBreakPlanks_2", "CollideBoardWorm", false, 0);
AddEntityCollideCallback("hungry_worm", "AreaBreakDoor", "CollideBreakDoor", false, 0);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("22_amb", true, 1, 5, 0, true);
}

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

}
09-13-2013, 03:50 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Script problem, need help please

What is the issue?
09-13-2013, 03:59 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#3
RE: Script problem, need help please

I don't know, it just says Unexpected end of file. No idea what could possibly cause it.
09-13-2013, 04:00 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#4
RE: Script problem, need help please

That's way, way too long. Get yourself Notepad++, put on C++ mode, and swift through your script.

"Veni, vidi, vici."
"I came, I saw, I conquered."
09-13-2013, 04:01 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Script problem, need help please

When it says unexpected end of file it means you accidently placed a
"
or
(
or
{

and not closing it with
"
or
)
or
}

EDIT:

Also this line
if(GetLocalVarInt("StartWorm") < 5) AddTimer("", fEventSpeed, "TimerStartWorm");
}
Seems out of place. Try deleting it

Trying is the first step to success.
(This post was last modified: 09-13-2013, 04:21 PM by FlawlessHappiness.)
09-13-2013, 04:20 PM
Find
Javist Offline
Junior Member

Posts: 46
Threads: 3
Joined: Sep 2010
Reputation: 0
#6
RE: Script problem, need help please

Hard to say.
No offense, but, pasted code looks horrible. I mean the style of code. No indentations.
Probably, the forum has trimmed them. Few advices:
- Never paste big code as text. Pastebin (or analogue) is your best friend.
- Use advanced text editor, such as NP++ with code hlting etc.
- "==true" is not neccessary, as well as "==false" (use "cond" and "!cond" instead).

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep.
(This post was last modified: 09-13-2013, 06:48 PM by Javist.)
09-13-2013, 04:20 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#7
RE: Script problem, need help please

I just can't find it. I'm sorry.
09-13-2013, 04:26 PM
Find




Users browsing this thread: 1 Guest(s)