| |
Ask the Plotscripting Moogle
#1
Since there seems to be much more demand than supply for plotscripting
in the OHRRPGCE community, and since I'm such a nice guy (*cough*), I present
you with a beautiful new column on how to plotscript. Since this is the
first one, I can't really answer any questions, so I'm doing the Scary
Game article that should've appeared in last issue's Design
area. Future issues will feature the Frequently Asked Questions since the
last issue, so e-mail me at moogle1@wizardmail.com
with anything you'd like to see here.
By the way, this issue has fairly advanced examples -- if you don't
understand variables, loops, etc., then you should learn those first.
__ __ __
___ __ _ _ ___ ____ __
The Claw Game
script,claw,begin
variable(ctr)
showtextbox(39) #instructions
waitfortextbox
for (ctr,1,3,1) #you get 3 tries
do
(
while (keyispressed(28)==false) do #until enter
is pressed
(
if (keyispressed(75)) then (walknpc(0,left,1)
setnpcdirection(0,down))
if (keyispressed(77)) then (walknpc(0,right,1)
setnpcdirection(0,down))
wait(2)
)
walknpc(0,down,15) #drop the hand
waitfornpc(0)
#determine points by where the hand was stopped
if (npcy(0)==4) then (showtextbox(40)) #1pt
if (npcy(0)==5) then (showtextbox(40)) #1pt
if (npcy(0)==6) then (showtextbox(41)) #5pt
if (npcy(0)==7) then (showtextbox(41)) #5pt
if (npcy(0)==8) then (showtextbox(42)) #10pt
if (npcy(0)==9) then (showtextbox(43)) #miss!
suspendobstruction #so the hand can get back up
walknpc(0,up,15)
setnpcdirection(0,down)
waitfornpc(0)
resumeobstruction
)
usedoor(0)
end
Although you may have had no idea how this game was done, it's really
not too complicated. The points you get are based on where the hand stops,
and the hand stops when it bumps into the candy NPC. Text boxes tell you
how many points you get from the candy, then the hand is taken back to
the top of the screen.
The tricky part is that the "claw" isn't your hero -- it's an NPC. The
hero is hidden to the side under an obstructing tile and surrounded by
walls. Because the player doesn't control the claw directly, you don't
have to worry about the claw moving where it shouldn't.
__ __ __
___ __ _ _ ___ ____ __
Pumpkin Racer
script,racer,begin
set tag(tag:Choice,on)
suspend player #so the player doesn't press down
showtextbox(36) #instructions
waitfortextbox
set hero speed(me,10) #makes him fast
walk hero(me,up,60) #starts the player's movement
while (checktag(tag:Choice))
do
(
if(keyispressed(77)) then (walk hero(me,right,1))
if(keyispressed(75)) then (walk hero(me,left,1))
setherodirection(me,up)
wait(2)
)
resume player
end
Again, this isn't as hard as it seems. It's even a short script.
You must consider, however, that if the player presses down or up, the
hero will stop. That's why the script doesn't let him control the character.
Instead, it detects whether right or left is pressed and moves the hero
appropriately. The obstacles (pumpkins, in this case) are "touch" NPCs.
Colliding into them turns off the tag, ending the loop. They will need
a text box to do this, as well as to leave the racing area and tell the
player it's over.
It's also a good idea to set the hero's speed back to 4. It's not in
the script above since it wasn't necessary in Scary Game.
__ __ __
___ __ _ _ ___ ____ __
Candy Flinch
script,flinch,begin
variable(cnt)
variable(dly)
variable(ctr)
variable(candys) #improper grammar, but i just realized
"candy" was a function
set variable(candys,1)
set variable(cnt,8)
set tag(tag:Choice,true)
showtextbox(37) #instructions
waitfortextbox
suspendobstruction
while (cnt>>0)
do
(
set tag(tag:Choice,true)
#change point values as difficulty increases
if (cnt==4) then
(
alter npc(2,npcstat:picture,28) #picture
of 5 candies
set variable(candys,5)
)
if (cnt==2) then
(
alter npc(2,npcstat:picture,29) #picture
of 10 candies
set variable(candys,10)
)
set variable(dly,random(30,50)) #random delay for
red light
for(ctr,0,dly,1) do
(
wait(1)
if (keyispressed(28)) then (set variable(ctr,0))
#pressing enter resets the time
)
set npc direction(3,up) #npc 3 is the light. rotating
changes its color.
set tag(tag:Choice,false)
for(ctr,0,cnt,1) do #here you should press enter
(
wait(1)
if (keyispressed(28)) then
(
set tag(tag:Choice,true)
setvariable(ctr,cnt--1)
)
)
decrement(cnt)
if (check tag(tag:Choice)) then #if you hit enter
in time
(
walk npc(1,up,1)
candy(candys) #cool-looking line! gives
you candies.
wait(10)
walk npc(1,down,1)
wait(10)
setnpcdirection(1,up)
setnpcdirection(3,down)
)
else (set variable(cnt,0))
)
set tag(tag:Choice,off)
showtextbox(38)
walk npc(0,down,1)
wait(5)
resumeobstruction
waitfortextbox
usedoor(0)
end
Honestly, I can't remember which script I was supposed to put third.
I chose Candy Flinch because it's easy to explain. If you haven't played
Scary Game, Candy Flinch is a game where you must press Enter just
as the lights turn blue. Waiting too long ends the game.
It's a long script. It has lots of variables. Don't be afraid of it,
though, because it can smell fear.
First, it suspends obstruction so that the hands can move on top of
the candy. Then it checks to see if it should increase the point value
of the candy, since the game becomes both more difficult and more rewarding
as you progress. It decides how much time should be spent on the red light,
then waits that long -- resetting the wait if the player jumps the gun.
The time that the player has to press Enter keeps getting smaller. If
he wins, his "hand" grabs the candy. If he was too slow, the game ends
and the other player's hand grabs it.
__ __ __
___ __ _ _ ___ ____ __
In Conclusion
Send me your questions. That's how this column will operate in the future:
no questions means no column. Please don't send me "Could you show
me the script for..." questions. I would be much happier to answer your
"How could I..." or "Is it possible to..." questions.
Responses are at my discretion. If I choose not to answer your question,
then that's my prerogative... though I hope I can get around to everyone's
questions, depending on the popularity of the column. E-mail me at moogle1@wizardmail.com.
|