taisei/src/plrmodes.c

139 lines
3.3 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
2024-05-16 23:30:41 +02:00
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "plrmodes.h"
#include "plrmodes/reimu.h"
#include "plrmodes/marisa.h"
#include "plrmodes/youmu.h"
#include "portrait.h"
static PlayerCharacter *player_characters[] = {
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
&character_reimu,
&character_marisa,
&character_youmu,
};
static PlayerMode *player_modes[] = {
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
&plrmode_reimu_a,
&plrmode_reimu_b,
&plrmode_marisa_a,
&plrmode_marisa_b,
&plrmode_youmu_a,
&plrmode_youmu_b,
};
PlayerCharacter *plrchar_get(CharacterID id) {
assert((unsigned)id < NUM_CHARACTERS);
PlayerCharacter *pc = player_characters[id];
assert(pc->id == id);
return pc;
2011-07-05 15:20:19 +02:00
}
void plrchar_preload(PlayerCharacter *pc, ResourceGroup *rg) {
const char *name = pc->lower_name;
portrait_preload_base_sprite(rg, name, NULL, RESF_DEFAULT);
portrait_preload_face_sprite(rg, name, "normal", RESF_DEFAULT);
char buf[64];
plrchar_player_anim_name(pc, sizeof(buf), buf);
res_group_preload(rg, RES_ANIM, RESF_DEFAULT, buf, NULL);
}
void plrchar_render_bomb_portrait(PlayerCharacter *pc, Sprite *out_spr) {
const char *name = pc->lower_name;
Sprite *s_base = portrait_get_base_sprite(name, NULL);
Sprite *s_face = portrait_get_face_sprite(name, "normal");
portrait_render(s_base, s_face, out_spr);
}
int plrchar_player_anim_name(PlayerCharacter *pc, size_t bufsize, char buf[bufsize]) {
const char *name = pc->lower_name;
assert(bufsize >= strlen("player/") + strlen(name) + 1);
return snprintf(buf, bufsize, "player/%s", name);
}
Animation *plrchar_player_anim(PlayerCharacter *pc) {
char buf[64];
plrchar_player_anim_name(pc, sizeof(buf), buf);
return res_anim(buf);
}
int plrmode_repr(char *out, size_t outsize, PlayerMode *mode, bool internal) {
assert(mode->character != NULL);
assert((unsigned)mode->shot_mode < NUM_SHOT_MODES_PER_CHARACTER);
return snprintf(out, outsize, "%s%c",
internal ? mode->character->lower_name : mode->character->proper_name,
mode->shot_mode + 'A'
);
}
PlayerMode *plrmode_find(CharacterID char_id, ShotModeID shot_id) {
for(int i = 0; i < NUM_PLAYER_MODES; ++i) {
PlayerMode *mode = player_modes[i];
if(mode->character->id == char_id && mode->shot_mode == shot_id) {
return mode;
}
2017-03-30 17:11:21 +02:00
}
return NULL;
2011-11-01 21:20:40 +01:00
}
PlayerMode *plrmode_parse(const char *name) {
CharacterID char_id = (CharacterID)-1;
ShotModeID shot_id = (ShotModeID)-1;
char buf[strlen(name) + 1];
strcpy(buf, name);
2011-11-01 21:20:40 +01:00
for(int i = 0; i < sizeof(buf); ++i) {
buf[i] = tolower(buf[i]);
}
if(!*buf) {
log_debug("Got an empty string");
return NULL;
}
2011-07-05 15:20:19 +02:00
char shot = buf[sizeof(buf) - 2];
if(shot < 'a' || shot >= 'a' + NUM_SHOT_MODES_PER_CHARACTER) {
log_debug("Got invalid shotmode: %c", shot);
return NULL;
}
shot_id = shot - 'a';
buf[sizeof(buf) - 2] = 0;
for(int i = 0; i < NUM_CHARACTERS; ++i) {
PlayerCharacter *chr = player_characters[i];
if(!strcmp(buf, chr->lower_name)) {
char_id = chr->id;
2011-07-05 15:20:19 +02:00
}
}
if(char_id == (CharacterID)-1) {
log_debug("Got invalid character: %s", buf);
return NULL;
}
return plrmode_find(char_id, shot_id);
2017-04-02 10:16:52 +02:00
}
void plrmode_preload(PlayerMode *mode, ResourceGroup *rg) {
assert(mode != NULL);
plrchar_preload(mode->character, rg);
if(mode->procs.preload) {
mode->procs.preload(rg);
}
}