Initial commit
This commit is contained in:
4689
engines/ultima/nuvie/script/script.cpp
Normal file
4689
engines/ultima/nuvie/script/script.cpp
Normal file
File diff suppressed because it is too large
Load Diff
197
engines/ultima/nuvie/script/script.h
Normal file
197
engines/ultima/nuvie/script/script.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_SCRIPT_SCRIPT_H
|
||||
#define NUVIE_SCRIPT_SCRIPT_H
|
||||
|
||||
#include "common/lua/lua.h"
|
||||
|
||||
#include "ultima/shared/std/string.h"
|
||||
#include "ultima/shared/std/containers.h"
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/misc/u6_misc.h"
|
||||
#include "ultima/nuvie/usecode/usecode.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class Configuration;
|
||||
class MapCoord;
|
||||
class Spell;
|
||||
class Obj;
|
||||
class Actor;
|
||||
class NuvieIO;
|
||||
class SoundManager;
|
||||
|
||||
#define NUVIE_SCRIPT_NOT_STARTED 255
|
||||
#define NUVIE_SCRIPT_ERROR 0
|
||||
#define NUVIE_SCRIPT_FINISHED 1
|
||||
#define NUVIE_SCRIPT_GET_TARGET 2
|
||||
#define NUVIE_SCRIPT_GET_DIRECTION 3
|
||||
#define NUVIE_SCRIPT_GET_INV_OBJ 4
|
||||
#define NUVIE_SCRIPT_ADVANCE_GAME_TIME 5
|
||||
#define NUVIE_SCRIPT_ADVANCE_REAL_TIME 6
|
||||
#define NUVIE_SCRIPT_TALK_TO_ACTOR 7
|
||||
#define NUVIE_SCRIPT_GET_SPELL 8
|
||||
#define NUVIE_SCRIPT_GET_OBJ 9
|
||||
#define NUVIE_SCRIPT_GET_PLAYER_OBJ 10 //can get an object immediately surrounding the player or from their inventory.
|
||||
|
||||
#define NUVIE_SCRIPT_CB_ADV_GAME_TIME 1
|
||||
|
||||
class ScriptThread {
|
||||
lua_State *L;
|
||||
int start_nargs;
|
||||
uint32 data;
|
||||
uint8 state;
|
||||
|
||||
public:
|
||||
|
||||
ScriptThread(lua_State *l, int nargs) {
|
||||
L = l;
|
||||
start_nargs = nargs;
|
||||
data = 0;
|
||||
state = NUVIE_SCRIPT_NOT_STARTED;
|
||||
}
|
||||
~ScriptThread() { }
|
||||
uint32 get_data() {
|
||||
return data;
|
||||
}
|
||||
uint8 start() {
|
||||
return resume(start_nargs);
|
||||
}
|
||||
uint8 resume_with_location(const MapCoord &loc);
|
||||
uint8 resume_with_direction(NuvieDir dir);
|
||||
uint8 resume_with_spell_num(uint8 spell_num);
|
||||
uint8 resume_with_obj(Obj *obj);
|
||||
uint8 resume_with_nil();
|
||||
uint8 resume(int narg = 0);
|
||||
bool finished() {
|
||||
return lua_status(L) != LUA_YIELD ? true : false;
|
||||
}
|
||||
int get_error() {
|
||||
return lua_status(L);
|
||||
}
|
||||
|
||||
bool is_running() {
|
||||
return !finished();
|
||||
}
|
||||
uint8 get_state() {
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
#define SCRIPT_DISPLAY_HIT_MSG true
|
||||
class Script {
|
||||
static Script *script;
|
||||
Configuration *config;
|
||||
nuvie_game_t gametype; // what game is being played?
|
||||
SoundManager *soundManager;
|
||||
lua_State *L;
|
||||
|
||||
public:
|
||||
|
||||
Script(Configuration *cfg, GUI *gui, SoundManager *sm, nuvie_game_t type);
|
||||
~Script();
|
||||
|
||||
bool init();
|
||||
|
||||
/* Return instance of self */
|
||||
static Script *get_script() {
|
||||
return script;
|
||||
}
|
||||
Configuration *get_config() {
|
||||
return config;
|
||||
}
|
||||
SoundManager *get_sound_manager() {
|
||||
return soundManager;
|
||||
}
|
||||
|
||||
bool run_script(const char *script);
|
||||
bool call_load_game(NuvieIO *objlist);
|
||||
bool call_save_game(NuvieIO *objlist);
|
||||
|
||||
bool play_cutscene(const char *script_file);
|
||||
MovementStatus call_player_before_move_action(sint16 *rel_x, sint16 *rel_y);
|
||||
bool call_player_post_move_action(bool didMove);
|
||||
bool call_player_pass();
|
||||
bool call_actor_update_all();
|
||||
bool call_actor_init(Actor *actor, ActorAlignment alignment);
|
||||
bool call_actor_attack(Actor *actor, MapCoord location, Obj *weapon, Actor *foe);
|
||||
bool call_actor_map_dmg(Actor *actor, MapCoord location);
|
||||
bool call_actor_tile_dmg(Actor *actor, uint16 tile_num);
|
||||
bool call_actor_hit(Actor *actor, uint8 dmg, bool display_hit_msg = false);
|
||||
uint8 call_actor_str_adj(Actor *actor);
|
||||
uint8 call_actor_dex_adj(Actor *actor);
|
||||
uint8 call_actor_int_adj(Actor *actor);
|
||||
bool call_look_obj(Obj *obj);
|
||||
int call_obj_get_readiable_location(Obj *obj);
|
||||
uint8 actor_get_max_magic_points(const Actor *actor);
|
||||
bool call_actor_get_obj(Actor *actor, Obj *obj, Obj *container = nullptr);
|
||||
bool call_actor_subtract_movement_points(Actor *actor, uint8 points);
|
||||
bool call_actor_resurrect(Actor *actor);
|
||||
bool call_use_keg(Obj *obj); //we need this until we move all usecode into script.
|
||||
bool call_has_usecode(Obj *obj, UseCodeEvent usecode_type);
|
||||
ScriptThread *call_use_obj(Obj *obj, Actor *actor);
|
||||
bool call_ready_obj(Obj *obj, Actor *actor);
|
||||
bool call_move_obj(Obj *obj, sint16 rel_x, sint16 rel_y);
|
||||
bool call_handle_alt_code(uint16 altcode);
|
||||
|
||||
bool call_magic_get_spell_list(Spell **spell_list);
|
||||
bool call_actor_use_effect(Obj *effect_obj, Actor *actor);
|
||||
bool call_function(const char *func_name, int num_args, int num_return, bool print_stacktrace = true) const;
|
||||
ScriptThread *call_function_in_thread(const char *function_name);
|
||||
bool run_lua_file(const char *filename);
|
||||
bool call_moonstone_set_loc(uint8 phase, MapCoord location); //this is a hack until we have 'use' moonstone in script.
|
||||
bool call_advance_time(uint16 minutes);
|
||||
bool call_can_get_obj_override(Obj *obj) const;
|
||||
bool call_out_of_ammo(Actor *attacker, Obj *weapon, bool print_message);
|
||||
bool call_is_avatar_dead();
|
||||
bool call_is_ranged_select(UseCodeType operation);
|
||||
bool call_set_g_show_stealing(bool stealing);
|
||||
uint8 call_get_combat_range(uint16 absx, uint16 absy);
|
||||
uint8 call_get_weapon_range(uint16 obj_n);
|
||||
|
||||
MapCoord call_moonstone_get_loc(uint8 phase);
|
||||
bool call_update_moongates(bool visible);
|
||||
|
||||
uint8 call_play_midgame_sequence(uint16 seq_num);
|
||||
bool call_talk_script(uint8 script_number);
|
||||
bool call_talk_to_obj(Obj *obj);
|
||||
bool call_talk_to_actor(Actor *actor);
|
||||
bool call_is_container_obj(uint16 obj_n);
|
||||
uint8 call_get_portrait_number(Actor *actor);
|
||||
bool call_player_attack();
|
||||
|
||||
uint16 call_get_tile_to_object_mapping(uint16 tile_n);
|
||||
bool call_is_tile_object(uint16 obj_n);
|
||||
|
||||
ScriptThread *new_thread(const char *scriptfile);
|
||||
ScriptThread *new_thread_from_string(const char *script);
|
||||
|
||||
protected:
|
||||
bool call_loadsave_game(const char *function, NuvieIO *objlist);
|
||||
void seed_random();
|
||||
};
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
1871
engines/ultima/nuvie/script/script_actor.cpp
Normal file
1871
engines/ultima/nuvie/script/script_actor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
36
engines/ultima/nuvie/script/script_actor.h
Normal file
36
engines/ultima/nuvie/script/script_actor.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_SCRIPT_SCRIPT_ACTOR_H
|
||||
#define NUVIE_SCRIPT_SCRIPT_ACTOR_H
|
||||
|
||||
#include "common/lua/lua.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
void nscript_init_actor(lua_State *L);
|
||||
bool nscript_new_actor_var(lua_State *L, uint16 actor_num);
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
1954
engines/ultima/nuvie/script/script_cutscene.cpp
Normal file
1954
engines/ultima/nuvie/script/script_cutscene.cpp
Normal file
File diff suppressed because it is too large
Load Diff
233
engines/ultima/nuvie/script/script_cutscene.h
Normal file
233
engines/ultima/nuvie/script/script_cutscene.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUVIE_SCRIPT_SCRIPT_CUTSCENE_H
|
||||
#define NUVIE_SCRIPT_SCRIPT_CUTSCENE_H
|
||||
|
||||
#include "common/lua/lua.h"
|
||||
|
||||
#include "ultima/nuvie/gui/gui.h"
|
||||
#include "ultima/nuvie/gui/widgets/gui_widget.h"
|
||||
#include "ultima/nuvie/files/u6_shape.h"
|
||||
#include "ultima/nuvie/fonts/wou_font.h"
|
||||
#include "ultima/nuvie/conf/configuration.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Nuvie {
|
||||
|
||||
class SoundManager;
|
||||
class Font;
|
||||
class U6LineWalker;
|
||||
class Cursor;
|
||||
|
||||
class CSImage {
|
||||
public:
|
||||
U6Shape *orig_shp;
|
||||
U6Shape *scaled_shp;
|
||||
U6Shape *shp;
|
||||
uint16 scale;
|
||||
uint16 refcount;
|
||||
|
||||
CSImage(U6Shape *shape) {
|
||||
orig_shp = shape;
|
||||
scaled_shp = nullptr;
|
||||
shp = shape;
|
||||
scale = 100;
|
||||
refcount = 0;
|
||||
}
|
||||
virtual ~CSImage() {}
|
||||
|
||||
void setScale(uint16 percentage);
|
||||
uint16 getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
virtual void updateEffect() { };
|
||||
};
|
||||
|
||||
#define STAR_FIELD_NUM_STARS 70
|
||||
|
||||
class CSStarFieldImage : public CSImage {
|
||||
|
||||
private:
|
||||
uint16 w;
|
||||
uint16 h;
|
||||
struct {
|
||||
uint8 color;
|
||||
U6LineWalker *line;
|
||||
} stars[STAR_FIELD_NUM_STARS];
|
||||
public:
|
||||
CSStarFieldImage(U6Shape *shape);
|
||||
~CSStarFieldImage() override {}
|
||||
void updateEffect() override;
|
||||
};
|
||||
|
||||
struct CSSprite {
|
||||
sint16 x;
|
||||
sint16 y;
|
||||
uint8 opacity;
|
||||
CSImage *image;
|
||||
bool visible;
|
||||
Common::Rect clip_rect;
|
||||
Std::string text;
|
||||
uint16 text_color;
|
||||
uint8 text_align;
|
||||
|
||||
CSSprite() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
opacity = 255;
|
||||
image = nullptr;
|
||||
visible = false;
|
||||
clip_rect = Common::Rect();
|
||||
text = "";
|
||||
text_color = 0xffff;
|
||||
text_align = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct CSMidGameData {
|
||||
Std::vector<Std::string> text;
|
||||
Std::vector<CSImage *> images;
|
||||
};
|
||||
|
||||
struct TransferSaveData {
|
||||
int gameType;
|
||||
Common::String name;
|
||||
int gender;
|
||||
Common::String className;
|
||||
int str;
|
||||
int dex;
|
||||
int intelligence;
|
||||
int magic;
|
||||
int exp;
|
||||
int level;
|
||||
};
|
||||
|
||||
void nscript_init_cutscene(lua_State *L, Configuration *cfg, GUI *gui, SoundManager *sm);
|
||||
|
||||
class ScriptCutscene : public GUI_Widget {
|
||||
private:
|
||||
Configuration *config;
|
||||
GUI *gui;
|
||||
Cursor *cursor;
|
||||
Std::list<CSSprite *> sprite_list; // in paint order
|
||||
Screen *screen;
|
||||
uint8 *palette;
|
||||
SoundManager *sound_manager;
|
||||
WOUFont *font;
|
||||
Common::Rect clip_rect;
|
||||
uint16 x_off, y_off;
|
||||
uint32 next_time;
|
||||
uint32 loop_interval;
|
||||
uint8 screen_opacity;
|
||||
uint8 bg_color;
|
||||
bool solid_bg;
|
||||
bool rotate_game_palette;
|
||||
|
||||
public:
|
||||
ScriptCutscene(GUI *g, Configuration *cfg, SoundManager *sm);
|
||||
~ScriptCutscene() override;
|
||||
|
||||
Std::vector<Std::string> load_text(const char *filename, uint8 idx);
|
||||
|
||||
Std::vector<CSMidGameData> load_midgame_file(const char *filename);
|
||||
|
||||
TransferSaveData load_transfer_save();
|
||||
|
||||
CSImage *load_image(const char *filename, int idx, int sub_idx = 0);
|
||||
Std::vector<Std::vector<CSImage *> > load_all_images(const char *filename);
|
||||
void add_sprite(CSSprite *s) {
|
||||
sprite_list.push_back(s);
|
||||
}
|
||||
void remove_sprite(CSSprite *s) {
|
||||
sprite_list.remove(s);
|
||||
}
|
||||
|
||||
void load_palette(const char *filename, int idx);
|
||||
void set_palette_entry(uint8 idx, uint8 r, uint8 g, uint8 b);
|
||||
void rotate_palette(uint8 idx, uint8 length);
|
||||
void set_screen_opacity(uint8 new_opacity);
|
||||
void enable_game_palette_rotation(bool val) {
|
||||
rotate_game_palette = val;
|
||||
}
|
||||
|
||||
void set_update_interval(uint16 interval);
|
||||
void update();
|
||||
|
||||
void wait();
|
||||
void Display(bool full_redraw) override;
|
||||
void Hide() override;
|
||||
|
||||
void print_text(CSImage *image, const char *string, uint16 *x, uint16 *y, uint16 startx, uint16 width, uint8 color);
|
||||
void print_text_raw(CSImage *image, const char *string, uint16 x, uint16 y, uint8 color) const;
|
||||
|
||||
SoundManager *get_sound_manager() {
|
||||
return sound_manager;
|
||||
}
|
||||
|
||||
uint16 get_x_off() const {
|
||||
return x_off;
|
||||
}
|
||||
uint16 get_y_off() const {
|
||||
return y_off;
|
||||
}
|
||||
|
||||
Font *get_font() {
|
||||
return (Font *)font;
|
||||
}
|
||||
Configuration *get_config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
void hide_sprites();
|
||||
|
||||
void set_bg_color(uint8 new_color) {
|
||||
bg_color = new_color;
|
||||
}
|
||||
void set_solid_bg(bool value) {
|
||||
solid_bg = value;
|
||||
}
|
||||
|
||||
Screen *get_screen() {
|
||||
return screen;
|
||||
}
|
||||
|
||||
uint16 get_text_width(const char *text) {
|
||||
return font->getStringWidth(text);
|
||||
}
|
||||
|
||||
private:
|
||||
bool is_lzc(const char *filename);
|
||||
CSImage *load_image_from_lzc(const Common::Path &filename, uint16 idx, uint16 sub_idx);
|
||||
void display_wrapped_text(CSSprite *s);
|
||||
int display_wrapped_text_line(Std::string str, uint8 text_color, int x, int y, uint8 align_val);
|
||||
|
||||
bool load_u4_save_file(TransferSaveData &saveData);
|
||||
bool load_u5_save_file(TransferSaveData &saveData);
|
||||
};
|
||||
|
||||
ScriptCutscene *get_cutscene();
|
||||
|
||||
} // End of namespace Nuvie
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user