taisei/src/player.h

238 lines
6 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
2019-07-03 20:00:56 +02:00
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#ifndef IGUARD_player_h
#define IGUARD_player_h
#include "taisei.h"
2017-03-06 13:02:46 +01:00
#ifdef DEBUG
#define PLR_DPS_STATS
#endif
#include "util.h"
#include "enemy.h"
2012-08-15 16:36:39 +02:00
#include "gamepad.h"
2017-10-03 17:25:38 +02:00
#include "aniplayer.h"
#include "resource/animation.h"
#include "entity.h"
enum {
PLR_MAX_POWER = 400,
PLR_MAX_POWER_OVERFLOW = 200,
Lots of disorganized (mostly) visual overhaul (#156) * WIP some projectile effects * fix segfault * Laser smoothing and glow via post-processing blur magic TODO: make it optional * fix memory corruption * fix memory corruption for realsies now * fix color_get_hsl for out-of-range colors * some more bullet flare tweaks * some lame clear effect workarounds * spawn bullet flares after frame 0; looks better and fixes some problems * New baryon explosion; fix petal_explosion; leanify everything * Add missing bullet flare sprite, rebuild main atlas * improve batching efficiency with bullet spawn flares * forgot git add * Group projectiles/particles by shader where possible * Another take on baryon explosion; make fg framebuffers 16bit * WIP some settings for toasters * remove stupid debug log * microoptimization that probably does nothing anyway * somewhat more intuitive quality settings * Whitelist more particles (MarisaB is on hold) * Whitelist (and fix) some more stage6 particles (mostly ToE) * Add a spell name background * Experimental radial healthbar for bosses * healthbar tweaks * thiccer healthbars in response to feedback * remove healthbar survival timer; just fade out on survivals * Add linear healthbars option; WIP other boss HUD tweaks * Use the proper spell card name format * New font and some random garbage to go along with it * Generate static font outlines for use in text shaders * Use outlines in overlay text shader * Complete boss HUD/healthbar fading logic * fix boss timer limit * stage5 bombs explosion effect * split PFLAG_NOSPAWNZOOM into PFLAG_NOSPAWNFLARE and PFLAG_NOSPAWNFADE; introduce PFLAG_NOSPAWNEFFECTS which disables both (it's just the two values OR'd together) simplify vampiric vapor bullet spawning effect * Remove spawn fade-in from super-fast stage5 fairy projectiles (limiters) * lower particle density in v.vapor in minimal mode * graze effect tweaks * fix text shortening, tweak replay menu layout * stupid debug spam * revisit grazing effects again * dumb debug spam again * improve boss attack timer * overlay effect for boss deaths (similar to the player one) * spice up spellcard declaration (HUD) * don't spawn boss death overlay if fleed * modify Exo2 font to use tabular figures * adjust replay menu for the font change * draw timer & power with standard font (phasing out the numbers font) * WIP new HUD; random fixes/tweaks * hud: move difficulty indicator * hud: move debug stuff around * preloads, mostly * fix youmuA batching conflict * shitty workaround for the shitty screenshake shit * remove extraspell lag by stopping to draw stagebg sooner which is possible because extra spells have a different spellcard_intro timing. Fun fact of the day: the duration of spellcard_intro is always ATTACK_START_DELAY_EXTRA even for normal spells! * new stain particle * i disabled background rendering… * "batch" marisa_b masterspark draws * remove these once a new atlas is generated * make toe quick again * hopefully fix all occurences of changed stain and ScaleFade behavior * tweaking reimu_a and toe boson launch effects * make lhc fast again * softer involnerability effect * fix stage 1 snow on the water bug (and improve performance) translated the time to the future a bit because it only seemed to be an issue for small time values * remove unnecessary spawnflare from toe * tone down extra spell start effect * experimental ReimuB gap shader optimization * fix python3 shebangs * generate simple blur shaders w/ hardcoded kernels * New loading screen * lasers: fix incorrect draw hook registration * add webp support for atlas generator * Use ImageMagick for atlas composition (adds 16-bit support) * Atlas maintenance * make the vampiric vapor bullets less prone to invisibility * Revert a few particles to the quadratic fade curve * experimental baryon effect * improve baryon sprites * disable the baryon effect on minimal postprocessing setting
2019-01-04 23:59:39 +01:00
PLR_MAX_LIVES = 8,
PLR_MAX_BOMBS = 8,
// -Wpedantic doesn't like this
// PLR_MAX_PIV = UINT32_MAX,
#define PLR_MAX_PIV UINT32_MAX
#define PLR_MAX_GRAZE UINT32_MAX
#define PLR_MAX_VOLTAGE UINT16_MAX
PLR_MAX_LIFE_FRAGMENTS = 5,
PLR_MAX_BOMB_FRAGMENTS = 500,
PLR_START_LIVES = 2,
PLR_START_BOMBS = 3,
PLR_START_PIV = 10000,
2017-04-08 01:09:08 +02:00
PLR_STGPRACTICE_LIVES = PLR_MAX_LIVES,
PLR_STGPRACTICE_BOMBS = PLR_START_BOMBS,
PLR_MIN_BORDER_DIST = 16,
PLR_POWERSURGE_POWERCOST = 200,
PLR_RESPAWN_TIME = 60,
};
#define PLR_SPAWN_POS_X (VIEWPORT_W * 0.5)
#define PLR_SPAWN_POS_Y (VIEWPORT_H - 64.0)
#define PLR_SPAWN_POS CMPLX(PLR_SPAWN_POS_X, PLR_SPAWN_POS_Y)
static const float PLR_POWERSURGE_POSITIVE_DRAIN_MAX = (0.15 / 60.0);
static const float PLR_POWERSURGE_POSITIVE_DRAIN_MIN = (0.15 / 60.0);
static const float PLR_POWERSURGE_NEGATIVE_DRAIN_MAX = (0.15 / 60.0);
static const float PLR_POWERSURGE_NEGATIVE_DRAIN_MIN = (0.01 / 60.0);
static const float PLR_POWERSURGE_POSITIVE_GAIN = (1.50 / 60.0);
static const float PLR_POWERSURGE_NEGATIVE_GAIN = (0.40 / 60.0);
typedef enum {
// do not reorder these or you'll break replays
INFLAG_UP = 1,
INFLAG_DOWN = 2,
INFLAG_LEFT = 4,
INFLAG_RIGHT = 8,
INFLAG_FOCUS = 16,
INFLAG_SHOT = 32,
INFLAG_SKIP = 64,
} PlrInputFlag;
enum {
INFLAGS_MOVE = INFLAG_UP | INFLAG_DOWN | INFLAG_LEFT | INFLAG_RIGHT
};
typedef struct Player Player;
typedef struct PowerSurgeBonus {
uint baseline;
uint score;
uint gain_rate;
float discharge_power;
float discharge_range;
float discharge_damage;
} PowerSurgeBonus;
struct Player {
ENTITY_INTERFACE_NAMED(Player, ent);
complex pos;
complex velocity;
complex deathpos;
complex lastmovedir;
struct PlayerMode *mode;
AniPlayer ani;
EnemyList slaves;
EnemyList focus_circle;
struct {
float positive;
float negative;
struct {
int activated, expired;
} time;
int power;
double damage_done;
double damage_accum;
PowerSurgeBonus bonus;
} powersurge;
uint64_t points;
uint64_t extralife_threshold;
uint extralives_given;
uint point_item_value;
uint graze;
uint voltage;
int lives;
int bombs;
int life_fragments;
int bomb_fragments;
int continues_used;
int focus;
int power;
int power_overflow;
int continuetime;
int recovery;
int deathtime;
int respawntime;
int bombtotaltime;
int inputflags;
int lastmovesequence; // used for animation
2012-08-15 16:36:39 +02:00
int axis_ud;
int axis_lr;
float bomb_cutin_alpha;
bool gamepadmove;
bool iddqd;
2017-03-06 13:02:46 +01:00
#ifdef PLR_DPS_STATS
int dmglogframe;
int dmglog[240];
2017-03-06 13:02:46 +01:00
#endif
};
// this is used by both player and replay code
enum {
EV_PRESS,
EV_RELEASE,
EV_OVER, // replay-only
EV_AXIS_LR,
EV_AXIS_UD,
EV_CHECK_DESYNC, // replay-only
EV_FPS, // replay-only
EV_INFLAGS,
EV_CONTINUE,
};
// This is called first before we even enter stage_loop.
// It's also called right before syncing player state from a replay stage struct, if a replay is being watched or recorded, before every stage.
// The entire state is reset here, and defaults for story mode are set.
void player_init(Player *plr);
// This is called early in stage_loop, before creating or reading replay stage data.
// State that is not supposed to be preserved between stages is reset here, and any plrmode-specific resources are preloaded.
void player_stage_pre_init(Player *plr);
// This is called right after the stage's begin proc. After that, the actual game loop starts.
void player_stage_post_init(Player *plr);
// Yes, that's 3 different initialization functions right here.
2017-11-25 16:51:43 +01:00
void player_free(Player *plr);
void player_draw_overlay(Player *plr);
void player_logic(Player *plr);
bool player_should_shoot(Player *plr, bool extra);
2017-10-24 04:57:14 +02:00
bool player_set_power(Player *plr, short npow);
bool player_add_power(Player *plr, short pdelta);
2012-07-20 16:11:24 +02:00
void player_move(Player*, complex delta);
2011-07-05 15:20:19 +02:00
2012-07-20 16:11:24 +02:00
void player_realdeath(Player*);
void player_death(Player*);
Lots of disorganized (mostly) visual overhaul (#156) * WIP some projectile effects * fix segfault * Laser smoothing and glow via post-processing blur magic TODO: make it optional * fix memory corruption * fix memory corruption for realsies now * fix color_get_hsl for out-of-range colors * some more bullet flare tweaks * some lame clear effect workarounds * spawn bullet flares after frame 0; looks better and fixes some problems * New baryon explosion; fix petal_explosion; leanify everything * Add missing bullet flare sprite, rebuild main atlas * improve batching efficiency with bullet spawn flares * forgot git add * Group projectiles/particles by shader where possible * Another take on baryon explosion; make fg framebuffers 16bit * WIP some settings for toasters * remove stupid debug log * microoptimization that probably does nothing anyway * somewhat more intuitive quality settings * Whitelist more particles (MarisaB is on hold) * Whitelist (and fix) some more stage6 particles (mostly ToE) * Add a spell name background * Experimental radial healthbar for bosses * healthbar tweaks * thiccer healthbars in response to feedback * remove healthbar survival timer; just fade out on survivals * Add linear healthbars option; WIP other boss HUD tweaks * Use the proper spell card name format * New font and some random garbage to go along with it * Generate static font outlines for use in text shaders * Use outlines in overlay text shader * Complete boss HUD/healthbar fading logic * fix boss timer limit * stage5 bombs explosion effect * split PFLAG_NOSPAWNZOOM into PFLAG_NOSPAWNFLARE and PFLAG_NOSPAWNFADE; introduce PFLAG_NOSPAWNEFFECTS which disables both (it's just the two values OR'd together) simplify vampiric vapor bullet spawning effect * Remove spawn fade-in from super-fast stage5 fairy projectiles (limiters) * lower particle density in v.vapor in minimal mode * graze effect tweaks * fix text shortening, tweak replay menu layout * stupid debug spam * revisit grazing effects again * dumb debug spam again * improve boss attack timer * overlay effect for boss deaths (similar to the player one) * spice up spellcard declaration (HUD) * don't spawn boss death overlay if fleed * modify Exo2 font to use tabular figures * adjust replay menu for the font change * draw timer & power with standard font (phasing out the numbers font) * WIP new HUD; random fixes/tweaks * hud: move difficulty indicator * hud: move debug stuff around * preloads, mostly * fix youmuA batching conflict * shitty workaround for the shitty screenshake shit * remove extraspell lag by stopping to draw stagebg sooner which is possible because extra spells have a different spellcard_intro timing. Fun fact of the day: the duration of spellcard_intro is always ATTACK_START_DELAY_EXTRA even for normal spells! * new stain particle * i disabled background rendering… * "batch" marisa_b masterspark draws * remove these once a new atlas is generated * make toe quick again * hopefully fix all occurences of changed stain and ScaleFade behavior * tweaking reimu_a and toe boson launch effects * make lhc fast again * softer involnerability effect * fix stage 1 snow on the water bug (and improve performance) translated the time to the future a bit because it only seemed to be an issue for small time values * remove unnecessary spawnflare from toe * tone down extra spell start effect * experimental ReimuB gap shader optimization * fix python3 shebangs * generate simple blur shaders w/ hardcoded kernels * New loading screen * lasers: fix incorrect draw hook registration * add webp support for atlas generator * Use ImageMagick for atlas composition (adds 16-bit support) * Atlas maintenance * make the vampiric vapor bullets less prone to invisibility * Revert a few particles to the quadratic fade curve * experimental baryon effect * improve baryon sprites * disable the baryon effect on minimal postprocessing setting
2019-01-04 23:59:39 +01:00
void player_graze(Player *plr, complex pos, int pts, int effect_intensity, const Color *color);
2017-10-31 10:48:30 +01:00
void player_event(Player *plr, uint8_t type, uint16_t value, bool *out_useful, bool *out_cheat);
bool player_event_with_replay(Player *plr, uint8_t type, uint16_t value);
void player_applymovement(Player* plr);
void player_fix_input(Player *plr);
void player_add_life_fragments(Player *plr, int frags);
void player_add_bomb_fragments(Player *plr, int frags);
void player_add_lives(Player *plr, int lives);
void player_add_bombs(Player *plr, int bombs);
2019-04-07 00:55:13 +02:00
void player_add_points(Player *plr, uint points, complex location);
void player_add_piv(Player *plr, uint piv, complex location);
void player_add_voltage(Player *plr, uint voltage);
bool player_drain_voltage(Player *plr, uint voltage);
void player_extend_powersurge(Player *plr, float pos, float neg);
2018-07-30 09:04:09 +02:00
void player_register_damage(Player *plr, EntityInterface *target, const DamageInfo *damage);
void player_cancel_powersurge(Player *plr);
void player_placeholder_bomb_logic(Player *plr);
2017-11-26 14:06:35 +01:00
bool player_is_bomb_active(Player *plr);
bool player_is_powersurge_active(Player *plr);
bool player_is_vulnerable(Player *plr);
bool player_is_alive(Player *plr);
void player_powersurge_calc_bonus(Player *plr, PowerSurgeBonus *bonus);
uint64_t player_next_extralife_threshold(uint64_t step);
2017-11-26 14:06:35 +01:00
// Progress is normalized from 0: bomb start to 1: bomb end
double player_get_bomb_progress(Player *plr);
void player_damage_hook(Player *plr, EntityInterface *target, DamageInfo *dmg);
void player_preload(void);
Add Reimu Hakurei as a playable character (#106) * Reimu (#101) * add the reimu * Add Reimu story * account for various blunders * add reimu dialog picture * Reimu: WIP yin-yang orbs * reimu: fix up indents * Reimu: swap the shotmode names to match the kanji order in her Japanese name * Reimu: compatibility with the latest system * WIP ReimuA crap * ReimuA homing trails * more ReimuA stuff * more ReimuA adjustments + enhanced DPS stats * Reimu: stubs for new player animation sequences * Reimu: occupy the 0th character slot * Reimu: tweak needle sprite * Reimu: buff movement speed to better match Touhou * Reimu: fixup for the recent projectile changes * ReimuA: make homing shots a bit smaller; give them custom effect on collision * Reimu: add intermediate frames; move some loose sprites to the atlas * Reimu: fix compile errors * replace DBL_MAX by INFINITY * Don’t draw reimu orbs twice fixes #127 * add new reimu dialog pic * ReimuA adjustments (mostly homing); it's still OP * wip ReimuB gaps * still not sure where i'm going with these gaps * meh * Reimu: premultiplied alpha fixups after rebase * reimuB shot pattern with basic power scaling (not balanced at all) * reimuB: some lame-ass particle effects * ReimuB bomb effect prototype * reimuA bomb prototype * fix reimu shots for the new damage system * Reimu: use the new player_is_bomb_active() function, add placeholder BG for ReimuB * some reimuB bomb projectiles * ReimuB bomb bg and some framebuffer utils required to support it. Might reuse this at least in part for ReimuA unless we come up with something better. * hack to fix ReimuB bomb fade; refactoring needed * reimuA damaging bombs * fix ub * prevent nan when reimuA bombs without enemies present * add a bomb_bg to reimuA * ... * various fantasy seal tweaks * Reimu: placeholder bomb sounds; slight fantasy seal buff * fix null pointer dereference * Reimu "balance" adjustments; minor fixes * putting bandaids over gunshot wounds * Add aoe damage and bullet cancel to ReimuB's bomb * more exorcism porn * make reimu bomb bg runes better visible on dark backgrounds * More ReimuA shot changes
2018-08-11 21:13:48 +02:00
// FIXME: where should this be?
complex plrutil_homing_target(complex org, complex fallback);
#endif // IGUARD_player_h