No Description

event.cpp 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. #include "event.h"
  2. QString EventType::Object = "event_object";
  3. QString EventType::Warp = "event_warp";
  4. QString EventType::CoordScript = "event_trap";
  5. QString EventType::CoordWeather = "event_trap_weather";
  6. QString EventType::Sign = "event_sign";
  7. QString EventType::HiddenItem = "event_hidden_item";
  8. QString EventType::SecretBase = "event_secret_base";
  9. Event::Event()
  10. {
  11. }
  12. Event* Event::createNewEvent(QString event_type, QString map_name)
  13. {
  14. Event *event;
  15. if (event_type == EventType::Object) {
  16. event = createNewObjectEvent();
  17. } else if (event_type == EventType::Warp) {
  18. event = createNewWarpEvent(map_name);
  19. } else if (event_type == EventType::CoordScript) {
  20. event = createNewCoordScriptEvent();
  21. } else if (event_type == EventType::CoordWeather) {
  22. event = createNewCoordWeatherEvent();
  23. } else if (event_type == EventType::Sign) {
  24. event = createNewSignEvent();
  25. } else if (event_type == EventType::HiddenItem) {
  26. event = createNewHiddenItemEvent();
  27. } else if (event_type == EventType::SecretBase) {
  28. event = createNewSecretBaseEvent();
  29. }
  30. event->setX(0);
  31. event->setY(0);
  32. event->put("elevation", 3);
  33. return event;
  34. }
  35. Event* Event::createNewObjectEvent()
  36. {
  37. Event *event = new Event;
  38. event->put("event_group_type", "object_event_group");
  39. event->put("event_type", EventType::Object);
  40. event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
  41. event->put("movement_type", "1");
  42. event->put("radius_x", 0);
  43. event->put("radius_y", 0);
  44. event->put("script_label", "NULL");
  45. event->put("event_flag", "0");
  46. event->put("replacement", "0");
  47. event->put("trainer_see_type", "0");
  48. event->put("sight_radius_tree_id", 0);
  49. return event;
  50. }
  51. Event* Event::createNewWarpEvent(QString map_name)
  52. {
  53. Event *event = new Event;
  54. event->put("event_group_type", "warp_event_group");
  55. event->put("event_type", EventType::Warp);
  56. event->put("destination_warp", 0);
  57. event->put("destination_map_name", map_name);
  58. return event;
  59. }
  60. Event* Event::createNewCoordScriptEvent()
  61. {
  62. Event *event = new Event;
  63. event->put("event_group_type", "coord_event_group");
  64. event->put("event_type", EventType::CoordScript);
  65. event->put("script_label", "NULL");
  66. event->put("script_var", "VAR_TEMP_0");
  67. event->put("script_var_value", "0");
  68. return event;
  69. }
  70. Event* Event::createNewCoordWeatherEvent()
  71. {
  72. Event *event = new Event;
  73. event->put("event_group_type", "coord_event_group");
  74. event->put("event_type", EventType::CoordWeather);
  75. event->put("weather", "COORD_EVENT_WEATHER_SUNNY");
  76. return event;
  77. }
  78. Event* Event::createNewSignEvent()
  79. {
  80. Event *event = new Event;
  81. event->put("event_group_type", "bg_event_group");
  82. event->put("event_type", EventType::Sign);
  83. event->put("player_facing_direction", "0");
  84. event->put("script_label", "NULL");
  85. return event;
  86. }
  87. Event* Event::createNewHiddenItemEvent()
  88. {
  89. Event *event = new Event;
  90. event->put("event_group_type", "bg_event_group");
  91. event->put("event_type", EventType::HiddenItem);
  92. event->put("item", "ITEM_POTION");
  93. event->put("flag", "FLAG_HIDDEN_ITEM_0");
  94. return event;
  95. }
  96. Event* Event::createNewSecretBaseEvent()
  97. {
  98. Event *event = new Event;
  99. event->put("event_group_type", "bg_event_group");
  100. event->put("event_type", EventType::SecretBase);
  101. event->put("secret_base_id", "SECRET_BASE_RED_CAVE2_1");
  102. return event;
  103. }
  104. QString Event::buildObjectEventMacro(int item_index)
  105. {
  106. int radius_x = this->getInt("radius_x");
  107. int radius_y = this->getInt("radius_y");
  108. uint16_t x = this->getInt("x");
  109. uint16_t y = this->getInt("y");
  110. QString text = "";
  111. text += QString("\tobject_event %1").arg(item_index + 1);
  112. text += QString(", %1").arg(this->get("sprite"));
  113. text += QString(", %1").arg(this->get("replacement"));
  114. text += QString(", %1").arg(x);
  115. text += QString(", %1").arg(y);
  116. text += QString(", %1").arg(this->get("elevation"));
  117. text += QString(", %1").arg(this->get("movement_type"));
  118. text += QString(", %1").arg(radius_x);
  119. text += QString(", %1").arg(radius_y);
  120. text += QString(", %1").arg(this->get("trainer_see_type"));
  121. text += QString(", %1").arg(this->get("sight_radius_tree_id"));
  122. text += QString(", %1").arg(this->get("script_label"));
  123. text += QString(", %1").arg(this->get("event_flag"));
  124. text += "\n";
  125. return text;
  126. }
  127. QString Event::buildWarpEventMacro(QMap<QString, QString> *mapNamesToMapConstants)
  128. {
  129. QString text = "";
  130. text += QString("\twarp_def %1").arg(this->get("x"));
  131. text += QString(", %1").arg(this->get("y"));
  132. text += QString(", %1").arg(this->get("elevation"));
  133. text += QString(", %1").arg(this->get("destination_warp"));
  134. text += QString(", %1").arg(mapNamesToMapConstants->value(this->get("destination_map_name")));
  135. text += "\n";
  136. return text;
  137. }
  138. QString Event::buildCoordScriptEventMacro()
  139. {
  140. QString text = "";
  141. text += QString("\tcoord_event %1").arg(this->get("x"));
  142. text += QString(", %1").arg(this->get("y"));
  143. text += QString(", %1").arg(this->get("elevation"));
  144. text += QString(", %1").arg(this->get("script_var"));
  145. text += QString(", %1").arg(this->get("script_var_value"));
  146. text += QString(", %1").arg(this->get("script_label"));
  147. text += "\n";
  148. return text;
  149. }
  150. QString Event::buildCoordWeatherEventMacro()
  151. {
  152. QString text = "";
  153. text += QString("\tcoord_weather_event %1").arg(this->get("x"));
  154. text += QString(", %1").arg(this->get("y"));
  155. text += QString(", %1").arg(this->get("elevation"));
  156. text += QString(", %1").arg(this->get("weather"));
  157. text += "\n";
  158. return text;
  159. }
  160. QString Event::buildSignEventMacro()
  161. {
  162. QString text = "";
  163. text += QString("\tbg_event %1").arg(this->get("x"));
  164. text += QString(", %1").arg(this->get("y"));
  165. text += QString(", %1").arg(this->get("elevation"));
  166. text += QString(", %1").arg(this->get("player_facing_direction"));
  167. text += QString(", %1").arg(this->get("script_label"));
  168. text += "\n";
  169. return text;
  170. }
  171. QString Event::buildHiddenItemEventMacro()
  172. {
  173. QString text = "";
  174. text += QString("\tbg_hidden_item_event %1").arg(this->get("x"));
  175. text += QString(", %1").arg(this->get("y"));
  176. text += QString(", %1").arg(this->get("elevation"));
  177. text += QString(", %1").arg(this->get("item"));
  178. text += QString(", %1").arg(this->get("flag"));
  179. text += "\n";
  180. return text;
  181. }
  182. QString Event::buildSecretBaseEventMacro()
  183. {
  184. QString text = "";
  185. text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
  186. text += QString(", %1").arg(this->get("y"));
  187. text += QString(", %1").arg(this->get("elevation"));
  188. text += QString(", %1").arg(this->get("secret_base_id"));
  189. text += "\n";
  190. return text;
  191. }