![]() |
Defining a random x - 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: Defining a random x (/thread-15018.html) Pages:
1
2
|
RE: Defining a random x - palistov - 04-24-2012 Just be aware that if you plan on spawning an orb piece at random until all pieces are activated, there's an increasing chance that the RandInt() call will return a orb piece number which has already been used. This might cause player frustration. The easiest way to do this is create a global variable string and use AddGlobalVarString with the string to add being ""+RandomOrbNumberVariable. This way it just concatenates the most recent orb piece set active to the string. As an example: GVar "OrbPiecesActivated" "1" "15" "152" "1523" "15234" Before you want to spawn an orb, do a check to see if StringContains(GlobalVariableHere, ""+NewOrbPieceNumberHere) evaluates as true, and if it does, re-generate a new random orb number. This is a great example of why hard-coding is bad ![]() In some other languages you have to cast the number a string, but luckily AngelCode supports string concatenation with the + operator. But don't try adding a string on to an integer variable. That won't work. You can however, add integers on to strings. It will just stick that integer on to the end of it. RE: Defining a random x - Damascus - 04-24-2012 No, no you misunderstand. They all represent the same orb piece. There's only going to be one available, it's just going to be in a random place when you start the level. That way if you're doing a second playthrough, or have watched a Let's Play, you're not guaranteed to find the item in the same place as you thought it was. RE: Defining a random x - palistov - 04-24-2012 Ahhh I gotcha. |