mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-06-01 02:08:14 +00:00
The shield now heal the player
This commit is contained in:
+1
-1
@@ -59,6 +59,6 @@ void fireball(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void uppercut(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void water_jet(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void shield(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void ennemie_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
|
||||
void load_attacks(gc_scene *scene);
|
||||
@@ -31,6 +31,7 @@ struct combat_manager {
|
||||
enum combat_state state;
|
||||
char *last_attack;
|
||||
int last_damage;
|
||||
int last_enemy_damage;
|
||||
};
|
||||
|
||||
extern const struct combat_manager combat_manager;
|
||||
|
||||
@@ -87,16 +87,17 @@ void shield(gc_engine *engine, gc_entity *from, gc_entity *enemy)
|
||||
rend_set_anim(rend, "shield");
|
||||
}
|
||||
|
||||
void ennemie_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy)
|
||||
void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy)
|
||||
{
|
||||
struct combat_manager *this = GETSYS(engine, combat_manager);
|
||||
struct health_component *enemy_health = GETCMP(enemy, health_component);
|
||||
struct renderer *rend = GETCMP(from, renderer);
|
||||
float amount = random() % 10;
|
||||
int max = 20 - this->last_enemy_damage;
|
||||
|
||||
this->last_enemy_damage = MAX(MIN(random() % max, 10), 0);
|
||||
if (this->last_attack && !my_strcmp(this->last_attack, "shield"))
|
||||
amount *= (float)this->last_damage / 100;
|
||||
rem_health(enemy_health, engine, (int)amount);
|
||||
add_health(enemy_health, engine, 5);
|
||||
rem_health(enemy_health, engine, this->last_enemy_damage);
|
||||
if (rend)
|
||||
rend_set_anim(rend, "attack");
|
||||
}
|
||||
|
||||
+6
-6
@@ -62,12 +62,12 @@ const struct callback map_editor_callbacks[] = {
|
||||
};
|
||||
|
||||
const struct gc_data attacks[] = {
|
||||
{"attack", "Uppercut", &uppercut, NULL},
|
||||
{"attack", "Fireball", &fireball, NULL},
|
||||
{"attack", "Water jet", &water_jet, NULL},
|
||||
{"attack", "Shield", &shield, NULL},
|
||||
{"attack", "Aerial attack", &ennemie_attack, NULL},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
{"attack", "Uppercut", &uppercut, NULL},
|
||||
{"attack", "Fireball", &fireball, NULL},
|
||||
{"attack", "Water jet", &water_jet, NULL},
|
||||
{"attack", "Shield", &shield, NULL},
|
||||
{"attack", "Aerial attack", &enemy_attack, NULL},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
void load_attacks(gc_scene *scene)
|
||||
|
||||
Reference in New Issue
Block a user