<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Turn-Based_RPG</id>
	<title>Turn-Based RPG - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Turn-Based_RPG"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Turn-Based_RPG&amp;action=history"/>
	<updated>2026-05-20T18:36:49Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Turn-Based_RPG&amp;diff=1632&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Turn-Based_RPG&amp;diff=1632&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:12Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 11:33, 21 июля 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key digida:diff:1.41:old-1631:rev-1632 --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Turn-Based_RPG&amp;diff=1631&amp;oldid=prev</id>
		<title>scratch&gt;SMB Fan2010: fixed capitalization and updated the role-playing game link at the beginning of the article so that it points to the Wiki page on role playing video games</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Turn-Based_RPG&amp;diff=1631&amp;oldid=prev"/>
		<updated>2022-07-16T21:30:34Z</updated>

		<summary type="html">&lt;p&gt;fixed capitalization and updated the role-playing game link at the beginning of the article so that it points to the Wiki page on role playing video games&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A &amp;#039;&amp;#039;&amp;#039;turn-based RPG&amp;#039;&amp;#039;&amp;#039; is a form of [[RPG Projects|role-playing game]]. In turn-based RPGs, battles consist of turns where a player can command their characters to perform various actions to defeat opponents. Turn-based RPGs are one of the most popular types of RPGs on gaming consoles, but are not very popular as [[Project|Scratch projects]].&lt;br /&gt;
&lt;br /&gt;
This article contains a guide on how to create a turn-based system for an RPG.&lt;br /&gt;
&lt;br /&gt;
When finished, the project should look something like [[projects:archmage/1235930|this]].&lt;br /&gt;
&lt;br /&gt;
== Game Statistics ==&lt;br /&gt;
&lt;br /&gt;
Turn based RPG battles focus mainly on statistics and formulas. In this tutorial the player has the following statistics:&lt;br /&gt;
&lt;br /&gt;
Atk: Physical attack power&lt;br /&gt;
&lt;br /&gt;
Def: Physical defense&lt;br /&gt;
&lt;br /&gt;
MaxHP: Most HP (Health Points) the character can have&lt;br /&gt;
&lt;br /&gt;
HP: Health points, the player is dead when this is at 0&lt;br /&gt;
&lt;br /&gt;
MaxMP: Most MP (Magic Points) a character can have&lt;br /&gt;
&lt;br /&gt;
MP: Magic points, used for magic attacks&lt;br /&gt;
&lt;br /&gt;
MGAtk: Magic attack power&lt;br /&gt;
&lt;br /&gt;
MGDef: Defense from magic attacks&lt;br /&gt;
&lt;br /&gt;
Additionally, the player character has statistics for their weapons:&lt;br /&gt;
&lt;br /&gt;
Atk: A set increase in attack power&lt;br /&gt;
P: A random increase in attack power&lt;br /&gt;
&lt;br /&gt;
An enemy has the same statistics as the player character except without the extra statistics for weapons and Magic Points.&lt;br /&gt;
&lt;br /&gt;
The first thing you should do is create the statistic [[variable]]s. Variables belonging to the player character should start with &amp;quot;C_&amp;quot; those belonging to the player character&amp;#039;s weapon should start with &amp;quot;C_Wep&amp;quot; and those belonging to the enemy should start with &amp;quot;E_&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We are also going to gives the variables some test values when the green flag is clicked so that we may properly play the game during testing. When finished, your set of variables should look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
When flag clicked&lt;br /&gt;
set [C_Atk v] to [5]&lt;br /&gt;
set [C_Def v] to [5]&lt;br /&gt;
set [C_MGAtk v] to [15]&lt;br /&gt;
set [C_MGDef v] to [5]&lt;br /&gt;
set [C_MaxMP v] to [100]&lt;br /&gt;
set [C_MP v] to (C_MaxMP)&lt;br /&gt;
set [C_MaxHP v] to [100]&lt;br /&gt;
set [C_HP v] to (C_MaxHP)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When flag clicked&lt;br /&gt;
set [C_Wep_Atk v] to [5]&lt;br /&gt;
set [C_Wep_P v] to [5]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When flag clicked&lt;br /&gt;
set [E_Atk v] to [5]&lt;br /&gt;
set [E_Def v] to [10]&lt;br /&gt;
set [E_MaxHP v] to [120]&lt;br /&gt;
set [E_HP v] to (E_MaxHP)&lt;br /&gt;
set [E_MGAtk v] to [0]&lt;br /&gt;
set [E_MGDef v] to [0]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Battle Formulas ==&lt;br /&gt;
&lt;br /&gt;
Next you will learn the formulas for the different attacks. The variables you have just created fit snugly into those formulas. The formulas we will use are based on a classic RPG called Super Mario RPG.&lt;br /&gt;
&lt;br /&gt;
Player Melee Attack Damage Formula:&lt;br /&gt;
&lt;br /&gt;
C_Atk(C_Wep_Atk+(pick random (0-C_Wep_P) to (C_Wep_P))-E_Def)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
(((C_Atk) + ((C_Wep_Atk) + (pick random ((0) - (C_Wep_P)) to (C_Wep_P)))) - (E_Def))&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Player Magic Attack Damage Formula:&lt;br /&gt;
&lt;br /&gt;
C_MGAtk+&amp;quot;spellrating&amp;quot;-E_MGDef&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
(((C_Atk) + (22)) - (E_MGDef))&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Each spell has a strength rating which must be set.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enemy Melee Attack Damage Formula:&lt;br /&gt;
&lt;br /&gt;
E_Atk-C_Def&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
((E_Atk) - (C_Def))&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enemy Magic Attack Damage Formula:&lt;br /&gt;
&lt;br /&gt;
E_MGAtk+&amp;quot;spellrating&amp;quot;-C_MGDef&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
(((E_MGAtk) + (0)) - (C_MGDEF))&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Each enemy spell has a strength rating which must be set.&lt;br /&gt;
&lt;br /&gt;
You need to build these scripts and leave them on the stage. They will be used as parts of the scripts for the battle actions.&lt;br /&gt;
&lt;br /&gt;
== Programming Actions ==&lt;br /&gt;
&lt;br /&gt;
Now that you know how the game will handle formulas and stats, it is time to allow the user to play a simple RPG game.&lt;br /&gt;
&lt;br /&gt;
To control the game, we need a few variables that serve to make the game run as opposed to building the battle formulas.&lt;br /&gt;
&lt;br /&gt;
You will now need to create the following variables:&lt;br /&gt;
&lt;br /&gt;
dam: Stores the results of the damage calculations&lt;br /&gt;
&lt;br /&gt;
gamestate: Tells the game what is currently supposed to be doing e.g. letting the player pick attacks, or letting the enemy character attack&lt;br /&gt;
&lt;br /&gt;
* The number of the gamestate variable tells the program different things. This is the list of values for the variable:&lt;br /&gt;
&lt;br /&gt;
1. Wait for player to enter a command&lt;br /&gt;
&lt;br /&gt;
2. Wait for player character animation to finish&lt;br /&gt;
&lt;br /&gt;
3. Allow the enemy to pick an action and carry it out&lt;br /&gt;
&lt;br /&gt;
0. The RPG battle is over&lt;br /&gt;
&lt;br /&gt;
C_Stance: Tells the character sprite which animation to play e.g. standing, attacking, cast spell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
E_Stance: Tells the enemy sprite which animation to play e.g. standing, attacking, cast spell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The stance variables tell the which animations to play, for this game we will make the following animations:&lt;br /&gt;
&lt;br /&gt;
# Idle animation&lt;br /&gt;
# Attack animation 1 (melee)&lt;br /&gt;
# Attack animation 2 (spell)&lt;br /&gt;
# Hurt animation&lt;br /&gt;
# Death animation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will also need the following [[Broadcast]]s:&lt;br /&gt;
&lt;br /&gt;
melee: Makes the player character use a melee attack&lt;br /&gt;
&lt;br /&gt;
spell: Makes the player character do a magic attack&lt;br /&gt;
&lt;br /&gt;
emelee: Makes the enemy character use a melee attack&lt;br /&gt;
&lt;br /&gt;
espell: Makes the enemy character do a magic attack&lt;br /&gt;
&lt;br /&gt;
stance: Tells the player sprite to do an animation&lt;br /&gt;
&lt;br /&gt;
enemy_stance: Tells the enemy sprite to do an animation&lt;br /&gt;
&lt;br /&gt;
Now, create the following scripts on the stage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [melee v]&lt;br /&gt;
set [C_Stance v] to [2]&lt;br /&gt;
set [gamestate v] to [2]&lt;br /&gt;
broadcast [stance v] and wait&lt;br /&gt;
set [dam v] to (((C_Atk) + ((C_Wep_Atk) + (pick random ((0) - (C_Wep_P)) to (C_Wep_P)))) - (E_Def))&lt;br /&gt;
if &amp;lt;(dam) &amp;lt; (0)&amp;gt; then&lt;br /&gt;
set [dam v] to (0)&lt;br /&gt;
end&lt;br /&gt;
change [E_HP v] by ((-1) * (dam))&lt;br /&gt;
set [E_Stance v] to [4]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [gamestate v] to [3]&lt;br /&gt;
set [C_Stance v] to [1]&lt;br /&gt;
broadcast [stance v]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
when I receive [spell v]&lt;br /&gt;
set [C_Stance v] to [3]&lt;br /&gt;
set [gamestate v] to [2]&lt;br /&gt;
broadcast [stance v] and wait&lt;br /&gt;
set [dam v] to (((C_Atk) + (22)) - (E_MGDef))&lt;br /&gt;
if &amp;lt;(dam) &amp;lt; (0)&amp;gt; then&lt;br /&gt;
set [dam v] to [0]&lt;br /&gt;
end&lt;br /&gt;
change [E_HP v] by ((-1) * (dam))&lt;br /&gt;
set [E_Stance v] to [4]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [gamestate v] to [3]&lt;br /&gt;
set [C_Stance v] to [1]&lt;br /&gt;
broadcast [stance v]&lt;br /&gt;
&lt;br /&gt;
when I receive [emelee v]&lt;br /&gt;
set [E_Stance v] to [2]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [dam v] to ((E_Atk) - (C_Def))&lt;br /&gt;
if &amp;lt;(dam) &amp;lt; (0)&amp;gt; then&lt;br /&gt;
set [dam v] to [0]&lt;br /&gt;
end&lt;br /&gt;
change [C_HP v] by ((-1) * (dam))&lt;br /&gt;
set [C_Stance v] to [4]&lt;br /&gt;
broadcast [stance v] and wait&lt;br /&gt;
set [E_Stance v] to [1]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [gamestate v] to [1]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
when I receive [espell v]&lt;br /&gt;
set [E_Stance v] to [3]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [dam v] to (((E_MGAtk) + (0)) - (C_MGDef))&lt;br /&gt;
if &amp;lt;(dam) &amp;lt; (0)&amp;gt; then&lt;br /&gt;
set [dam v] to [0]&lt;br /&gt;
end&lt;br /&gt;
change [C_HP v] by ((-1) * (dam))&lt;br /&gt;
set [C_Stance v] to [4]&lt;br /&gt;
broadcast [stance v] and wait&lt;br /&gt;
set [E_Stance v] to [1]&lt;br /&gt;
broadcast [E_stance v] and wait&lt;br /&gt;
set [gamestate v] to [1]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will also need a way to allow the player to broadcast these actions so make 2 buttons with the following scripts:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Melee Button&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when this sprite clicked&lt;br /&gt;
if &amp;lt;(gamestate) = (1)&amp;gt; then&lt;br /&gt;
broadcast [melee v]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
when flag clicked&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;(gamestate) = (1)&amp;gt; then&lt;br /&gt;
show&lt;br /&gt;
else&lt;br /&gt;
hide&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Spell Button&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when this sprite clicked&lt;br /&gt;
if &amp;lt;&amp;lt;(gamestate) = (1)&amp;gt; and &amp;lt;&amp;lt;(C_MP) &amp;gt; (15)&amp;gt; or &amp;lt;(C_MP) = (15)&amp;gt;&amp;gt;&amp;gt; then&lt;br /&gt;
broadcast [spell v] and wait&lt;br /&gt;
change [mp v] by (-15)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
when flag clicked&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;(gamestate) = (1)&amp;gt; then&lt;br /&gt;
show&lt;br /&gt;
else&lt;br /&gt;
hide&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The player should only be able to press these buttons when the gamestate variable is at 1 so we hide them if the variable is not at one. The buttons work in similar ways but the spell button check to see if the player has enough MP and only make the broadcast if there is enough MP.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As a finishing touch we are going to set the variables that are not involved in the battle formulas to a default value.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when flag clicked&lt;br /&gt;
switch backdrop to [background1 v]&lt;br /&gt;
set [gamestate v] to [1]&lt;br /&gt;
set [C_Stance v] to [1]&lt;br /&gt;
set [E_Stance v] to [1]&lt;br /&gt;
broadcast [stance v]&lt;br /&gt;
broadcast [E_stance v]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Character Animation ==&lt;br /&gt;
&lt;br /&gt;
You will need an animation for each stance, you can either draw them yourself, download a premade sprite sheet, or use a sprite generator such as the [http://www.charas-project.net/charas2/index.php?lang=en&amp;amp;generator=3 Charas-Project Generator]&lt;br /&gt;
&lt;br /&gt;
For this project, the article will use the Charas generator for quick and easy sprites but those who are more artistically inclined can draw them. If you are not drawing sprite then you must import the sprite sheets and cut the sprite out. For a quick guide on how to do this go to [[ar-topic:13743|this forum topic]].&lt;br /&gt;
&lt;br /&gt;
The animations that you need are the following:&lt;br /&gt;
&lt;br /&gt;
# Idle animation&lt;br /&gt;
# Attack animation 1 (melee)&lt;br /&gt;
# Attack animation 2 (spell)&lt;br /&gt;
# Hurt animation&lt;br /&gt;
# Death animation&lt;br /&gt;
&lt;br /&gt;
To make the character sprites to play a little animation every time the stance broadcasts are called so we need a script like this one. The [[blocks]] inside the if blocks are for the animations are can be customized in any way you like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [stance v]&lt;br /&gt;
if &amp;lt;(C_HP) &amp;lt; [1]&amp;gt; then&lt;br /&gt;
switch costume to [dead_1 v]&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(C_Stance) = [1]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(C_Stance) = [2]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
move (100) steps&lt;br /&gt;
switch costume to [melee_1 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
switch costume to [melee_2 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
switch costume to [melee_3 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
go to x: (-90) y: (-89)&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(C_Stance) = [3]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
move (100) steps&lt;br /&gt;
switch costume to [spell_1 v]&lt;br /&gt;
wait (1) secs&lt;br /&gt;
go to x: (-90) y: (-89)&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(C_Stance) = [4]&amp;gt; then&lt;br /&gt;
say (dam)&lt;br /&gt;
switch costume to [hurt_1 v]&lt;br /&gt;
repeat (3)&lt;br /&gt;
move (-10) steps&lt;br /&gt;
end&lt;br /&gt;
repeat (3)&lt;br /&gt;
move (10) steps&lt;br /&gt;
end&lt;br /&gt;
wait (0.5) secs&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
say []&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script for the enemy sprite will look the same except that the broadcast will be the enemy&amp;#039;s broadcast (E_stance) and the stance variable will belong to the enemy (E_stance).&lt;br /&gt;
&lt;br /&gt;
A picture of the enemy script can be seen below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [E_stance v]&lt;br /&gt;
if &amp;lt;(E_HP) &amp;lt; [1]&amp;gt; then&lt;br /&gt;
switch costume to [dead_1 v]&lt;br /&gt;
else&lt;br /&gt;
if &amp;lt;(E_Stance) = [1]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(E_Stance) = [2]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
move (100) steps&lt;br /&gt;
switch costume to [melee_1 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
switch costume to [melee_2 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
switch costume to [melee_3 v]&lt;br /&gt;
wait (0.1) secs&lt;br /&gt;
go to x: (90) y: (-89)&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(E_Stance) = [3]&amp;gt; then&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
move (100) steps&lt;br /&gt;
switch costume to [spell_1 v]&lt;br /&gt;
wait (1) secs&lt;br /&gt;
go to x: (90) y: (-89)&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(E_Stance) = [4]&amp;gt; then&lt;br /&gt;
say (dam)&lt;br /&gt;
switch costume to [hurt_1 v]&lt;br /&gt;
repeat (3)&lt;br /&gt;
move (-10) steps&lt;br /&gt;
end&lt;br /&gt;
repeat (3)&lt;br /&gt;
move (10) steps&lt;br /&gt;
end&lt;br /&gt;
wait (0.5) secs&lt;br /&gt;
switch costume to [idle v]&lt;br /&gt;
say []&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automating the Enemy ==&lt;br /&gt;
&lt;br /&gt;
Since the enemy does not have a player to control its actions, it will do so on its own.&lt;br /&gt;
&lt;br /&gt;
Build this script on the enemy sprite and it should attack the player by itself when gamestate is equal to 3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when flag clicked&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;(gamestate) = [3]&amp;gt; then&lt;br /&gt;
if &amp;lt;(E_HP) &amp;lt; [1]&amp;gt; then&lt;br /&gt;
broadcast [win_battle v] and wait&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(gamestate) = [3]&amp;gt; then&lt;br /&gt;
set [randAtk v] to (pick random (1) to (2))&lt;br /&gt;
if &amp;lt;(randAtk) = [1]&amp;gt; then&lt;br /&gt;
broadcast [emelee v] and wait&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(randAtk) = [2]&amp;gt; then&lt;br /&gt;
broadcast [espell v] and wait&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;(C_HP) &amp;lt; [1]&amp;gt; then&lt;br /&gt;
broadcast [lose_battle v] and wait&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script as you can see also is able to call the broadcasts that end the game, the win_battle and lose_battle broadcasts.&lt;br /&gt;
&lt;br /&gt;
== Ending the Game ==&lt;br /&gt;
&lt;br /&gt;
There are two conditions in which the game ends:&lt;br /&gt;
&lt;br /&gt;
# The player loses all HP and loses the game&lt;br /&gt;
# The enemy character loses all HP and the player wins&lt;br /&gt;
&lt;br /&gt;
As you can see from the above script that automates the enemy, the enemy checks to see if these conditions have been fulfilled and calls the appropriate broadcast.&lt;br /&gt;
&lt;br /&gt;
In the demo project, a different background plays and the gamestate is set to 0, which means that the battle sequence is done.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [lose_battle v]&lt;br /&gt;
set [gamestate v] to [0]&lt;br /&gt;
switch backdrop to [background3 v]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
when I receive [win_battle v]&lt;br /&gt;
set [gamestate v] to [0]&lt;br /&gt;
switch backdrop to [background2 v]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finishing Remarks ==&lt;br /&gt;
&lt;br /&gt;
Test your project out, if you followed this tutorial correctly, then you should have a working RPG project. If it is not working then it is likely you did not correctly copy the scripts in this article. The best way to troubleshoot is to compare it with the example one given at the start of this article.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[RPG]]&lt;br /&gt;
* [[RPG Projects]]&lt;br /&gt;
* [[How to Make an RPG Overworld]]&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
[[Category:RPGs]]&lt;br /&gt;
[[Category:Game Design Tutorials]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;SMB Fan2010</name></author>
	</entry>
</feed>