Fixes returning daggers and resets erupt attack

This commit is contained in:
Linus Probert 2019-05-20 15:37:25 +02:00
parent 7f232beb32
commit 68f4e152d3
4 changed files with 48 additions and 18 deletions

View File

@ -50,8 +50,7 @@ effect_damage_surroundings(Position *pos,
monster_push(r->monster, monster_push(r->monster,
roommatrix_get_player(rm), roommatrix_get_player(rm),
rm, rm,
dir dir);
);
} }
} else if (r->player && damagePlayer) { } else if (r->player && damagePlayer) {
CombatResult result = stats_fight(attackerStats, &r->player->stats); CombatResult result = stats_fight(attackerStats, &r->player->stats);

View File

@ -87,6 +87,14 @@ get_projectile_pos_for(Projectile *p)
return projectilePos; return projectilePos;
} }
static void
clear_processed_spaces(Projectile *p)
{
memset(&p->processedSpaces,
false,
sizeof(p->processedSpaces[0][0]) * MAP_ROOM_WIDTH * MAP_ROOM_HEIGHT);
}
void void
projectile_update(Projectile *p, UpdateData *data) projectile_update(Projectile *p, UpdateData *data)
{ {
@ -134,7 +142,8 @@ projectile_update(Projectile *p, UpdateData *data)
} else { } else {
p->bounceCount += 1; p->bounceCount += 1;
vector2d_reverse(&p->velocity); vector2d_reverse(&p->velocity);
alive = p->bounceCount < player_has_artifact(data->player, DAGGER_BOUNCE); clear_processed_spaces(p);
alive = p->bounceCount <= player_has_artifact(data->player, DAGGER_BOUNCE);
} }
mixer_play_effect(SWORD_HIT); mixer_play_effect(SWORD_HIT);

View File

@ -15,9 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#ifndef ROOMMATRIX_H_
#define ROOMMATRIX_H_
#include <stdbool.h> #include <stdbool.h>
#include "defines.h" #include "defines.h"
@ -87,6 +85,9 @@ roommatrix_render_lightmap(RoomMatrix*, Camera*);
RoomSpace* RoomSpace*
roommatrix_get_space_for(RoomMatrix*, const Position *p); roommatrix_get_space_for(RoomMatrix*, const Position *p);
Player *
roommatrix_get_player(RoomMatrix*);
#ifdef DEBUG #ifdef DEBUG
void void
roommatrix_render_debug(RoomMatrix*, Camera*); roommatrix_render_debug(RoomMatrix*, Camera*);
@ -94,8 +95,3 @@ roommatrix_render_debug(RoomMatrix*, Camera*);
void void
roommatrix_destroy(RoomMatrix*); roommatrix_destroy(RoomMatrix*);
Player *
roommatrix_get_player(RoomMatrix*);
#endif // ROOMMATRIX_H_

View File

@ -954,13 +954,39 @@ skill_erupt(Skill *skill, SkillData *data)
particle_engine_eldritch_explosion(player->sprite->pos, DIM(32, 32)); particle_engine_eldritch_explosion(player->sprite->pos, DIM(32, 32));
mixer_play_effect(BLAST_EFFECT); mixer_play_effect(BLAST_EFFECT);
int range = 1 + player_has_artifact(player, SKILL_RADIUS); Position playerMPos = position_to_matrix_coords(&player->sprite->pos);
effect_damage_surroundings(&player->sprite->pos, int range = player_has_artifact(player, SKILL_RADIUS);
rm, for (Sint32 i = -1 - range; i <= 1 + range; ++i) {
&player->stats, for (Sint32 j = -1 - range; j <= 1 + range; ++j) {
range,
1 + player_has_artifact(player, PUSH_BACK), if (i == 0 && j == 0)
false); continue;
Position matrixPos = POS(playerMPos.x + i, playerMPos.y + j);
if (!position_in_roommatrix(&matrixPos))
continue;
RoomSpace *r = &rm->spaces[matrixPos.x][matrixPos.y];
if (r->monster) {
player->stats.advantage = true;
CombatResult result = stats_fight(&player->stats, &r->monster->stats);
player->stats.advantage = false;
monster_hit(r->monster, result.dmg, result.critical);
gui_log("%s takes %d damage from the explosion", r->monster->label, result.dmg);
monster_set_state(r->monster, SCARED, 3);
int lvl = 1 + player_has_artifact(player, PUSH_BACK);
Vector2d dir = vector2d_to_direction(&VEC2D((float) i, (float) j));
for (int k = 0; k < lvl; ++k) {
if (r->monster->stats.hp > 0)
monster_push(r->monster,
player,
rm,
dir);
}
}
}
}
return true; return true;
} }