Exemplo n.º 1
0
/**
 @brief 첫번째 보유스킬을 사용한다
 그냥 편의 함수.
*/
XSkillUser::xUseSkill XSkillUser::UseSkill( XSkillReceiver *pTarget, const XE::VEC2& vPos )
{
	xUseSkill info;
	if( XBREAK( m_listUseSkill.empty() ) ) {
		info.errCode = xCANCEL;
		return info;
	}
	XSkillDat *pUseSkill = m_listUseSkill.GetFirst();
	int level = GetSkillLevel( pUseSkill );
	return UseSkill( pUseSkill, level, pTarget, vPos );
}
int
nws_ping(char *hostname, int port, double *bandwidth, double *latency) {

  const char *OPTION_NAMES[OPTION_COUNT] = {"size", "buffer", "message"};
  const unsigned int OPTION_DEFAULTS[OPTION_COUNT] = {256, 64, 32};

  int j;
  int length;
  char options[255 + 1];
  unsigned int optionValues[OPTION_COUNT];
  SkillResult *results;
  unsigned short sensorPort;
  double timeOut;
  struct host_desc targetHost;
  char targetOptions[255 + 1];
  char host_and_port[256];

  debug = 0;
  memcpy(optionValues, OPTION_DEFAULTS, sizeof(OPTION_DEFAULTS));
  sensorPort = (unsigned short) port;
  timeOut = DEFAULT_TIMEOUT;


  options[0] = '\0';
  for(j = 0; j < OPTION_COUNT; j++)
    sprintf(options, "%s\t%s:%d", options, OPTION_NAMES[j], optionValues[j]);

  if (strlen(hostname) < 64) {
    memset(&targetHost, 0, sizeof(struct host_desc));
    strcpy(targetHost.host_name, hostname);
  } else {
    return -1;
  }

  memset(host_and_port, 0, 256);
  sprintf(host_and_port, "%s:%d", hostname, sensorPort);
  sprintf(targetOptions, "%s\ttarget:%s", options, host_and_port);
  UseSkill(tcpMessageMonitor, targetOptions, timeOut, &results, &length);

  if(results[0].succeeded) {
    *bandwidth = results[0].measurement;
    *latency = results[1].measurement;
    return 0;
  }
  else {
    *bandwidth = 0;
    *latency = 0;
  }

  return 0;
}
Exemplo n.º 3
0
void Enemy::Ctrl()
{
	if(StateTime > 0 || fabs(GetBody()->GetLinearVelocity().y) > 0.2f)return;
	Character* Player = GetPlayer();
	if(GetCharaType() == Mapchip_CommonEnemy1)
	{
		double Dis = GetDistance(x,y,Player->x,Player->y);
		if(Dis < 150 && Dis > 30)
		{
			if(Player->x-x < 0)Direction = ImageDirection_Left;
			else Direction = ImageDirection_Right;
			if(Player->x != x)GetBody()->SetLinearVelocity(b2Vec2((Player->x-x) / abs(Player->x-x) * 3,0));
		}else if(Dis <= 30)
		{
			UseSkill(Skill_Sword_Front,Equipment_Sword_Normal);
			StateTime += 500;
		}
	}
}
Exemplo n.º 4
0
void ObjectPool::SkillEffect()
{
	//效率很低。。
	for (int i = 0; i < pool.size();i++)
	{
		if (!pool[i]->IsDead() && pool[i]->IsSkill() && !pool[i]->IsItem())
		{
			SKILL *abc = dynamic_cast<SKILL*>(pool[i]);
			for (int j = 0; j < pool.size(); j++)
			{
				if (!pool[j]->IsDead() && !pool[j]->IsSkill() && pool[j]->IsShield())
					ShieldEffect(dynamic_cast<Shield*>(pool[j]), abc);
				if (pool[i]->IsDead())
					break;
			}
			if (!abc->EffectAll())
			{
				if (abc->IsThisSkillEnemy())
				{
					UseSkillForHero(&Hero::GetHero(), abc);
					for (int j = 0; j < pool.size(); j++)
					if (pool[j]->IsMine() && !abc->GetIsPenetrate() && ballcrash(pool[j]->GetX(), pool[j]->GetY(), pool[j]->GetCollisionRange(), abc->GetX(), abc->GetY()) && abc->interaction(pool[j]))
					{
						abc->effect(pool[j]);
						pool[j]->Underattack(pool[i]);
					}
				}
				else
				{
					for (int j = 0; j < pool.size(); j++)
					{
						if (!pool[j]->IsSkill() && !pool[j]->IsDead() && !pool[j]->IsShield())
						{
							if (!pool[j]->IsMine())
								UseSkill(pool[j], abc);
							else
							{
								if (!abc->IsDead() && !abc->GetIsPenetrate() && ballcrash(pool[j]->GetX(), pool[j]->GetY(), pool[j]->GetCollisionRange(), abc->GetX(), abc->GetY()) && abc->interaction(pool[j]))
								{
									abc->effect(pool[j]);
									pool[j]->Underattack(pool[i]);
								}
							}
						}
						else
						{
							if (pool[j]->IsItem() && !abc->IsDead() && abc->IsBullet() && ballcrash(pool[j]->GetX(), pool[j]->GetY(), 50, abc->GetX(), abc->GetY()))
							{
								abc->effect(pool[j]);
								pool[j]->Underattack(pool[i]);
							}
						}
						if (pool[i]->IsDead())
							break;
					}
				}
				abc->AfterOneEffect();
			}
			else
			{
				UseSkillForHero(&Hero::GetHero(), abc);
				for (int j = 0; j < pool.size(); j++)
				{
					if (!pool[j]->IsSkill() && !pool[j]->IsDead() && !pool[j]->IsShield())
					{
						if (!pool[j]->IsMine())
							UseSkill(pool[j], abc);
						else
						{
							if (!abc->IsDead() && !abc->GetIsPenetrate() && ballcrash(pool[j]->GetX(), pool[j]->GetY(), pool[j]->GetCollisionRange(), abc->GetX(), abc->GetY()) && abc->interaction(pool[j]))
							{
								abc->effect(pool[j]);
								pool[j]->Underattack(pool[i]);
							}
						}
					}
					else
					{
						if (pool[j]->IsItem() && !abc->IsDead() && abc->IsBullet() && abc->GetRange() > 1 && ballcrash(pool[j]->GetX(), pool[j]->GetY(), 50, abc->GetX(), abc->GetY()))
						{

							abc->effect(pool[j]);
							pool[j]->Underattack(pool[i]);
						}
					}
					if (pool[i]->IsDead())
						break;
				}
			abc->AfterOneEffect();
			}
		}
	}
}
Exemplo n.º 5
0
bool Game_Battler::UseItem(int item_id) {
	const RPG::Item* item = ReaderUtil::GetElement(Data::items, item_id);
	if (!item) {
		Output::Warning("UseItem: Can't use item with invalid ID %d", item_id);
		return false;
	}

	if (item->type == RPG::Item::Type_medicine) {
		bool was_used = false;

		int hp_change = item->recover_hp_rate * GetMaxHp() / 100 + item->recover_hp;
		int sp_change = item->recover_sp_rate * GetMaxSp() / 100 + item->recover_sp;

		if (IsDead()) {
			// Check if item can revive
			if (item->state_set.empty() || !item->state_set[0]) {
				return false;
			}

			// Revive gives at least 1 Hp
			if (hp_change == 0) {
				ChangeHp(1);
				was_used = true;
			}
		} else if (item->ko_only) {
			// Must be dead
			return false;
		}

		if (hp_change > 0 && !HasFullHp()) {
			ChangeHp(hp_change);
			was_used = true;
		}

		if (sp_change > 0 && !HasFullSp()) {
			ChangeSp(sp_change);
			was_used = true;
		}

		for (int i = 0; i < (int)item->state_set.size(); i++) {
			if (item->state_set[i]) {
				was_used |= HasState(Data::states[i].ID);
				RemoveState(Data::states[i].ID);
			}
		}

		return was_used;
	}

	if (item->type == RPG::Item::Type_switch) {
		return true;
	}

	switch (item->type) {
		case RPG::Item::Type_weapon:
		case RPG::Item::Type_shield:
		case RPG::Item::Type_armor:
		case RPG::Item::Type_helmet:
		case RPG::Item::Type_accessory:
			return item->use_skill && UseSkill(item->skill_id);
		case RPG::Item::Type_special:
			return UseSkill(item->skill_id);
	}

	return false;
}
Exemplo n.º 6
0
bool Game_Battler::UseItem(int item_id, const Game_Battler* source) {
	const RPG::Item* item = ReaderUtil::GetElement(Data::items, item_id);
	if (!item) {
		Output::Warning("UseItem: Can't use item with invalid ID %d", item_id);
		return false;
	}

	if (item->type == RPG::Item::Type_medicine) {
		bool was_used = false;
		int revived = 0;
		int hp_change = item->recover_hp_rate * GetMaxHp() / 100 + item->recover_hp;
		int sp_change = item->recover_sp_rate * GetMaxSp() / 100 + item->recover_sp;

		if (IsDead()) {
			// Check if item can revive
			if (item->state_set.empty() || !item->state_set[0]) {
				return false;
			}
		} else if (item->ko_only) {
			// Must be dead
			return false;
		}

		for (int i = 0; i < (int)item->state_set.size(); i++) {
			if (item->state_set[i]) {
				was_used |= HasState(Data::states[i].ID);
				if (i == 0 && HasState(i + 1))
					revived = 1;
				RemoveState(Data::states[i].ID);
			}
		}

		if (hp_change > 0 && !HasFullHp()) {
			ChangeHp(hp_change - revived);
			was_used = true;
		}

		if (sp_change > 0 && !HasFullSp()) {
			ChangeSp(sp_change);
			was_used = true;
		}

		return was_used;
	}

	if (item->type == RPG::Item::Type_switch) {
		return true;
	}

	bool do_skill = (item->type == RPG::Item::Type_special)
		|| (item->use_skill && (
				item->type == RPG::Item::Type_weapon
				|| item->type == RPG::Item::Type_shield
				|| item->type == RPG::Item::Type_armor
				|| item->type == RPG::Item::Type_helmet
				|| item->type == RPG::Item::Type_accessory
				)
				);

	if (do_skill) {
		auto* skill = ReaderUtil::GetElement(Data::skills, item->skill_id);
		if (skill == nullptr) {
			Output::Warning("UseItem: Can't use item %d skill with invalid ID %d", item->ID, item->skill_id);
			return false;
		}
		UseSkill(item->skill_id, source);
	}

	return false;
}
Exemplo n.º 7
0
void Player::Ctrl()
{
	//プレイヤーがマップから落ちた場合はHPを0にする
	if(y > Screen_Height + 30)HP = 0;

	//プレイヤーが地面に接触しているかを確認
	bool Flag = false;
	for(b2ContactEdge *i = GetBody()->GetContactList();i;i = i->next)
	{
		string Str = (char*)i->contact->GetFixtureB()->GetBody()->GetUserData();
		if(i->contact->GetManifold()->localNormal.y == 1)
		{
			Flag = true;
		}
		
	}

	//プレイヤーのコンボが途切れていて、かつ地面にいる場合はADを初期化する
	if(ComboCount == 0 && Flag && JudgeSkillCancel())InitAllSkillAvailableCount();

	//コンボが繋がった場合、EXゲージを増やす
	if(ComboCount > BeforeComboCount)EX += ComboCount;
	if(EX > MaxEX)EX = MaxEX;

	//スタン中は行動できない
	if(State == Skill_None_Stan && StateTime > 0)return;

	//スキルウィンドウ表示中は行動できない
	if(SkillWindow.Visible)return;

	//スキル使用
	int Key[9] = {KEY_INPUT_Q,KEY_INPUT_W,KEY_INPUT_E,
					KEY_INPUT_A,KEY_INPUT_S,KEY_INPUT_D,
					KEY_INPUT_Z,KEY_INPUT_X,KEY_INPUT_C};
	for(int i=0;i<9;i++)
	{
		if(CheckKeyDown(Key[i]) && (SkillSet[i%3][(int)(i/3)][3] > 0 || SkillSet[i%3][(int)(i/3)][3] == -1))
		{
			if(SkillConsumeEX[SkillSet[i%3][(int)(i/3)][0]] <= EX)
			{
				if(UseSkill(SkillSet[i%3][(int)(i/3)][0],Equipments[0]))
				{//スキル使用成功時にはAD,EXを減らす
					EX -= SkillConsumeEX[SkillSet[i%3][(int)(i/3)][0]];
					SkillSet[i%3][(int)(i/3)][3]--;
				}
			}
		}
	}

	//スキル使用中には移動、ジャンプができない
	if(!JudgeSkillCancel())return;
	b2Vec2 Vect = GetBody()->GetLinearVelocity();

	//移動
	if(CheckHitKey(KEY_INPUT_LEFT))
	{
		Vect.x = -MoveSpeed;
		Direction = ImageDirection_Left;
	}
	if(CheckHitKey(KEY_INPUT_RIGHT))
	{
		Vect.x = MoveSpeed;
		Direction = ImageDirection_Right;
	}

	if(Flag && CheckKeyDown(KEY_INPUT_SPACE))
	{//ジャンプ(空中不可)
		Vect.y = -MoveSpeed*2.5;
	}

	//地面との摩擦
	if(Flag && Vect.x != 0)Vect.x -= (float32)(Vect.x / fabs(Vect.x) * 0.13);

	//ベクトルを適用
	GetBody()->SetLinearVelocity(Vect);
}
int
main(int argc,
     char **argv) {

  const char *OPTION_NAMES[OPTION_COUNT] = {"size", "buffer", "message"};
  const unsigned int OPTION_DEFAULTS[OPTION_COUNT] = {64, 32, 16};

  const char *curr;
  unsigned int endTime;
  int hostIndex;
  int i;
  int j;
  int length;
  char options[255 + 1];
  unsigned int optionValues[OPTION_COUNT];
  unsigned int repeatPeriod;
  const SkillResult *results;
  unsigned short sensorPort;
  unsigned int *size;
  unsigned int startTime;
  double timeOut;
  struct host_desc targetHost;
  char targetOptions[255 + 1];
  const char* USAGE = 
    "nws_ping [-d] [-repeat seconds] [-size experiment,buffer,message] [-timeout seconds] host ...";

  debug = 0;
  memcpy(optionValues, OPTION_DEFAULTS, sizeof(OPTION_DEFAULTS));
  repeatPeriod = 0;
  sensorPort = DefaultHostPort(SENSOR_HOST);
  timeOut = DEFAULT_TIMEOUT;

  for(i = 1; i < argc; i++) {

    if(*argv[i] == '-') {

      if(++i == argc) {
        fprintf(stderr, "usage: %s\n", USAGE);
        exit(1);
      }

      switch(argv[i - 1][1]) {

      case 'r':
        repeatPeriod = atoi(argv[i]);
        break;

      case 's':
        /*
        ** Parse the comma-delimited size list, allowing each element to
        ** default if unspecified (e.g. "32", "10,,5" and ",,8" are all legal).
        */
        curr = argv[i];
        memcpy(optionValues, OPTION_DEFAULTS, sizeof(OPTION_DEFAULTS));
        for(size = optionValues;
            size < &optionValues[OPTION_COUNT];
            size++) {
          if(isdigit((int)*curr)) {
            *size = 0;
            for( ; isdigit((int)*curr); curr++)
              *size = *size * 10 + *curr - '0';
            if(*curr == ',')
              curr++;
          }
          else if(*curr == ',') {
            curr++;
          }
        }
        break;

      case 't':
        timeOut = atof(argv[i]);
        break;

      case 'd':
	debug = 1;
	break;

      default:
        fprintf(stderr, "usage: %s\n", USAGE);
        exit(1);
        break;

      }

    }
    else {

      break;

    }

  }

  if(i >= argc) {
    fprintf(stderr, "usage: %s\n", USAGE);
    exit(1);
  }

  options[0] = '\0';
  for(j = 0; j < OPTION_COUNT; j++)
    sprintf(options, "%s\t%s:%d", options, OPTION_NAMES[j], optionValues[j]);

  while(1) {

    startTime = (unsigned int)CurrentTime();

    for(hostIndex = i; hostIndex < argc; hostIndex++) {

      HostDValue(argv[hostIndex], sensorPort, &targetHost);

      printf("(%dk", optionValues[0]);
      for(j = 1; j < OPTION_COUNT; j++) {
        printf(",%dk", optionValues[j]);
      }
      printf(") to %s:", HostDImage(&targetHost));

      sprintf(targetOptions, "%s\ttarget:%s", options, HostDImage(&targetHost));
      UseSkill(tcpMessageMonitor, targetOptions, timeOut, &results, &length);

      if(results[0].succeeded) {
        for(j = 0; j < length; j++)
          printf(" %s: %f %s",
                 ResourceName(results[j].resource),
                 results[j].measurement,
                 ResourceLabel(results[j].resource));
      }
      else
        printf(" failed");
      printf("\n");


    }

    fflush(stdout);

    if(repeatPeriod == 0)
      break;
 
    endTime = (unsigned int)CurrentTime();
    if((endTime - startTime) < repeatPeriod)
      sleep(repeatPeriod - (endTime - startTime));

  }

  return 0;

}
Exemplo n.º 9
0
void Dash(int user_id) {
	Position tmp = { -1, -1, -1 };
	UseSkill(DASH, user_id, -1, tmp);
}
Exemplo n.º 10
0
void Shield(int user_id) {
	Position tmp = { -1, -1, -1 };
	UseSkill(SHIELD, user_id, -1, tmp);
}
Exemplo n.º 11
0
void ShortAttack(int user_id) {
	Position tmp = { -1, -1, -1 };
	UseSkill(SHORT_ATTACK, user_id, -1, tmp);
}
Exemplo n.º 12
0
void LongAttack(int user_id, int target_id) {
	Position tmp = { -1, -1, -1 };
	UseSkill(LONG_ATTACK, user_id, target_id, tmp);
}