96 lines
2.6 KiB
C
96 lines
2.6 KiB
C
#include "item.h"
|
|
#include "aoe.h"
|
|
#include "comp/fighter.h"
|
|
#include "comp/physical.h"
|
|
#include "comp/visible.h"
|
|
#include <gint/defs/util.h>
|
|
|
|
entity_t *item_make(int type, vec2 position)
|
|
{
|
|
entity_t *e = aoe_make(AOE_ITEM, position, fix(9999.0));
|
|
|
|
visible_t *v = getcomp(e, visible);
|
|
v->sprite_plane = VERTICAL;
|
|
v->shadow_size = 3;
|
|
v->z = fix(0.35);
|
|
|
|
physical_t *p = getcomp(e, physical);
|
|
p->hitbox = (rect){ -fix(4)/16, fix(3)/16, -fix(2)/16, fix(1)/16 };
|
|
|
|
aoe_t *aoe = getcomp(e, aoe);
|
|
aoe->origin = NULL;
|
|
aoe->repeat_delay = 0;
|
|
aoe->data.item.type = type;
|
|
|
|
if(type == ITEM_LIFE) {
|
|
visible_set_anim(e, &anims_item_life, 1);
|
|
}
|
|
else if(type == ITEM_POTION_ATK) {
|
|
visible_set_anim(e, &anims_item_potion_atk, 1);
|
|
}
|
|
else if(type == ITEM_POTION_COOLDOWN) {
|
|
visible_set_anim(e, &anims_item_potion_cooldown, 1);
|
|
}
|
|
else if(type == ITEM_POTION_DEF) {
|
|
visible_set_anim(e, &anims_item_potion_def, 1);
|
|
}
|
|
else if(type == ITEM_POTION_FRZ) {
|
|
visible_set_anim(e, &anims_item_potion_frz, 1);
|
|
}
|
|
else if(type == ITEM_POTION_HP) {
|
|
visible_set_anim(e, &anims_item_potion_hp, 1);
|
|
}
|
|
else if(type == ITEM_POTION_SPD) {
|
|
visible_set_anim(e, &anims_item_potion_spd, 1);
|
|
}
|
|
else if(type == ITEM_SCEPTER1) {
|
|
visible_set_anim(e, &anims_item_stick1, 1);
|
|
}
|
|
else if(type == ITEM_SCEPTER2) {
|
|
visible_set_anim(e, &anims_item_stick2, 1);
|
|
}
|
|
else if(type == ITEM_SWORD1) {
|
|
visible_set_anim(e, &anims_item_sword1, 1);
|
|
}
|
|
else if(type == ITEM_SWORD2) {
|
|
visible_set_anim(e, &anims_item_sword2, 1);
|
|
}
|
|
|
|
return e;
|
|
}
|
|
|
|
void item_pick_up(int type, entity_t *player)
|
|
{
|
|
fighter_t *f = getcomp(player, fighter);
|
|
|
|
if(type == ITEM_LIFE && f) {
|
|
int added = max(f->HP_max / 2, 8);
|
|
f->HP_max += added;
|
|
f->HP += added;
|
|
}
|
|
else if(type == ITEM_POTION_ATK && f) {
|
|
/* TODO: Double attack for 10 seconds */
|
|
}
|
|
else if(type == ITEM_POTION_COOLDOWN && f) {
|
|
/* TODO: Restore all cooldowns */
|
|
}
|
|
else if(type == ITEM_POTION_DEF && f) {
|
|
/* TODO: Defense +50% for 10 seconds */
|
|
}
|
|
else if(type == ITEM_POTION_FRZ && f) {
|
|
/* TODO: Freeze all monsters for 5 seconds */
|
|
}
|
|
else if(type == ITEM_POTION_HP && f) {
|
|
int restored = max(f->HP_max / 2, 8);
|
|
f->HP = min(f->HP + restored, f->HP_max);
|
|
}
|
|
else if(type == ITEM_POTION_SPD && f) {
|
|
/* TODO: Speed +50% for 10 seconds */
|
|
}
|
|
|
|
else if(type >= ITEM_EQUIPMENT_START && type < ITEM_EQUIPMENT_END
|
|
&& f->player) {
|
|
/* TODO: Give item to player */
|
|
}
|
|
}
|