I'm still hard at work updating my wacko scripts for Entrepreneur: The Beginning into more manageable templates and functions so that updates can come out faster and better optimized, and I am getting close to the end of the first round. Normally I would post an update related to the game in Entrepreneur Central, but this one's different because this one is about giving something more general back to you guys.
By updating the scripting for the game, I've come up with some simple functions to make common practices much easier and faster to manage. Here are some of the frequently-used functions (well, frequently in my scripts) that would benefit any game. Chances are you already have something similar in place, but for those who don't, or for those who are still learning plotscripting, or for those who want to jump into a new game and save time doing so, here are some script functions you might like for your own games (with description). They should be easily copied and pasted into whatever script you're working on. Remember, these are designed as functions, not triggered scripts, so they should be used as a line in your script once you've defined them.
Note: Some scripts use constants and global variables. I'll make a note which ones you'll need to add to your constants definitions and global variables list.
Here is Part 1 of this feature.
______________________
Function:
Simple Textbox Display
Name:
Basic Text (textbox)
Description:
Shortens textbox display commands to a single line. This should be used only when you want the player to manually advance text and only when nothing is supposed to happen while the text is displayed. It's extremely common.
Usage Example:
script,talk to me,begin
walk hero (0,north,1)
wait for hero (0)
basic text (2)
walk hero (0,west,1)
wait for hero (0)
basic text (3)
end
Script for Function:
Code: Select all
script,basic text,which box,begin
show text box (which box)
wait for text box
end
______________________
Function:
Simple Camera Pan
Name:
Basic Camera (x,y,speed)
Description:
Simplify camera movement down to a single line. Functions like "basic text."
Usage Example:
script,talk to me,begin
walk hero (0,north,1)
wait for hero (0)
basic text (2)
walk hero (0,west,1)
wait for hero (0)
basic text (3)
basic camera (10,10,10)
basic text (4)
end
Script for Function:
Code: Select all
script,basic camera,x,y,speed,begin
focus camera (x,y,speed)
wait for camera
end
Pan Camera Deluxe (direction,distance,speed)
Note: This is the "pan camera" equivalent to the above script function.
Code: Select all
script,pan camera deluxe,direction,distance,speed,begin
pan camera (direction,distance,speed)
wait for camera
end
Function:
Simplified Walking
Names:
(heroes)
Basic Hero Walk (who,place,direction)
Walk Hero Deluxe (who,direction,distance)
Walk Hero Advanced (who,direction,distance,new direction)
Basic Hero Walk Advanced (who,place,direction,new direction)
Move Hero Backward (who,direction,distance)
(npcs)
Basic NPC Walk (who,place,direction)
Walk NPC Deluxe (who,direction,distance)
Walk NPC Advanced (who,direction,distance,new direction)
Basic NPC Walk Advanced (who,place,direction,new direction)
Move NPC Backward (who,direction,distance)
Description:
Simplify hero and NPC movement down to a single line. Functions like "basic text."
Usage Example:
script,talk to me,begin
walk hero deluxe (0,north,1)
basic text (2)
walk hero deluxe (0,west,1)
basic text (3)
basic camera (10,10,10)
basic text (4)
move hero backward (0,east,1)
end
Scripts for Function:
Note: The following script function simplifies walking to a coordinate, namely "walk hero to x" or "walk hero to y." "axis:xline" and "axis:yline" should be defined as constants. These axis lines will serve as the point to which you want the hero or npc (defined in a separate script function) to walk.
Looks Like:
basic hero walk (0,12,axis:xline)
basic hero walk (0,15,axis:yline)
Note: This would send the hero to (12, 15) on the map.
Note 2: The script function could be simplified even further if you want to merge all x and y arguments and destinations together.
Code: Select all
script,basic hero walk,who,place,direction,begin
if (direction==axis:xline) then(
walk hero to x (who,place)
)
if (direction==axis:yline) then(
walk hero to y (who,place)
)
wait for hero (who)
end
Code: Select all
script,walk hero deluxe,who,direction,distance,begin
walk hero (who,direction,distance)
wait for hero (who)
end
Code: Select all
script,walk hero advanced,who,direction,distance,new direction,begin
walk hero (who,direction,distance)
wait for hero (who)
set hero direction (who,new direction)
end
Code: Select all
script,basic hero walk advanced,who,place,direction,new direction,begin
if (direction==axis:xline) then(
walk hero to x (who,place)
)
if (direction==axis:yline) then(
walk hero to y (who,place)
)
wait for hero (who)
set hero direction (who,new direction)
end
Code: Select all
script,move hero backward,who,direction,distance,begin
variable (opposite direction)
switch (direction) do(
case (north) do(
opposite direction := south
)
case (east) do(
opposite direction := west
)
case (south) do(
opposite direction := north
)
case (west) do(
opposite direction := east
)
)
walk hero (who,opposite direction,distance)
set hero direction (who,direction)
wait for hero (who)
end
Code: Select all
script,basic npc walk,who,place,direction,begin
if (direction==axis:xline) then(
walk npc to x (who,place)
)
if (direction==axis:yline) then(
walk npc to y (who,place)
)
wait for npc (who)
end
Code: Select all
script,walk npc deluxe,who,direction,distance,begin
walk npc (who,direction,distance)
wait for npc (who)
end
Code: Select all
script,walk npc advanced,who,direction,distance,new direction,begin
walk npc (who,direction,distance)
wait for npc (who)
set npc direction (who,new direction)
end
Code: Select all
script,basic npc walk advanced,who,place,direction,new direction,begin
if (direction==axis:xline) then(
walk npc to x (who,place)
)
if (direction==axis:yline) then(
walk npc to y (who,place)
)
wait for npc (who)
set npc direction (who,new direction)
end
Code: Select all
script,move npc backward,who,direction,distance,begin
variable (opposite direction)
switch (direction) do(
case (north) do(
opposite direction := south
)
case (east) do(
opposite direction := west
)
case (south) do(
opposite direction := north
)
case (west) do(
opposite direction := east
)
)
walk npc (who,opposite direction,distance)
set npc direction (who,direction)
wait for hero (who)
end
Function:
Automatic NPC Facing
Name:
NPC Face Forward (who,direction)
Description:
NPCs have several interaction attributes like "change direction," "face player," and "do not face player" that can be defined in CUSTOM. Because NPCs don't automatically face heroes through scripting, however, conversations between heroes and npcs may look awkward if they're not facing each other. Here's a quick way to fix that issue.
Usage Example:
script,talk to me,begin
variable (d)
walk hero deluxe (0,north,1)
d := hero direction (0)
npc face forward (1,d)
basic text (2)
walk hero deluxe (0,west,1)
basic text (3)
basic camera (10,10,10)
basic text (4)
move hero backward (0,east,1)
end
Script for Function:
Code: Select all
script,npc face forward,who,direction,begin
if (direction==north) then(
set npc direction (who,south)
)
if (direction==east) then(
set npc direction (who,west)
)
if (direction==south) then(
set npc direction (who,north)
)
if (direction==west) then(
set npc direction (who,east)
)
end
Function:
Simple Range Checks
Name:
In Range (v,min,max)
Description:
Instead of writing "if ((object>=10) && (object<=99)) then(" to show a range, which can get messy if you're nesting, you can simplify range checks by plugging variables and values into the "in range" arguments.
Usage Example:
script,talk to me,begin
variable (d)
if (in range (object,10,99)) then(
walk hero deluxe (0,north,1)
d := hero direction (0)
npc face forward (1,d)
basic text (2)
walk hero deluxe (0,west,1)
basic text (3)
basic camera (10,10,10)
basic text (4)
move hero backward (0,east,1)
)
end
Script for Function:
Code: Select all
script,in range,v,min,max,begin
if (v < min) then(
exit returning (false)
)
if (v > max) then(
exit returning (false)
)
exit returning (true)
end
Okay, that covers Part 1. I'll post Part 2 after I've had lunch. It will feature slightly more complicated things than the above. If you're keeping score, the functions above are merely designed as shortcuts to using built-in waits or excessive typing. Use them if you want. They can shorten your code considerably if you have a lot of textboxes or hero and npc movement.