![]() |
Random Scares - 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 Articles (https://www.frictionalgames.com/forum/forum-40.html) +---- Thread: Random Scares (/thread-21190.html) |
RE: Random Scares - Adrianis - 04-18-2013 (04-18-2013, 12:10 PM)Your Computer Wrote:(04-18-2013, 11:11 AM)BeeKayK Wrote: can a switch script determine if the case has been used before? If I remember correctly it does convert integers to boolean values when evaluating an if condition, at least in terms of 0 being false and anything else being true, as in C, if that's what you meant. RE: Random Scares - Your Computer - 04-18-2013 (04-18-2013, 12:40 PM)Adrianis Wrote: If I remember correctly it does convert integers to boolean values when evaluating an if condition, at least in terms of 0 being false and anything else being true, as in C, if that's what you meant. If you test the code: PHP Code: if(1){} You will get the error: Expression must be of boolean type. In C (and many other languages), that would be the same as writing: PHP Code: if(true){} In HPL2 scripting, it's not. RE: Random Scares - Adrianis - 04-18-2013 Fair enough then, I thought I had some code in a test map on my home PC where I tried that out thinking it would be useful, but I guess not... RE: Random Scares - CarnivorousJelly - 04-19-2013 (04-18-2013, 11:11 AM)BeeKayK Wrote: can a switch script determine if the case has been used before? Correct me if I'm wrong, but I think you could add local (or global) variables and an "if" statement to restrict how many times/if the case is used more than once. I'm not entirely certain since I don't fully understand how the original script works. What I think I'm saying up ^ there: Code: ///*insert opening part of switch script here*//// Is that in any way possibly right, or should I just go home and focus on mapping? Edit: just realized I put the same == number, thanks Robosprog ![]() RE: Random Scares - Adrianis - 04-19-2013 (04-19-2013, 05:57 AM)Kiandra Wrote: You can definately do it like that, but if you looking at having 5+ different events, all of which you need to keep track of, it's going to get very inneficient (but not really a problem*) to keep them all in seperate variables. Doing it you're way would look more like... Code: void PlrCollideSwitch(string &in asParent, string &in asChild, int alState) * the possibility for hard-to-track bugs is pretty high doing it like that. It's ok if your ready for it RE: Random Scares - FlawlessHappiness - 04-20-2013 Your's adrianis isn't enough. You're gonna need a if(GetLocalVarInt("Variable") == 1) too to get { int x = RandInt(1, 5) switch(x) } this again RE: Random Scares - Adrianis - 04-20-2013 (04-20-2013, 09:42 AM)BeeKayK Wrote: Your's adrianis isn't enough. Not sure quite what you mean. The RandInt will be generated again if the function is called again. If you're saying you need to repeat the RandInt call to get a number that has not been used already, that's a whole other issue. RE: Random Scares - FlawlessHappiness - 04-23-2013 if(asTimer == "PlayerAh") { int AhVariable = RandInt(1, 2) switch(AhVariable) { case 1: PlaySoundAtEntity("Aaaah1", "player_react_guardian1.snt", "Player", 0, false); AddTimer("PlayerAh", RandInt(10, 20), "Ambience"); break; case 2: PlaySoundAtEntity("Aaaah2", "player_react_guardian2.snt", "Player", 0, false); AddTimer("PlayerAh", RandInt(10, 20), "Ambience"); break; } } This is my script. Why am i getting an error, that it expected a ; at the highlighted text? Don't worry, this is not my whole script file. I know this single passage wouldn't work in any way. It's a part of a timer, as you see in the top of the script RE: Random Scares - PutraenusAlivius - 04-24-2013 (04-23-2013, 06:48 PM)BeeKayK Wrote: if(asTimer == "PlayerAh")TRY if(asTimer == "PlayerAh") { int AhVariable = RandInt(1, 2); switch(AhVariable) { case 1: PlaySoundAtEntity("Aaaah1", "player_react_guardian1.snt", "Player", 0, false); AddTimer("PlayerAh", RandInt(10, 20), "Ambience"); break; case 2: PlaySoundAtEntity("Aaaah2", "player_react_guardian2.snt", "Player", 0, false); AddTimer("PlayerAh", RandInt(10, 20), "Ambience"); break; } } RE: Random Scares - FlawlessHappiness - 04-24-2013 I tried. Now just nothing happens |