カスタマイズ可能なトップダウンシューティングゲームのミニゲーム – GALV_InvaderMiniGame.js

タイトル
A customizable top-down shooter minigame
作者名
ヘルプ
Galv's Invader Mini Game
----------------------------------------------------------------------------
A top down shooter mini game. A big thanks to all my patreon supporters to
make this possible.

Below is a description of how to set up and change the mini game during your
RPG gameplay. This is not a plugin for users new to RPG Maker MV as it
currently requires knowledge of eventing, script calls, database animations
and basic javascript.

Future plans include an Invader Mini Game Building App that will generate
the required script calls to set up their mini game more easily.

----------------------------------------------------------------------------
HOW IT WORKS
----------------------------------------------------------------------------
The mini game was created to allow for a lot of customization during the
game. This is a rundown that will try to explain how it works.

CONTROLS
Left, Right, Up, Down and the default 'ok' button are the main controls.
If the mouse or a touch screen is used, autofire will activate and the left
and right movement will be controlled by pressing the left and right of the
screen as defined in the 'Touch Edges' plugin setting.

The "Bomb Button" and "Charge Button" controls can be changed to any of the
following list. (This is default in RPG Maker)

KEY CODE Keys bound to
------------------------------
tab tab
ok Z or enter or space
shift shift
control control or alt
escape X or esc or insert or numpad0
pageup Q or pageup
pagedown W or pagedown
left leftarrow or numpad4
up uparrow or numpad8
right rightarrow or numpad6
down downarrow or numpad2


REQUIRED
1. a new folder in your project's files: /img/invader/
2. image files for the HUD named as below:
/img/invader/invaderHudHull1.png
/img/invader/invaderHudHull2.png
/img/invader/invaderHudShield1.png
/img/invader/invaderHudShield2.png
(included in the downloads on galvs-scripts.com)
3. images for object, modules, layers, etc. depending on your setup.
feel free to use images from the demo in your game or as guides to make
your own graphics
4. the desire to learn, willingness to experiment and patience to succeed

THE BUILDING BLOCKS
A rundown of the base elements of the mini game is below:

1 - Game Objects
An "Object" in the mini game refers to: enemies, powerups and other hazards
that will appear physically while playing the mini game.
These objects can be configured to act like the different "things" in the
mini game by changing movement AI, graphics, hp, effects, modules, etc.

2 - Player
The "Player" is just a game object (exactly as above) but this object is
controlled by the player and does not use some of Game Object settings
such as movement AI (obviously!)

3 - Modules
A "Module" is something that can be equipped to and enhance Game Objects.
They can be things such as weapons, shields, engines, armor, etc. A game
object must have "slots" to equip modules to.
The player can have temporary modules added to it via object powerups.
These modules will disappear after the level is finished.

4 - Phases
A "Phase" refers to a portion of a mini game "Level". Each phase can have
different parameters telling it how long to last, what enemies and powerups
to spawn, music, background and more. Each "Level" can contain as many
phases as desired.

5 - Levels
Every time the player starts this mini game, they play a "Level" of it.
Level settings contain each level's name and phase data. This data is saved
for all levels of unique name once you create them and can be accessed or
changed during the game as required.
During a "Level", a player will challenge each "Phase" in order until every
phase in the level settings has been completed or the player is defeated.
Records of playing each level (score,wins,losses,kills,etc) are kept in the
level data which you can access with eventing.

Each of the above elements are set up using SCRIPT event commands.
These elements are saved in $gameSystem.invader

BOMBS
The plugin settings allow you to change some settings about bombs. This
feature was designed for the player to have limited use panic button that
can destroy or highly damage all enemies on screen.

----------------------------------------------------------------------------
EDITABLE ATTRIBUTES
----------------------------------------------------------------------------
Below is a list of attributes the mini games uses for each of the above.
Most of these were included in the plugin settings for you to assign default
values to them - which means during setup if you don't assign a value to
any of the below attributes, it will refer to the default instead.

GAME OBJECTS
----------------------------------------------------------------------------
VAR NAME TYPE DESCRIPTION
id Integer Unique identifier
name String Name of object
description String Description of object
graphic String Graphic found in /img/invader/
frames Integer Number of frames/cells across in graphic sheet
rows Integer Number of rows in graphic sheet
frameSpeed Integer Time passed between frame animations
z Integer Z level of object (lower appears below)
visibleModules Boolean Draw equipped modules onto object - true/false

movementAi String Designate type of AI. Can be one of:
'','follow','erratic','static','custom'
vertSpeed Integer Speed object moves vertically down the screen
horzspeed Integer Max speed object moves horizontally in follow
and erratic AI settings. Or set horizontal
movement in 'static' AI seting.
xStart Array [x,x] starts in random x between %'s of screen
xLimit Array [x,x] movement restricted between %'s of screen
yLimit Integer vertical movement stopped when at y% of screen
yLimitSpeedY Array [y,ymax] - when reaching yLimit, speed of
acceleration is changed by y (negative to
reverse direction) up to a max of ymax
yLimitSpeedX Array [x,xmax] - when reaching yLimit, speed of
horizontal movement is changed by x up to a max
of xmax

hp Integer Maximum hull points
sp Integer Maximum shield points
armor Integer Hull damage taken is reduced by the armor value
hitbox Object {w:100,h:100} - width and height of hitbox
hittable Boolean Projectiles can hit object - true/false
hitAnim Integer Animation ID played when hit (if gun has none)
shieldAnim Integer Animation ID played when shields are hit
scoreMod Integer Score change when object is destroyed
countKill Boolean true or false if object counted as a kill
dieAnim Integer Animation ID played on object
dieItem Array [itemType,id] - to gain an item when shot
dieTrigger String Custom code to run when object dies. eg:
'this.endPhase();'
'$gameSwitches.setValue(1,true);'

canCollide Boolean Player can collide with object - true/false
collideDie Boolean Object dies instantly on collide - true/false
collideAnim Integer Animation ID played on collidee
collideIgnoreS Boolean Collision ignores shields - true/false
collideDamageHp Integer Damage caused to hull when colliding
collideDamageSp Integer Damage caused to shields when colliding
collideHpMod Integer Heal hull points
collideSpMod Integer Heal shield points
collideItem Array [['itemType',id]] - gain an item on collision
itemType can be one of the following:
'armor','weapon','item','module','object',
'pupModule' or 'bomb'. If 'bomb' then the id
is actually number of bombs gained instead.
a negative id number will remove previous
pupModules (this ONLY works for pupModules)
multiple items can be gained, eg:
[[itemType,id],[itemType,id],[itemType,id]]

slots Object Slots object controls equipping modules:
{
id: { Integer Unique slot ID
xy: [0,0], Array Location of module (0,0 is center)
size: 2, Integer Max size of module that can fit here
type: 'weapon', String What type of module can fit here
type can be 'object' for 'attaching'
module: null Integer ID of module in the slot. null = none
if type has 'object' in it's name, this
becomes an object ID that is connected
to the slot. Connected objects move with
their parent object.
},
}


GAME MODULES
----------------------------------------------------------------------------
VAR NAME TYPE DESCRIPTION
id Integer Unique identifier
name String Name of module
description String Description of module
graphic String Graphic found in /img/invader/ this graphic
will overlay the object it is equipped to
and must be the same amount of frames/rows
xy Array Location of module [0,0] is center. This
will take priority over a slot's xy

hp Integer Hull point enhancement
sp Integer Shield point enhancement
armor Integer Armor point enhancement
speed Integer Speed enhancement
energy Integer Energy requirement to equip to an object
size Integer Size of module
type String Type of module to use in slot restriction
Below values apply to types that contain
'weapon' in the typename

shootAnim Integer Animation ID played on shooting object
hitAnim Integer Animation ID played on projectile when hit
contactAnim Integer Animation ID played on target that is hit
shootSE Object {name:'',pan:0,pitch:100,volume:100}
if using chargeTime, this can be an array
of 3 sounds for each charge step
damageSp Integer Damage caused to shields
damageHp Integer Damage caused to hull
ignoreS Boolean Projectile ignores shields - true/false
ignoreA Boolean Projectile ignores armor - true/false
fireRate Array [a,b] random shoot time between a and b
projectileSpeed Integer Speed projectile travels
projectileAngles Array List of angles. Module will fire as many
projectiles as there are angles in array
projectileGraphic String Graphic found in /img/invader/
projectileZ Integer Z level of object (lower appears below)
projectileHitBox Object {w:100,h:100} width,height of proj hitbox
projectilePenetrate Boolean Projectile continues when hit true/false
projectileTick Integer For large projectiles. Amount of frames
an object remains in a large projectile
area before it repeats the damage.

chargeTime Integer Frames a weapon can chargeup for. If this
is > 0, weapon uses charge button instead
of the normal shoot button. 60 frames/s
The charge settings below only work if
this is > 0 as well.
chargeRate Array [min,max,full] damange % of charge time
min-max = 0-100%, full = >100%
chargeAnims Array [a,b,c] anims played during charge time
a = 0-50%, b = 50-100%, c = >100%
chargeAnimDelay Integer Frames of delay between charge animations
chargeAngles Array [a,b,c] number of projectileAngles used
a = 0-50%, b = 50-100%, c = >100%

upgradeModule Integer The ID of a different module used for when
obtaining this module weapon powerup when
it has been picked up already. A module
without this attribute can be obtained
unlimted times. Make this 0 to only be
be able to pick it up once in-game


GAME PHASES
----------------------------------------------------------------------------
VAR NAME TYPE DESCRIPTION
id Integer Unique identifier
splashImage String Graphic found in /img/invader/ for phase start
beginAnim Integer Animation ID played on player on phase start
gainItem Array [['itemType',id]] - to gain item on phase start
works like 'collideItem' for 'objects'

length Integer Second duration before phase ends
delayEnd Integer Second delay after phase ends
delayBegin Integer Second during phase start (SplashImage display)

enemyFreq Array [a,b] enemy spawn random seconds between a & b
enemies Array List of enemy ID's that can spawn in phase
eSpawnType Integer 0 = spawn in array order, repeating the list
1 = spawn randomly from the list
2 = spawn in order but stop when list is empty

pupFreq Array [a,b] pups spawn random seconds between a & b
pups Array List of powerup ID's that can spawn in phase
pSpawnType Integer 0 = spawn in array order, repeating the list
1 = spawn randomly from the list
2 = spawn in order but stop when list is empty

bgm Object {name:'',pan:0,pitch:100,volume:100}
bgmFade Integer Seconds bgm fades out at end of phase
bgs Object {name:'',pan:0,pitch:100,volume:100}
bgsFade Integer Seconds bgs fades out at end of phase

layers Object Object containing layer graphic data:
{
1: { Layer ID
graphic: '', graphic from /img/invader/
opacity: 255, how transparent the layer is
xs: 0, speed layer moves horizontally
ys: 2, speed layer moves vertically
ox: 0.1, layer offset depending on player location
z: -10, z level of layer
fadeSpeed: 10 Speed layer fades in (except phase 1)
},
};

Layers that are created remain from phase to phase unless you use the
same layer ID in a new phase - then the previous layer will disappear
after a while. It remains visible for a time so the new layer with same ID
can fade in over the old one.



GAME LEVELS
----------------------------------------------------------------------------
VAR NAME TYPE DESCRIPTION
id Integer Unique identifier
splashImage String Graphic found in /img/invader/ for level start
beginAnim Integer Animation ID played on player on level start

victoryImage String Graphic found in /img/invader/ for victory
meVictory Object {name:'',pan:0,pitch:100,volume:100}
defeatImage String Graphic found in /img/invader/ for defeat
meDefeat Object {name:'',pan:0,pitch:100,volume:100}

delayEnd Integer Second delay after phase ends
delayBegin Integer Second during phase start

contMusic Boolean Continue playing music from map - true/false


----------------------------------------------------------------------------

SCRIPT CALLS

----------------------------------------------------------------------------
These script calls are what control all aspects of your mini gameplay in
your project. One important thing to note is that RPGMaker MV's event
'script' box only allows a limited number of lines - but it allows a lot of
text on one line. So these script calls can be done on one line - it might
be better to copy/paste into a text editor in order to read or write them
easier.

----------------------------------------------------------------------------
SCRIPT CALL - CREATING GAME DATA
----------------------------------------------------------------------------

Galv.INVADER.create('type',id,{parameters});

----------------------------------------------------------------------------
This script call is used to build modules, objects and phases.
'type' = 'object', 'module' or 'phase'
id = unique identifier of the object, module or phase
parameters = an object containing parameters (from the above lists)
----------------------------------------------------------------------------
EXAMPLE MODULE:
Galv.INVADER.create('module',1,{
type:'weapon',graphic:'module0',projectileGraphic:'bullet0',
fireRate:[1,25],projectileSpeed:15
});

EXAMPLE OBJECT:
Galv.INVADER.create('object',2,{
hp:5,graphic:'enemy0',frames:4,hitbox:{w:90,h:80},dieAnim:10,
xStart:[10,90],yStart:[0,0],z:4,dieTrigger:'this.endPhase()',
slots: {
0: {xy: [0,0], size: 2, type: 'weapon', module: 1}
1: {xy: [0,0], size: 2, type: 'armor', module: 2}
},
});

EXAMPLE PHASE:
var p1 = {1:{graphic:'layer_ground2',opacity:255,xs:0,ys:1.5,ox:0,z:-30}};
Galv.INVADER.create('phase',0,{splashImage:'heading1',layers:p1,enemies:[2],
bgm: {name:'03_Endless_Battle',pitch:120,volume:90}
});

----------------------------------------------------------------------------
SCRIPT CALLS - CHANGING GAME DATA
----------------------------------------------------------------------------

Galv.INVADER.change('type',id,{parameters});

----------------------------------------------------------------------------
This script call works exactly like the create function, but instead of
creating a new one, it modifies ones that have already been created. This
will only modify parameters you assign and it will keep all others intact.
----------------------------------------------------------------------------

Galv.INVADER.changeSlot(objectId,slotId,{parameters});

----------------------------------------------------------------------------
This will modify the parameters of a slot of the specified object.
----------------------------------------------------------------------------

----------------------------------------------------------------------------
SCRIPT CALL - LEVEL SETUP
----------------------------------------------------------------------------

Galv.INVADER.buildLevel(id,{params},[phaseIds]);

----------------------------------------------------------------------------
This script call is used to build levels.
id = unique identifier of the level
parameters = an object containing parameters (from the above LEVEL list)
phaseIds = an array containing, in order, phases for the level
----------------------------------------------------------------------------
EXAMPLE LEVEL:
Galv.INVADER.buildLevel(1,{splashImage:'heading0',beginAnim:1},[0,1,2,3,4]);
----------------------------------------------------------------------------

----------------------------------------------------------------------------
OTHER SCRIPT CALLS
----------------------------------------------------------------------------

Galv.INVADER.run(id); Start the mini game on a pre-made level id

Galv.INVADER.equipModule(objId,slotId,moduleId); equip module to object

Galv.INVADER.setPlayer(objId); Make an object id the player

----------------------------------------------------------------------------

----------------------------------------------------------------------------
SCRIPT TO USE IN VARIABLES OR CONDITIONAL BRANCHES
----------------------------------------------------------------------------
In all the below examples, 'x' is the level Id number, to get the data for
that particular level that has been stored.

Galv.INVADER.record(x).result returns "win" or "lose" depending on
the last mini game play.

Galv.INVADER.record(x).time returns last play time
Galv.INVADER.record(x).bestTime returns best play time for the level
Galv.INVADER.record(x).score returns last play score
Galv.INVADER.record(x).highScore returns best score for the level
Galv.INVADER.record(x).wins returns how many wins for the level
Galv.INVADER.record(x).losses returns how many losses for the level
Galv.INVADER.record(x).kills returns how many kills for last level
Galv.INVADER.record(x).totalKills returns how many total kills for level

----------------------------------------------------------------------------
CONDITIONAL BRANCH EXAMPLE:
Galv.INVADER.record(1).result == "win" conditional branch check
----------------------------------------------------------------------------

----------------------------------------------------------------------------
NOTES:
BestTime and highScore are only recorded when the players wins. If the
player loses, time and score will be recorded for you to use, but it will
not count toward the highScore or bestTime.
----------------------------------------------------------------------------
パラメータ
param -DEFAULT SETTINGS-
desc
default
param HUD X Padding
desc Distance between edge of screen and hull/shield bars
default 4

param HUD Y Padding
desc Distance between edge of screen and hull/shield bars
default 0

param HUD H Animation
desc Animation played on the hull HUD bar when shield is damaged
default 0

param HUD S Animation
desc Animation played on the shield HUD bar when shield is damaged
default 0

param Resume Text
desc The text command for resuming the game from pause menu
default Resume

param Quit Text
desc The text command for quitting the game from pause menu
default Quit

param -- PLAYER --
desc
default
param Touch Edges
desc Pixel width on either side of the screen that will move left/right when pressed.
default 300

param Vertical Movement
desc If the player can move freely vertically instead of being stuck to horizontal axis. true or false
default false

param Vertical Block
desc The amount of pixels on bottom and top of screen the player will stop at when moving vertically.
default 50

param Charge Button
desc The button used to hold down and charge charging weapons.
See help file for info.
default shift

param Charge Shot
desc toggle or hold - for weapons with the charge ability using
default hold

param Bomb Button
desc The button used to drop a bomb.
See help file for info.
default control

param Bomb Graphic
desc Bomb image name from /img/invader/ folder
default bomb

param Bomb Damage
desc Amount of HP damage bombs cause to all enemies on screen
default 9999

param Bomb Anim
desc The animation played on player when bomb goes off on screen
default 0

param Starting Bombs
desc The amount of bombs player starts with in each level
default 0

param Max Bombs
desc The max amount of bombs the player can pick and and hold during level
default 3

param -- OBJECTS --
desc Objects created without specifing a parameter will use the below defaults
default
param Object Name
desc Name of the object appearing in menu scenes
default ????

param Object Desc
desc Description of the object appearing in menu scenes
default An unknown object

param Object Graphic
desc Graphic spritesheet used from /img/invader/ folder
default

param Visible Modules
desc true or false. If module graphics display on object or not.
default false

param Object Frames
desc Number of frames in an object spritesheet
Default: 4
default 4

param Object FrameSpeed
desc Speed frames display for the object (smaller is faster)
Default: 10
default 10

param Object Hitbox
desc Width,Height of the object's collision/hit box, centered on the object graphic
default 90,60

param Object Hull Points
desc Default hull points (hit points) the object has
default 1

param Object Armor
desc Reduce hull damage by the armor amount.
default 0

param Object Shield Points
desc Default shield 'hit points'
default 0

param Object Score
desc Default score earned by destroying object.
default 10

param Object Move Speed
desc Vertical,Horizonal move speed
default 0.5,20

param Object Spawn X
desc min,max - set object's x position to a random % of screen width
default 0,100

param Object X Limit
desc min,max - set object's min/max x it can move into to a random % of screen width. Dont use negatives.
default 0,100

param Object Y Limit
desc % of the screen height that the enemy will stop at or change behavior
Default 150 to make sure off screen
default 150

param Object Y LimitSpeedY
desc Progressive Y speed change when Y limit is reached and the maximum speed allowed.
default 0,0

param Object Y LimitSpeedX
desc Progressive X speed change when Y limit is reached and the maximum speed allowed.
default 0,0

param Object Z
desc The z priority level of the object
Default 5
default 5

param Movement AI
desc Leave blank for straight movement. Options are:
erratic,follow,custom
default
param Object Hittable
desc true or false - Can object be hit with shots?
Default true
default true

param Hit Animation
desc Animation ID for when object is hit by a projectile but not destroyed. A gun's 'contactAnim' will override this
default 0

param Hit Shield Animation
desc Animation ID for when object is hit by a projectile and shields take damage
default 0

param Destroyed Animation
desc Animation ID for when object is "destroyed"
default 4

param Collision
desc true or false. If object can collide with player or not
default true

param Collide Damage HP
desc Amount of hull damage the object causes to the other object on collision
default 10

param Collide Damage SP
desc Amount of shield damage the object causes to the other object on collision
default 10

param Collide Ignore Shield
desc Collision damage from this object will ignore shields and do hull damage directly
default false

param Collide Animation
desc Animation played on the player when collide with object.
default 0

param -- MODULES --
desc Modules created without specifing a parameter will use the below defaults
default
param Module Name
desc Name of the module appearing in menu scenes
default Module

param Module Desc
desc The description of the module appearing in menu scenes
default An unidentified module

param Module Type
desc Default "type" for modules is the most common - weapon
default weapon

param Module Hit Animation
desc Animation displayed on target when projectile from module hits it
default 5

param Module Shoot SE
desc Sound effect played when a weapon module fires a projectile
SE_Name,volume,pitch
default Shot1,80,120

param Module Shield Damage
desc Damage weapon projectile does to shield points
default 1

param Module Hull Damage
desc Damage weapon projectile does to hull points
default 1

param Module Fire Rate
desc random firing rate between between x,y 10ths/second (player shooting always uses lowest)
default 1,2

param Module Bullet Speed
desc How fast the projectiles fired from this module move
default 10

param Module Bullet Graphic
desc Graphic used for the projectile fired from this module
default bullet0

param Module Bullet Z
desc Z level bullet graphic is displayed at
default 2

param -- PHASES --
desc Phases created without specifing a parameter will use the below defaults
default
param Phase Name
desc Name of the phase (however not currently used anywhere)
default New Phase

param Phase Image
desc Image displayed when phase starts - lasts as long as phase start delay
default
param Phase Start Animation
desc Animation played on player when phase starts
default 0

param Phase Length
desc How many seconds the phase lasts until next phase begins
default 15

param Phase Start Delay
desc How many seconds phase start (and phase splash image display) lasts for
default 3

param Phase End Delay
desc How many seconds phase stays without spawning enemies before next phase begins
default 3

param Phase Enemy Spawn Time
desc Random between low,high seconds between each enemy spawning in this phase
default 0.5,2

param Phase Enemy Spawn Type
desc 0 = cycle through enemy list, 1 = random enemy from enemy list, 2 = cycle once then stop
default 1

param Phase PUp Spawn Time
desc Random between low,high seconds between each enemy spawning in this phase
default 10,30

param Phase PUp Spawn Type
desc 0 = cycle through PUp list, 1 = random PUp from PUp list, 2 = cycle once then stop
default 1

param -- LEVELS --
desc Levels built without specifing a parameter will use the below defaults
default
param Level Begin Animation
desc Animation played on player when level starts
default 0

param Level Start Delay
desc How many seconds level start (and level splash image display) lasts for
default 2

param Level End Delay
desc How many seconds level end (and win/lose image display) lasts for
default 3

param Victory Image
desc Image displayed when level starts - lasts as long as level start delay
default headingWin

param Defeat Image
desc Image displayed when player is defeated - lasts as long as level end delay
default headingLose

param Victory ME
desc ME played on victory
SE_Name,volume,pitch
default Victory1,100,100

param Defeat ME
desc ME played on defeat
SE_Name,volume,pitch
default Defeat1,100,100

ライセンス表記
feature was designed for the player to have limited use panic button that
xLimit Array [x,x] movement restricted between %'s of screen
yLimit Integer vertical movement stopped when at y% of screen
yLimitSpeedY Array [y,ymax] - when reaching yLimit, speed of
yLimitSpeedX Array [x,xmax] - when reaching yLimit, speed of
'script' box only allows a limited number of lines - but it allows a lot of
- Added horizontal speed when Y limit reached

紹介ページ https://galvs-scripts.com/category/rmmv-plugins/mv-scenessystems/#post-1597