Beispiel #1
0
/**
 * @brief Notifies the script that the enemy is receiving an attack
 * with a custom effect, which means that your script decides what happens.
 * and returns the number of life points to remove.
 * @param attack the type of attack received
 * @param sprite the sprite of the enemy that receives the attack, or NULL
 * if the attack does not come from a pixel-precise collision test.
 * @return the number of life points to remove from the enemy
 */
int EnemyScript::event_custom_attack_received(EnemyAttack attack, Sprite* sprite) {

  int result = 0;
  if (sprite != NULL) {
    // pixel-perfect collision
    notify_script("event_custom_attack_received", "si i",
        Enemy::get_attack_name(attack).c_str(), create_sprite_handle(*sprite), &result);
  }
  else {
    notify_script("event_custom_attack_received", "s i",
        Enemy::get_attack_name(attack).c_str(), &result);
  }
  return result;
}
Beispiel #2
0
/**
 * @brief Notifies the script that the hero is using an inventory item
 * in front of an NPC.
 *
 * @param npc_name name of the npc the hero is facing
 * @param item_name name of the inventory item that is being used
 * @param variant variant of this inventory item
 * @return true if the script has handled the event,
 * i.e. if the function event_npc_interaction_item exists in the script and returned true
 */
bool Script::event_npc_interaction_item(const std::string& npc_name,
    const std::string& item_name, int variant) {

  int interaction = 0;
  notify_script("event_npc_interaction_item", "ssi b", npc_name.c_str(),
      item_name.c_str(), variant, &interaction);

  return interaction != 0;
}
Beispiel #3
0
/**
 * @brief Notifies the script that the enemy just died.
 *
 * This function is called when the dying animation is totally finished.
 */
void EnemyScript::event_dead() {

  notify_script("event_dead");
}
Beispiel #4
0
/**
 * @brief Notifies the script that the enemy has just been hurt.
 * @param attack the type of attack received
 * @param life_lost the number of life points just lost
 */
void EnemyScript::event_hurt(EnemyAttack attack, int life_lost) {

  notify_script("event_hurt", "si", Enemy::get_attack_name(attack).c_str(), life_lost);
}
Beispiel #5
0
/**
 * @brief Notifies the script that the animation of a sprite of the enemy has just finished.
 * @param sprite a sprite of the enemy
 * @param animation the current animation
 * @param frame the new frame
 */
void EnemyScript::event_sprite_frame_changed(Sprite& sprite, const std::string& animation, int frame) {

  notify_script("event_sprite_frame_changed", "isi",
      create_sprite_handle(sprite), animation.c_str(), frame);
}
Beispiel #6
0
/**
 * @brief Notifies the script that the game is being suspended or resumed.
 * @param suspended true if the game becomes suspended, false if it is resumed.
 */
void EnemyScript::event_set_suspended(bool suspended) {

  notify_script("event_suspended", "b", suspended);
}
Beispiel #7
0
/**
 * @brief Notifies the script that a dialog has just started to be displayed
 * in the dialog box.
 * @param dialog_id id of the dialog
 */
void Script::event_dialog_started(const std::string& dialog_id) {

  notify_script("event_dialog_started", "s", dialog_id.c_str());
}
Beispiel #8
0
/**
 * @brief Notifies the script that there was just a collision between an NPC and fire.
 * @param npc_name name of the NPC
 */
void Script::event_npc_collision_fire(const std::string &npc_name) {

  notify_script("event_npc_collision_fire", "s", npc_name.c_str());
}
Beispiel #9
0
/**
 * @brief Notifies the script that the layer of the enemy has changed.
 * @param layer the new layer
 */
void EnemyScript::event_layer_changed(Layer layer) {

  notify_script("event_layer_changed", "i", layer);
}
Beispiel #10
0
/**
 * @brief Notifies the script that the enemy has just moved.
 * @param xy the new position of the enemy on the map
 */
void EnemyScript::event_position_changed(const Rectangle& xy) {

  notify_script("event_position_changed", "ii", xy.get_x(), xy.get_y());
}
Beispiel #11
0
/**
 * @brief Notifies the script that the enemy is about to be displayed.
 *
 * Your script may display additional things above the enemy.
 */
void EnemyScript::event_post_display() {

  notify_script("event_post_display");
}
Beispiel #12
0
/**
 * @brief Notifies the script that the enemy is restarting its movement because
 * something happended (for example the enemy has just been created,
 * or it was just hurt)
 */
void EnemyScript::event_restart() {

  notify_script("event_restart");
}
Beispiel #13
0
/**
 * @brief Notifies the script that the enemy has just been disabled.
 */
void EnemyScript::event_disabled() {

  notify_script("event_disabled");
}
Beispiel #14
0
/**
 * @brief Notifies the script that an instance of the enemy has just been created on the map.
 */
void EnemyScript::event_appear() {

  notify_script("event_appear");
}
Beispiel #15
0
/**
 * @brief Notifies the script that the player has just pressed the action
 * key in front of an NPC.
 * @param npc_name name of the NPC
 */
void Script::event_npc_interaction(const std::string& npc_name) {

  notify_script("event_npc_interaction", "s", npc_name.c_str());
}
Beispiel #16
0
/**
 * @brief Notifies the script that the movement of the enemy
 * was stopped because of an obstacle.
 */
void EnemyScript::event_obstacle_reached() {

  notify_script("event_obstacle_reached");
}
Beispiel #17
0
/**
 * @brief Notifies the script that the movement of the enemy has just finished.
 * @param movement the current movement of the enemy
 */
void EnemyScript::event_movement_finished(Movement& movement) {

  notify_script("event_movement_finished", "i", create_movement_handle(movement));
}
Beispiel #18
0
/**
 * @brief Notifies the script that another map has just been started.
 * @param map the new current map
 */
void Script::event_map_changed(Map &map) {

  notify_script("event_map_changed", "i", map.get_id());
}
Beispiel #19
0
/**
 * @brief Notifies the script that the animation of a sprite of the enemy has just finished.
 * @param sprite a sprite of the enemy
 * @param animation the animation that was playing
 */
void EnemyScript::event_sprite_animation_finished(Sprite& sprite, const std::string& animation) {

  notify_script("event_sprite_animation_finished", "is",
      create_sprite_handle(sprite), animation.c_str());
}
Beispiel #20
0
/**
 * @brief Notifies the script that the dialog box has just finished.
 *
 * This function is called when the last group of 3 lines of a dialog is
 * finished.
 * The dialog box has just been closed but the game is still suspended.
 * Note that this event is not called if the dialog was skipped.
 *
 * @param dialog_id id of the dialog that has just finished
 * @param answer the answer selected by the player: 0 for the first one,
 * 1 for the second one, -1 if there was no question
 */
void Script::event_dialog_finished(const std::string& dialog_id, int answer) {

  notify_script("event_dialog_finished", "si", dialog_id.c_str(), answer);
}
Beispiel #21
0
/**
 * @brief Notifies the script that it can update itself.
 *
 * This function is called at each cycle of the main loop,
 * so if you define it in your script, take care of the performances.
 */
void EnemyScript::event_update() {

  notify_script("event_update");
}