Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
Help with Global Var Ints that are not working!
Hey guys it's been a hell long time since I posted something here and I missed you all. But I am trying to learn how to work with global var ints <---------- I'm bad at it
and I tried making something like this, example picking up a rod it will set a global var int void PickCycleRod(string &in asEntity, string &in asType) { GiveSanityBoostSmall(); //For machine room scare SetGlobalVarInt("GlassJarPickedUp", 1); }
then made this on start in the level which i'll be enterign after picking up that rod
if(GetGlobalVarInt("GlassJarPickedUp")==1) { SetEntityActive("glass_container_1", true); } }
named the entity int he level "glass_container_1" near player start to test it, since it's my first time using global var ints! and guess what?
....
It doesn't work, the entity doesn't appear in the level, maybe I did something wrong or not but do you guys see any problems?
and no Traggey I didn't make the same thread, you might see an older thread with the same title but this one is just help of why it isn't working not the one where I don't understand global var ints!
(This post was last modified: 05-20-2014, 06:49 PM by Radical Batz.)
|
|
05-20-2014, 06:18 PM |
|
Wapez
Senior Member
Posts: 360
Threads: 37
Joined: Mar 2012
Reputation:
19
|
RE: Help with Global Var Ints!
Firstly, there's two brackets in the last code block. I'm sure it belongs to another function like OnStart, but just sayin', it doesn't have anything to do with this script, so might as well remove it.
Secondly, your script looks fine from what I'm seeing. Can you post the entire script files in Code blocks within spoiler tags? I'm sure I can find the problem for you then.
|
|
05-20-2014, 06:34 PM |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
RE: Help with Global Var Ints!
(05-20-2014, 06:34 PM)Wapez Wrote: Firstly, there's two brackets in the last code block. I'm sure it belongs to another function like OnStart, but just sayin', it doesn't have anything to do with this script, so might as well remove it.
Secondly, your script looks fine from what I'm seeing. Can you post the entire script files in Code blocks within spoiler tags? I'm sure I can find the problem for you then.
void OnStart()
{
AddUseItemCallback("", "RustyHammer", "wooden_boards_block_1", "UseHammerOnPlanks", false);
AddEntityCollideCallback("Player", "AreaFall", "EventFall", true, 1);
AddTimer("", 1.0f, "TimerInteractPlanks");
AddEntityCollideCallback("Player", "AreaScare", "EventCatacomb", true, 1);
AddEntityCollideCallback("Player", "AreaByeLantern", "LanternGone", true, 1);
SetEntityPlayerInteractCallback("AreaUseHammer", "InteractPlanks", true);
}
void EventCatacomb(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(25, true);
AddEffectVoice("voices", "catacombvoice.ogg", "Voice", "OMG",
false, "EventCatacomb", 1, 1);
}
void UseHammerOnPlanks(string &in asItem, string &in asEntity)
{
SetEntityActive("wooden_boards_block_1", false);
SetEntityActive("wooden_boards_block_2", true);
PlaySoundAtEntity("", "break_wood.snt", "wooden_boards_block_1", 0, false);
CreateParticleSystemAtEntity("PSDoor_3", "ps_break_wood.ps", "wooden_boards_block_1", false);
SetSwingDoorLocked("cellar_wood01_1", false, true);
}
void Youbetterwork(string &in asEntity)
{
GiveSanityDamage(25, true);
AddEffectVoice("voices", "catacombvoice.ogg", "Voice", "OMG",
false, "EventCatacomb", 1, 1);
}
void EventFall(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("wooden_boards_block_3", false);
SetEntityActive("wooden_boards_block_5", true);
SetEntityActive("wooden_boards_block_4", false);
SetEntityActive("wooden_boards_block_6", true);
SetEntityActive("block_box_1", false);
SetSwingDoorLocked("cellar_wood01_slow_1", false, true);
PlaySoundAtEntity("", "break_wood.snt", "wooden_boards_block_5", 0, false);
PlaySoundAtEntity("scare", "react_pant.snt", "Player", 0.75f, false);
PlayMusic("05_event_falling.ogg", false, 10, 0.5f, 9, false);
CreateParticleSystemAtEntity("PSDoor_3", "ps_break_wood.ps", "wooden_boards_block_4", false);
GetPlayerHealth();
}
void PickCycleRod(string &in asEntity, string &in asType)
{
GiveSanityBoostSmall();
//For machine room scare
SetGlobalVarInt("GlassJarPickedUp", 1);
}
void OnEnter()
{
PlayMusic("penumbra_music_E1_A7", true, 1, 5, 0, true);
}
Other Level.
void OnStart()
{
AddTimer("thunder", 1, "TimerThunder");
AddTimer("AreaScrape_", RandFloat(3.0f,10.f), "TimerAreaScrape");
AddTimer("AreaBirds_", RandFloat(3.0f,10.f), "TimerAreaBirds");
AddEntityCollideCallback("Player", "AreaDoor", "EventDoor", true, 1);
AddEntityCollideCallback("Player", "AreaScare", "Scare", true, 1);
AddUseItemCallback("", "BasementKey", "BasementDoor", "UseBasementKeyOnDoor", true);
for(int i=1;i<=3;i++) for(int j=1;j<=3;j++)
AddUseItemCallback("guiding_rod0"+i+"0"+j, "guiding_rod0"+i, "ra0"+j, "UseRod", false);
GiveSanityBoost();
if(GetGlobalVarInt("GlassJarPickedUp")==1)
{
SetEntityActive("glass_container_1", true);
}
}
void TimerAreaScrape(string &in asTimer)
{
int iRand = RandInt(1, 6);
PlaySoundAtEntity(asTimer+iRand, "15_wall_crawl.snt", asTimer+iRand, 1, false);
AddTimer("EndRadial", 4.0f, "TimerEndRadial");
AddTimer(asTimer, RandFloat(15.0f, 30.0f), "TimerAreaScrape");
}
void TimerAreaBirds(string &in asTimer)
{
int iRand = RandInt(1, 6);
PlaySoundAtEntity(asTimer+iRand, "scare_wings.snt", asTimer+iRand, 1, false);
AddTimer("EndRadial", 4.0f, "TimerEndRadial");
AddTimer(asTimer, RandFloat(15.0f, 30.0f), "TimerAreaBirds");
}
void TimerThunder(string &in asTimer)
{
AddLocalVarInt("ThunderStep", 1); //What step to play in the event
float fEventSpeed = RandFloat(0.05f, 0.15f); //The default time between steps in an event
switch(GetLocalVarInt("ThunderStep")) {
case 1:
ThunderLights(2,0.05f);
break;
case 2:
ThunderLights(1,0.05f);
break;
case 3:
ThunderLights(3,0.05f);
break;
case 4:
ThunderLights(1,0.05f);
break;
case 5:
ThunderLights(2,0.05f);
break;
case 6:
ThunderLights(3,0.05f);
break;
case 7:
ThunderLights(1,0.3f);
PlaySoundAtEntity("Thunder", "general_thunder.snt", "AreaThunder", 0.0f, false);
break;
}
if(GetLocalVarInt("ThunderStep") < 8) AddTimer("thunder", fEventSpeed, "TimerThunder");
else {
SetLocalVarInt("ThunderStep", 0);
AddTimer("thunder", RandFloat(10.0f, 30.0f), "TimerThunder");
}
}
void ThunderLights(int alIntensity, float afFade)
{
/*Skip parts of a flash everynow and then but not the first strong light
**and not the last "back to normal" light
*/
if(RandFloat(1, 3) == 1 && (GetLocalVarInt("ThunderStep") != 3 or GetLocalVarInt("ThunderStep") != 7)) return;
float fF = 0.2f;
switch(alIntensity) {
case 1:
for(int i=0;i<=5;i++) FadeLightTo("spotthunder_"+i,0.52f,0.55f,0.6f,0.45f,-1,afFade-0.04f);
for(int i=0;i<=7;i++) FadeLightTo("pointthunder_"+i,0.32f,0.35f,0.4f,0.2f,-1,afFade-0.025f);
for(int i=0;i<=3;i++) FadeLightTo("ambthunder_"+i,0.2f,0.25f,0.35f,-1,-1,afFade);
break;
case 2:
for(int i=0;i<=5;i++) FadeLightTo("spotthunder_"+i,0.82f+fF,0.85f+fF,0.9f+fF,0.9f+fF,-1,afFade-0.04f);
for(int i=0;i<=7;i++) FadeLightTo("pointthunder_"+i,0.72f+fF,0.75f+fF,0.8f+fF,0.4f+fF,-1,afFade-0.025f);
for(int i=0;i<=3;i++) FadeLightTo("ambthunder_"+i,0.25f+fF,0.3f+fF,0.4f+fF,-1,-1,afFade);
break;
case 3:
for(int i=0;i<=5;i++) FadeLightTo("spotthunder_"+i,0.92f+fF,0.95f+fF,1+fF,1+fF,-1,afFade-0.04f);
for(int i=0;i<=7;i++) FadeLightTo("pointthunder_"+i,0.82f+fF,0.85f+fF,0.9f+fF,0.5f+fF,-1,afFade-0.025f);
for(int i=0;i<=3;i++) FadeLightTo("ambthunder_"+i,0.3f+fF,0.35f+fF,0.45f+fF,-1,-1,afFade);
break;
}
}
void PlsDontgoback(string &in asEntity)
{
if (GetSwingDoorLocked("Cantgoback") == true)
{
SetMessage("Messages", "Cantgoback", 0);
}
}
void EventDoor(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_3", false, false);
SetSwingDoorDisableAutoClose("mansion_3", true);
PlaySoundAtEntity("creak", "joint_door_move_special.snt", "mansion_3", 1, false);
GiveSanityDamage(10, true);
AddEffectVoice("voices", "Scare_Voice.ogg", "Voice", "HolyGesus",
false, "EventDoor", 1, 1);
AddTimer("", 2, "TimerStopSound");
AddTimer("mansion_3", 0, "TimerMoveDoor");
}
void TimerMoveDoor(string &in asTimer)
{
if(GetLocalVarInt("VarDoor") == 50) return;
AddLocalVarInt("VarDoor", 1);
AddTimer(asTimer, 0.03, "TimerMoveDoor");
AddPropForce(asTimer, -20, 0, 0, "world");
}
void TimerStopSound(string &in asTimer)
{
StopSound("creak", 0.4);
}
void UseBasementKeyOnDoor(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("BasementDoor", false);
PlaySoundAtEntity("", "unlock_door.ogg", asEntity, 0, false);
RemoveItem(asItem);
}
string sEntity = "lever_nice01_1";
void UseRod(string &in asItem, string &in asEntity)
{
/*If rod in slot already, do not enter a second
*/
if(GetLocalVarInt(asEntity) == 1){
SetMessage("Ch01Lvl03", "SlotTaken", 0);
PlaySoundAtEntity("clank", "impact_generic_hard_low", asEntity, 0.05f, false);
return;
}
/*If rod and slot correct, set rod string to _correct, else _error
*/
if(asItem == "guiding_rod01" && asEntity == "ra01"){
SetLocalVarString(asItem, asEntity+"_correct");
}
else if(asItem == "guiding_rod02" && asEntity == "ra02"){
SetLocalVarString(asItem, asEntity+"_correct");
}
else if(asItem == "guiding_rod03" && asEntity == "ra03"){
SetLocalVarString(asItem, asEntity+"_correct");
} else {
SetLocalVarString(asItem, asEntity+"_error");
}
/*Remove item from inventory, create item at position in world and set area taken
*/
RemoveItem(asItem);
CreateEntityAtArea(asItem, asItem, "magic_"+asEntity, true);
PlaySoundAtEntity("s"+asItem, "13_rod_in", "magic_"+asEntity, 0, false);
SetEntityCallbackFunc(asItem, "PickRod");
SetLocalVarInt(asEntity, 1);
AddLocalVarInt("RodsInPosition", 1);
/*If all three rods are correct end the puzzle
*/
if(GetLocalVarString("guiding_rod01") == "ra01_correct" && GetLocalVarString("guiding_rod02") == "ra02_correct" &&
GetLocalVarString("guiding_rod03") == "ra03_correct"){
SetLeverStuckState(sEntity, 0, true);
PlaySoundAtEntity("done"+asItem, "13_press_done", "magic_"+asEntity, 0, false);
for(int i=1;i<=6;i++){
CreateParticleSystemAtEntity("PressP"+i, "ps_steam.ps", "PressParticles_"+i, true);
PlaySoundAtEntity("PressS"+i, "13_steam", "PressParticles_"+i, 0.5, true);
}
for(int i=1;i<=3;i++)
SetEntityInteractionDisabled("guiding_rod0"+i, true);
return;
}
/*Incorrect rod positions*/
if(GetLocalVarInt("RodsInPosition") == 3){
PlaySoundAtEntity("error1", "13_press_fail", "magic_"+asEntity, 0, false);
PlaySoundAtEntity("error2", "17_attach_crank.snt", "magic_"+asEntity, 0.5f, false);
}
AddDebugMessage(asItem+" Value: "+GetLocalVarString(asItem), false);
}
void UnlockDoor(string &in asEntity, int LeverState)
{
if(LeverState == 1)
{
SetSwingDoorLocked("hatch_ceiling_1", false, true);
SetPropStaticPhysics("hatch_ceiling_1", false);
SetEntityActive("Message", false);
GiveSanityBoostSmall();
PlaySoundAtEntity("", "unlock_door.ogg", "hatch_ceiling_1", 0, false);
SetLeverStuckState(asEntity, LeverState, false);
PlayMusic("15_puzzle_hole.ogg", false, 0.7, 0.1, 1, false);
SetEntityActive("LadderArea_1", true);
}
}
void PickRod(string &in asEntity, string &in asType)
{
/*If a rod is removed, set the area to empty
*/
if(StringContains(GetLocalVarString(asEntity), "ra01")){
SetLocalVarInt("ra01", 0);
PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra01", 0, false);
CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra01", false);
}
else if(StringContains(GetLocalVarString(asEntity), "ra02")){
SetLocalVarInt("ra02", 0);
PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra02", 0, false);
CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra02", false);
}
else if(StringContains(GetLocalVarString(asEntity), "ra03")){
SetLocalVarInt("ra03", 0);
PlaySoundAtEntity("s"+asEntity, "13_rod_out", "ra03", 0, false);
CreateParticleSystemAtEntity("p"+asEntity, "ps_steam_puff.ps", "ra03", false);
}
AddLocalVarInt("RodsInPosition", -1);
}
void Scare(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("coffin_dirty_1",true);
AddGlobalVarInt("ItemsPicked", 1);
}
void OnEnter()
{
PlayMusic("watercorridor.ogg", true, 0.5, 5, 0, true);
}
|
|
05-20-2014, 06:38 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Help with Global Var Ints that are not working!
Have you made sure that the entity you're trying to enable is actually able to do so? It won't work with StaticProp entities. If the game runs without crashing, there are no syntax errors, and from what I can see...
Wait, hang on. Is it because you have it in OnStart instead of OnEnter? If you already entered the level before triggering the variable, it won't check for it again.
If you place it in OnEnter, make sure to also change the variable once it's executed so it won't happen again next time you enter.
|
|
05-20-2014, 07:46 PM |
|
|