PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
obj_npc.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef OBJ_NPC_H
20 #define OBJ_NPC_H
21 
22 #include <QString>
23 #include <QStringList>
24 #include <common_features/size.h>
25 
26 #include "../graphics/graphics.h"
27 #include "spawn_effect_def.h"
28 
29 // //Defines:// //
30 // obj_npc //
31 // npc_Markers //
32 // //////////// //
33 
34 struct obj_npc
35 {
36  unsigned long id; // [npc-1]
37  QString name; // name="Goomba"
38  QString group; // group="Enemy" ;The sort category
39  QString category; // category="Enemy" ;The sort category
40  QString image_n; // image="npc-1.gif" ;NPC Image file
41  QString mask_n;
42 
43  /* OpenGL */
44  bool isInit;
45  PGE_Texture * image;
46  GLuint textureID;
47  long textureArrayId;
48  long animator_ID;
49  PGE_Size image_size;
50  /* OpenGL */
51 
52  QString algorithm_script; // ; Filename of the lua algorithm
53  unsigned long effect_1; // default-effect=2 ;Spawn effect ID on jump-die
54  unsigned long effect_2; // shell-effect=4 ;effect on kick by shell or other NPC
55 
56  enum blockSpawn {
57  spawn_warp=0,
58  spawn_bump
59  };
60  unsigned int block_spawn_type;
61  float block_spawn_speed;
62  bool block_spawn_sound;//Play sound on spawn from block (if false - spawn without 'radish' sound)
63 
64 
65  // ; graphics
66  int gfx_offset_x; // gfx-offst-x=0
67  int gfx_offset_y; // gfx-offst-y=2
68  int gfx_h; // gfx-height-y=32
69  int gfx_w; // gfx-width-y=32
70  bool custom_physics_to_gfx; //The GFX size defining by physics size in the custom configs
71  int grid; // grid=32
72  int grid_offset_x; // grid-offset-x=0
73  int grid_offset_y; // grid-offset-y=0
74 
75  int grid_attach_style; //0 - middle, 1 - left side
76 
77  int framestyle; // frame-style=0 ; (0-2) This option in some alhoritmes can be ignored
78  unsigned int frames; // frames=2
79  unsigned int framespeed;// frame-speed=128
80  bool foreground; // foreground=0
81  bool background; // background=0
82  double z_offset;
83  bool ani_bidir; // animation-bidirectional=0
84  bool ani_direct; // animation-direction=0
85 
86  bool ani_directed_direct; //Animation direction will be gotten from NPC's direction
87 
88  // ; for editor
89  bool custom_animate;//custom-animation=0
90  //; this option useful for non-standart algorithmic sprites (for example, bosses)
91 
92  int custom_ani_alg; //;custom-animation-alg=0 ; Custom animation algorithm
93  //0 simple frame range, 1 - frame Jump; 2 - custom animation sequances
94  int custom_ani_fl; // ;custom-animation-fl=0 ; First frame for LEFT
95  int custom_ani_el; // ;custom-animation-el=0 ; end frame for LEFT / Jump step
96  int custom_ani_fr; // ;custom-animation-fr=0 ; first frame for RIGHT
97  int custom_ani_er; // ;custom-animation-er=0 ; end frame for RIGHT / Jump step
98 
99  QList<int> frames_left; //Frame srquence for left
100  QList<int> frames_right; //Frame sequence for right
101 
102  bool container; // container=0; NPC can contain another NPC inside itself which is released when it dies
103  unsigned long contents_id; //contents-id=0; ID of contained NPC
104  bool container_elastic; //Elastic sprite of container (like sizable block)
105  int container_elastic_border_w; //Width of border to draw elastic container
106  bool container_show_contents; //Show contents of container
107  float container_content_z_offset; //Render target sprite with next offset
108  bool container_crop_contents; //Crop contents GFX size to the size of an item
109  int container_align_contents; //align contents to center-0 or top-1
110 
111  unsigned int display_frame;
112 
113  bool no_npc_collions;// ; this option disabling collisions in editor with other NPCs, but with NPC's of same ID collisions will be checked
114 
115  bool special_option; // ; Special option
116  // have-special=0; Special NPC's option, what can used by NPC's algorithm
117  QString special_name; // ;special-name="Cheep-cheep" ; 60
118  int special_type; // ;special-type=0; 61 0 - combobox, 1 - spin, 2 - npc-id
119  QStringList special_combobox_opts;//;special-combobox-size=3; 62 quantity of options
120  //;special-option-0="Swim"; 63 set title for 0 option combobox
121  //;special-option-1="Jump"; 64 set title for 1 option combobox
122  //;special-option-2="Projective" ; 65 set title for 2 option combobox
123  int special_spin_min; // ;special-spin-min=0 ; 66 minimum value of spin
124  int special_spin_max; // ;special-spin-max=25 ; 67 maximum value of spin
125  int special_spin_value_offset; // have-special-2=0 ; Special NPC's option, what can used by NPC's algorithm
126 
127  bool special_option_2; // Second special option
128 
129  QList<long > special_2_npc_spin_required; // special-2-npc-spin-required
130  QList<long > special_2_npc_box_required; // special-2-npc-box-required
131 
132  QString special_2_name; // ;special-2-name="Cheep-cheep" ; 60
133  int special_2_type; // ;special-2-type=0 ; 61 0 combobox, 1 - spin
134  QStringList special_2_combobox_opts; //;special-combobox-size=3 ; 62 quantity of options
135  //;special-option-0="Swim" ; 63 set title for 0 option combobox
136  //;special-option-1="Jump" ; 64 set title for 1 option combobox
137  //;special-option-2="Projective" ; 65 set title for 2 option combobox
138  int special_2_spin_min; // ;special-2-spin-min=0 ; 66 minimum value of spin
139  int special_2_spin_max; // ;special-2-spin-max=25 ; 67 maximum value of spin
140  int special_2_spin_value_offset; //special-2-spin-value-offset
141 
142  //;game process
143  int score;// score=2 ; Add scores to player (value 0-13)
144  // ; 0, 10, 100, 200, 400, 800, 1000, 2000, 4000, 8000, 1up, 2up, 5up, 3up
145 
146  int coins; //Add number of coins
147 
148  int speed; // speed=64 ; Default movement speed in px/s
149  bool movement; // moving=1 ; NPC simply moving right/left
150  bool scenery; // scenery=0 ; NPC as block or BGO
151  bool keep_position; // scenery=0 ; Keep NPC's position on despawn
152  bool activity; // activity=1 ; NPC has "Activated" event, doing regular loops, etc.
153  // If flag is false, NPC doing job while on screen only and keeps position
154  bool shared_ani;// shared-animation ; All NPC's of same ID will do same animation
155  bool immortal; // immortal=0 ; NPC Can't be destroy
156  bool can_be_eaten; // yoshicaneat=1 ; NPC can be eaten by yoshi
157  bool takable; // takeble=0 ; NPC destroyble on contact with player
158  int takable_snd; //Play sound-id on take
159  bool grab_side;// grab-side=0 ; NPC can be grabbed on side
160  bool grab_top; // grab-top=0 ; NPC can be grabbed on top
161  bool grab_any; // grab-any=0 ; NPC can be grabbed on any collisions
162  int health; // default-health=1 ; NPC's health value
163  bool hurt_player; // hurtplayer=1 ; Hurt player on contact
164  bool hurt_npc; // hurtnpc=0 ; Hurt other npc on contact
165 
166  //Hardcoded sound effects
167  int hit_sound_id;
168  int death_sound_id;
169 
170 
171  //;Editor featured
172  QString direct_alt_title;
173  QString direct_alt_left;
174  QString direct_alt_right;
175  bool direct_disable_random;
176 
177  bool allow_bubble; //allow-bubble=1 ; Allow packable into the bubble
178  bool allow_egg; // allow-egg=1 ; Allow packable into the egg
179  bool allow_lakitu; // allow-lakitu=1 ; Allow packable into the SMW Lakitu
180  bool allow_buried; // allow-burred=1 ; Allow packable under the herb
181 
182 // ; Physics
183  unsigned int height; // ; Size of NPC's body (Collision box)
184  // fixture-height=32
185  unsigned int width; // fixture-width=32
186  bool block_npc; // block-npc=1 ; NPC is a solid object for NPC's
187  bool block_npc_top; // block-npc-top=0 ; on NPC's top can be stay other NPC's
188  bool block_player; // block-player=0 ; NPC is a solid object for player
189  bool block_player_top; // block-player-top=0 ; on NPC's top can be stay player
190  bool collision_with_blocks; // collision-blocks=1 ; Enable collisions with blocks
191  bool gravity; // gravity=1 ; Enable gravitation for this NPC
192  bool adhesion; // adhesion=0 ; allows to NPC walking on wall and on celling
193 
194 // ;Events
195  bool deactivation; //deactivate=1 ; Deactivate on state offscreen > 4 sec ago
196  int deactivetionDelay;
197 
198  bool deactivate_off_room; //Decativate NPC outed of section box
199 
200  bool bump_on_stomp; // Bumps playable character on stomp attak of this NPC
201  bool kill_slide_slope; // kill-slside=1 ; Kill on Slope slide
202  bool kill_on_jump; // kill-onjump=1 ; Kill on jump on NPC's head
203  bool kill_by_npc; // kill-bynpc=1 ; Kill by contact with other NPC with hurt-npc
204  //; for example: moving SHELL have "HURT_NPC", and shell kiling ALL NPCs on contact
205  bool kill_on_pit_fall; // NPC will die on falling into pit
206 
207  bool kill_by_fireball;// kill-fireball=1 ; kill on collision with NPC, marked as "fireball"
208  bool freeze_by_iceball;// kill-iceball=1 ; freeze on collision with NPC, marked as "iceball"
209  bool kill_hammer; // kill-hammer=1 ; kill on collision with NPC, marked as "hammer" or "boomerang"
210  bool kill_tail; // kill-tail=1 ; kill on tail attack
211  bool kill_by_spinjump;// kill-spin=1 ; kill on spin jump
212  bool kill_by_statue; // kill-statue=1 ; kill on tanooki statue fall
213  bool kill_by_mounted_item; // kill-with-mounted=1 ; kill on jump with mounted items
214  bool kill_on_eat; // kill-on-eat=1 ; Kill on eat, or transform into other
215  bool turn_on_cliff_detect; // cliffturn=0 ; NPC turns on cliff
216  bool lava_protect; // lava-protection=0 ; NPC will not be burn in lava
217 
218  bool is_star; //If this marker was set, this NPC will be markered as "star"
219  //Quantity placed NPC's with marker "star" will be save in LVL-file
220 
221  bool exit_is; //This NPC is an exit
222  int exit_walk_direction; //Direction to walk offscreen (if 0 - player will don't walk
223  int exit_code; //Trigger exit code
224  int exit_delay; //Time to wait after triggering of exit
225  int exit_snd; //Custom exit sound if code more than 10
226 
227  bool climbable; //this is a climbable NPC
228 
229  //Editor defaults
230  bool default_friendly;
231  bool default_friendly_value;
232 
233  bool default_nomovable;
234  bool default_nomovable_value;
235 
236  bool default_boss;
237  bool default_boss_value;
238 
239  bool default_special;
240  long default_special_value;
241 };
242 
243 
244 
246 {
247  // ;Defines for SMBX64
248  unsigned long bubble; // bubble=283 ; NPC-Container for packed in bubble
249  unsigned long egg; // egg=96 ; NPC-Container for packed in egg
250  unsigned long lakitu; // lakitu=284 ; NPC-Container for spawn by lakitu
251  unsigned long buried; // burred=91 ; NPC-Container for packed in herb
252 
253  unsigned long ice_cube; // icecube=263 ; NPC-Container for frozen NPCs
254 
255  // ;markers
256  unsigned long iceball; // iceball=265
257  unsigned long fireball; // fireball=13
258  unsigned long hammer; // hammer=171
259  unsigned long boomerang;// boomerang=292
260  unsigned long coin_in_block; // coin-in-block=10
261 
262  // some physics settings
263  float phs_gravity_accel;
264  float phs_max_fall_speed;
265  //effects
266  unsigned long eff_lava_burn; //Lava burn effect [Effect to spawn on contact with lava]
267 
268  //projectile properties
269  SpawnEffectDef projectile_effect;
270  long projectile_sound_id;
271  float projectile_speed;
272 
273  //Talking NPC's properties
274  QString talking_sign_img;
275 };
276 
277 #endif // OBJ_NPC_H
278 
Definition: spawn_effect_def.h:8
Definition: pge_texture.h:32
Definition: size.h:23
Definition: obj_npc.h:34
Definition: obj_npc.h:245