/* Send every player information about map */
void SendPropInfo(GAME Game)
{
  char PropInfo[MESSAGE_LENGTH];
  PROPERTIES properties = Game.Map.Properties;

  sprintf(
	  PropInfo,
	  "Gametype:%s\nSize:%iX%i\nLenght of River:%i\n"
      "Number of Armoryies:%i\nNumber of Healers:%i\nNumber of Wormholes:%i\n",
      /*GTfromType(properties.gametype)*/"Normal game", 
	  properties.W, 
	  properties.H, 
	  properties.RiverLength, 
	  properties.ArmoriesNumber,
	  properties.HealersNumber, 
	  0);

  InformPlayers(Game, PropInfo);
  logprintf(PropInfo);
} /* End of 'SendPropInfo' function */
/* Send result to all players */
void SendResult(GAME Game, RESULT Result)
{
  char name[MESSAGE_LENGTH];
  char subject[MESSAGE_LENGTH];
  char message[MESSAGE_LENGTH];

  sprintf(name, Game.Players[Game.Current_player].Name);

  if (Result.Player != -1)
    sprintf(subject, Game.Players[Result.Player].Name);

  if (Result.Result == RESULT_UNKNOWN_COMMAND)
    sprintf(message, "Unknown Command\n\n");
  if (Result.Result == RESULT_NOT_ENOUGH_BULLETS)
    sprintf(message, "%s tried to shoot, but he/she haven't enough bullets.\n\n", name);
  if (Result.Result == RESULT_SHOOTED)
    sprintf(message, "%s shot %s. %s now is wounded.\n\n", name, subject, subject);
  if (Result.Result == RESULT_SHOT_MISSED)
    sprintf(message, "%s shot %s. %s now is wounded.\n\n", name, "void", "Void");
  if (Result.Result == RESULT_HIT)
    sprintf(message, "%s hit %s with a knife. %s now is wounded.\n\n", name, subject, subject);
  if (Result.Result == RESULT_HIT_MISSED)
    sprintf(message, "%s hit %s with a knife. %s now is wounded.\n\n", name, "void", "Void");
  if (Result.Result == RESULT_WAY_IS_BLOCKED)
    sprintf(message, "Wall!\n\n");
  if (Result.Result == RESULT_WALK)
    sprintf(message, "Succesful walk.\n\n");
  if (Result.Result == RESULT_ARMORY_REACHED)
    sprintf(message, "Succesful walk and armory reached!\n\n");
  if (Result.Result == RESULT_HEALER_REACHED)
    sprintf(message, "Succesful walk and healer reached!\n\n");
  if (Result.Result == RESULT_TREASURE_REACHED)
    sprintf(message, "Treasure reached!\n\n");
  if (Result.Result == RESULT_EXIT_FOUND)
    sprintf(message, "Exit!\n\n");
  if (Result.Result == RESULT_WINNER)
    sprintf(message, "%s wins!\n\n", name);

  InformPlayers(Game, message);
} /* End of 'SendResult' function */
Exemple #3
0
        void UpdateAI(const uint32 p_Diff) override
        {
            events.Update(p_Diff);

            if (m_DownDraft)
            {
                if (m_DownDraftDiffCancel <= p_Diff)
                {
                    m_DownDraft = false;

                    m_DownDraftDiffCancel = 10000;
                }
                else
                    m_DownDraftDiffCancel -= p_Diff;

                if (m_DownDraftDiff <= p_Diff)
                {
                    std::list<Player*> l_PlayerListDown;
                    me->GetPlayerListInGrid(l_PlayerListDown, 50.0f);

                    if (l_PlayerListDown.empty())
                        return;

                    for (auto itr : l_PlayerListDown)
                    {
                        if (!itr->HasAura(133755))
                        itr->CastSpell(itr, 133331);
                        //itr->GetMotionMaster()->MoveKnockbackFrom(itr->GetPositionX(), itr->GetPositionY(), 6.0f, 3.0f);
                    }

                    m_DownDraftDiff = 3700;
                }
                else
                    m_DownDraftDiff -= p_Diff;
            }

            if (!UpdateVictim())
                return;

            if (me->HasUnitState(UnitState::UNIT_STATE_CASTING))
                return;

            switch (events.ExecuteEvent())
            {
                case eJiKunEvents::EventEnrage:
                    me->CastSpell(me, eJiKunSpells::SpellEnrage);
                    break;
                case eJiKunEvents::EventCaw:
                    InformPlayers("Ji Kun is casting Caw, SPREAD OUT!");

                    if (Unit * l_Random = SelectTarget(SelectAggroTarget::SELECT_TARGET_RANDOM, 0, 45.0f, true))
                        me->CastSpell(l_Random, eJiKunSpells::SpellCaw);

                    events.ScheduleEvent(eJiKunEvents::EventCaw, 25 * TimeConstants::IN_MILLISECONDS);
                    break;
                case eJiKunEvents::EventQuills:
                    me->CastSpell(me, eJiKunSpells::SpellQuills);

                    InformPlayers("Ji Kun sends her[Quils] flying in every direction");

                    events.ScheduleEvent(eJiKunEvents::EventQuills, 45 * TimeConstants::IN_MILLISECONDS);
                    break;
                case eJiKunEvents::EventInfectedTalon:
                    if (Unit * l_Random = SelectTarget(SelectAggroTarget::SELECT_TARGET_RANDOM, 0, 100.0f, true))
                        me->CastSpell(l_Random, eJiKunSpells::SpellInfectedTalonAura);

                    events.ScheduleEvent(eJiKunEvents::EventInfectedTalon, 10 * TimeConstants::IN_MILLISECONDS);
                    break;
                case eJiKunEvents::EventTalonRake:
                    if (Unit * l_Victim = me->getVictim())
                    {
                        me->CastSpell(l_Victim, eJiKunSpells::SpellInfectedTalonAura);
                        me->CastSpell(l_Victim, eJiKunSpells::SpellTalonRake);
                    }

                    events.ScheduleEvent(eJiKunEvents::EventTalonRake, 58 * TimeConstants::IN_MILLISECONDS);
                    break;
                case eJiKunEvents::EventDownDraft:
                    m_DownDraft = true;
                    m_DownDraftDiff = 3000;
                    m_DownDraftDiffCancel = 10000;
                    me->CastSpell(me, eJiKunSpells::SpellDownDraft);

 
                    InformPlayers("Ji Kun uses her wings to create a massive [Down Draft]!");
                    events.ScheduleEvent(eJiKunEvents::EventDownDraft, 80 * TimeConstants::IN_MILLISECONDS);
                    break;
                case eJiKunEvents::EventDownDraftDis:
                    m_DownDraft = false;
                    break;
                case eJiKunEvents::EventFeedPool:
                    me->CastSpell(me, eJiKunSpells::SpellFeedYoung);
              
                    events.ScheduleEvent(eJiKunEvents::EventFeedPool, 38 * TimeConstants::IN_MILLISECONDS);
                    break;
                    // Eggs
                case eJiKunEvents::EventYoungEgg:
                {                  
                    m_Count++;

                    GameObject* beacon = NULL;

                    if (m_Count == 8)
                        m_Count = 0;

                    switch (m_Count)
                    {
                        case 0:
                            beacon = me->SummonGameObject(148937, l_PositionLowBottom.GetPositionX(), l_PositionLowBottom.GetPositionY(), l_PositionLowBottom.GetPositionZ(), l_PositionLowBottom.GetOrientation(), 0,0,0,0,0);
                            
                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            for (int i = 0; i < 7; i++)
                            {
                                me->SummonCreature(CreatureYoungEggOfJiKun, l_PositionLowBottom.GetPositionX() + i, l_PositionLowBottom.GetPositionY() + i, l_PositionLowBottom.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            }
                            break;
                        case 1:
                            beacon = me->SummonGameObject(148937, l_PositionTopBottom.GetPositionX(), l_PositionTopBottom.GetPositionY(), l_PositionTopBottom.GetPositionZ(), l_PositionTopBottom.GetOrientation(), 0, 0, 0, 0, 0);

                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            for (int i = 0; i < 7; i++)
                            {
                                me->SummonCreature(CreatureYoungEggOfJiKun, l_PositionTopBottom.GetPositionX() + i, l_PositionTopBottom.GetPositionY() + i, l_PositionTopBottom.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            }
                            break;
                        case 2:
                            beacon = me->SummonGameObject(148937, l_PositionMidBottom.GetPositionX(), l_PositionMidBottom.GetPositionY(), l_PositionMidBottom.GetPositionZ(), l_PositionMidBottom.GetOrientation(), 0, 0, 0, 0, 0);

                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            for (int i = 0; i < 7; i++)
                            {
                                me->SummonCreature(CreatureYoungEggOfJiKun, l_PositionMidBottom.GetPositionX() + i, l_PositionMidBottom.GetPositionY() + i, l_PositionMidBottom.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            }
                            break;
                        case 3:
                            beacon = me->SummonGameObject(148937, l_PositionTopTop.GetPositionX(), l_PositionTopTop.GetPositionY(), l_PositionTopTop.GetPositionZ(), l_PositionTopTop.GetOrientation(), 0, 0, 0, 0, 0);
                            InformPlayers("Ji Kun spawn Hatchlings in the upper nests!");

                            me->SummonCreature(CreatureMatureEggOfJiKun, l_PositionTopTop.GetPositionX(), l_PositionTopTop.GetPositionY(), l_PositionTopTop.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            break;
                        case 4:
                            beacon = me->SummonGameObject(148937, l_PositionLowBottom.GetPositionX(), l_PositionLowBottom.GetPositionY(), l_PositionLowBottom.GetPositionZ(), l_PositionLowBottom.GetOrientation(), 0, 0, 0, 0, 0);

                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            for (int i = 0; i < 7; i++)
                            {
                                me->SummonCreature(CreatureYoungEggOfJiKun, l_PositionLowBottom.GetPositionX() + i, l_PositionLowBottom.GetPositionY() + i, l_PositionLowBottom.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            }
                            break;
                        case 5:
                            InformPlayers("Ji Kun spawn Hatchlings in the upper nests!");


                            beacon = me->SummonGameObject(148937, l_PositionMidTop.GetPositionX(), l_PositionMidTop.GetPositionY(), l_PositionMidTop.GetPositionZ(), l_PositionMidTop.GetOrientation(), 0, 0, 0, 0, 0);

                            me->SummonCreature(CreatureMatureEggOfJiKun, l_PositionMidTop.GetPositionX(), l_PositionMidTop.GetPositionY(), l_PositionMidTop.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            break;
                        case 6:
                            InformPlayers("Ji Kun spawn Hatchlings in the upper nests!");

                            beacon = me->SummonGameObject(148937, l_PositionLowBottom.GetPositionX(), l_PositionLowBottom.GetPositionY(), l_PositionLowBottom.GetPositionZ(), l_PositionLowBottom.GetOrientation(), 0, 0, 0, 0, 0);

                            me->SummonCreature(CreatureMatureEggOfJiKun, l_PositionLowBottom.GetPositionX(), l_PositionLowBottom.GetPositionY(), l_PositionLowBottom.GetPositionY(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            break;
                        case 7:
                            beacon = me->SummonGameObject(148937, l_PositionLowBottom.GetPositionX(), l_PositionLowBottom.GetPositionY(), l_PositionLowBottom.GetPositionZ(), l_PositionLowBottom.GetOrientation(), 0, 0, 0, 0, 0);

                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            for (int i = 0; i < 7; i++)
                            {
                                me->SummonCreature(CreatureYoungEggOfJiKun, l_PositionLowBottom.GetPositionX() + i, l_PositionLowBottom.GetPositionY() + i, l_PositionLowBottom.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            }
                            break;
                        case 8:
                            InformPlayers("Ji Kun spawn Hatchlings in the lower nests!");

                            beacon = me->SummonGameObject(148937, l_PositionMidTop.GetPositionX(), l_PositionMidTop.GetPositionY(), l_PositionMidTop.GetPositionZ(), l_PositionMidTop.GetOrientation(), 0, 0, 0, 0, 0);

                            me->SummonCreature(CreatureMatureEggOfJiKun, l_PositionMidTop.GetPositionX(), l_PositionMidTop.GetPositionY(), l_PositionMidTop.GetPositionZ(), TempSummonType::TEMPSUMMON_MANUAL_DESPAWN);
                            break;                        
                    }

                    if (beacon)
                        me->m_Events.AddEvent(new ji_kun_delete_beacons(beacon, 0), me->m_Events.CalculateTime(7000));

                    events.ScheduleEvent(eJiKunEvents::EventYoungEgg, 40 * TimeConstants::IN_MILLISECONDS);
                    break;
                }
            }

            DoMeleeAttackIfReady();
        }
/* Get another command */
COMMAND ReadCommand( GAME Game )
{
  int i = 0;
  char ch = '\0';
  char message[MESSAGE_LENGTH];
  char question[MESSAGE_LENGTH];
  char *answer;
  COMMAND command;

  sprintf(question, "%s, your actions:", Game.Players[Game.Current_player].Name);
  answer = AskPlayer(Game.Players[Game.Current_player], question);

  sprintf(message, "%s: %s\n", Game.Players[Game.Current_player].Name, answer);
  InformPlayers(Game, message);

  logprintf(message);

  command.Command = COMMAND_UNKNOVN;
  command.Destination = DESTINATION_NULL;

  if (strcmp(answer, "Move up") == 0)
  {
    command.Command = COMMAND_WALK;
    command.Destination = DESTINATION_UP;
  }
  if (strcmp(answer, "Move right") == 0)
  {
    command.Command = COMMAND_WALK;
    command.Destination = DESTINATION_RIGHT;
  }
  if (strcmp(answer, "Move down") == 0)
  {
    command.Command = COMMAND_WALK;
    command.Destination = DESTINATION_DOWN;
  }
  if (strcmp(answer, "Move left") == 0)
  {
    command.Command = COMMAND_WALK;
    command.Destination = DESTINATION_LEFT;
  }
  if (strcmp(answer, "Shoot up") == 0)
  {
    command.Command = COMMAND_SHOOT;
    command.Destination = DESTINATION_UP;
  }
  if (strcmp(answer, "Shoot right") == 0)
  {
    command.Command = COMMAND_SHOOT;
    command.Destination = DESTINATION_RIGHT;
  }
  if (strcmp(answer, "Shoot down") == 0)
  {
    command.Command = COMMAND_SHOOT;
    command.Destination = DESTINATION_DOWN;
  }
  if (strcmp(answer, "Shoot left") == 0)
  {
    command.Command = COMMAND_SHOOT;
    command.Destination = DESTINATION_LEFT;
  }
  if (strcmp(answer, "Hit with knife") == 0)
  {
    command.Command = COMMAND_KNIFE;
  }

  free(answer);

  return command;
} /* End of 'ReadCommand' function */