Tutorial 1: Forcefield

Regions are powerful, and why not show it! You could even use regions to track players' movements. For instance, let's say your Dream is anticipating the arrival of a very infamous individual known as Ms. Agatha Frumpybottoms. There's only one issue though... this woman is a high school principal with very low tolerance for riff raff, and therefore exudes an aura that makes everyone around her shiver. Wouldn’t it be cool to make a special set of triggers that make it so the other students will actively avoid approaching her? We'll showcase how to do this with region DS by creating a force field of space around Principal Frumpybottoms that others cannot enter. The principal, however, will still be able to move up to others.

The bulk of the triggers will be listed below, and an explanation will follow:

(0:1) Whenever someone moves,
(1:5) and they successfully moved,
(1:70) and their name is {Agatha|Frumpybottoms},
(5:351) set variable %pos_diamondTop to the X,Y position the triggering player moved to.
(5:351) set variable %pos_diamondBottom to the X,Y position the triggering player moved to.
(5:352) move the position in variable %pos_diamondTop northeast (up and right) 1 step(s).
(5:355) move the position in variable %pos_diamondTop northwest (up and left) 1 step(s).
(5:353) move the position in variable %pos_diamondBottom southeast (down and right) 1 step(s).
(5:354) move the position in variable %pos_diamondBottom southwest (down and left) 1 step(s).
(3:30) in region 1,
(5:120) make this/these location(s) part of region 0.
(3:3) within the diamond (%pos_diamondTop) - (%pos_diamondBottom),
(5:120) make this/these location(s) part of region 1.

The first three lines simply detect when the principal moves to a new location. The next two lines, both (5:351), set two variables to her new position. This may seem redundant, but is intentional!

Note: The point of using two separate variables is so that we can define a diamond area on the map to add a no-walk zone for other players. This will be the area around the principal.

The next four lines move the position of %pos_diamondTop and %pos_diamondBottom to the tile directly north and south of the principal, respectively. This will be the diamond range we'll apply the no-walk region to.

The next two lines, (3:30) and (5:120), simply change all locations on the map where region 1 is, to instead be region 0. This is because region 1 is what we’re using to apply the no-walk zone to. We are also assuming that the rest of the map is region 0 in this case. If it isn't, the principal may be unintentionally resetting the regions in other locations on the map!

Finally, the last two lines reapply region 1 to the specified diamond range from the variables that were following the principal around.

Okay! So, now the principal does have a zone around her every time she moves, but without more DS, it won't have a visual effect in the game at all. That means we need to add in a trigger to make the players move back if they approach her (or something else could happen, if you have other ideas in your own Dream!)

(0:69) When someone first moves into region 1, from a different region,
(1:170) and their name is not {Agatha|Frumpybottoms},
(5:18) move the triggering player back where they came from.
(5:200) emit message {You dare not approach Principal Frumpybottoms!} to the triggering player.

There you have it! Players will now be moved back to their starting square if they tried to move into the principal, but she can approach them without an issue.

Account E-Mail

Password