Badstormer
Junior Member
Posts: 5
Threads: 1
Joined: Jun 2015
Reputation:
0
Expected Identifier error
I have searched for hours on this forum and fixed every error I could find in this script, yet a persistent 'expected identifier' error continues to crash the game every time the third map in the story is loaded. This began happening after I implemented a 'venom' mechanic which takes effect after getting bit by a spider - it is a bit crude, but it will work for now.
568 line wall of text here
Spoiler below!
void OnStart()
{
// Add callbacks
AddUseItemCallback("", "03key1", "castle_1", "doorunlock", true);
AddUseItemCallback("", "stone_hammer_chipper", "hammerdoor", "hammerdoor", true);
AddEntityCollideCallback("Player", "musicstart", "startmusic1", true, 1);
AddEntityCollideCallback("Player", "message1", "message1", true, 1);
AddEntityCollideCallback("Player", "rockparticle1", "rockparticle1", true, 1);
AddEntityCollideCallback("Player", "rockparticle2", "rockparticle2", true, 1);
AddEntityCollideCallback("Player", "rockparticle3", "rockparticle3", true, 1);
AddEntityCollideCallback("Player", "rockparticle4", "rockparticle4", true, 1);
AddEntityCollideCallback("Player", "deeprumb", "ladderrumb", true, 1);
AddEntityCollideCallback("Player", "sanitynormal", "insanitytrue", true, 1);
AddEntityCollideCallback("Player", "brutespawnsound", "brutesound1", true, 1);
AddEntityCollideCallback("Player", "brutespawnsound_1", "brutesound2", true, 1);
AddEntityCollideCallback("Player", "brutegroanarea1", "brutegroan1", true, 1);
AddEntityCollideCallback("Player", "bruteleavearea", "bruteleave", true, 1);
// Preload stuff
PreloadSound("player_jump.snt");
PreloadSound("player_climb.snt");
PreloadSound("player_crouch.snt");
PreloadSound("player_stand.snt");
PreloadSound("step_walk_wood.snt");
PreloadSound("step_sneak_wood.snt");
PreloadSound("step_run_wood.snt");
PreloadSound("step_walk_fabric.snt");
PreloadSound("step_sneak_fabric.snt");
PreloadSound("step_run_fabric.snt");
PreloadSound("impact_wood_high.snt");
PreloadSound("impact_wood_low.snt");
PreloadSound("impact_wood_med.snt");
PreloadSound("impact_paper_low.snt");
PreloadSound("impact_paper_med.snt");
PreloadSound("impact_paper_high.snt");
PreloadSound("impact_book_low.snt");
PreloadSound("impact_book_med.snt");
PreloadSound("impact_book_high.snt");
PreloadSound("impact_generic_soft_med.snt");
PreloadSound("impact_generic_soft_low.snt");
PreloadSound("impact_generic_soft_high.snt");
PreloadSound("impact_generic_hard_med.snt");
PreloadSound("impact_generic_hard_low.snt");
PreloadSound("impact_generic_hard_high.snt");
PreloadSound("impact_organic_low.snt");
PreloadSound("impact_organic_med.snt");
PreloadSound("impact_organic_high.snt");
PreloadSound("impact_rock_low.snt");
PreloadSound("impact_rock_med.snt");
PreloadSound("impact_rock_high.snt");
PreloadSound("impact_metal_med.snt");
PreloadSound("impact_metal_low.snt");
PreloadSound("impact_metal_high.snt");
PreloadSound("hit_wood.snt");
PreloadSound("break_wood.snt");
PreloadSound("break_wood_metal.snt");
PreloadSound("step_run_dirt.snt");
PreloadSound("step_walk_dirt.snt");
PreloadSound("step_sneak_dirt.snt");
PreloadSound("step_run_water.snt");
PreloadSound("step_sneak_water.snt");
PreloadSound("step_walk_water.snt");
PreloadSound("amb_alert.snt");
PreloadSound("amb_hunt.snt");
PreloadSound("amb_idle.snt");
PreloadSound("amb_idle_scratch.snt");
PreloadSound("amb_idle_whimp.snt");
PreloadSound("attack_claw.snt");
PreloadSound("attack_claw_hit.snt");
PreloadSound("attack_launch.snt");
PreloadSound("enabled.snt");
PreloadSound("hit_generic.snt");
PreloadSound("metal_run.snt");
PreloadSound("metal_walk.snt");
PreloadSound("notice.snt");
PreloadSound("notice_long.snt");
PreloadSound("unlock_door.snt");
PreloadSound("10_rock_move.snt");
PreloadSound("player_ladder_wood_attach.snt");
PreloadSound("player_ladder_wood_down.snt");
PreloadSound("player_ladder_wood_dettach.snt");
PreloadParticleSystem("ps_dust_falling_small_thin.ps");
// Variables
SetLocalVarInt("hits", 0);
SetLocalVarInt("cycles", 0);
SetGlobalVarInt("venommessage02", 0);
// Intro sequence
FadeOut(0);
AddTimer("introtimer", 0.5f, "introstart");
// Misc
AddTimer("globalvarvenomcheck", 1, "globalvarvenomcheck");
}
void OnEnter()
{
}
void OnLeave()
{
}
// Intro sequence
void introstart(string &in asTimer)
{
if(GetLocalVarInt("cycles") == 0)
{
AddTimer("", 1, "introsound");
SetLocalVarInt("cycles", 1);
}
else if(GetLocalVarInt("cycles") < 16)
{
AddTimer("", 0.6f, "introsound2");
AddLocalVarInt("cycles", 1);
}
else if(GetLocalVarInt("cycles") == 16)
{
AddLocalVarInt("cycles", 1);
PlaySoundAtEntity("", "player_ladder_wood_dettach.snt", "Player", 0, false);
AddTimer("", 1, "introstart");
}
else if(GetLocalVarInt("cycles") == 17)
{
FadeIn(3);
}
}
// End intro sequence
// Player effects
void insanitytrue(string &in asParent, string &in asChild, int alState)
{
SetSanityDrainDisabled(false);
}
// Sounds/music
void introsound(string &in asTimer)
{
PlaySoundAtEntity("", "player_ladder_wood_attach.snt", "Player", 0, false);
AddTimer("", 0.1f, "introstart");
}
void introsound2(string &in asTimer)
{
PlaySoundAtEntity("", "player_ladder_wood_down.snt", "Player", 0, false);
AddTimer("", 0.1f, "introstart");
}
void startmusic1(string &in asParent, string &in asChild, int alState)
{
PlayMusic("dan_brute.ogg", true, 1, 7.5f, 5, false);
SetSanityDrainDisabled(true);
}
void brutesound1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "enabled.snt", "brutespawnsoundarea", 0, false);
}
void brutesound1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "notice.snt", "brutespawnsoundarea_1", 0, false);
AddTimer("spidervenomstart", 0.1f, "spidervenomstart");
}
void brutegroan1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amb_alert.snt", "brutegroan1", 0, false);
}
void bruteleave(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amb_idle.snt", "bruteleavesound", 0, false);
AddTimer("dogsrun3", 3.25f, "bruteleave2");
}
void bruteleave2(string &in asTimer)
{
PlaySoundAtEntity("", "door_level_cellar_open.snt", "bruteleavesound", 0, false);
StopMusic(7.5f, 5);
}
void ladderrumb(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "mine_deep_rumb.snt", "Player", 0, false);
SetEntityActive("rock_debris01_1", true);
SetEntityActive("rock_debris01_2", true);
SetEntityActive("rock_debris01_3", true);
SetEntityActive("rock_debris01_4", true);
SetEntityActive("rock_debris01_5", true);
StartScreenShake(0.03f, 5, 0.75f, 1.5f);
}
// Particle sequences
void rockparticle1(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_dust_falling_small_thin.ps", "particlearea1", false);
PlaySoundAtEntity("", "10_rock_move.snt", "particlearea1", 0, false);
StartScreenShake(0.02f, 3, 0.5f, 1);
AddTimer("", 1, "rockmove");
}
void rockmove(string &in asTimer)
{
SetPropStaticPhysics("stone_small01_brown_1",false);
SetPropStaticPhysics("stone_small01_brown_3",false);
SetPropStaticPhysics("stone_small01_brown_4",false);
}
void rockparticle2(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_dust_falling_small_thin.ps", "particlearea2", false);
PlaySoundAtEntity("", "10_rock_move.snt", "particlearea2", 0, false);
StartScreenShake(0.02f, 3, 0.5, 1);
}
void rockparticle3(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_dust_falling_small_thin.ps", "particlearea3", false);
PlaySoundAtEntity("", "10_rock_move.snt", "particlearea3", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_falling_small_thin.ps", "particlearea4", false);
PlaySoundAtEntity("", "10_rock_move.snt", "particlearea4", 0, false);
AutoSave();
StartScreenShake(0.04f, 3, 0.5f, 1.2f);
}
void rockparticle4(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_dust_falling_small.ps", "rockparticlearea4", false);
PlaySoundAtEntity("", "10_rock_move.snt", "rockparticlearea4", 0, false);
StartScreenShake(0.02f, 3, 0.5f, 1);
}
// Messages
void message1(string &in asParent, string &in asChild, int alState)
{
if(GetGlobalVarInt("housenoteread") == 1)
{
SetMessage("Messages", "03message1-1", 7.5f);
AddTimer("", 8.5f, "quest11");
}
else
{
SetMessage("Messages", "03message1-2", 10);
AddTimer("venomcheck", 10.5f, "quest12");
}
}
void quest11(string &in asTimer)
{
AddQuest("quest1-1", "03quest1-1");
AddQuest("quest1-1-1", "03quest1-1-1");
}
void quest12(string &in asTimer)
{
AddQuest("quest1-2", "03quest1-2");
}
// Door stuff
void locked1(string &in entity)
{
SetMessage("Messages", "03locked1", 5);
}
// Hammer
void hammerdoor(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_hammer_move_1", true);
SetEntityActive("stone_chipper_move_1", true);
SetPlayerCrouching(false);
StartPlayerLookAt("stone_hammer_move_1", 3.0f, 3.0f, "");
PlaySoundAtEntity("cumble1", "15_rock_break", "padlock_rusty_1", 0, false);
PlaySoundAtEntity("begin", "15_make_hammer", "Player", 0.25f, false);
PlaySoundAtEntity("crumble", "03_rock_move", "padlock_rusty_1", 2.0f, false);
if(GetLocalVarInt("hits") == 0)
{
SetLocalVarInt("hits", 1);
AddTimer("movehammer", 0.1f, "TimerMoveHammer");
AddTimer("movechipper", 0.27f, "TimerMoveHammer");
AddTimer("resethammer", 0.4f, "TimerMoveHammer");
AddTimer("resetchipper", 0.6f, "TimerMoveHammer");
}
}
void TimerMoveHammer(string &in asTimer)
{
if(asTimer == "movehammer")
{
SetMoveObjectState("stone_hammer_move_1", 0.17);
CreateParticleSystemAtEntity("breakps", "ps_impact_dirt_low.ps", "chipperparticle", false);
}
else if(asTimer == "movechipper")
{
StopPlayerLookAt();
SetMoveObjectState("stone_chipper_move_1", 0.05);
PlaySoundAtEntity("bang", "impact_rock_high", "stone_chipper_move_1", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "stone_hammer_move_1", 0, false);
}
else if(asTimer == "resethammer")
{
SetMoveObjectState("stone_hammer_move_1", 0);
}
else if(asTimer == "resetchipper")
{
SetMoveObjectState("stone_chipper_move_1", 0.02);
}
if(GetLocalVarInt("hits") < 6 && asTimer == "resetchipper")
{
AddTimer("movehammer", 0.1f, "TimerMoveHammer");
AddTimer("movechipper", 0.27f, "TimerMoveHammer");
AddTimer("resethammer", 0.35f, "TimerMoveHammer");
AddTimer("resetchipper", 0.5f, "TimerMoveHammer");
AddLocalVarInt("hits", 1);
}
else if(GetLocalVarInt("hits") == 6 && asTimer == "resetchipper")
{
AddTimer("movehammer", 0.2f, "TimerMoveHammer");
AddTimer("movechipper", 0.37f, "TimerMoveHammer");
AddTimer("break", 0.42f, "TimerMoveHammer");
AddTimer("resethammer", 0.5f, "TimerMoveHammer");
AddTimer("resetchipper", 0.8f, "TimerMoveHammer");
AddLocalVarInt("hits", 1);
}
else if(GetLocalVarInt("hits") == 7 && asTimer == "break")
{
BreakHole();
}
else if(GetLocalVarInt("hits") == 7 && asTimer == "resetchipper")
{
SetEntityActive("stone_hammer_move_1", false);
SetEntityActive("stone_chipper_move_1", false);
}
}
void BreakHole()
{
SetEntityActive("padlock_rusty_1", false);
SetEntityActive("padlock_broken_1", true);
CreateParticleSystemAtEntity("breakps", "ps_impact_dirt_high.ps", "padlock_rusty_1", false);
SetEntityActive("stone_chipper_move_1", false);
SetSwingDoorLocked("castle_1", false, false);
GiveSanityBoost();
}
// Spider venom
void globalvarvenomcheck(string &in asEntity)
{
if(GetGlobalVarInt("02-1") == 1)
{
AddTimer("02health", 1, "02health");
}
}
void spidervenomstart(string &in asEntity)
{
SetPlayerHealth(85);
AddTimer("checkhealth", 0.1f, "checkhealth");
}
void checkhealth(string &in asTimer)
{
if(GetPlayerHealth < 85)
{
AddTimer("venommessage", 15, "venommessage");
AddTimer("venomeffects", 10, "venom");
}
else
{
AddTimer("checkhealth", 1, "checkhealth");
}
}
void venom(string &in asTimer)
{
if(GetGlobalVarInt("venom") == 1)
{
AddTimer("venom", 12.5f, "venom");
AddTimer("imagetrail", 12.5f, "imagetrail");
GivePlayerDamage(2.5f, "", false, false);
}
}
void imagetrail(string &in asTimer)
{
switch(GetGlobalVarInt("fade"))
{
case 0:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.15f, 5);
break;
case 1:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.3f, 5);
break;
case 2:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.4f, 5);
break;
case 3:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.55f, 5);
break;
case 4:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.7f, 5);
break;
case 5:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.8f, 5);
break;
case 6:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(0.9f, 5);
break;
case 7:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.15f, 5);
break;
case 8:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.25f, 5);
break;
case 9:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.35f, 5);
break;
case 10:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.5f, 5);
break;
case 11:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.65f, 5);
break;
case 12:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.8f, 5);
break;
case 13:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(1.9f, 5);
break;
case 14:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(2, 5);
break;
case 15:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(2.15f, 5);
break;
case 16:
AddGlobalVarInt("fade", 1);
FadeImageTrailTo(2.5f, 5);
break;
default:
FadeRadialBlurTo(0.75f, 300);
SetRadialBlurStartDist(0.5f);
}
}
void venommessage(string &in asTimer)
{
SetMessage("Messages", "venommessage", 7.5f);
}
void 02health(string &in asTimer)
{
if(HasItem("health1"))
{
AddTimer("02healthtimer1", 2.5f, "02health");
}
else
{
SetGlobalVarInt("02-1", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
void 03health1(string &in asTimer)
{
if(HasItem("health2"))
{
SetGlobalVarInt("03-1", 1);
AddTimer("03health1", 2.5f, "03health1");
}
else
{
SetGlobalVarInt("03-1", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
void 03health2(string &in asTimer)
{
if(HasItem("health3"))
{
SetGlobalVarInt("03-2", 1);
AddTimer("03health2", 2.5f, "03health2");
}
else
{
SetGlobalVarInt("03-2", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
Any ideas?
(This post was last modified: 06-02-2015, 08:19 PM by Badstormer .)
06-02-2015, 08:11 PM
A.M Team
Banned
Posts: 811
Threads: 63
Joined: Sep 2014
RE: Expected Identifier error
Tip: Use the ['spoiler][/spoiler'] tags to condense long .hps files...
06-02-2015, 08:17 PM
Badstormer
Junior Member
Posts: 5
Threads: 1
Joined: Jun 2015
Reputation:
0
RE: Expected Identifier error
Thanks, had no idea how to do that.
06-02-2015, 08:20 PM
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
RE: Expected Identifier error
What is the error?
Specifically, line number and such.
Post a picture of it.
EDIT:
Line 507 is a problem.
if(HasItem("health1"))
You didn't specify if it was true or false.
It's the same case in 528 and 550
Trying is the first step to success.
06-02-2015, 10:22 PM
Badstormer
Junior Member
Posts: 5
Threads: 1
Joined: Jun 2015
Reputation:
0
RE: Expected Identifier error
Lines 506, 527 and 549 are where the errors are, sorry for not including that. And not specifying true or false would explain the errors, I will fix that and test this again...
Edit: Nope, still borked. The game crashes when entering the map without an error code, as I was entering it from a different map. These are the errors from the hpl.log -
main (506, 6) : ERR : Expected identifier
main (527, 6) : ERR : Expected identifier
main (549, 6) : ERR : Expected identifier
(This post was last modified: 06-02-2015, 10:51 PM by Badstormer .)
06-02-2015, 10:33 PM
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
RE: Expected Identifier error
Great, so how do those lines look right now?
Trying is the first step to success.
06-02-2015, 11:44 PM
Badstormer
Junior Member
Posts: 5
Threads: 1
Joined: Jun 2015
Reputation:
0
RE: Expected Identifier error
Here are the lines and their functions.
Spoiler below!
void 02health(string &in asTimer)
{
if(HasItem("health1")==true)
{
AddTimer("02healthtimer1", 2.5f, "02health");
}
else
{
SetGlobalVarInt("02-1", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
void 03health1(string &in asEntity, string &in type)
{
if(HasItem("health2")==true)
{
SetGlobalVarInt("03-1", 1);
AddTimer("03health1", 2.5f, "03health1");
}
else
{
SetGlobalVarInt("03-1", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
void 03health2(string &in asEntity, string &in type)
{
if(HasItem("health3")==true)
{
SetGlobalVarInt("03-2", 1);
AddTimer("03health2", 2.5f, "03health2");
}
else
{
SetGlobalVarInt("03-2", 0);
RemoveTimer("imagetrail");
RemoveTimer("venom");
FadeRadialBlurTo(0, 20);
FadeImageTrailTo(0, 30);
if(GetGlobalVarInt("venommessage02") == 0)
{
SetMessage("Messages", "venommessage02", 5);
SetGlobalVarInt("venommessage02", 1);
}
}
}
I modified the code a bit to experiment with any potential solutions, and unsurprisingly, the error persisted. If the code seems different, that is why.
(This post was last modified: 06-02-2015, 11:57 PM by Badstormer .)
06-02-2015, 11:54 PM
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
RE: Expected Identifier error
Got it!
The problem lies in that the functions start with a number.
02health
03health1
03health2
For some reason it screws up the script.
Start with a letter instead.
Trying is the first step to success.
06-03-2015, 01:54 AM
Badstormer
Junior Member
Posts: 5
Threads: 1
Joined: Jun 2015
Reputation:
0
RE: Expected Identifier error
Sure enough, it works. Thanks for the assistance, my own frustration levels went through the roof and then some from this error.
06-03-2015, 04:23 AM
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
RE: Expected Identifier error
What gave it away was, that in my editor the function name lit up in a color it was not supposed to.
I use geany.
Trying is the first step to success.
06-03-2015, 06:06 PM