暫無描述

grass_animation.c 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <oe_images/oea_grass_normal.h>
  2. #include <pokeagb/pokeagb.h>
  3. struct SpriteTiles sprite_tiles_grass_normal[5] = {{.data = oea_grass_normalTiles + (0x80/4) * 0, .tag = 0, .size = 0x80},
  4. {.data = oea_grass_normalTiles + (0x80/4) * 1, .tag = 0, .size = 0x80},
  5. {.data = oea_grass_normalTiles + (0x80/4) * 2, .tag = 0, .size = 0x80},
  6. {.data = oea_grass_normalTiles + (0x80/4) * 3, .tag = 0, .size = 0x80},
  7. {.data = oea_grass_normalTiles + (0x80/4) * 4, .tag = 0, .size = 0x80}};
  8. struct Template grass_template_normal = {.tiles_tag = 0xFFFF,
  9. .pal_tag = 0x1005,
  10. .oam = &oam_data_grass,
  11. .animation = &anim_image_grass,
  12. .graphics = sprite_tiles_grass_normal,
  13. .rotscale = &rotscale_empty,
  14. .callback = oac_grass};
  15. void grass_step_general(struct NpcState *npc) {
  16. oe_state.effect_pos.x = npc->to.x;
  17. oe_state.effect_pos.y = npc->to.y;
  18. oe_state.priority = (npc->height) >> 4;
  19. oe_state.field_c = 2;
  20. oe_state.local_id_and_mapnumber = (npc->local_id << 8) | (npc->local_map_number);
  21. oe_state.local_mapbank = npc->local_map_bank;
  22. oe_state.sav1_location = (((saveblock1->location.map) << 8) | saveblock1->location.bank);
  23. oe_state.field_1c = 1;
  24. (void)oe_exec(4);
  25. }
  26. void grass_step_elastic(struct NpcState *npc) {
  27. oe_state.effect_pos.x = npc->to.x;
  28. oe_state.effect_pos.y = npc->to.y;
  29. oe_state.priority = (npc->height) >> 4;
  30. oe_state.field_c = 2;
  31. oe_state.local_id_and_mapnumber = (npc->local_id << 8) | (npc->local_map_number);
  32. oe_state.local_mapbank = npc->local_map_bank;
  33. oe_state.sav1_location = (((saveblock1->location.map) << 8) | saveblock1->location.bank);
  34. oe_state.field_1c = 0;
  35. /* use variable to determine the oe animation to play */
  36. (void)oe_exec(4);
  37. }
  38. void oei_grass_normal(void) {
  39. s16 x = (s16)oe_state.effect_pos.x;
  40. s16 y = (s16)oe_state.effect_pos.y;
  41. oe_adjust_coordinates(&x, &y, 8, 8);
  42. u8 objid = template_instanciate_reverse_search(&grass_template_normal, x, y, 0);
  43. if (objid != 64) {
  44. struct Object *obj = &objects[objid];
  45. obj->bitfield2 |= 2;
  46. obj->final_oam.priority = oe_state.field_c & 3;
  47. obj->priv[0] = oe_state.priority;
  48. obj->priv[1] = oe_state.effect_pos.x;
  49. obj->priv[2] = oe_state.effect_pos.y;
  50. obj->priv[3] = oe_state.local_id_and_mapnumber;
  51. obj->priv[4] = oe_state.local_mapbank;
  52. obj->priv[5] = oe_state.sav1_location;
  53. if (oe_state.field_1c)
  54. obj_anim_image_seek(obj, 4);
  55. }
  56. }