Esempio n. 1
0
DWORD  CBuild::SetValue(const char* strName, DWORD dwValue)
{
	if(strcmp(strName,"HP") == 0)
	{
        SetHp(dwValue);
		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
    else if(strcmp(strName,"MAXHP") == 0)
	{
        SetMaxHp(dwValue);
		if(dwValue<GetHp())
		{
           SetHp(dwValue);
		}

		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
    else if(strcmp(strName,"SWITCH") == 0)
	{
		//SetSwitch((bool)dwValue);
	}
    else if(strcmp(strName,"REFRESH") == 0)
	{
		SetHp(dwValue);
		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
	return 1;
}
Esempio n. 2
0
void Game_Actor::SetLevel(int _level) {
	GetData().level = min(max(_level, 1), GetMaxLevel());
	// Ensure current HP/SP remain clamped if new Max HP/SP is less.
	SetHp(GetHp());
	SetSp(GetSp());

}
Character::Character(std::string fromString) {
    std::vector<std::string> tokens = utils::Tokenfy(fromString, '|');
    if (tokens[0] == "PLAYER_OBJECT") {
        SetName(tokens[57]);
        SetLastname(tokens[58]);
        SetRace(tokens[59]);
        SetGender(tokens[60]);
        SetFace(tokens[61]);
        SetSkin(tokens[62]);
        SetZone(tokens[63]);
        SetLevel(std::stoi(tokens[64]));
        SetHp(std::stoi(tokens[65]));
        SetMaxHp(std::stoi(tokens[66]));
        SetBp(std::stoi(tokens[67]));
        SetMaxBp(std::stoi(tokens[68]));
        SetMp(std::stoi(tokens[69]));
        SetMaxMp(std::stoi(tokens[70]));
        SetEp(std::stoi(tokens[71]));
        SetMaxEp(std::stoi(tokens[72]));
        SetStrength(std::stoi(tokens[73]));
        SetConstitution(std::stoi(tokens[74]));
        SetIntelligence(std::stoi(tokens[75]));
        SetDexterity(std::stoi(tokens[76]));
        SetX(std::stof(tokens[77]));
        SetY(std::stof(tokens[78]));
        SetZ(std::stof(tokens[79]));
        SetPitch(std::stof(tokens[80]));
        SetYaw(std::stof(tokens[81]));
    }
    // if (tokens[0] == "NPC_OBJECT") {
    //    
    // }
}
Esempio n. 4
0
cMonster*	cMonsterSpawn::CreateMonster(const D3DXVECTOR3& vPos, char* pKey)
{
	++m_nCount;
	auto pMonster = (cMonster*)CreateObject<cMonster>(vPos, pKey);
	pMonster->SetHp(7 / m_fPer);
//	pMonster->SetIsDivide(true);
	return pMonster;
}
Esempio n. 5
0
cMonster*	cMonsterSpawn::CreateThrowMonster(const D3DXVECTOR3& vPos, char* pKey)
{
	++m_nCount;
	auto pMonster = (cMonster*)CreateObject<ThrowerMonster>(vPos, pKey);
	pMonster->SetHp(7 / m_fPer);

	return pMonster;
}
Esempio n. 6
0
void Game_Actor::Init() {
	const std::vector<RPG::Learning>& skills = Data::actors[data.ID - 1].skills;
	for (int i = 0; i < (int) skills.size(); i++)
		if (skills[i].level <= GetLevel())
			LearnSkill(skills[i].skill_id);
	SetHp(GetMaxHp());
	SetSp(GetMaxSp());
	SetExp(exp_list[GetLevel() - 1]);
}
void Game_Battler::ChangeHp(int hp) {
	if (!IsDead()) {
		SetHp(GetHp() + hp);

		// Death
		if (GetHp() <= 0) {
			AddState(RPG::State::kDeathID);
		}
	}
}
Esempio n. 8
0
void ShootType::ShootMissile(const b2Vec2& initPos)
{
    auto missile = new Missile();

    missile->SetDynamicBody(m_Owner, m_MissileType, initPos, m_MissileScale);
    missile->SetTargetPos(m_TargetPos);
    missile->SetSpeed(m_MissileSpeed);
    missile->SetDamage(m_Damage);
    missile->SetRange(m_Range);
	missile->SetMaxHp(m_MissileHp);
	missile->SetHp(m_MissileHp);
    missile->MissileShoot();
}
Esempio n. 9
0
void Game_Enemy::ChangeHp(int hp) {
	SetHp(GetHp() + hp);

	if (this->hp == 0) {
		// Death
		SetGauge(0);
		SetDefending(false);
		SetCharged(false);
		RemoveAllStates();
		AddState(1);
	} else {
		// Back to life
		RemoveState(1);
	}
}
Esempio n. 10
0
bool Barricade::Action_in(Game_Manager* gm_)
{	
	if(!isLive())
	{
		return true;
	}
	if(time--<=0)
	{
		SetHp(0);
		return true;
	}

	CommonAction(gm_);
	return false;
}
Esempio n. 11
0
void Game_Battler::AddState(int state_id) {
	const RPG::State* state = ReaderUtil::GetElement(Data::states, state_id);
	if (!state) {
		Output::Warning("AddState: Can't add state with invalid ID %d", state_id);
		return;
	}

	if (IsDead()) {
		return;
	}
	if (state_id == 1) {
		SetGauge(0);
		RemoveAllStates();
		SetCharged(false);
		SetHp(0);
		SetAtkModifier(0);
		SetDefModifier(0);
		SetSpiModifier(0);
		SetAgiModifier(0);
		SetIsDefending(false);
		SetCharged(false);
		attribute_shift.clear();
		attribute_shift.resize(Data::attributes.size());
	}

	std::vector<int16_t>& states = GetStates();
	if (state_id - 1 >= static_cast<int>(states.size())) {
		states.resize(state_id);
	}

	states[state_id - 1] = 1;

	// Clear states that are more than 10 priority points below the
	// significant state
	const RPG::State* sig_state = GetSignificantState();

	for (size_t i = 0; i < states.size(); ++i) {
		if (Data::states[i].priority <= sig_state->priority - 10) {
			states[i] = 0;
		}
	}

	if (IsDefending() && GetSignificantRestriction() != RPG::State::Restriction_normal) {
		SetIsDefending(false);
	}
}
Esempio n. 12
0
void CGameServerPlayer::SpawnNpc(uint32 id, uint32 appearanceId, uint32 stringId, float x, float y, float z, float angle)
{
	PacketData outgoingPacket(std::begin(g_spawnNpc), std::end(g_spawnNpc));

	uint32 packetIndex = 0x10;
	while(packetIndex < outgoingPacket.size())
	{
		auto packetPtr = outgoingPacket.data() + packetIndex;
		uint16 subPacketSize = *reinterpret_cast<uint16*>(packetPtr + 0x00);
		uint16 subPacketCmd = *reinterpret_cast<uint16*>(packetPtr + 0x12);
		*reinterpret_cast<uint32*>(packetPtr + 0x4) = id;
		if(subPacketCmd == 0xCE || subPacketCmd == 0xCF)
		{
			*reinterpret_cast<float*>(packetPtr + 0x28) = x;
			*reinterpret_cast<float*>(packetPtr + 0x2C) = y;
			*reinterpret_cast<float*>(packetPtr + 0x30) = z;
			*reinterpret_cast<float*>(packetPtr + 0x34) = angle;
		}
		else if(subPacketCmd == 0xCC)
		{
			static int magicNumber = 0;
			*reinterpret_cast<uint8*>(packetPtr + 0x40) = 0x30 + magicNumber;
			magicNumber++;
		}
		else if(subPacketCmd == 0xD6)
		{
			*reinterpret_cast<uint32*>(packetPtr + 0x20) = appearanceId;
		}
		else if(subPacketCmd == 0x13D)
		{
			*reinterpret_cast<uint32*>(packetPtr + 0x20) = stringId;
		}
		packetIndex += subPacketSize;
	}
	assert(packetIndex == outgoingPacket.size());

	{
		auto enemyActor = std::make_unique<CEnemyActor>();
		enemyActor->GlobalPacketReady.connect([&] (CActor* actor, const PacketPtr& packet) { QueueToCurrentComposite(actor, packet); });
		enemyActor->SetId(id);
		enemyActor->SetHp(ENEMY_INITIAL_HP);
		m_instance.AddActor(std::move(enemyActor));
	}

	QueuePacket(outgoingPacket);
}
Esempio n. 13
0
void Game_Battler::RemoveState(int state_id) {
	const RPG::State* state = ReaderUtil::GetElement(Data::states, state_id);
	if (!state) {
		Output::Warning("RemoveState: Can't delete state with invalid ID %d", state_id);
		return;
	}

	std::vector<int16_t>& states = GetStates();
	if (state_id - 1 >= static_cast<int>(states.size())) {
		return;
	}

	if (state_id == 1 && IsDead()) {
		SetHp(1);
	}

	states[state_id - 1] = 0;
}
Esempio n. 14
0
void Game_Actor::Init() {
	const std::vector<RPG::Learning>& skills = GetActor().skills;
	for (int i = 0; i < (int)skills.size(); i++) {
		if (skills[i].level <= GetLevel()) {
			LearnSkill(skills[i].skill_id);
		}
	}

	RemoveInvalidData();

	if (GetLevel() > 0) {
		SetHp(GetMaxHp());
		SetSp(GetMaxSp());
		SetExp(exp_list[GetLevel() - 1]);
	}

	AddEquipmentStates();
}
Esempio n. 15
0
Character::Character(std::string name, std::string lastname, std::string race, std::string gender, 
                     std::string face, std::string skin, std::string zone, int level, int hp, 
                     int maxHp, int bp, int maxBp, int mp, int maxMp, int ep, int maxEp, 
                     int strength, int constitution, int intelligence, int dexterity, float x, 
                     float y, float z, float pitch, float yaw) {
    SetName(name);
    SetLastname(lastname);
    SetRace(race);
    SetGender(gender);
    SetFace(face);
    SetSkin(skin);
    SetZone(zone);
    SetHead("head");
    SetChest("chest");
    SetArms("arms");
    SetHands("hands");
    SetLegs("legs");
    SetFeet("feet");
    SetCloak("cloak");
    SetNecklace("necklace");
    SetRingOne("ringOne");
    SetRingTwo("ringTwo");
    SetRightHand("rightHand");
    SetLeftHand("leftHand");
    SetLevel(level);
    SetHp(hp);
    SetMaxHp(maxHp);
    SetBp(bp);
    SetMaxBp(maxBp);
    SetMp(mp);
    SetMaxMp(maxMp);
    SetEp(ep);
    SetMaxEp(maxEp);
    SetStrength(strength);
    SetConstitution(constitution);
    SetIntelligence(intelligence);
    SetDexterity(dexterity);
    SetX(x);
    SetY(y);
    SetZ(z);
    SetPitch(pitch);
    SetYaw(yaw);
}
Esempio n. 16
0
CMonster::CMonster(void)
{
	SetType(TYPE_MONSTER);
	//memset(&m_BaseProperty.dwHP, 0, sizeof(tagMPro)-sizeof(string));
	SetHp(0);

	//FADE IN
	//--------------07.12.6liuke------------------
	//m_bIsCanTalk = FALSE;
	m_strTitle="";				// Monster的称号
	m_strOrigName = "";			// 原始名
	m_lCreatorType = 0;			// 创建关联者的类型

	m_State[STATE_STEP].iState = STATE_STEP;				// 步骤
	m_State[STATE_TRACE].iState = STATE_TRACE;				// 追踪
	m_State[STATE_QUEST].iState = STATE_QUEST;				// 任务

	m_CreatorGuid = CGUID::GUID_INVALID;

	InitNameValueMap();
}
Esempio n. 17
0
bool Enemy::InitData(const string& name)
{
	EnemyInfo* info = PlaneManager::getInstance()->GetEnemyInfo(name);
	SetName(name);
	ChangeBulletType(info->bulletType);
	SetHpMax(info->hpMax);
	SetHp(GetHpMax());
	_duration = info->duration;
	_stayTime = info->stayTime;
	SetMoveSpeed(info->moveSpeed);
	_score = info->score;
	_itemID = info->itemID;
	switch (info->layer)
	{
	case 1:
		SetOrder(LAYER_ENEMY_1);
		break;
	case 2:
		SetOrder(LAYER_ENEMY_2);
		break;
	case 3:
		SetOrder(LAYER_ENEMY_3);
		break;
	default:
		SetOrder(LAYER_ENEMY_1);
		break;
	}
	ChangeMoveState(info->moveStateID);
	SetMoveEnable(true);


	if (InitWithFile(info->imgPath))
	{
		return true;
	}

	return false;
}
Esempio n. 18
0
void Game_Actor::SetBaseMaxHp(int maxhp) {
	int new_hp_mod = GetData().hp_mod + (maxhp - GetBaseMaxHp());
	GetData().hp_mod = new_hp_mod;

	SetHp(GetData().current_hp);
}
Esempio n. 19
0
void Game_Actor::SetBaseMaxHp(int maxhp) {
	data.hp_mod += maxhp - GetBaseMaxHp();
	SetHp(data.current_hp);
}
Esempio n. 20
0
void Game_Battler::ChangeHp(int hp) {
	SetHp(GetHp() + hp);
}
Esempio n. 21
0
bool CMonster::DecordFromDataBlock(DBReadSet& readDB,bool bExData /* = true */)
{
	CMoveShape::DecordFromDataBlock(readDB, bExData);

	DWORD	dwHp = readDB.GetDwordFromByteArray();
	DWORD	dwMaxHp = readDB.GetDwordFromByteArray();
	WORD	wClass = readDB.GetWordFromByteArray();
	WORD	wFigure = readDB.GetWordFromByteArray();
	DWORD	dwSounID = readDB.GetDwordFromByteArray();
	DWORD	dwNameColor = readDB.GetDwordFromByteArray();
	DWORD	dwHpBarColor = readDB.GetDwordFromByteArray();
	WORD	wLevel = readDB.GetWordFromByteArray();
	/*m_dwCollectID		= */readDB.GetDwordFromByteArray();
	//if( m_dwCollectID != 0 )
	//{

	//}

	/*m_bIsBeenCollect        = */(readDB.GetByteFromByteArray() == 0)?false : true;
	/*m_bCanBeenCollect		= */(readDB.GetByteFromByteArray() == 0)?false : true;

	//	SetMaxHp(dwMaxHp);
	SetHp(dwHp);
	//	SetClass((eClass)wClass);
	//	SetFigure(wFigure);
	//	SetLevel(wLevel);


	long lMonsterType = -1;
	WORD wIsCanTalk = 0;
	char str[512];
	memset(str,'\0',512);
	//原始名
	m_strOrigName = readDB.GetStringFromByteArray( str,512);
	lMonsterType = readDB.GetWordFromByteArray();
	wIsCanTalk = readDB.GetWordFromByteArray();
	/*wIcon = */readDB.GetWordFromByteArray();
	/*wColor = */readDB.GetWordFromByteArray();
	m_strTitle = readDB.GetStringFromByteArray( str,512);
	// 设置阻挡类型
	BYTE bBlockType = readDB.GetByteFromByteArray();
	SetBlockType(CRegion::eBLOCK(bBlockType));
	// 任务保护信息(类型和GUID)
	m_lCreatorType = readDB.GetLongFromByteArray();
	readDB.GetBufferFromByteArray(m_CreatorGuid);
	//
	// 国家ID
	//SetCountry(readDB.GetByteFromByteArray());
	readDB.GetByteFromByteArray();
	//转身速度
	readDB.GetFloatFromByteArray();
	// BOSS等级
	WORD wBossLevel = readDB.GetWordFromByteArray();
	//	SetBossLevel(wBossLevel);

	SeteNpcType(eNpcType(lMonsterType));
	SetIsCanTalk(wIsCanTalk);
	//////////////////////////////////////////////////////////////////////////
	//怪物多重血条
	long lBaseMaxHp = readDB.GetLongFromByteArray();
	long lSize = readDB.GetLongFromByteArray();
	for( int i=0;i<lSize;i++)
	{
		long lHpRange = readDB.GetLongFromByteArray();
	}

	//	this->m_bAppearanceSoundPlayed = false;
	return true;
}