Fixes working explosions and artifacts

Artifacts:
- Explosive daggers
- Explosive kills
This commit is contained in:
Linus Probert 2019-05-25 13:11:24 +02:00
parent 68f4e152d3
commit 1d988d7f2f
9 changed files with 88 additions and 39 deletions

Binary file not shown.

View File

@ -77,6 +77,9 @@ artifact_set_effect(Artifact *a, MagicalEffect effect)
a->info.name = "Stick of dynamite"; a->info.name = "Stick of dynamite";
a->info.desc = "You are an explosive slayer"; a->info.desc = "You are an explosive slayer";
break; break;
case VOLATILE_DAGGERS:
a->info.name = "Glowing dagger";
a->info.desc = "Your daggers are volatile";
default: default:
break; break;
} }
@ -92,7 +95,8 @@ static int WarriorArtifacts[] = {
INCREASED_STUN, // 6 INCREASED_STUN, // 6
DAGGER_BOUNCE, // 7 DAGGER_BOUNCE, // 7
EXPLOSIVE_KILLS, // 8 EXPLOSIVE_KILLS, // 8
CHARGE_THROUGH // 9 VOLATILE_DAGGERS, // 9
CHARGE_THROUGH // 10
}; };
static int RogueArtifacts[] = { static int RogueArtifacts[] = {
@ -105,7 +109,8 @@ static int RogueArtifacts[] = {
INCREASED_STUN, // 6 INCREASED_STUN, // 6
DAGGER_BOUNCE, // 7 DAGGER_BOUNCE, // 7
EXPLOSIVE_KILLS, // 8 EXPLOSIVE_KILLS, // 8
PHASE_IMPROVEMENT // 9 VOLATILE_DAGGERS, // 9
PHASE_IMPROVEMENT // 10
}; };
static int MageArtifacts[] = { static int MageArtifacts[] = {
@ -118,7 +123,8 @@ static int MageArtifacts[] = {
INCREASED_STUN, // 6 INCREASED_STUN, // 6
DAGGER_BOUNCE, // 7 DAGGER_BOUNCE, // 7
EXPLOSIVE_KILLS, // 8 EXPLOSIVE_KILLS, // 8
SKILL_RADIUS // 9 VOLATILE_DAGGERS, // 9
SKILL_RADIUS // 10
}; };
/* Not in play yet */ /* Not in play yet */
@ -132,7 +138,8 @@ static int PaladinArtifacts[] = {
INCREASED_STUN, // 6 INCREASED_STUN, // 6
DAGGER_BOUNCE, // 7 DAGGER_BOUNCE, // 7
EXPLOSIVE_KILLS, // 8 EXPLOSIVE_KILLS, // 8
SKILL_RADIUS // 9 VOLATILE_DAGGERS, // 9
SKILL_RADIUS // 10
}; };
/* Not in play yet */ /* Not in play yet */
@ -146,7 +153,8 @@ static int EngineerArtifacts[] = {
INCREASED_STUN, // 6 INCREASED_STUN, // 6
DAGGER_BOUNCE, // 7 DAGGER_BOUNCE, // 7
EXPLOSIVE_KILLS, // 8 EXPLOSIVE_KILLS, // 8
PHASE_IMPROVEMENT // 9 VOLATILE_DAGGERS, // 9
PHASE_IMPROVEMENT // 10
}; };
static void static void
@ -268,6 +276,11 @@ artifact_sprite_for(MagicalEffect effect)
sprite_set_texture(sprite, t, 0); sprite_set_texture(sprite, t, 0);
sprite->clip = CLIP16(32, 0); sprite->clip = CLIP16(32, 0);
break; break;
case VOLATILE_DAGGERS:
t = texturecache_add("Extras/Artifacts.png");
sprite_set_texture(sprite, t, 0);
sprite->clip = CLIP16(16, 0);
break;
default: default:
break; break;
} }

View File

@ -33,6 +33,7 @@ typedef enum MagicalEffect {
SKILL_RADIUS, SKILL_RADIUS,
DAGGER_BOUNCE, DAGGER_BOUNCE,
EXPLOSIVE_KILLS, EXPLOSIVE_KILLS,
VOLATILE_DAGGERS,
LAST_ARTIFACT_EFFECT // Sentinel LAST_ARTIFACT_EFFECT // Sentinel
} MagicalEffect; } MagicalEffect;

View File

@ -24,6 +24,7 @@
void void
effect_damage_surroundings(Position *pos, effect_damage_surroundings(Position *pos,
RoomMatrix *rm, RoomMatrix *rm,
Player *player,
Stats *attackerStats, Stats *attackerStats,
unsigned int radius, unsigned int radius,
unsigned int pushRadius, unsigned int pushRadius,
@ -48,7 +49,7 @@ effect_damage_surroundings(Position *pos,
Vector2d dir = vector2d_to_direction(&VEC2D((float) i, (float) j)); Vector2d dir = vector2d_to_direction(&VEC2D((float) i, (float) j));
for (unsigned int k = 0; k < pushRadius; ++k) { for (unsigned int k = 0; k < pushRadius; ++k) {
monster_push(r->monster, monster_push(r->monster,
roommatrix_get_player(rm), player,
rm, rm,
dir); dir);
} }

View File

@ -24,6 +24,7 @@
void void
effect_damage_surroundings(Position *pos, effect_damage_surroundings(Position *pos,
RoomMatrix *rm, RoomMatrix *rm,
Player *player,
Stats *attackerStats, Stats *attackerStats,
unsigned int radius, unsigned int radius,
unsigned int pushRadius, unsigned int pushRadius,

View File

@ -92,6 +92,7 @@ load_effects(void)
effects[KEY_PICKUP] = load_effect("Sounds/FX/key_pickup.wav"); effects[KEY_PICKUP] = load_effect("Sounds/FX/key_pickup.wav");
effects[BLINK_EFFECT] = load_effect("Sounds/FX/blink.wav"); effects[BLINK_EFFECT] = load_effect("Sounds/FX/blink.wav");
effects[BLAST_EFFECT] = load_effect("Sounds/FX/blast.wav"); effects[BLAST_EFFECT] = load_effect("Sounds/FX/blast.wav");
effects[EXPLOSION_EFFECT] = load_effect("Sounds/FX/explosion.wav");
} }
void void

View File

@ -68,6 +68,7 @@ typedef enum Fx_t {
KEY_PICKUP, KEY_PICKUP,
BLINK_EFFECT, BLINK_EFFECT,
BLAST_EFFECT, BLAST_EFFECT,
EXPLOSION_EFFECT,
LAST_EFFECT LAST_EFFECT
} Fx; } Fx;

View File

@ -37,6 +37,7 @@
#include "trap.h" #include "trap.h"
#include "gamecontroller.h" #include "gamecontroller.h"
#include "event.h" #include "event.h"
#include "effect_util.h"
#ifdef STEAM_BUILD #ifdef STEAM_BUILD
#include "steam/steamworks_api_wrapper.h" #include "steam/steamworks_api_wrapper.h"
@ -150,6 +151,17 @@ on_monster_collision(Player *player,
player->stat_data.misses += 1; player->stat_data.misses += 1;
} }
player_monster_kill_check(player, monster); player_monster_kill_check(player, monster);
if (monster->stats.hp <= 0 && (player_has_artifact(player, EXPLOSIVE_KILLS))) {
mixer_play_effect(EXPLOSION_EFFECT);
particle_engine_fire_explosion(monster->sprite->pos, DIM(32, 32));
effect_damage_surroundings(&monster->sprite->pos,
matrix,
player,
&player->stats,
player_has_artifact(player, EXPLOSIVE_KILLS),
0,
false);
}
if (monster->stats.hp > 0) { if (monster->stats.hp > 0) {
if (get_random(10) < player_has_artifact(player, PUSH_BACK)) { if (get_random(10) < player_has_artifact(player, PUSH_BACK)) {

View File

@ -28,6 +28,8 @@
#include "item_builder.h" #include "item_builder.h"
#include "random.h" #include "random.h"
#include "update_data.h" #include "update_data.h"
#include "effect_util.h"
#include "particle_engine.h"
static void static void
onDaggerRender(Sprite *s) onDaggerRender(Sprite *s)
@ -95,6 +97,22 @@ clear_processed_spaces(Projectile *p)
sizeof(p->processedSpaces[0][0]) * MAP_ROOM_WIDTH * MAP_ROOM_HEIGHT); sizeof(p->processedSpaces[0][0]) * MAP_ROOM_WIDTH * MAP_ROOM_HEIGHT);
} }
static void
perform_dagger_explosion(Player *player, RoomMatrix *rm, Position *collisionPos)
{
if (player_has_artifact(player, VOLATILE_DAGGERS)) {
mixer_play_effect(EXPLOSION_EFFECT);
particle_engine_fire_explosion(*collisionPos, DIM(32, 32));
effect_damage_surroundings(collisionPos,
rm,
player,
&player->stats,
player_has_artifact(player, VOLATILE_DAGGERS),
0,
false);
}
}
void void
projectile_update(Projectile *p, UpdateData *data) projectile_update(Projectile *p, UpdateData *data)
{ {
@ -132,6 +150,7 @@ projectile_update(Projectile *p, UpdateData *data)
if (result.dmg > 0) { if (result.dmg > 0) {
gui_log("Your dagger pierced %s for %u damage", space->monster->lclabel, result.dmg); gui_log("Your dagger pierced %s for %u damage", space->monster->lclabel, result.dmg);
data->player->stat_data.hits += 1; data->player->stat_data.hits += 1;
perform_dagger_explosion(data->player, data->matrix, &collisionPos);
} else { } else {
gui_log("%s dodged your dagger", space->monster->label); gui_log("%s dodged your dagger", space->monster->label);
} }