mRows[i]->SetPosition(pos); } } mLastPoint = points[0]; return true; } /** * Clones the control and returns the new instance */ Control* Table::Clone() { Table* pTable = OTTER_NEW(Table, ()); memcpy((uint8*)pTable->GetData(), (uint8*)GetData(), sizeof(TableData)); ((ControlData*)pTable->GetData())->mID = GetParentView()->GenerateNewID(); mParent->AddControl(pTable); pTable->mEnableScrolling = this->mEnableScrolling; uint32 numRows = GetNumRows(); for(uint32 i = 0; i < numRows; i++) { pTable->AddRow((Row*)GetRow(i)->Clone()); } return pTable; } /* Draws the Table to screen
bool Game_Actor::IsSkillLearned(int skill_id) const { return std::find(GetData().skills.begin(), GetData().skills.end(), skill_id) != GetData().skills.end(); }
void Game_Actor::SetFace(const std::string& file_name, int index) { GetData().face_name.assign(file_name); GetData().face_id = index; }
void Game_Actor::SetBaseAgi(int agi) { int new_agility_mod = GetData().agility_mod + (agi - GetBaseAgi()); GetData().agility_mod = new_agility_mod; }
void Game_Actor::SetBattleRow(RowType battle_row) { GetData().row = int(battle_row); }
void Game_Actor::SetSp(int sp) { GetData().current_sp = min(max(sp, 0), GetMaxSp()); }
void Game_Actor::SetBaseDef(int def) { int new_defense_mod = GetData().defense_mod + (def - GetBaseDef()); GetData().defense_mod = new_defense_mod; }
void CMySuperGrid::HowToLoopThroughAllItems_that_has_a_checkmark_and_print_them_or_what_ever(CDC *pDC) { TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int cy = tm.tmHeight + tm.tmExternalLeading; int nLineY=0; nLineY+=cy; pDC->TextOut(10,nLineY,_T("GIVE ME A BREAK YOU KNOW PRINT PREVIEW IS NOT THE ISSUE HERE")); nLineY+=cy; nLineY+=cy; if(!GetItemCount()) return; int nIndex=0;//has to be the root if(nIndex!=-1) { //do a GetHeadPosition POSITION pos = GetRootHeadPosition(); while(pos != NULL) { CTreeItem *pParent = (CTreeItem*)GetNextRoot(pos); CTreeItem *pItem = pParent; CItemInfo* lp = GetData(pParent); if(lp->GetCheck())//very hard :)= { CString strData=lp->GetItemText(); strData+='\t'; nLineY+=cy; for(int nCol=0; nCol < lp->GetItemCount(); nCol++) { CString str = lp->GetSubItem(nCol); strData+=str; strData+='\t'; } pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0); nLineY+=cy; } //GetNext ....loop through all children for(;;) { CTreeItem *pCur = GetNext(pParent, pItem, TRUE, FALSE/*regardless of the item are hidden or not*/); if(!IsChildOf(pParent, pCur)) break; else if(pCur==pItem) break; CItemInfo* lp = GetData(pCur); if(lp->GetCheck()) { CString strData = lp->GetItemText(); strData+='\t'; for(int nCol=0; nCol < lp->GetItemCount(); nCol++) { CString str = lp->GetSubItem(nCol); strData+=str; strData+='\t'; } pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0); nLineY+=cy; } pItem=pCur; } }//while }//if }
//HOWTO: Search nodeptr that have a specific item and subitems also shows you how to select the node and delete it void CMySuperGrid::HowToSearch_I_am_using_hardcoded_values_here_cause_I_am_tired_now(void) { //one Item and two Subitems CTreeItem *pNode = Search(__T("Hello World"),_T("Happy"),_T("Programming"),NULL); if(pNode!=NULL) { CItemInfo *pInfo = GetData(pNode); AfxMessageBox(_T("Found Item ") + pInfo->GetItemText()); } else AfxMessageBox(_T("not found")); //one Item and one Subitem CTreeItem *pNode1 = Search(_T("Mission: Impossible"),_T("Allan Nielsen"),NULL); if(pNode1!=NULL) { CItemInfo *pInfo = GetData(pNode1); AfxMessageBox(_T("Found Item ") + pInfo->GetItemText()); } else AfxMessageBox(_T("not found")); //one Item and one Subitem CTreeItem *pNode2 = Search(_T("Training Agent"),_T("Mr. Bean"),NULL); if(pNode2!=NULL) { CItemInfo *pInfo = GetData(pNode2); AfxMessageBox(_T("Found Item") + pInfo->GetItemText()); } else AfxMessageBox(_T("not found")); CTreeItem *pNode3 = Search(_T("BC"),NULL); if(pNode3!=NULL) { CItemInfo *pInfo = GetData(pNode3); AfxMessageBox(_T("Found Item ") + pInfo->GetItemText()); int nIndex = SelectNode(pNode3); if(nIndex!=-1) if(AfxMessageBox(_T("Do you want to delete it"),MB_OKCANCEL)==IDOK) DeleteItemEx(pNode3, nIndex); } else AfxMessageBox(_T("not found")); CTreeItem *pItem = NULL; POSITION pos = GetRootHeadPosition(); while(pos != NULL) { CTreeItem * pRoot = (CTreeItem*)GetNextRoot(pos); pItem = SearchEx(pRoot, "AB"); if(pItem!=NULL) { CItemInfo *pInfo = GetData(pItem); AfxMessageBox(_T("Found Item ") + pInfo->GetItemText()); int nIndex = SelectNode(pItem); if(nIndex!=-1) if(AfxMessageBox(_T("Do you want to delete it"),MB_OKCANCEL)==IDOK) DeleteItemEx(pItem, nIndex); } } if( pItem == NULL ) AfxMessageBox(_T("not found")); }
void DataDeserializer::Deserialize<uint32_t>(uint32_t& value) { char data[4] = {0}; GetData(In, data, 4); value = MakeNumber<uint32_t>(data); }
void DataDeserializer::Deserialize<int64_t>(int64_t& value) { char data[8] = {0}; GetData(In, data, 8); value = MakeNumber<int64_t>(data); }
void DataDeserializer::Deserialize<int16_t>(int16_t& value) { char data[2] = {0}; GetData(In, data, 2); value = MakeWord<int16_t>(data[0], data[1]); }
void DataDeserializer::Deserialize<int8_t>(int8_t& value) { char data = 0; GetData(In, &data, 1); value = data; }
void DataDeserializer::Deserialize<uint8_t>(uint8_t& value) { char data = 0; GetData(In, &data, 1); value = static_cast<uint8_t>(data); }
void Game_Actor::SetBaseMaxSp(int maxsp) { int new_sp_mod = GetData().sp_mod + (maxsp - GetBaseMaxSp()); GetData().sp_mod = new_sp_mod; SetSp(GetData().current_sp); }
//this is just one way to search items...strItem must match and then all subitems must be //a match before returning the node //the search function here search all nodes regardless if collapsed or expanded CMySuperGrid::CTreeItem* CMySuperGrid::Search(CString strItem,...) { if(!GetItemCount()) return NULL; va_list args; va_start(args, strItem); int nCount=0; for(;;) { LPCTSTR lpsz = va_arg(args, LPCTSTR); if(lpsz==NULL) break; nCount++; } POSITION pos = GetRootHeadPosition(); while(pos != NULL) { CTreeItem *pParent = (CTreeItem*)GetNextRoot(pos); CTreeItem *pItem = pParent; CItemInfo* lp = GetData(pParent); CString strData = lp->GetItemText(); if(strData==strItem)//must be a match before going further...suit you self { va_start(args, strItem); int nResult=0; for(int i=0; i<nCount;i++) { LPCTSTR lpsz = va_arg(args, LPCTSTR); for(int nCol=0; nCol < lp->GetItemCount(); nCol++) { CString str = lp->GetSubItem(nCol); if(!str.CompareNoCase(lpsz)) { nResult++; break; } } } va_end(args); if(nCount==nResult)//all args was found return node return pParent; } //GetNext ....loop through all children for(;;) { CTreeItem *pCur = GetNext(pParent, pItem, TRUE, FALSE/*regardless of the item are hidden or not, set to TRUE if only visible items must be included in the search*/); if(!IsChildOf(pParent, pCur)) break; else if(pCur==pItem) break; CItemInfo* lp = GetData(pCur); CString strData = lp->GetItemText(); if(strData==strItem)//must be a match before going further { va_start(args, strItem); int nResult=0; for(int i=0; i<nCount;i++) { LPCTSTR lpsz = va_arg(args, LPCTSTR); for(int nCol=0; nCol < lp->GetItemCount(); nCol++) { CString str = lp->GetSubItem(nCol); if(!str.CompareNoCase(lpsz)) { nResult++; break; } } } va_end(args); if(nCount==nResult)//all args was found return node return pCur; } pItem=pCur;//next; } } return NULL; }
void Game_Actor::SetHp(int hp) { GetData().current_hp = min(max(hp, 0), GetMaxHp()); }
void instance_stratholme::Update(uint32 uiDiff) { if (m_uiBarthilasRunTimer) { if (m_uiBarthilasRunTimer <= uiDiff) { Creature* pBarthilas = GetSingleCreatureFromStorage(NPC_BARTHILAS); if (pBarthilas && pBarthilas->isAlive() && !pBarthilas->isInCombat()) pBarthilas->NearTeleportTo(aStratholmeLocation[1].m_fX, aStratholmeLocation[1].m_fY, aStratholmeLocation[1].m_fZ, aStratholmeLocation[1].m_fO); SetData(TYPE_BARTHILAS_RUN, DONE); m_uiBarthilasRunTimer = 0; } else m_uiBarthilasRunTimer -= uiDiff; } if (m_uiBaronRunTimer) { if (m_uiYellCounter == 0 && m_uiBaronRunTimer <= 10*MINUTE*IN_MILLISECONDS) { DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_10_MIN, NPC_BARON); ++m_uiYellCounter; } else if (m_uiYellCounter == 1 && m_uiBaronRunTimer <= 5*MINUTE*IN_MILLISECONDS) { DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_5_MIN, NPC_BARON); ++m_uiYellCounter; } if (m_uiBaronRunTimer <= uiDiff) { SetData(TYPE_BARON_RUN, FAIL); DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_FAIL, NPC_BARON); m_uiBaronRunTimer = 0; debug_log("SD2: Instance Stratholme: Baron run event reached end. Event has state %u.", GetData(TYPE_BARON_RUN)); } else m_uiBaronRunTimer -= uiDiff; } if (m_uiMindlessSummonTimer) { if (m_uiMindlessCount < 30) { if (m_uiMindlessSummonTimer <= uiDiff) { if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON)) { // Summon mindless skeletons and move them to random point in the center of the square if (Creature* pTemp = pBaron->SummonCreature(NPC_MINDLESS_UNDEAD, aStratholmeLocation[4].m_fX, aStratholmeLocation[4].m_fY, aStratholmeLocation[4].m_fZ, aStratholmeLocation[4].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0)) { float fX, fY, fZ; pBaron->GetRandomPoint(aStratholmeLocation[5].m_fX, aStratholmeLocation[5].m_fY, aStratholmeLocation[5].m_fZ, 20.0f, fX, fY, fZ); pTemp->GetMotionMaster()->MovePoint(0, fX, fY, fZ); m_luiUndeadGUIDs.push_back(pTemp->GetObjectGuid()); ++m_uiMindlessCount; } } m_uiMindlessSummonTimer = 400; } else m_uiMindlessSummonTimer -= uiDiff; } else m_uiMindlessSummonTimer = 0; } if (m_uiSlaugtherSquareTimer) { if (m_uiSlaugtherSquareTimer <= uiDiff) { // Call next Abomnations for (GUIDSet::const_iterator itr = m_sAbomnationGUID.begin(); itr != m_sAbomnationGUID.end(); ++itr) { Creature* pAbom = instance->GetCreature(*itr); // Skip killed and already walking Abomnations if (!pAbom || !pAbom->isAlive() || pAbom->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) continue; // Let Move to somewhere in the middle if (!pAbom->isInCombat()) { if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_PORT_SLAUGTHER)) { float fX, fY, fZ; pAbom->GetRandomPoint(pDoor->GetPositionX(), pDoor->GetPositionY(), pDoor->GetPositionZ(), 10.0f, fX, fY, fZ); pAbom->GetMotionMaster()->MovePoint(0, fX, fY, fZ); } } break; } // TODO - how fast are they called? m_uiSlaugtherSquareTimer = urand(15000, 30000); } else m_uiSlaugtherSquareTimer -= uiDiff; } }
void Game_Actor::SetBaseAtk(int atk) { int new_attack_mod = GetData().attack_mod + (atk - GetBaseAtk()); GetData().attack_mod = new_attack_mod; }
void Game_Actor::SetName(const std::string &new_name) { GetData().name = new_name; }
void Game_Actor::SetBaseSpi(int spi) { int new_spirit_mod = GetData().spirit_mod + (spi - GetBaseSpi()); GetData().spirit_mod = new_spirit_mod; }
void Game_Actor::SetTitle(const std::string &new_title) { GetData().title = new_title; }
Game_Actor::RowType Game_Actor::GetBattleRow() const { return RowType(GetData().row); }
void Game_Actor::SetSprite(const std::string &file, int index, bool transparent) { GetData().sprite_name = file; GetData().sprite_id = index; GetData().sprite_flags = transparent ? 3 : 0; }
void Game_Actor::RemoveInvalidData() { /* The following actor data is cleaned up: - Invalid equipment is removed - An invalid class is removed - Invalid states are removed - Level is between 0 and 99, and does not exceed MaxLevel For "external data" (not from LCF Actor or LSD SaveActor) the data is verified in the corresponding functions. */ // Filter out invalid equipment int eq_types[] = { RPG::Item::Type_weapon, HasTwoWeapons() ? RPG::Item::Type_weapon : RPG::Item::Type_shield, RPG::Item::Type_armor, RPG::Item::Type_helmet, RPG::Item::Type_accessory }; auto& equipment = GetWholeEquipment(); for (size_t i = 0; i < equipment.size(); ++i) { int eq_id = equipment[i]; RPG::Item* item = ReaderUtil::GetElement(Data::items, eq_id); if (!item && eq_id != 0) { Output::Debug("Actor %d: Removing invalid item %d from equipment slot %d", GetId(), eq_id, eq_types[i]); SetEquipment(i + 1, 0); } else if (item && item->type != eq_types[i]) { Output::Debug("Actor %d: Removing item %d (of type %d) from equipment slot %d (needs type %d)", GetId(), item->ID, item->type, i + 1, eq_types[i]); SetEquipment(i + 1, 0); } else if (item && !IsItemUsable(item->ID)) { Output::Debug("Actor %d: Removing item %d from equipment slot %d (Not equippable by this actor)", GetId(), item->ID, i + 1); SetEquipment(i + 1, 0); } } // Remove invalid class if (GetData().class_id > 0) { const RPG::Class* cls = ReaderUtil::GetElement(Data::classes, GetData().class_id); if (!cls) { Output::Warning("Actor %d: Removing invalid class %d", GetId(), GetData().class_id); SetClass(0); } } // Remove invalid skills for (int16_t skill_id : GetSkills()) { const RPG::Skill* skill = ReaderUtil::GetElement(Data::skills, skill_id); if (!skill) { Output::Warning("Actor %d: Removing invalid skill %d", GetId(), skill_id); UnlearnSkill(skill_id); } } // Remove invalid states if (GetStates().size() > Data::states.size()) { Output::Warning("Actor %d: State array contains invalid states (%d > %d)", GetId(), GetStates().size(), Data::states.size()); GetStates().resize(Data::states.size()); } // Remove invalid levels // Special handling for the game COLORS: Lost Memories which uses level 0 // through database editing. Hopefully no game uses negative levels. if (GetLevel() == 0) { Output::Debug("Actor %d: Special handling for level 0", GetId()); } else if (GetLevel() < 0) { Output::Warning("Actor %d: Invalid level %d, changed to 1", GetId(), GetLevel()); SetLevel(1); } else if (GetLevel() > GetMaxLevel()) { Output::Warning("Actor %d: Invalid level %d, changed to %d", GetId(), GetLevel(), GetMaxLevel()); SetLevel(GetMaxLevel()); } }
void Game_Actor::SetClass(int _class_id) { if (_class_id != 0) { const RPG::Class* cls = ReaderUtil::GetElement(Data::classes, _class_id); if (!cls) { Output::Warning("Actor %d: Can't change to invalid class %d", GetId(), _class_id); return; } } GetData().class_id = _class_id; GetData().changed_battle_commands = true; // Any change counts as a battle commands change. // The class settings are not applied when the actor has a class on startup // but only when the "Change Class" event command is used. if (_class_id > 0) { GetData().super_guard = GetClass()->super_guard; GetData().lock_equipment = GetClass()->lock_equipment; GetData().two_weapon = GetClass()->two_weapon; GetData().auto_battle = GetClass()->auto_battle; GetData().battler_animation = GetClass()->battler_animation; GetData().battle_commands = GetClass()->battle_commands; } else { GetData().super_guard = GetActor().super_guard; GetData().lock_equipment = GetActor().lock_equipment; GetData().two_weapon = GetActor().two_weapon; GetData().auto_battle = GetActor().auto_battle; GetData().battler_animation = 0; GetData().battle_commands = GetActor().battle_commands; } MakeExpList(); // Set EXP to at least minimum value if (GetExp() < GetBaseExp()) { SetExp(GetBaseExp()); } }
void Game_Actor::UnlearnAllSkills() { GetData().skills.clear(); GetData().skills_size = 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); }
const std::vector<int16_t>& Game_Actor::GetWholeEquipment() const { return GetData().equipped; }
void Update(uint32 diff) { if (!instance->HavePlayers()) return; // portals should spawn if other portal is dead and doors are closed if (bActive && uiMainEventPhase == IN_PROGRESS) { if (uiActivationTimer < diff) { AddWave(); bActive = false; uiActivationTimer = 5000; } else uiActivationTimer -= diff; } // if main event is in progress and players have wiped then reset instance if ( uiMainEventPhase == IN_PROGRESS && CheckWipe()) { SetData(DATA_REMOVE_NPC, 1); StartBossEncounter(uiFirstBoss, false); StartBossEncounter(uiSecondBoss, false); SetData(DATA_MAIN_DOOR,GO_STATE_ACTIVE); SetData(DATA_WAVE_COUNT, 0); uiMainEventPhase = NOT_STARTED; if (Creature* pSinclari = instance->GetCreature(uiSinclari)) { pSinclari->SetVisible(true); std::list<Creature*> GuardList; pSinclari->GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f); if (!GuardList.empty()) { for (std::list<Creature*>::const_iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr) { if (Creature* pGuard = *itr) { pGuard->SetVisible(true); pGuard->SetReactState(REACT_AGGRESSIVE); pGuard->GetMotionMaster()->MovePoint(1,pGuard->GetHomePosition()); } } } pSinclari->GetMotionMaster()->MovePoint(1,pSinclari->GetHomePosition()); pSinclari->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE); } } // Cyanigosa is spawned but not tranformed, prefight event Creature* pCyanigosa = instance->GetCreature(uiCyanigosa); if (pCyanigosa && !pCyanigosa->HasAura(CYANIGOSA_SPELL_TRANSFORM)) { if (uiCyanigosaEventTimer <= diff) { switch(uiCyanigosaEventPhase) { case 1: pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false); DoScriptText(CYANIGOSA_SAY_SPAWN, pCyanigosa); uiCyanigosaEventTimer = 7*IN_MILLISECONDS; ++uiCyanigosaEventPhase; break; case 2: pCyanigosa->GetMotionMaster()->MoveJump(MiddleRoomLocation.GetPositionX(), MiddleRoomLocation.GetPositionY(), MiddleRoomLocation.GetPositionZ(), 10.0f, 20.0f); pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false); uiCyanigosaEventTimer = 7*IN_MILLISECONDS; ++uiCyanigosaEventPhase; break; case 3: pCyanigosa->RemoveAurasDueToSpell(CYANIGOSA_BLUE_AURA); pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_SPELL_TRANSFORM, 0); pCyanigosa->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); pCyanigosa->SetReactState(REACT_AGGRESSIVE); uiCyanigosaEventTimer = 2*IN_MILLISECONDS; ++uiCyanigosaEventPhase; break; case 4: uiCyanigosaEventPhase = 0; break; } } else uiCyanigosaEventTimer -= diff; } // if there are NPCs in front of the prison door, which are casting the door seal spell and doors are active if (GetData(DATA_NPC_PRESENCE_AT_DOOR) && uiMainEventPhase == IN_PROGRESS) { // if door integrity is > 0 then decrase it's integrity state if(GetData(DATA_DOOR_INTEGRITY)) { if(uiDoorSpellTimer < diff) { SetData(DATA_DOOR_INTEGRITY,GetData(DATA_DOOR_INTEGRITY)-1); uiDoorSpellTimer =2000; } else uiDoorSpellTimer -= diff; } // else set door state to active (means door will open and group have failed to sustain mob invasion on the door) else { SetData(DATA_MAIN_DOOR,GO_STATE_ACTIVE); uiMainEventPhase = FAIL; DespawnInvadersInVioletHold(instance->GetCreature(uiSinclari)); } } }