Random events

  • 10 Replies
  • 5696 Views
Random events
« on: August 13, 2009, 04:48:18 »
Hi, I've been a big fan of Knytt Stories for awhile but just recently tried making anything in the level editor. I've got an idea for basically warping to one of several different screens from a pre-defined list, which seems easy enough to do with flags and shifters. But what I want to do is randomize WHICH flag is turned on. I didn't see anything relating to random events in the PDF manual, or anything in the forum.

Is this possible to do, maybe by scripting in the world.ini file?

*

Offline Bored2death

  • 454
  • 0
  • My attempt at a Nurykabe Tiled room XD
    • View Profile
Re: Random events
« Reply #1 on: August 13, 2009, 04:50:57 »
I'm sorry to say, but this is not really all that easy to do. The only thing I can think of is having the character fall into a room, and at the bottom are three different types of shifts, each turning on a different flag. Try from there.
Spoiler: Achievements (click to show/hide)

*

Offline Pumpkinbot

  • 1134
  • 20
  • No terrain is too hard. Not even dragons.
    • View Profile
    • My DeviantART page
Re: Random events
« Reply #2 on: August 13, 2009, 09:07:36 »
I'd wanna do this, too, for a WarioWare styled game. :shifty:
A God, a Messiah, an Angel, a King, a Prince, and an All Terrain Vehicle.

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Random events
« Reply #3 on: August 13, 2009, 13:12:02 »
Long answer short, it is not possible to use a random factor for doing anything. There simply is no random function.

You can simulate randomness by several ways: example, make a run and a jump. and based on where you land, a shift teleports you to a new screen. You just have achieved a random 1 out of 3. Doing it again, gives you a random 1 out of 9. Again for 1 out of 27.

Of cource, each possible outcome must have its own screen/flag.
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline minmay

  • 654
  • 8
    • View Profile
    • Cow Muffins
Re: Random events
« Reply #4 on: August 14, 2009, 01:39:55 »
I'm terribly sorry to say this but you're all horribly wrong and didn't really think about how you were posting "no u cant do dis its imposibl" when you really didn't know if it was possible and you knew you didn't know.  Uh, sorry.

It is possible to make what is random for the purposes of gameplay, and it only takes two shifts and one tile.

STEP ONE: Place two different shifts on the same tile.  It doesn't matter which shift ID's you use or which layers you put them on.
STEP TWO: Set them both to shift on touch, set one to the Spot shape, and set another one to the Circle shape.  Assuming you don't want your players to think "oh god what is that horrible animating piece of crap over there, I guess it's a couple of shifts both on the same tile for some reason, maybe I should step on them," make them invisible.
STEP THREE: Go on ahead and set their destinations/flags.  It is important that they do teleport the player away.
STEP FOUR: This is very important.  Make sure that the pair of shifts can only be approached by walking/running into it.  If the player jumps up into it, or falls onto it, they'll always trigger the Spot shift in the first case and the Circle shift in the second.

What happens is: when the player walks into the shift, if the Circle shift is in its largest animation frame, it is triggered, otherwise the Spot shift is triggered.  If they run, then the cut-off point is in the middle of the animation.  But this only works from the right side.  If someone walks in from the left side, the Spot shift will always be triggered.  Running is better but probably pretty useless.

This means a 1/(frames in Circle animation, which I believe to be 6, but the animation is contained within KS itself, and I'm not downloading the MMF2 trial just to find how many bloody frames are in a bloody animation) chance of the Circle shift being triggered, if the player is walking.  (If the player is running, it seems very close to 1/2, which is nice, but I'm not sure.) If you want a different chance - and indeed you probably will - you'll need to use multiple screens, which is just as awkward as you'd expect in terms of gameplay.

Now, this isn't a random choice, and someone with a ludicrously fast response time could potentially manipulate the result (as could someone who uses a crappy computer or CPUKiller-type program to slow down KS), but for all practical purposes it is good enough.



The main problem is that they have to walk/run into it, it can only be from the right side, et al.  It is very difficult to incorporate seamlessly.

Is this confusing?  Probably!  That's why I made an example level for it!  Download it here, if you must.
« Last Edit: August 14, 2009, 01:41:41 by minmay »

*

Offline Shawnachu

  • 223
  • 1
  • Contemplating
    • View Profile
Re: Random events
« Reply #5 on: August 14, 2009, 02:11:01 »
...Dang. That's a clever idea  :O

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Random events
« Reply #6 on: August 14, 2009, 13:59:41 »
Indeed very clever Minmay, but may I point out, that that still isn't random? :)

I ment random in the sense of: ShiftFlag(A)=Random(true;false)

Thats what Liquid Bacteria is asking.

For that reason, I said that its not possible, but it can be achieved using a workaround. Yours is indeed the best one I've seen, which basically randomises between true and false (2 shifts)
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline minmay

  • 654
  • 8
    • View Profile
    • Cow Muffins
Re: Random events
« Reply #7 on: August 14, 2009, 18:33:25 »
He didn't specifically want it to be doable by scripting.  He said "maybe."

And of course it isn't random; I mention that enough in my post, I think.

Either way, if you want to pick a "random" result, this is the best way to do it.

*

Offline Pick Yer Poison

  • 782
  • 3
  • One cool cat.
    • View Profile
Re: Random events
« Reply #8 on: August 14, 2009, 20:08:28 »
Technically speaking, a computer cannot generate "true randomness." The most it can do is create a value based on input, although those can be fairly randomized inputs (e.g. what frame a user presses a button on). So what minmay has there is basically a simplified version of a computer's own randomization process; taking input from the user in such a way that the user has trouble inputting a specific value.

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Random events
« Reply #9 on: August 14, 2009, 21:02:19 »
Lets not turn this into a discussion what random is.

Is this possible to do, maybe by scripting in the world.ini file?

I basically said no to this part, and explained it.
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

Re: Random events
« Reply #10 on: August 15, 2009, 00:16:49 »
That is a really clever idea, minmay. It's a lot better than the pseudo-randomization I was thinking of. The limitation doesn't seem like it would be too difficult to design around.

The other suggestions for pseudo-randomization are good too. I really appreciate everyone's ideas!