bool CChar::Use_Seed( CItem * pSeed, CPointMap * pPoint ) { ADDTOCALLSTACK("CChar::Use_Seed"); // Use the seed at the current point on the ground or some new point that i can touch. // IT_SEED from IT_FRUIT ASSERT(pSeed); CPointMap pt; if ( pPoint ) pt = *pPoint; else if ( pSeed->IsTopLevel() ) pt = pSeed->GetTopPoint(); else pt = GetTopPoint(); if ( !CanTouch(pt) ) { SysMessageDefault(DEFMSG_MSG_SEED_REACH); return false; } // is there soil here ? IT_DIRT if ( !IsPriv(PRIV_GM) && !g_World.IsItemTypeNear(pt, IT_DIRT, 0, false) ) { SysMessageDefault(DEFMSG_MSG_SEED_TARGSOIL); return(false); } const CItemBase *pItemDef = pSeed->Item_GetDef(); ITEMID_TYPE idReset = static_cast<ITEMID_TYPE>(RES_GET_INDEX(pItemDef->m_ttFruit.m_idReset)); if ( idReset == 0 ) { SysMessageDefault(DEFMSG_MSG_SEED_NOGOOD); return false; } // Already a plant here ? CWorldSearch AreaItems(pt); for (;;) { CItem *pItem = AreaItems.GetItem(); if ( !pItem ) break; if ( pItem->IsType(IT_TREE) || pItem->IsType(IT_FOLIAGE) ) // there's already a tree here { SysMessageDefault(DEFMSG_MSG_SEED_ATREE); return false; } if ( pItem->IsType(IT_CROPS) ) // there's already a plant here pItem->Delete(); } // plant it and consume the seed. CItem *pPlant = CItem::CreateScript(idReset, this); ASSERT(pPlant); pPlant->MoveToUpdate(pt); if ( pPlant->IsType(IT_CROPS) || pPlant->IsType(IT_FOLIAGE) ) { pPlant->m_itCrop.m_ReapFruitID = pSeed->GetID(); pPlant->Plant_CropReset(); } else { pPlant->SetDecayTime(10 * g_Cfg.m_iDecay_Item); } pSeed->ConsumeAmount(); return true; }
void CLaserBeam::UpdateLaser(const CLaserBeam::SLaserUpdateDesc& laserUpdateDesc) { if(m_pLaserParams && m_laserOn) { IEntity* pLaserEntity = CreateLaserEntity(); if (pLaserEntity) { m_lastLaserUpdatePosition = laserUpdateDesc.m_laserPos; m_lastLaserUpdateDirection = laserUpdateDesc.m_laserDir; m_laserUpdateTimer += laserUpdateDesc.m_frameTime; UpdateLaserGeometry(*pLaserEntity); if(m_laserUpdateTimer < LASER_UPDATE_TIME) return; m_laserUpdateTimer = Random(0.0f, LASER_UPDATE_TIME * 0.4f); if ((laserUpdateDesc.m_ownerCloaked && !laserUpdateDesc.m_weaponZoomed) || laserUpdateDesc.m_bOwnerHidden) { pLaserEntity->Hide(true); return; } pLaserEntity->Hide(false); const float range = m_pLaserParams->laser_range[GetIndexFromGeometrySlot()]; // Use the same flags as the AI system uses for visbility. const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living; const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit); //If we did not get a result, just cancel it, we will queue a new one again RayCastRequest::Priority requestPriority = RayCastRequest::MediumPriority; if (m_queuedRayId != 0) { g_pGame->GetRayCaster().Cancel(m_queuedRayId); m_queuedRayId = 0; requestPriority = RayCastRequest::HighPriority; } IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem(); IPhysicalEntity* pSkipEntity = NULL; uint8 numSkips = 0; CItem* pItem = static_cast<CItem*>(pItemSystem->GetItem(m_ownerEntityId)); if(pItem) { if(pItem->IsAccessory()) { CItem* pParentItem = static_cast<CItem*>(pItemSystem->GetItem(pItem->GetParentId())); if(pParentItem) { pItem = pParentItem; } } IEntity* pOwnerEnt = 0; CWeapon* pWeapon = static_cast<CWeapon*>(pItem->GetIWeapon()); if (pWeapon && pWeapon->GetHostId() != 0) { pOwnerEnt = gEnv->pEntitySystem->GetEntity(pWeapon->GetHostId()); } else { pOwnerEnt = pItem->GetOwner(); } if(pOwnerEnt) { IPhysicalEntity* pOwnerPhysics = pOwnerEnt->GetPhysics(); if(pOwnerPhysics) { pSkipEntity = pOwnerPhysics; numSkips++; } } } m_queuedRayId = g_pGame->GetRayCaster().Queue( requestPriority, RayCastRequest(laserUpdateDesc.m_laserPos, laserUpdateDesc.m_laserDir*range, objects, flags, &pSkipEntity, numSkips), functor(*this, &CLaserBeam::OnRayCastDataReceived)); } } else if (!m_pLaserParams) { GameWarning("LASER PARAMS: Item of type CLaser is missing it's laser params!"); } }
void ClassCalc::GetAttackDamage(LPOBJ lpUser) { #if (ENABLETEST_ZTLUA == 1) ZTLuaManager* LuaMng = new ZTLuaManager(FILE_LUA_CHARACTERBASICS); ZTLuaUnit::Bind(LuaMng->getLua()); ZTLuaItem::Bind(LuaMng->getLua()); LuaMng->Call("setAttackDamage", lpUser->m_Index); ZTLuaManager::Delete(LuaMng); #else CItem* Right = &lpUser->pInventory[0]; CItem* Left = &lpUser->pInventory[1]; int Strength = lpUser->Strength + lpUser->AddStrength; int Dexterity = lpUser->Dexterity + lpUser->AddDexterity; int Vitality = lpUser->Vitality + lpUser->AddVitality; int Energy = lpUser->Energy + lpUser->AddEnergy; WORD Class = lpUser->Class; // ---- if( Class == CLASS_WIZARD || Class == CLASS_KNIGHT ) { lpUser->m_AttackDamageMinRight = Strength / this->m_Data[Class].AttackDamageMinRightDiv1; lpUser->m_AttackDamageMaxRight = Strength / this->m_Data[Class].AttackDamageMaxRightDiv1; lpUser->m_AttackDamageMinLeft = Strength / this->m_Data[Class].AttackDamageMinLeftDiv1; lpUser->m_AttackDamageMaxLeft = Strength / this->m_Data[Class].AttackDamageMaxLeftDiv1; } else if( Class == CLASS_ELF ) { if( (Right->m_Type >= ITEMGET(4,8) && Right->m_Type < ITEMGET(4,15) ) || (Left->m_Type >= ITEMGET(4,0) && Left->m_Type < ITEMGET(4,7)) || Right->m_Type == ITEMGET(4,16) || Left->m_Type == ITEMGET(4,17) || Right->m_Type == ITEMGET(4,18) || Right->m_Type == ITEMGET(4,19) || Left->m_Type == ITEMGET(4,20) || Left->m_Type == ITEMGET(4,21) || Left->m_Type == ITEMGET(4,22) || Left->m_Type == ITEMGET(4,23) || Left->m_Type == ITEMGET(4,24) || Left->m_Type == ITEMGET(4,25) || Right->m_Type == ITEMGET(4,26) || Left->m_Type == ITEMGET(4,27)) { if( (Right->IsItem() && !Right->m_IsValidItem) || (Left->IsItem() && !Left->m_IsValidItem) ) { lpUser->m_AttackDamageMinRight = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMinRightDiv3; lpUser->m_AttackDamageMaxRight = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMaxRightDiv3; lpUser->m_AttackDamageMinLeft = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMinLeftDiv3; lpUser->m_AttackDamageMaxLeft = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMaxLeftDiv3; } else { lpUser->m_AttackDamageMinRight = (Dexterity / this->m_Data[Class].AttackDamageMinRightDiv1) + (Strength / this->m_Data[Class].AttackDamageMinRightDiv2); lpUser->m_AttackDamageMaxRight = (Dexterity / this->m_Data[Class].AttackDamageMaxRightDiv1) + (Strength / this->m_Data[Class].AttackDamageMaxRightDiv2); lpUser->m_AttackDamageMinLeft = (Dexterity / this->m_Data[Class].AttackDamageMinLeftDiv1) + (Strength / this->m_Data[Class].AttackDamageMinLeftDiv2); lpUser->m_AttackDamageMaxLeft = (Dexterity / this->m_Data[Class].AttackDamageMaxLeftDiv1) + (Strength / this->m_Data[Class].AttackDamageMaxLeftDiv2); } } else { lpUser->m_AttackDamageMinRight = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMinRightDiv3; lpUser->m_AttackDamageMaxRight = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMaxRightDiv3; lpUser->m_AttackDamageMinLeft = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMinLeftDiv3; lpUser->m_AttackDamageMaxLeft = (Dexterity + Strength) / this->m_Data[Class].AttackDamageMaxLeftDiv3; } } else if( Class == CLASS_MAGUMSA || Class == CLASS_DARKLORD ) { lpUser->m_AttackDamageMinRight = (Strength / this->m_Data[Class].AttackDamageMinRightDiv1) + (Energy / this->m_Data[Class].AttackDamageMinRightDiv2); lpUser->m_AttackDamageMaxRight = (Strength / this->m_Data[Class].AttackDamageMaxRightDiv1) + (Energy / this->m_Data[Class].AttackDamageMaxRightDiv2); lpUser->m_AttackDamageMinLeft = (Strength / this->m_Data[Class].AttackDamageMinLeftDiv1) + (Energy / this->m_Data[Class].AttackDamageMinLeftDiv2); lpUser->m_AttackDamageMaxLeft = (Strength / this->m_Data[Class].AttackDamageMaxLeftDiv1) + (Energy / this->m_Data[Class].AttackDamageMaxLeftDiv2); } else if( Class == CLASS_SUMMONER ) { lpUser->m_AttackDamageMinRight = ((Strength + Dexterity) / this->m_Data[Class].AttackDamageMinRightDiv1); lpUser->m_AttackDamageMaxRight = ((Strength + Dexterity) / this->m_Data[Class].AttackDamageMaxRightDiv1); lpUser->m_AttackDamageMinLeft = ((Strength + Dexterity) / this->m_Data[Class].AttackDamageMinLeftDiv1); lpUser->m_AttackDamageMaxLeft = ((Strength + Dexterity) / this->m_Data[Class].AttackDamageMaxLeftDiv1); } else if( Class == CLASS_FIGHTER ) { lpUser->m_AttackDamageMinRight = Vitality / this->m_Data[Class].AttackDamageMinRightDiv1 + Strength / this->m_Data[Class].AttackDamageMinRightDiv2; lpUser->m_AttackDamageMaxRight = Vitality / this->m_Data[Class].AttackDamageMaxRightDiv1 + Strength / this->m_Data[Class].AttackDamageMaxRightDiv2; lpUser->m_AttackDamageMinLeft = Vitality / this->m_Data[Class].AttackDamageMinLeftDiv1 + Strength / this->m_Data[Class].AttackDamageMinLeftDiv2; lpUser->m_AttackDamageMaxLeft = Vitality / this->m_Data[Class].AttackDamageMaxLeftDiv1 + Strength / this->m_Data[Class].AttackDamageMaxLeftDiv2; } else { lpUser->m_AttackDamageMinRight = Strength / 8; lpUser->m_AttackDamageMaxRight = Strength / 4; lpUser->m_AttackDamageMinLeft = Strength / 8; lpUser->m_AttackDamageMaxLeft = Strength / 4; } #endif }
void CSeparateDlg::Update( CObservable* pObservable, CTObject* pObj ) { assert( pObservable ); assert( pObj && strcmp( pObj->toString() ,"Separate" ) == 0 ); if( pObj == NULL || strcmp( pObj->toString() ,"Separate" ) ) return; CTEventSeparate* pEvent = (CTEventSeparate*)pObj; switch( pEvent->GetID() ) { case CTEventSeparate::EID_REMOVE_MATERIAL_ITEM: ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 2: EID_REMOVE_MATERIAL_ITEM"); m_MaterialItemSlot.DetachIcon(); break; case CTEventSeparate::EID_SET_MATERIAL_ITEM: { CItem* pItem = pEvent->GetItem(); ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 1: EID_SET_MATERIAL_ITEM Item Type %i Item ID %i", pItem->GetType(), pItem->GetItemNo()); assert( pItem ); if( pItem ) m_MaterialItemSlot.AttachIcon( pItem->CreateItemIcon() ); break; } case CTEventSeparate::EID_REMOVE_OUTPUT_ITEM: { ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 4: EID_REMOVE_OUTPUT_ITEM"); int iIndex = pEvent->GetIndex(); //assert( iIndex >= 0 && iIndex < (int)m_OutputItemSlots.size() ); if( iIndex >= 0 && iIndex < (int)m_OutputItemSlots.size() ) m_OutputItemSlots[iIndex].DetachIcon(); break; } case CTEventSeparate::EID_SET_OUTPUT_ITEM: { ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 3: EID_SET_OUTPUT_ITEM"); int e = m_OutputItemSlots.size(); int iIndex = pEvent->GetIndex(); //assert( iIndex >= 0 && iIndex < (int)m_OutputItemSlots.size() ); if( iIndex >= 0 && iIndex < (int)m_OutputItemSlots.size() ) { CItem* pItem = pEvent->GetItem(); ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 3: EID_SET_OUTPUT_ITEM Item Type %i Item ID %i", pItem->GetType(), pItem->GetItemNo()); //assert( pItem && m_OutputItemSlots[iIndex].GetIcon() == NULL ); if( pItem && m_OutputItemSlots[iIndex].GetIcon() == NULL ) { m_OutputItemSlots[iIndex].AttachIcon( pItem->CreateItemIcon() ); } else if( pItem && m_OutputItemSlots[iIndex].GetIcon() != NULL) { m_OutputItemSlots[iIndex].DetachIcon(); m_OutputItemSlots[iIndex].AttachIcon( pItem->CreateItemIcon() ); } else { assert(" pItem && m_OutputItemSlots[iIndex].GetIcon() == NULL ?? "); //PY: Logically speaking, this can never happen unless it is simultaineously neither NULL or Not NULL. Duhh!! } } break; } case CTEventSeparate::EID_RECEIVE_RESULT: { ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Event 5: EID_RECEIVE_RESULT"); ChangeState( STATE_RESULT ); break; } default: { ClientLog (LOG_NORMAL, "CSeperateDlg::Update. Invalid Seperate Event"); assert( 0 && "Invalid Separate Event Type" ); } break; } }
int CUIHelper::CalcItemEntryHeight (CSpaceObject *pSource, const CItem &Item, const RECT &rcRect, DWORD dwOptions) const // CalcItemEntryHeight // // Computes the height necessary to paint the item entry. { const CVisualPalette &VI = m_HI.GetVisuals(); const CG16bitFont &LargeBold = VI.GetFont(fontLargeBold); const CG16bitFont &Medium = VI.GetFont(fontMedium); bool bNoIcon = ((dwOptions & OPTION_NO_ICON) == OPTION_NO_ICON); bool bTitle = ((dwOptions & OPTION_TITLE) == OPTION_TITLE); // Get the item CItemCtx Ctx(&Item, pSource); CItemType *pType = Item.GetType(); if (pType == NULL) return ITEM_DEFAULT_HEIGHT; // Compute the rect where the reference text will paint RECT rcDrawRect = rcRect; rcDrawRect.left += ITEM_TEXT_MARGIN_X; rcDrawRect.right -= ITEM_TEXT_MARGIN_X; if (!bNoIcon) rcDrawRect.left += ICON_WIDTH; int iLevel = pType->GetApparentLevel(); // Compute the height of the row int cyHeight = 0; // Account for margin cyHeight += ITEM_TEXT_MARGIN_Y; // Item title cyHeight += LargeBold.GetHeight(); if (bTitle) cyHeight += ITEM_TITLE_EXTRA_MARGIN; // Attributes TArray<SDisplayAttribute> Attribs; if (Item.GetDisplayAttributes(Ctx, &Attribs)) { int cyAttribs; FormatDisplayAttributes(Attribs, rcDrawRect, &cyAttribs); cyHeight += cyAttribs + ATTRIB_SPACING_Y; } // Reference CString sReference = pType->GetReference(Ctx); // If this is a weapon, then add room for the weapon damage if (Item.GetReferenceDamageType(pSource, -1, 0, NULL, NULL)) cyHeight += Medium.GetHeight(); // If this is armor or a shield, then add room for damage resistance else if (Item.GetReferenceDamageAdj(pSource, 0, NULL, NULL)) cyHeight += Medium.GetHeight(); // Measure the reference text int iLines; if (!sReference.IsBlank()) { iLines = Medium.BreakText(sReference, RectWidth(rcDrawRect), NULL, 0); cyHeight += iLines * Medium.GetHeight(); } // Measure the description CString sDesc = Item.GetDesc(); iLines = Medium.BreakText(sDesc, RectWidth(rcDrawRect), NULL, 0); cyHeight += iLines * Medium.GetHeight(); // Margin cyHeight += ITEM_TEXT_MARGIN_BOTTOM; // Done cyHeight = Max(ITEM_DEFAULT_HEIGHT, cyHeight); return cyHeight; }
BOOL CJewelOfHarmonySystem::StrengthenItemByJewelOfHarmony(LPOBJ lpObj, int source, int target) { if ( this->m_bSystemStrengthenItem == FALSE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 52)), lpObj->m_Index, 1); return FALSE; } if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( lpObj->pInventory[source].IsItem() == FALSE ) return FALSE; if ( lpObj->pInventory[target].IsItem() == FALSE ) return FALSE; CItem * pSource = &lpObj->pInventory[source]; CItem * pTarget = &lpObj->pInventory[target]; if ( this->IsStrengthenByJewelOfHarmony(pTarget) == TRUE ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Already Strengtened [%s][%s]", lpObj->AccountID, lpObj->Name); return FALSE; } if (pTarget->IsSetItem() == TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 44)), lpObj->m_Index, 1); CLog.LogAdd("[JewelOfHarmony][Strengten Item] SetItem not enable to Strengtened [%s][%s]", lpObj->AccountID, lpObj->Name); return FALSE; } int iItemType = this->_GetItemType(pTarget); if ( iItemType == JEWELOFHARMONY_ITEM_TYPE_NULL ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Invalid ItemType[%d]", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iItemType); return FALSE; } int iItemOption = this->_GetSelectRandomOption(pTarget, iItemType); if ( iItemOption == AT_JEWELOFHARMONY_NOT_STRENGTHEN_ITEM ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail - NOT OPTION [%s][%s] Name[%s] Type[%d] Serial[%d] ItemType[%d]", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iItemType); return FALSE; } int iItemOptionLevel = this->m_itemOption[iItemType][iItemOption].iRequireLevel; int iSuccessRate = rand() % 100; if ( iSuccessRate >= this->m_iRateStrengthenSuccess ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d)", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 45)), lpObj->m_Index, 1); return TRUE; } this->_MakeOption(pTarget, iItemOption, iItemOptionLevel); CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Success [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d) Option %d OptionLevel %d", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess, iItemOption, iItemOptionLevel); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 46)), lpObj->m_Index, 1); gObjMakePreviewCharSet(lpObj->m_Index); float levelitemdur = (float)ItemGetDurability(lpObj->pInventory[target].m_Type, lpObj->pInventory[target].m_Level, lpObj->pInventory[target].IsExtItem(), lpObj->pInventory[target].IsSetItem()); lpObj->pInventory[target].m_Durability = levelitemdur * lpObj->pInventory[target].m_Durability / lpObj->pInventory[target].m_BaseDurability; lpObj->pInventory[target].Convert(lpObj->pInventory[target].m_Type, lpObj->pInventory[target].m_Option1, lpObj->pInventory[target].m_Option2, lpObj->pInventory[target].m_Option3, lpObj->pInventory[target].m_NewOption, lpObj->pInventory[target].m_SetOption, lpObj->pInventory[target].m_ItemOptionEx,lpObj->pInventory[target].m_ItemSocket); return TRUE; }
// timer expired, should I grow? bool CItem::Plant_OnTick() { ADDTOCALLSTACK("CItem::Plant_OnTick"); ASSERT( IsType(IT_CROPS) || IsType(IT_FOLIAGE)); // If it is in a container, kill it. if ( !IsTopLevel()) { return false; } // Make sure the darn thing isn't moveable SetAttr(ATTR_MOVE_NEVER); Plant_SetTimer(); // No tree stuff below here if ( IsAttr(ATTR_INVIS)) // If it's invis, take care of it here and return { SetHue( HUE_DEFAULT ); ClrAttr(ATTR_INVIS); Update(); return true; } const CItemBase * pItemDef = Item_GetDef(); ITEMID_TYPE iGrowID = pItemDef->m_ttCrops.m_idGrow; if ( iGrowID == -1 ) { // Some plants generate a fruit on the ground when ripe. ITEMID_TYPE iFruitID = static_cast<ITEMID_TYPE>(RES_GET_INDEX(pItemDef->m_ttCrops.m_idGrow)); if ( m_itCrop.m_ReapFruitID ) { iFruitID = static_cast<ITEMID_TYPE>(RES_GET_INDEX(m_itCrop.m_ReapFruitID)); } if ( ! iFruitID ) { return( true ); } // put a fruit on the ground if not already here. CWorldSearch AreaItems( GetTopPoint() ); for (;;) { CItem * pItem = AreaItems.GetItem(); if ( pItem == NULL ) { CItem * pItemFruit = CItem::CreateScript( iFruitID ); ASSERT(pItemFruit); pItemFruit->MoveToDecay(GetTopPoint(),10*g_Cfg.m_iDecay_Item); break; } if ( pItem->IsType( IT_FRUIT ) || pItem->IsType( IT_REAGENT_RAW )) break; } // NOTE: ??? The plant should cycle here as well ! iGrowID = pItemDef->m_ttCrops.m_idReset; } if ( iGrowID > 0 ) { SetID(static_cast<ITEMID_TYPE>(RES_GET_INDEX(iGrowID))); Update(); return true; } // some plants go dormant again ? // m_itCrop.m_Fruit_ID = iTemp; return true; }
void CGItemListArea::PaintItem (CG16bitImage &Dest, const CItem &Item, const RECT &rcRect, bool bSelected) // PaintItem // // Paints the item { // Item context CItemCtx Ctx(&Item, m_pListData->GetSource()); CItemType *pItemType = Item.GetType(); // Paint the image DrawItemTypeIcon(Dest, rcRect.left, rcRect.top, pItemType); RECT rcDrawRect = rcRect; rcDrawRect.left += ICON_WIDTH + ITEM_TEXT_MARGIN_X; rcDrawRect.right -= ITEM_TEXT_MARGIN_X; rcDrawRect.top += ITEM_TEXT_MARGIN_Y; // Paint the attribute blocks RECT rcAttrib; rcAttrib = rcDrawRect; rcAttrib.bottom = rcAttrib.top + m_pFonts->MediumHeavyBold.GetHeight(); if (Item.IsDamaged()) PaintItemModifier(Dest, CONSTLIT("Damaged"), RGB_ILLEGAL_BACKGROUND, &rcAttrib); else if (Item.IsDisrupted()) PaintItemModifier(Dest, CONSTLIT("Ionized"), RGB_ILLEGAL_BACKGROUND, &rcAttrib); if (pItemType->IsKnown() && pItemType->HasAttribute(CONSTLIT("Military"))) PaintItemModifier(Dest, CONSTLIT("Military"), RGB_MILITARY_BACKGROUND, &rcAttrib); if (pItemType->IsKnown() && pItemType->HasAttribute(CONSTLIT("Illegal"))) PaintItemModifier(Dest, CONSTLIT("Illegal"), RGB_ILLEGAL_BACKGROUND, &rcAttrib); CString sEnhanced = Item.GetEnhancedDesc(m_pListData->GetSource()); if (!sEnhanced.IsBlank()) { bool bDisadvantage = (*(sEnhanced.GetASCIIZPointer()) == '-'); PaintItemModifier(Dest, sEnhanced, (bDisadvantage ? RGB_ILLEGAL_BACKGROUND : RGB_MILITARY_BACKGROUND), &rcAttrib); } // Paint the item name int cyHeight; RECT rcTitle = rcDrawRect; rcTitle.right = rcAttrib.right; m_pFonts->LargeBold.DrawText(Dest, rcTitle, m_pFonts->wItemTitle, Item.GetNounPhrase(nounCount | nounNoModifiers), 0, CG16bitFont::SmartQuotes | CG16bitFont::TruncateLine, &cyHeight); rcDrawRect.top += cyHeight; // Stats CString sStat; int iLevel = pItemType->GetApparentLevel(); CString sReference = pItemType->GetReference(Ctx); DamageTypes iDamageType; CString sDamageRef; int iDamageAdj[damageCount]; int iHP; if (Item.GetReferenceDamageType(m_pListData->GetSource(), -1, 0, &iDamageType, &sDamageRef)) { // Paint the initial text sStat = strPatternSubst("Level %s —", strLevel(iLevel)); int cxWidth = m_pFonts->Medium.MeasureText(sStat, &cyHeight); m_pFonts->Medium.DrawText(Dest, rcDrawRect, m_pFonts->wItemRef, sStat, 0, 0, &cyHeight); // Paint the damage type reference m_pUIRes->DrawReferenceDamageType(Dest, rcDrawRect.left + cxWidth + DAMAGE_ADJ_SPACING_X, rcDrawRect.top, iDamageType, sDamageRef); rcDrawRect.top += cyHeight; // Paint additional reference in the line below if (!sReference.IsBlank()) { m_pFonts->Medium.DrawText(Dest, rcDrawRect, m_pFonts->wItemRef, sReference, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } } else if (Item.GetReferenceDamageAdj(m_pListData->GetSource(), 0, &iHP, iDamageAdj)) { // Paint the initial text sStat = strPatternSubst("Level %s — hp: %d ", strLevel(iLevel), iHP); int cxWidth = m_pFonts->Medium.MeasureText(sStat, &cyHeight); m_pFonts->Medium.DrawText(Dest, rcDrawRect, m_pFonts->wItemRef, sStat, 0, 0, &cyHeight); // Paint the damage type array m_pUIRes->DrawReferenceDamageAdj(Dest, rcDrawRect.left + cxWidth + DAMAGE_ADJ_SPACING_X, rcDrawRect.top, iLevel, iHP, iDamageAdj); rcDrawRect.top += cyHeight; // Paint additional reference in the line below if (!sReference.IsBlank()) { m_pFonts->Medium.DrawText(Dest, rcDrawRect, m_pFonts->wItemRef, sReference, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } } else { if (sReference.IsBlank()) sStat = strPatternSubst("Level %s", strLevel(iLevel)); else sStat = strPatternSubst("Level %s — %s", strLevel(iLevel), sReference); m_pFonts->Medium.DrawText(Dest, rcDrawRect, m_pFonts->wItemRef, sStat, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } // Description CString sDesc = Item.GetDesc(); m_pFonts->Medium.DrawText(Dest, rcDrawRect, (bSelected ? m_pFonts->wItemDescSelected : m_pFonts->wItemDesc), sDesc, 0, CG16bitFont::SmartQuotes, &cyHeight); rcDrawRect.top += cyHeight; }
void ObjBotWarper::MakeBot() { if(this->Enabled == true) { for(int botNum=0;botNum<MAX_BOTWARPER;botNum++) { if(this->bot[botNum].Enabled == true) { int result = gObjAddCallMon(); if(result >= 0) { this->bot[botNum].index = result; gObj[result].m_PosNum = (WORD)-1; gObj[result].X = this->bot[botNum].X; gObj[result].Y = this->bot[botNum].Y; gObj[result].m_OldX = this->bot[botNum].X; gObj[result].m_OldY = this->bot[botNum].Y; gObj[result].TX = this->bot[botNum].X; gObj[result].TY = this->bot[botNum].Y; gObj[result].MTX = this->bot[botNum].X; gObj[result].MTY = this->bot[botNum].Y; gObj[result].Dir = this->bot[botNum].Dir; gObj[result].MapNumber = this->bot[botNum].Map; gObj[result].Live = TRUE; gObj[result].PathCount = 0; gObj[result].IsBot = 10; gObjSetMonster(result,this->bot[botNum].Class,"PetBot"); gObj[result].ChangeUP = this->bot[botNum].Class & 0x07; // Set Second Type of Character gObj[result].Class = this->bot[botNum].Class; gObj[result].Level = 400; gObj[result].Life = 1; gObj[result].MaxLife = 2; gObj[result].Mana = 1; gObj[result].MaxMana = 2; gObj[result].Experience = 0; gObj[result].DbClass = this->bot[botNum].Class; gObj[result].pInventory = new CItem[INVENTORY_NORMAL_SIZE]; gObj[result].Inventory1 = new CItem[INVENTORY_NORMAL_SIZE]; gObj[result].InventoryMap1 = new BYTE[INVENTORY_NORMAL_SIZE]; gObj[result].pInventoryMap = new BYTE[INVENTORY_NORMAL_SIZE]; for (int i=0;i<INVENTORY_NORMAL_SIZE;i++) { gObj[result].pInventory[i].Clear(); gObj[result].Inventory1[i].Clear(); } memset(&gObj[result].pInventoryMap[0], (BYTE)-1, INVENTORY_NORMAL_SIZE); memset(&gObj[result].InventoryMap1[0], (BYTE)-1, INVENTORY_NORMAL_SIZE); strncpy(gObj[result].Name,this->bot[botNum].Name,sizeof(gObj[result].Name)); for(int i=0;i<9;i++) { if(this->bot[botNum].body[i].num >= 0 && this->bot[botNum].body[i].Enabled == true) { CItem item; item.m_Level = this->bot[botNum].body[i].level; item.m_SkillOption = 0; item.m_LuckOption = 1; item.m_Z28Option = this->bot[botNum].body[i].opt; item.m_Durability = 255.0f; item.m_JewelOfHarmonyOption = 0; item.m_ItemOptionEx = 0; item.m_ItemSlot1 = 0; item.m_ItemSlot2 = 0; item.m_ItemSlot3 = 0; item.m_ItemSlot4 = 0; item.m_ItemSlot5 = 0; item.Convert(this->bot[botNum].body[i].num,item.m_SkillOption,item.m_LuckOption,item.m_Z28Option,0,0,item.m_ItemOptionEx,3); gObj[result].pInventory[i].m_SkillOption = item.m_SkillOption; gObj[result].pInventory[i].m_LuckOption = item.m_LuckOption; gObj[result].pInventory[i].m_Z28Option = item.m_Z28Option; gObj[result].pInventory[i].m_JewelOfHarmonyOption = item.m_JewelOfHarmonyOption; gObj[result].pInventory[i].m_ItemOptionEx = item.m_ItemOptionEx; item.m_Number = 0; gObjInventoryInsertItemPos(gObj[result].m_Index,item,i,0); } } gObj[result].Inventory1 = gObj[result].pInventory; gObj[result].InventoryMap1 = gObj[result].pInventoryMap; gObjMakePreviewCharSet(result); gObj[result].m_AttackType = 0; gObj[result].BotSkillAttack = 0; gObj[result].m_Attribute = 100; gObj[result].TargetNumber = (WORD)-1; gObj[result].m_ActState.Emotion = 0; gObj[result].m_ActState.Attack = 0; gObj[result].m_ActState.EmotionCount = 0; gObj[result].PathCount = 0; gObj[result].BotPower = 0; gObj[result].BotDefense = this->bot[botNum].OnlyVip; gObj[result].BotLife = 1; gObj[result].BotMaxLife = 1; gObj[result].BotLvlUpDefense = 1; gObj[result].BotLvlUpPower = 1; gObj[result].BotLvlUpLife = 1; gObj[result].BotLvlUpMana = 1; gObj[result].BotLvlUpExp = 1; gObj[result].BotLvlUpMaxLevel = 1; gObj[result].m_MoveRange = 1; gObj[result].BotFollowMe = 0; gObj[result].NextExp = gLevelExperience[gObj[result].Level]; GCRecallMonLife(gObj[result].m_RecallMon,gObj[result].MaxLife,gObj[result].Life); ChatSend(&gObj[result],"I'll Warp you!"); GCActionSend(&gObj[result],AT_SALUTE1,result,result); } } } } }
bool CChar::Use_Item_Web( CItem * pItemWeb ) { ADDTOCALLSTACK("CChar::Use_Item_Web"); // IT_WEB // IT_EQ_STUCK // Try to break out of the web. // Or just try to damage it. // // RETURN: true = held in place. // false = walk thru it. if ( GetDispID() == CREID_GIANT_SPIDER || !pItemWeb || !pItemWeb->IsTopLevel() || IsStatFlag(STATF_DEAD|STATF_Insubstantial) || IsPriv(PRIV_GM) ) return false; // just walk through it // Try to break it. int iStr = pItemWeb->m_itWeb.m_Hits_Cur; if ( iStr == 0 ) iStr = pItemWeb->m_itWeb.m_Hits_Cur = 60 + Calc_GetRandVal(250); // Since broken webs become spider silk, we should get out of here now if we aren't in a web. CItem *pFlag = LayerFind(LAYER_FLAG_Stuck); if ( CanMove(pItemWeb, false) ) { if ( pFlag ) pFlag->Delete(); return false; } if ( pFlag ) { if ( pFlag->IsTimerSet() ) // don't allow me to try to damage it too often return true; } int iDmg = pItemWeb->OnTakeDamage(Stat_GetAdjusted(STAT_STR), this); switch ( iDmg ) { case 0: // damage blocked case 1: // web survived default: // unknown if ( GetTopPoint() == pItemWeb->GetTopPoint() ) // is character still stuck on the web? break; case 2: // web turned into silk case INT_MAX: // web destroyed if ( pFlag ) pFlag->Delete(); return false; } // Stuck in it still. if ( !pFlag ) { if ( iDmg < 0 ) return false; // First time message. pFlag = CItem::CreateBase(ITEMID_WEB1_1); ASSERT(pFlag); pFlag->SetAttr(ATTR_DECAY); pFlag->SetType(IT_EQ_STUCK); pFlag->m_uidLink = pItemWeb->GetUID(); pFlag->SetTimeout(pItemWeb->GetTimerDAdjusted()); LayerAdd(pFlag, LAYER_FLAG_Stuck); } else { if ( iDmg < 0 ) { pFlag->Delete(); return false; } SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SWEB_STUCK), pItemWeb->GetName()); } return true; }
void CShop::Load() { // Create a variable to store the item names char szName[MAX_PATH] = {0}; char szType[MAX_PATH] = {0}; // Open our info file in "read" mode. FILE *fp = fopen(kItemInfoFile, "r"); // Make sure we found the file, if not report the error if(!fp) { // Display an error message if we couldn't find the file MessageBox(NULL, "Unable to find items in the items file", "Error", MB_OK); return; } // Keep going through the file until we reach the end of it while(!feof(fp)) { CItem tempItem; // Create a temp item tile int life = 0, str = 0, protection = 0; // Create variables for read data and item's image CHAR_INFO image = {'I', FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE}; // Read in the current line for this item in the info file fscanf(fp, "%s > lifeInc: %d strengthInc: %d protectionInc: %d type: %s\n", szName, &life, &str, &protection, szType); // Set the info read in for this item tempItem.SetChar(image); tempItem.SetLifeInc(life); tempItem.SetStrengthInc(str); tempItem.SetProtectionInc(protection); tempItem.SetName(szName); // Let's grab the type of this item string strType = szType; int type = kItem; // Depending on the string read in, set the item's type if(strType == "head") type = kHead; else if(strType == "chest") type = kChest; else if(strType == "weapon") type = kWeapon; else if(strType == "feet") type = kFeet; // Set the numeric item type tempItem.SetItemType(type); // Set this tile type as an item tempItem.SetType(kItemType); // Here is where the random selection comes in. We give this item a %50 chance // of not being added to the shop keeper's list of items being sold. if(rand() % 3) m_vItems.push_back(tempItem); // Make sure that the size of our item list isn't over the maximum limit for shops if((int)m_vItems.size() >= kMaxShopKeeperInv) break; } // Close the file, a success! fclose(fp); }
bool CChar::Use_Train_ArcheryButte( CItem * pButte, bool fSetup ) { ADDTOCALLSTACK("CChar::Use_Train_ArcheryButte"); // IT_ARCHERY_BUTTE ASSERT(pButte); ITEMID_TYPE AmmoID; if ( GetDist(pButte) < 2 ) // if we are standing right next to the butte, retrieve the arrows/bolts { if ( pButte->m_itArcheryButte.m_AmmoCount == 0 ) { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_EMPTY); return true; } AmmoID = pButte->m_itArcheryButte.m_AmmoType; CItemBase *pAmmoDef = CItemBase::FindItemBase(AmmoID); if ( pAmmoDef ) { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_REM), pAmmoDef->GetName(), (pButte->m_itArcheryButte.m_AmmoCount == 1) ? "" : g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_REMS)); Emote(pszMsg); CItem *pRemovedAmmo = CItem::CreateBase(AmmoID); ASSERT(pRemovedAmmo); pRemovedAmmo->SetAmount(pButte->m_itArcheryButte.m_AmmoCount); ItemBounce(pRemovedAmmo); } // Clear the target pButte->m_itArcheryButte.m_AmmoType = ITEMID_NOTHING; pButte->m_itArcheryButte.m_AmmoCount = 0; return true; } SKILL_TYPE skill = Fight_GetWeaponSkill(); if ( !g_Cfg.IsSkillFlag(skill, SKF_RANGED) ) { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_WS); return true; } if ( Skill_GetBase(skill) > g_Cfg.m_iSkillPracticeMax ) { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_SKILL); return true; } // Make sure we have some ammo CItem *pWeapon = m_uidWeapon.ItemFind(); ASSERT(pWeapon); const CItemBase *pWeaponDef = pWeapon->Item_GetDef(); // Determine ammo type CVarDefCont *pVarAmmoType = pWeapon->GetDefKey("AMMOTYPE", true); RESOURCE_ID_BASE rid; LPCTSTR t_Str; if ( pVarAmmoType ) { t_Str = pVarAmmoType->GetValStr(); rid = static_cast<RESOURCE_ID_BASE>(g_Cfg.ResourceGetID(RES_ITEMDEF, t_Str)); } else { rid = pWeaponDef->m_ttWeaponBow.m_idAmmo; } AmmoID = static_cast<ITEMID_TYPE>(rid.GetResIndex()); // If there is a different ammo type on the butte currently, tell us to remove the current type first if ( (pButte->m_itArcheryButte.m_AmmoType != ITEMID_NOTHING) && (pButte->m_itArcheryButte.m_AmmoType != AmmoID) ) { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_X); return true; } // We need to be correctly aligned with the target before we can use it // For the south facing butte, we need to have the same X value and a Y > 2 // For the east facing butte, we need to have the same Y value and an X > 2 if ( !pButte->IsTopLevel() ) { badalign: SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_P); return true; } int targDistX = GetTopPoint().m_x - pButte->GetTopPoint().m_x; int targDistY = GetTopPoint().m_y - pButte->GetTopPoint().m_y; if ( (pButte->GetID() == ITEMID_ARCHERYBUTTE_S) || (pButte->GetID() == ITEMID_MONGBATTARGET_S) ) { if ( !(targDistX == 0 && targDistY > 2) ) goto badalign; } else { if ( !(targDistY == 0 && targDistX > 2) ) goto badalign; } if ( !CanSeeLOS(pButte, LOS_NB_WINDOWS) ) //we should be able to shoot through a window { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_BLOCK); return true; } if ( fSetup ) { if ( Skill_GetActive() == NPCACT_TRAINING ) return true; UpdateAnimate(ANIM_ATTACK_WEAPON); m_Act_TargPrv = m_uidWeapon; m_Act_Targ = pButte->GetUID(); Skill_Start(NPCACT_TRAINING); return true; } CVarDefCont *pCont = pWeapon->GetDefKey("AMMOCONT",true); if ( m_pPlayer && AmmoID ) { int iFound = 1; if ( pCont ) { //check for UID CGrayUID uidCont = static_cast<DWORD>(pCont->GetValNum()); CItemContainer *pNewCont = dynamic_cast<CItemContainer*>(uidCont.ItemFind()); if ( !pNewCont ) //if no UID, check for ITEMID_TYPE { t_Str = pCont->GetValStr(); RESOURCE_ID_BASE rContid = static_cast<RESOURCE_ID_BASE>(g_Cfg.ResourceGetID(RES_ITEMDEF, t_Str)); ITEMID_TYPE ContID = static_cast<ITEMID_TYPE>(rContid.GetResIndex()); if ( ContID ) pNewCont = dynamic_cast<CItemContainer*>(ContentFind(rContid)); } if ( pNewCont ) iFound = pNewCont->ContentConsume(RESOURCE_ID(RES_ITEMDEF, AmmoID)); else iFound = ContentConsume(RESOURCE_ID(RES_ITEMDEF, AmmoID)); } else iFound = ContentConsume(RESOURCE_ID(RES_ITEMDEF, AmmoID)); if ( iFound ) { SysMessageDefault(DEFMSG_ITEMUSE_ARCHB_NOAMMO); return(true); } } // OK...go ahead and fire at the target // Check the skill bool fSuccess = Skill_UseQuick(skill, Calc_GetRandLLVal(40)); // determine animation parameters CVarDefCont *pVarAnim = pWeapon->GetDefKey("AMMOANIM", true); CVarDefCont *pVarAnimColor = pWeapon->GetDefKey("AMMOANIMHUE", true); CVarDefCont *pVarAnimRender = pWeapon->GetDefKey("AMMOANIMRENDER", true); ITEMID_TYPE AmmoAnim; DWORD AmmoHue; DWORD AmmoRender; if ( pVarAnim ) { t_Str = pVarAnim->GetValStr(); rid = static_cast<RESOURCE_ID_BASE>(g_Cfg.ResourceGetID(RES_ITEMDEF, t_Str)); AmmoAnim = static_cast<ITEMID_TYPE>(rid.GetResIndex()); } else AmmoAnim = static_cast<ITEMID_TYPE>(pWeaponDef->m_ttWeaponBow.m_idAmmoX.GetResIndex()); AmmoHue = pVarAnimColor ? static_cast<DWORD>(pVarAnimColor->GetValNum()) : 0; AmmoRender = pVarAnimRender ? static_cast<DWORD>(pVarAnimRender->GetValNum()) : 0; pButte->Effect(EFFECT_BOLT, AmmoAnim, this, 16, 0, false, AmmoHue, AmmoRender); pButte->Sound(0x224); // Did we destroy the ammo? const CItemBase *pAmmoDef = NULL; if ( AmmoID ) pAmmoDef = CItemBase::FindItemBase(AmmoID); if ( !fSuccess ) { // Small chance of destroying the ammo if ( pAmmoDef && !Calc_GetRandVal(10) ) { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_DEST), pAmmoDef->GetName()); Emote(pszMsg, NULL, true); return true; } static LPCTSTR const sm_Txt_ArcheryButte_Failure[] = { g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_MISS_1), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_MISS_2), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_MISS_3), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_MISS_4) }; Emote(sm_Txt_ArcheryButte_Failure[Calc_GetRandVal(COUNTOF(sm_Txt_ArcheryButte_Failure))]); } else { // Very small chance of destroying another arrow if ( pAmmoDef && !Calc_GetRandVal(50) && pButte->m_itArcheryButte.m_AmmoCount ) { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_SPLIT), pAmmoDef->GetName()); Emote(pszMsg, NULL, true); return true; } static LPCTSTR const sm_Txt_ArcheryButte_Success[] = { g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_HIT_1), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_HIT_2), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_HIT_3), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_ARCHB_HIT_4) }; Emote(sm_Txt_ArcheryButte_Success[Calc_GetRandVal(COUNTOF(sm_Txt_ArcheryButte_Success))]); } // Update the target if ( AmmoID ) { pButte->m_itArcheryButte.m_AmmoType = AmmoID; pButte->m_itArcheryButte.m_AmmoCount++; } return true; }
void CChar::Use_CarveCorpse( CItemCorpse * pCorpse ) { ADDTOCALLSTACK("CChar::Use_CarveCorpse"); CREID_TYPE CorpseID = pCorpse->m_itCorpse.m_BaseID; CCharBase *pCorpseDef = CCharBase::FindCharBase(CorpseID); if ( !pCorpseDef || pCorpse->m_itCorpse.m_carved ) { SysMessageDefault(DEFMSG_CARVE_CORPSE_NOTHING); return; } CChar *pChar = pCorpse->m_uidLink.CharFind(); CPointMap pnt = pCorpse->GetTopLevelObj()->GetTopPoint(); UpdateAnimate(ANIM_BOW); if ( pCorpse->m_TagDefs.GetKeyNum("BLOOD", true) ) { CItem *pBlood = CItem::CreateBase(ITEMID_BLOOD4); ASSERT(pBlood); pBlood->SetHue(pCorpseDef->m_wBloodHue); pBlood->MoveToDecay(pnt, 5 * TICK_PER_SEC); } size_t iItems = 0; for ( size_t i = 0; i < pCorpseDef->m_BaseResources.GetCount(); i++ ) { long long iQty = pCorpseDef->m_BaseResources[i].GetResQty(); RESOURCE_ID rid = pCorpseDef->m_BaseResources[i].GetResourceID(); if ( rid.GetResType() != RES_ITEMDEF ) continue; ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex()); if ( id == ITEMID_NOTHING ) break; iItems++; CItem *pPart = CItem::CreateTemplate(id, NULL, this); ASSERT(pPart); switch ( pPart->GetType() ) { case IT_FOOD: case IT_FOOD_RAW: case IT_MEAT_RAW: SysMessageDefault(DEFMSG_CARVE_CORPSE_MEAT); //pPart->m_itFood.m_MeatType = CorpseID; break; case IT_HIDE: SysMessageDefault(DEFMSG_CARVE_CORPSE_HIDES); //pPart->m_itSkin.m_creid = CorpseID; if ( (g_Cfg.m_iRacialFlags & RACIALF_HUMAN_WORKHORSE) && IsHuman() ) // humans always find 10% bonus when gathering hides, ores and logs (Workhorse racial trait) iQty = iQty * 110 / 100; break; case IT_FEATHER: SysMessageDefault(DEFMSG_CARVE_CORPSE_FEATHERS); //pPart->m_itSkin.m_creid = CorpseID; break; case IT_WOOL: SysMessageDefault(DEFMSG_CARVE_CORPSE_WOOL); //pPart->m_itSkin.m_creid = CorpseID; break; /*case IT_DRAGON_SCALE: // TO-DO (typedef IT_DRAGON_SCALE doesn't exist yet) SysMessageDefault(DEFMSG_CARVE_CORPSE_SCALES); //pPart->m_itSkin.m_creid = CorpseID; break;*/ default: break; } if ( iQty > 1 ) pPart->SetAmount(static_cast<unsigned int>(iQty)); if ( pChar && pChar->m_pPlayer ) { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_CORPSE_NAME), pPart->GetName(), pChar->GetName()); pPart->SetName(pszMsg); pPart->m_uidLink = pChar->GetUID(); pPart->MoveToDecay(pnt, pPart->GetDecayTime()); continue; } pCorpse->ContentAdd(pPart); } if ( iItems < 1 ) SysMessageDefault(DEFMSG_CARVE_CORPSE_NOTHING); CheckCorpseCrime(pCorpse, false, false); pCorpse->m_itCorpse.m_carved = 1; // mark as been carved pCorpse->m_itCorpse.m_uidKiller = GetUID(); // by you if ( pChar && pChar->m_pPlayer ) pCorpse->SetTimeout(0); // reset corpse timer to make it turn bones }
int CChar::Do_Use_Item(CItem *pItem, bool fLink) { ADDTOCALLSTACK("CChar::Do_Use_Item"); if (!pItem) return false; if (m_pNPC && (IsTrigUsed(TRIGGER_DCLICK) || IsTrigUsed(TRIGGER_ITEMDCLICK))) // for players, DClick was called before this function { if (pItem->OnTrigger(ITRIG_DCLICK, this) == TRIGRET_RET_TRUE) return false; } CItemSpawn *pSpawn = static_cast<CItemSpawn *>(pItem->m_uidSpawnItem.ItemFind()); if (pSpawn) pSpawn->DelObj(pItem->GetUID()); // remove this item from it's spawn when DClicks it int fAction = true; switch(pItem->GetType()) { case IT_ITEM_STONE: { // Give them this item if (pItem->m_itItemStone.m_wAmount == USHRT_MAX) { SysMessageDefault(DEFMSG_MSG_IT_IS_DEAD); return true; } if (pItem->m_itItemStone.m_wRegenTime) { if (pItem->IsTimerSet()) { SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_MSG_STONEREG_TIME), pItem->GetTimerDiff() / TICK_PER_SEC); return true; } pItem->SetTimeout(pItem->m_itItemStone.m_wRegenTime * TICK_PER_SEC); } ItemBounce(CItem::CreateTemplate(pItem->m_itItemStone.m_ItemID, GetPackSafe(), this)); if (pItem->m_itItemStone.m_wAmount != 0) { pItem->m_itItemStone.m_wAmount--; if (pItem->m_itItemStone.m_wAmount == 0) pItem->m_itItemStone.m_wAmount = USHRT_MAX; } return true; } case IT_SEED: return Use_Seed(pItem, NULL); case IT_BEDROLL: return Use_BedRoll(pItem); case IT_KINDLING: return Use_Kindling(pItem); case IT_SPINWHEEL: { if (fLink) return false; // Just make them spin pItem->SetAnim(static_cast<ITEMID_TYPE>(pItem->GetID() + 1), 2 * TICK_PER_SEC); SysMessageDefault(DEFMSG_ITEMUSE_SPINWHEEL); return true; } case IT_TRAIN_DUMMY: { if (fLink) return false; Use_Train_Dummy(pItem, true); return true; } case IT_TRAIN_PICKPOCKET: { if (fLink) return false; Use_Train_PickPocketDip(pItem, true); return true; } case IT_ARCHERY_BUTTE: { if (fLink) return false; Use_Train_ArcheryButte(pItem, true); return true; } case IT_LOOM: { if (fLink) return false; SysMessageDefault(DEFMSG_ITEMUSE_LOOM); return true; } case IT_BEE_HIVE: { if (fLink) return false; // Get honey from it ITEMID_TYPE id = ITEMID_NOTHING; if (!pItem->m_itBeeHive.m_honeycount) SysMessageDefault(DEFMSG_ITEMUSE_BEEHIVE); else { switch(Calc_GetRandVal(3)) { case 1: id = ITEMID_JAR_HONEY; break; case 2: id = ITEMID_BEE_WAX; break; } } if (id) { ItemBounce(CItem::CreateScript(id, this)); pItem->m_itBeeHive.m_honeycount--; } else { SysMessageDefault(DEFMSG_ITEMUSE_BEEHIVE_STING); OnTakeDamage(Calc_GetRandVal(5), this, DAMAGE_POISON | DAMAGE_GENERAL); } pItem->SetTimeout(15 * 60 * TICK_PER_SEC); return true; } case IT_MUSICAL: { if (!Skill_Wait(SKILL_MUSICIANSHIP)) { m_Act_Targ = pItem->GetUID(); Skill_Start(SKILL_MUSICIANSHIP); } break; } case IT_CROPS: case IT_FOLIAGE: { // Pick cotton/hay/etc fAction = pItem->Plant_Use(this); break; } case IT_FIGURINE: { // Create the creature here if (Use_Figurine(pItem) != NULL) pItem->Delete(); return true; } case IT_TRAP: case IT_TRAP_ACTIVE: { // Activate the trap (plus any linked traps) int iDmg = pItem->Use_Trap(); if (CanTouch(pItem->GetTopLevelObj()->GetTopPoint())) OnTakeDamage(iDmg, NULL, DAMAGE_HIT_BLUNT | DAMAGE_GENERAL); break; } case IT_SWITCH: { // Switches can be linked to gates and doors and such. // Flip the switch graphic. pItem->SetSwitchState(); break; } case IT_PORT_LOCKED: if (!fLink && !IsPriv(PRIV_GM)) { SysMessageDefault(DEFMSG_ITEMUSE_PORT_LOCKED); return true; } case IT_PORTCULIS: // Open a metal gate vertically pItem->Use_Portculis(); break; case IT_DOOR_LOCKED: if (!ContentFindKeyFor(pItem)) { SysMessageDefault(DEFMSG_MSG_KEY_DOORLOCKED); if (!pItem->IsTopLevel()) return false; if (pItem->IsAttr(ATTR_MAGIC)) // show it's magic face { ITEMID_TYPE id = (GetDispID() & DOOR_NORTHSOUTH) ? ITEMID_DOOR_MAGIC_SI_NS : ITEMID_DOOR_MAGIC_SI_EW; CItem *pFace = CItem::CreateBase(id); ASSERT(pFace); pFace->MoveToDecay(pItem->GetTopPoint(), 4 * TICK_PER_SEC); } if (!IsPriv(PRIV_GM)) return true; } case IT_DOOR_OPEN: case IT_DOOR: { bool fOpen = pItem->Use_DoorNew(fLink); if (fLink || !fOpen) // don't link if we are just closing the door return true; } break; case IT_SHIP_PLANK: { // Close the plank if I'm inside the ship if (m_pArea->IsFlag(REGION_FLAG_SHIP) && m_pArea->GetResourceID() == pItem->m_uidLink) { if (pItem->m_itShipPlank.m_itSideType == IT_SHIP_SIDE_LOCKED && !ContentFindKeyFor(pItem)) { SysMessageDefault(DEFMSG_ITEMUSE_SHIPSIDE); return true; } return pItem->Ship_Plank(false); } else if (pItem->IsTopLevel()) { // Teleport to plank if I'm outside the ship CPointMap pntTarg = pItem->GetTopPoint(); pntTarg.m_z++; Spell_Teleport(pntTarg, true, false, false); } return true; } case IT_SHIP_SIDE_LOCKED: if (!ContentFindKeyFor(pItem)) { SysMessageDefault(DEFMSG_ITEMUSE_SHIPSIDE); return true; } case IT_SHIP_SIDE: // Open the plank pItem->Ship_Plank(true); return true; case IT_GRAIN: case IT_GRASS: case IT_GARBAGE: case IT_FRUIT: case IT_FOOD: case IT_FOOD_RAW: case IT_MEAT_RAW: { if (fLink) return false; Use_Eat(pItem); return true; } case IT_POTION: case IT_DRINK: case IT_PITCHER: case IT_WATER_WASH: case IT_BOOZE: { if (fLink) return false; Use_Drink(pItem); return true; } case IT_LIGHT_OUT: // can the light be lit? case IT_LIGHT_LIT: // can the light be doused? fAction = pItem->Use_Light(); break; case IT_CLOTHING: case IT_ARMOR: case IT_ARMOR_LEATHER: case IT_SHIELD: case IT_WEAPON_MACE_CROOK: case IT_WEAPON_MACE_PICK: case IT_WEAPON_MACE_SMITH: case IT_WEAPON_MACE_SHARP: case IT_WEAPON_SWORD: case IT_WEAPON_FENCE: case IT_WEAPON_BOW: case IT_WEAPON_AXE: case IT_WEAPON_XBOW: case IT_WEAPON_MACE_STAFF: case IT_JEWELRY: case IT_WEAPON_THROWING: { if (fLink) return false; return ItemEquip(pItem); } case IT_WEB: { if (fLink) return false; Use_Item_Web(pItem); return true; } case IT_SPY_GLASS: { if (fLink) return false; // Spyglass will tell you the moon phases static LPCTSTR const sm_sPhases[8] = { g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M1), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M2), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M3), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M4), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M5), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M6), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M7), g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_M8) }; SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_TR), sm_sPhases[g_World.GetMoonPhase(false)]); SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SPYGLASS_FE), sm_sPhases[g_World.GetMoonPhase(true)]); if (m_pArea && m_pArea->IsFlag(REGION_FLAG_SHIP)) ObjMessage(pItem->Use_SpyGlass(this), this); return true; } case IT_SEXTANT: { if (fLink) return false; if ((GetTopPoint().m_map <= 1) && (GetTopPoint().m_x > UO_SIZE_X_REAL)) // dungeons and T2A lands ObjMessage(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SEXTANT_T2A), this); else { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_SEXTANT), m_pArea->GetName(), pItem->Use_Sextant(GetTopPoint())); ObjMessage(pszMsg, this); } return true; } default: fAction = false; } return fAction | MASK_RETURN_FOLLOW_LINKS; }
BOOL CJewelOfHarmonySystem::SmeltItemBySmeltingStone(LPOBJ lpObj, int source, int target) { if ( this->m_bSystemSmeltingItem == FALSE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,51)), lpObj->m_Index, 1); return FALSE; } if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( lpObj->pInventory[source].IsItem() == FALSE ) return FALSE; if ( lpObj->pInventory[target].IsItem() == FALSE ) return FALSE; CItem * pSource = &lpObj->pInventory[source]; CItem * pTarget = &lpObj->pInventory[target]; if ( !this->IsStrengthenByJewelOfHarmony(pTarget) ) { CLog.LogAdd("[JewelOfHarmony][Smelt Item] Not Strengten Item [%s][%s]", lpObj->AccountID, lpObj->Name); return FALSE; } int iItemOptionLevel = this->_GetItemOptionLevel(pTarget); if ( iItemOptionLevel >= pTarget->m_Level ) { if ( iItemOptionLevel == 13 ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,41)), lpObj->m_Index, 1); } else { GCServerMsgStringSend(lMsg.Get(MSGGET(13,40)), lpObj->m_Index, 1); } CLog.LogAdd("[JewelOfHarmony][Smelt Item] Already Have Max OptionLevel [%s][%s] OptionLevel [%d] ItemLevel [%d]", lpObj->AccountID, lpObj->Name, iItemOptionLevel, pTarget->m_Level); return FALSE; } if ( this->_GetItemType(pTarget) == JEWELOFHARMONY_ITEM_TYPE_WEAPON ) { if ( this->GetItemStrengthenOption(pTarget) == AT_JEWELOFHARMONY_WEAPON_IMPROVE_MINATTACKDAMAGE ) { int iNextLevel = this->_GetItemOptionLevel(pTarget)+1; BYTE iValue = this->m_itemOption[JEWELOFHARMONY_ITEM_TYPE_WEAPON][AT_JEWELOFHARMONY_WEAPON_IMPROVE_MINATTACKDAMAGE].iItemEffectValue[iNextLevel]; if ( (pTarget->m_DamageMin+iValue) > (pTarget->m_DamageMax-1) ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,41)), lpObj->m_Index, 1); return FALSE; } } } int iSuccessRate = rand() % 100; int iRateSmeltingSuccess = 0; BOOL bIsNormalSmeltingStone = this->_IsJewelOfHarmonySmeltingItemNor(pSource->m_Type); if ( bIsNormalSmeltingStone == TRUE ) iRateSmeltingSuccess = this->m_iRateSmeltingSuccessNor; else iRateSmeltingSuccess = this->m_iRateSmeltingSuccessExt; if ( iSuccessRate >= iRateSmeltingSuccess ) { int iItemOptionNewLevel = _GetItemOptionRequireLevel(pTarget); pTarget->m_JewelOfHarmonyOption = pTarget->m_JewelOfHarmonyOption & 0xF0; pTarget->m_JewelOfHarmonyOption |= iItemOptionNewLevel & 0x0F; this->ShowStrengthenOption(pTarget); CLog.LogAdd("[JewelOfHarmony][Smelt Item] Smelt Item Fail by Normal[%d] [%s][%s] Name[%s] Type [%d] Serial [%d] Rate(%d/%d) Level(%d->%d)", bIsNormalSmeltingStone, lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, iRateSmeltingSuccess, iItemOptionLevel, iItemOptionNewLevel); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 47)), lpObj->m_Index, 1); } else { int iItemOptionNewLevel = iItemOptionLevel+1; pTarget->m_JewelOfHarmonyOption = pTarget->m_JewelOfHarmonyOption & 0xF0; pTarget->m_JewelOfHarmonyOption |= iItemOptionNewLevel & 0x0F; this->ShowStrengthenOption(pTarget); CLog.LogAdd("[JewelOfHarmony][Smelt Item] Smelt Item Success by Normal[%d] [%s][%s] Name[%s] Type [%d] Serial [%d] Rate(%d/%d) Level(%d->%d)", bIsNormalSmeltingStone, lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, iRateSmeltingSuccess, iItemOptionLevel, iItemOptionNewLevel & 0x0F); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 48)), lpObj->m_Index, 1); } return TRUE; }
void execute(CItem *_this) { item->SwitchToHand(hand); }
BOOL CJewelOfHarmonySystem::RestoreStrengthenItem(LPOBJ lpObj) { if ( this->m_bSystemRestoreStrengthen != TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,54)), lpObj->m_Index, 1); return TRUE; } lpObj->ChaosLock = TRUE; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg)); pMsg.Result = 0; int iStrengtenItemCount = 0; int iInvalidItemCount = 0; CItem * pItem = NULL; for ( int n=0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( this->IsStrengthenByJewelOfHarmony(&lpObj->pChaosBox[n]) == TRUE ) { iStrengtenItemCount++; pItem = &lpObj->pChaosBox[n]; } } } if ( iStrengtenItemCount != 1 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } int iItemOption = this->GetItemStrengthenOption(pItem); int iItemOptionLevel = this->_GetItemOptionLevel(pItem); int JEWEL_OF_HARMONY_RETORE_NEEDZEN = this->_GetZenForRestoreItem(pItem); if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } int iChaosTaxMoney = JEWEL_OF_HARMONY_RETORE_NEEDZEN * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100; if ( iChaosTaxMoney < 0 ) iChaosTaxMoney = 0; JEWEL_OF_HARMONY_RETORE_NEEDZEN += iChaosTaxMoney; if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) JEWEL_OF_HARMONY_RETORE_NEEDZEN = 0; if ( lpObj->Money < JEWEL_OF_HARMONY_RETORE_NEEDZEN ) { pMsg.Result = 2; gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } lpObj->Money -= JEWEL_OF_HARMONY_RETORE_NEEDZEN; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(lpObj->m_Index, lpObj->Money); LogChaosItem(lpObj, "JewelOfHarmony][Restore Item"); CLog.LogAdd("[JewelOfHarmony][Restore Item] - Restore Start"); CLog.LogAdd("[JewelOfHarmony][Restore Item] Restore Strengtened Item [%s][%s] Name[%s] ItemType[%d] Serial[%d] OptionType[%d] OptionLevel [%d] Money %d-%d", lpObj->AccountID, lpObj->Name, pItem->GetName(), pItem->m_Type, pItem->m_Number, iItemOption, iItemOptionLevel, lpObj->Money, JEWEL_OF_HARMONY_RETORE_NEEDZEN); pItem->m_JewelOfHarmonyOption = 0; GCUserChaosBoxSend(lpObj, 0); this->ShowStrengthenOption(pItem); lpObj->ChaosLock = FALSE; return TRUE; }
UINT16 CGoods::UseBox(DT_ITEM_DATA_LIST_CLI2& stBoxItemInfo) { SGoodsProp* pstGoodsProp = GetGoodsProp(); if(NULL == pstGoodsProp) { RETURN_OTHER_ERR; } SItemComposeProp* pstItemComposeProp = CItemComposePropMgr::Instance()->GetProp(pstGoodsProp->wKindID); if(NULL == pstItemComposeProp) { SYS_CRITICAL(_SDT("[%s: %d]: pstItemComposeProp is NULL!"), MSG_MARK); RETURN_OTHER_ERR; } CItemRateMap& mapComposeItem = pstItemComposeProp->mapComposeItem; if(0 == mapComposeItem.size()) { SYS_CRITICAL(_SDT("[%s: %d]: mapComposeItem[%d] is 0!"), MSG_MARK, pstGoodsProp->wKindID); RETURN_OTHER_ERR; } INT32 nGap = (INT32)(m_poOwner->GetBag().GetIdleSize()) - (INT32)(mapComposeItem.size()); if(nGap < 0) { //判断背包中是否存在该物品,若存在则可少使用一个格子 CBag& oBag = m_poOwner->GetBag(); for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++) { //只有物品有效,装备叠加数为1,则只找Goods if(oBag.GetGoodsItem(itr->first)) { nGap++; } } } //背包容量不足 if(nGap < 0) { return ERR_GOODS_USE::ID_BAG_FULL; } for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++) { //若是系统可以直接使用的物品,则使用 if(CItemMgr::Instance()->SysUseGoods(m_poOwner, itr->first, itr->second.wItemNum)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } else { ECreateItemRet eRet; CItem* poItem = CItemMgr::Instance()->CreateItemIntoBag(m_poOwner, itr->first, itr->second.wItemNum, eRet, 0, CRecordMgr::EAIT_BOX, m_stDT_GOODS_DATA.wKindID); if(NULL == poItem) { //异常 SYS_CRITICAL(_SDT("[%s: %d]: CreateItemIntoBag failed[%d]!"), MSG_MARK, itr->first); } //装备没有叠加数,可以直接poEquip->GetDT_EQUIP_DATA_CLI(stEquip); if(EIK_EQUIP == poItem->GetItemKind()) { CEquip* poEquip = dynamic_cast<CEquip*>(poItem); if(NULL == poEquip) { //异常 continue; } stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum].byItemType = EIK_EQUIP; DT_EQUIP_DATA_CLI& stEquip = stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum].stItemInfo.stEquip ; poEquip->GetDT_EQUIP_DATA_CLI(stEquip); } else { //内部礼包,返回的是礼包的物品 SGoodsProp* pstGoodsProp = CGoodsPropMgr::Instance()->GetPropByPrimaryKey(itr->first); if((pstGoodsProp) && (EGMK_INNERBOX == pstGoodsProp->byMainKindID)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(poItem->GetItemKindID(), 1, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } else { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } } } stBoxItemInfo.byItemNum++; } return ERR_GOODS_USE::ID_SUCCESS; }
void CCalCharacter::gObjCalCharacter(int aIndex) { LPOBJ lpObj = &gObj[aIndex]; int Strength = 0; int Dexterity = 0; int Vitality = 0; int Energy = 0; int Leadership = 0; // ---- CItem * Right = &lpObj->pInventory[0]; CItem * Left = &lpObj->pInventory[1]; CItem * Helm = &lpObj->pInventory[2]; CItem * Armor = &lpObj->pInventory[3]; CItem * Pants = &lpObj->pInventory[4]; CItem * Gloves = &lpObj->pInventory[5]; CItem * Boots = &lpObj->pInventory[6]; CItem * Wings = &lpObj->pInventory[7]; CItem * Helper = &lpObj->pInventory[8]; CItem * Amulet = &lpObj->pInventory[9]; CItem * Ring01 = &lpObj->pInventory[10]; CItem * Ring02 = &lpObj->pInventory[11]; lpObj->HaveWeaponInHand = true; // ------------------------------------------------------- // Check Weapon in hand // ------------------------------------------------------- if ( Right->IsItem() == false && Left->IsItem() == false ) { lpObj->HaveWeaponInHand = false; } else if ( Left->IsItem() == false && Right->m_Type == ITEMGET(4,15) ) // Arrow { lpObj->HaveWeaponInHand = false; } else if ( Right->IsItem() == false ) { int iType = Left->m_Type / MAX_SUBTYPE_ITEMS; if ( Left->m_Type == ITEMGET(4,7) ) // Bolt { lpObj->HaveWeaponInHand = false; } else if ( iType == 6 ) // Shield { lpObj->HaveWeaponInHand = false; } } // ------------------------------------------------------- lpObj->AddLife = 0; lpObj->AddMana = 0; lpObj->MonsterDieGetMoney = 0; lpObj->MonsterDieGetLife = 0; lpObj->MonsterDieGetMana = 0; lpObj->DamageReflect = 0; lpObj->DamageMinus = 0; lpObj->SkillLongSpearChange = false; if ( lpObj->m_iItemEffectValidTime > 0 ) { g_ItemAddOption.PrevSetItemLastEffectForHallowin(lpObj); } int iItemIndex; BOOL bIsChangeItem; // lc34 for ( iItemIndex=0; iItemIndex<MAX_PLAYER_EQUIPMENT;iItemIndex++) { if ( lpObj->pInventory[iItemIndex].IsItem() != FALSE ) { lpObj->pInventory[iItemIndex].m_IsValidItem = true; } } do { lpObj->SetOpAddMaxAttackDamage = 0; lpObj->SetOpAddMinAttackDamage = 0; lpObj->SetOpAddDamage = 0; lpObj->SetOpIncAGValue = 0; lpObj->SetOpAddCriticalDamageSuccessRate = 0; lpObj->SetOpAddCriticalDamage = 0; lpObj->SetOpAddExDamageSuccessRate = 0; lpObj->SetOpAddExDamage = 0; lpObj->SetOpAddSkillAttack = 0; lpObj->AddStrength = 0; lpObj->AddDexterity = 0; lpObj->AddVitality = 0; lpObj->AddEnergy = 0; lpObj->AddBP = 0; lpObj->iAddShield = 0; lpObj->SetOpAddAttackDamage = 0; lpObj->SetOpAddDefence = 0; lpObj->SetOpAddMagicPower = 0; lpObj->SetOpAddDefenceRate = 0; lpObj->SetOpIgnoreDefense = 0; lpObj->SetOpDoubleDamage = 0; lpObj->SetOpTwoHandSwordImproveDamage = 0; lpObj->SetOpImproveSuccessAttackRate = 0; lpObj->SetOpReflectionDamage = 0; lpObj->SetOpImproveSheldDefence = 0; lpObj->SetOpDecreaseAG = 0; lpObj->SetOpImproveItemDropRate = 0; lpObj->IsFullSetItem = false; memset(lpObj->m_AddResistance, 0, sizeof(lpObj->m_AddResistance)); bIsChangeItem = 0; gObjCalcSetItemStat(lpObj); gObjCalcSetItemOption(lpObj); for (iItemIndex=0;iItemIndex<MAX_PLAYER_EQUIPMENT;iItemIndex++) { if ( lpObj->pInventory[iItemIndex].IsItem() != FALSE && lpObj->pInventory[iItemIndex].m_IsValidItem != false ) { if ( gObjValidItem( lpObj, &lpObj->pInventory[iItemIndex], iItemIndex) != FALSE ) { lpObj->pInventory[iItemIndex].m_IsValidItem = true; } else { lpObj->pInventory[iItemIndex].m_IsValidItem = false; bIsChangeItem = TRUE; } } } } while ( bIsChangeItem != FALSE ); Strength = lpObj->Strength + lpObj->AddStrength; Dexterity = lpObj->Dexterity + lpObj->AddDexterity; Vitality = lpObj->Vitality + lpObj->AddVitality; Energy = lpObj->Energy + lpObj->AddEnergy; Leadership = lpObj->Leadership + lpObj->AddLeadership; switch ( lpObj->Class ) { case CLASS_WIZARD: lpObj->m_AttackDamageMinRight = (Strength / 8); lpObj->m_AttackDamageMaxRight = (Strength / 4); lpObj->m_AttackDamageMinLeft = (Strength / 8); lpObj->m_AttackDamageMaxLeft = (Strength / 4); break; case CLASS_KNIGHT: lpObj->m_AttackDamageMinRight = Strength / 6; lpObj->m_AttackDamageMaxRight = Strength / 4; lpObj->m_AttackDamageMinLeft = Strength / 6; lpObj->m_AttackDamageMaxLeft = Strength / 4; break; case CLASS_ELF: if ( (Right->m_Type >= ITEMGET(4,8) && Right->m_Type < ITEMGET(4,15) ) || (Left->m_Type >= ITEMGET(4,0) && Left->m_Type < ITEMGET(4,7)) || Right->m_Type == ITEMGET(4,16) || Left->m_Type == ITEMGET(4,17) || Right->m_Type == ITEMGET(4,18) || Right->m_Type == ITEMGET(4,19) || Left->m_Type == ITEMGET(4,20) || Left->m_Type == ITEMGET(4,21) || Left->m_Type == ITEMGET(4,22) || Left->m_Type == ITEMGET(4,23) || Left->m_Type == ITEMGET(4,24) ) { if ( (Right->IsItem() != FALSE && Right->m_IsValidItem == false) || (Left->IsItem() != FALSE && Left->m_IsValidItem == false) ) { lpObj->m_AttackDamageMinRight = (Dexterity + Strength ) / 7; lpObj->m_AttackDamageMaxRight = (Dexterity + Strength ) / 4; lpObj->m_AttackDamageMinLeft = (Dexterity + Strength ) / 7; lpObj->m_AttackDamageMaxLeft = (Dexterity + Strength ) / 4; } else { lpObj->m_AttackDamageMinRight = (Dexterity / 7) + (Strength / 14); lpObj->m_AttackDamageMaxRight = (Dexterity / 4) + (Strength / 8 ); lpObj->m_AttackDamageMinLeft = (Dexterity / 7) + (Strength / 14); lpObj->m_AttackDamageMaxLeft = (Dexterity / 4) + (Strength / 8 ); } } else { lpObj->m_AttackDamageMinRight = (Dexterity + Strength) / 7; lpObj->m_AttackDamageMaxRight = (Dexterity + Strength) / 4; lpObj->m_AttackDamageMinLeft = (Dexterity + Strength) / 7; lpObj->m_AttackDamageMaxLeft = (Dexterity + Strength) / 4; } break; case CLASS_MAGUMSA: lpObj->m_AttackDamageMinRight = (Strength / 6) + (Energy / 12); lpObj->m_AttackDamageMaxRight = (Strength / 4) + (Energy / 8); lpObj->m_AttackDamageMinLeft = (Strength / 6) + (Energy / 12); lpObj->m_AttackDamageMaxLeft = (Strength / 4) + (Energy / 8); break; case CLASS_DARKLORD: lpObj->m_AttackDamageMinRight = (Strength / 7) + (Energy / 14); lpObj->m_AttackDamageMaxRight = (Strength / 5) + (Energy / 10); lpObj->m_AttackDamageMinLeft = (Strength / 7) + (Energy / 14); lpObj->m_AttackDamageMaxLeft = (Strength / 5) + (Energy / 10); break; case CLASS_SUMMONER: lpObj->m_AttackDamageMinRight = (Strength / 8) + (Energy / 12); lpObj->m_AttackDamageMaxRight = (Strength / 4) + (Energy / 8); lpObj->m_AttackDamageMinLeft = (Strength / 8) + (Energy / 12); lpObj->m_AttackDamageMaxLeft = (Strength / 4) + (Energy / 8); break; case CLASS_FIGHTER: lpObj->m_AttackDamageMinRight = (Strength / 6) + (Energy / 12); lpObj->m_AttackDamageMaxRight = (Strength / 4) + (Energy / 8); lpObj->m_AttackDamageMinLeft = (Strength / 6) + (Energy / 12); lpObj->m_AttackDamageMaxLeft = (Strength / 4) + (Energy / 8); break; } if ( Wings->IsItem() != FALSE && Wings->m_IsValidItem != false ) { Wings->PlusSpecial(&lpObj->m_AttackDamageMinRight, 80); Wings->PlusSpecial(&lpObj->m_AttackDamageMaxRight, 80); Wings->PlusSpecial(&lpObj->m_AttackDamageMinLeft, 80); Wings->PlusSpecial(&lpObj->m_AttackDamageMaxLeft, 80); } int AddLeadership = 0; if ( Wings->IsItem() != FALSE && Wings->m_IsValidItem != false) { AddLeadership += Wings->m_Leadership; } if ( Right->m_Type != -1 ) { if ( Right->m_IsValidItem != false ) { if ( Right->m_Type >= ITEMGET(5,0) && Right->m_Type <= ITEMGET(6,0) ) // Check this { lpObj->m_AttackDamageMinRight += Right->m_DamageMin / 2; lpObj->m_AttackDamageMaxRight += Right->m_DamageMax / 2; } else { lpObj->m_AttackDamageMinRight += Right->m_DamageMin; lpObj->m_AttackDamageMaxRight += Right->m_DamageMax; } } if ( Right->m_SkillChange != FALSE ) { lpObj->SkillLongSpearChange = true; } Right->PlusSpecial(&lpObj->m_AttackDamageMinRight, 80); Right->PlusSpecial(&lpObj->m_AttackDamageMaxRight, 80); } if ( Left->m_Type != -1 ) { if ( Left->m_IsValidItem != false) { lpObj->m_AttackDamageMinLeft += Left->m_DamageMin; lpObj->m_AttackDamageMaxLeft += Left->m_DamageMax; } Left->PlusSpecial(&lpObj->m_AttackDamageMinLeft, 80); Left->PlusSpecial(&lpObj->m_AttackDamageMaxLeft, 80); } lpObj->m_CriticalDamage = 0; lpObj->m_ExcelentDamage = 0; if ( Wings->IsItem() != FALSE && Wings->m_IsValidItem != false ) { Wings->PlusSpecial(&lpObj->m_MagicDamageMin, 81); Wings->PlusSpecial(&lpObj->m_MagicDamageMax, 81); Wings->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Right->IsItem() != FALSE && Right->m_IsValidItem != false ) { Right->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Left->IsItem() != FALSE && Left->m_IsValidItem != false ) { Left->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Helm->IsItem() != FALSE && Helm->m_IsValidItem != false ) { Helm->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Armor->IsItem() != FALSE && Armor->m_IsValidItem != false ) { Armor->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Pants->IsItem() != FALSE && Pants->m_IsValidItem != false ) { Pants->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Gloves->IsItem() != FALSE && Gloves->m_IsValidItem != false ) { Gloves->PlusSpecial(&lpObj->m_CriticalDamage, 84); } if ( Boots->IsItem() != FALSE && Boots->m_IsValidItem != false ) { Boots->PlusSpecial(&lpObj->m_CriticalDamage, 84); } lpObj->m_MagicDamageMin = Energy / 9; lpObj->m_MagicDamageMax = Energy / 4; if ( Right->m_Type != -1 ) { if ( Right->m_Type == ITEMGET(0,31) || Right->m_Type == ITEMGET(0,21) || Right->m_Type == ITEMGET(0,23) || Right->m_Type == ITEMGET(0,25) || Right->m_Type == ITEMGET(0,28) ) { Right->PlusSpecial(&lpObj->m_MagicDamageMin, 80); Right->PlusSpecial(&lpObj->m_MagicDamageMax, 80); } else { Right->PlusSpecial(&lpObj->m_MagicDamageMin, 81); Right->PlusSpecial(&lpObj->m_MagicDamageMax, 81); } } lpObj->m_AttackRating = (Strength + Dexterity) / 2; if (lpObj->Class != CLASS_FIGHTER) // Rage Fighter - No Gloves { if ( Gloves->IsItem() != FALSE && Gloves->m_IsValidItem != false ) { lpObj->m_AttackRating += Gloves->ItemDefense(); } } // ---------------------------------------- // Attack Speed // ---------------------------------------- switch ( lpObj->Class ) { case CLASS_WIZARD: lpObj->m_AttackSpeed = Dexterity / 20; lpObj->m_MagicSpeed = Dexterity / 10; break; case CLASS_KNIGHT: lpObj->m_AttackSpeed = Dexterity / 15; lpObj->m_MagicSpeed = Dexterity / 20; break; case CLASS_ELF: lpObj->m_AttackSpeed = Dexterity / 50; lpObj->m_MagicSpeed = Dexterity / 50; break; case CLASS_MAGUMSA: lpObj->m_AttackSpeed = Dexterity / 15; lpObj->m_MagicSpeed = Dexterity / 20; break; case CLASS_DARKLORD: lpObj->m_AttackSpeed = Dexterity / 10; lpObj->m_MagicSpeed = Dexterity / 10; break; case CLASS_SUMMONER: lpObj->m_AttackSpeed = Dexterity / 20; lpObj->m_MagicSpeed = Dexterity / 20; break; case CLASS_FIGHTER: lpObj->m_AttackSpeed = Dexterity / 15; lpObj->m_MagicSpeed = Dexterity / 20; break; } bool bRight = false; bool bLeft = false; // ---------------------------------------- // Check if have weapon in Right Hand // ---------------------------------------- if ( Right->m_Type != ITEMGET(4,7) && Right->m_Type != ITEMGET(4,15) && Right->m_Type >= ITEMGET(0,0) && Right->m_Type < ITEMGET(6,0) ) { if ( Right->m_IsValidItem != false ) { bRight = true; } } // ---------------------------------------- // Check if have weapon in Left Hand // ---------------------------------------- if ( Left->m_Type != ITEMGET(4,7) && Left->m_Type != ITEMGET(4,15) && Left->m_Type >= ITEMGET(0,0) && Left->m_Type < ITEMGET(6,0) ) { if ( Left->m_IsValidItem != false ) { bLeft = true; } } if ( bRight != false && bLeft != false ) { lpObj->m_AttackSpeed += (Right->m_AttackSpeed + Left->m_AttackSpeed)/2; lpObj->m_MagicSpeed += (Right->m_AttackSpeed + Left->m_AttackSpeed)/2; } else if ( bRight!= false ) { lpObj->m_AttackSpeed += Right->m_AttackSpeed; lpObj->m_MagicSpeed += Right->m_AttackSpeed; } else if ( bLeft != false ) { lpObj->m_AttackSpeed += Left->m_AttackSpeed; lpObj->m_MagicSpeed += Left->m_AttackSpeed; } if ( lpObj->Class != CLASS_FIGHTER ) // Rage Fighter - No Gloves { if ( Gloves->m_Type != -1 ) { if ( Gloves->m_IsValidItem != false ) { lpObj->m_AttackSpeed += Gloves->m_AttackSpeed; lpObj->m_MagicSpeed += Gloves->m_AttackSpeed; } } } if ( Amulet->m_Type != -1 ) // Pendant { if ( Amulet->m_IsValidItem != false ) { lpObj->m_AttackSpeed += Amulet->m_AttackSpeed; lpObj->m_MagicSpeed += Amulet->m_AttackSpeed; } } // ---------------------------------------- // Wizard Ring Effect // ---------------------------------------- if ( (lpObj->pInventory[10].IsItem() == TRUE && lpObj->pInventory[10].m_Type == ITEMGET(13,20) && lpObj->pInventory[10].m_Level == 0 && lpObj->pInventory[10].m_Durability > 0.0f ) || (lpObj->pInventory[11].IsItem() == TRUE && lpObj->pInventory[11].m_Type == ITEMGET(13,20) && lpObj->pInventory[11].m_Level == 0 && lpObj->pInventory[11].m_Durability > 0.0f ) ) { lpObj->m_AttackDamageMinRight += lpObj->m_AttackDamageMinRight * 10 / 100; lpObj->m_AttackDamageMaxRight += lpObj->m_AttackDamageMaxRight * 10 / 100; lpObj->m_AttackDamageMinLeft += lpObj->m_AttackDamageMinLeft * 10 / 100; lpObj->m_AttackDamageMaxLeft += lpObj->m_AttackDamageMaxLeft * 10 / 100; lpObj->m_MagicDamageMin += lpObj->m_MagicDamageMin * 10 / 100; lpObj->m_MagicDamageMax += lpObj->m_MagicDamageMax * 10 / 100; lpObj->m_AttackSpeed += 10; lpObj->m_MagicSpeed += 10; } // ---------------------------------------- // Speed Hack Detect // ---------------------------------------- switch ( lpObj->Class ) { case CLASS_WIZARD: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_MagicSpeed*2 * gDecTimePerAttackSpeed) ); break; case CLASS_KNIGHT: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_AttackSpeed * gDecTimePerAttackSpeed) ); break; case CLASS_ELF: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_AttackSpeed * gDecTimePerAttackSpeed) ); break; case CLASS_MAGUMSA: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_AttackSpeed * gDecTimePerAttackSpeed) ); break; case CLASS_DARKLORD: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_AttackSpeed * gDecTimePerAttackSpeed) ); break; case CLASS_SUMMONER: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_MagicSpeed*2 * gDecTimePerAttackSpeed) ); break; case CLASS_FIGHTER: lpObj->m_DetectSpeedHackTime = (gAttackSpeedTimeLimit - (lpObj->m_MagicSpeed*2 * gDecTimePerAttackSpeed) ); break; } if ( lpObj->m_DetectSpeedHackTime < gMinimumAttackSpeedTime ) { lpObj->m_DetectSpeedHackTime = gMinimumAttackSpeedTime; } // ---------------------------------------- // Successful Blocking // ---------------------------------------- switch ( lpObj->Class ) { case CLASS_WIZARD: lpObj->m_SuccessfulBlocking = Dexterity / 3; break; case CLASS_KNIGHT: lpObj->m_SuccessfulBlocking = Dexterity / 3; break; case CLASS_ELF: lpObj->m_SuccessfulBlocking = Dexterity / 4; break; case CLASS_MAGUMSA: lpObj->m_SuccessfulBlocking = Dexterity / 3; break; case CLASS_DARKLORD: lpObj->m_SuccessfulBlocking = Dexterity / 7; break; case CLASS_SUMMONER: lpObj->m_SuccessfulBlocking = Dexterity / 3; break; case CLASS_FIGHTER: lpObj->m_SuccessfulBlocking = Dexterity / 5; break; } if ( Left->m_Type != -1 ) { if ( Left->m_IsValidItem != false ) { lpObj->m_SuccessfulBlocking += Left->m_SuccessfulBlocking; Left->PlusSpecial(&lpObj->m_SuccessfulBlocking, 82); } } // ---------------------------------------- // Character Set & Succesful Blocking // ---------------------------------------- bool Success = true; if ( lpObj->Class == CLASS_MAGUMSA ) // Magic Gladiator (No Helmet) { for ( int j=3;j<=6;j++) { if ( lpObj->pInventory[j].m_Type == -1 ) { Success = false; break; } if ( lpObj->pInventory[j].m_IsValidItem == false ) { Success = false; break; } } } else if ( lpObj->Class == CLASS_FIGHTER ) // Rage Fighter (No Gloves) { for ( int l=2;l<6;l++) { if ( l != 5 ) { if ( lpObj->pInventory[l].m_Type == -1 ) { Success = false; break; } if ( lpObj->pInventory[l].m_IsValidItem == false ) { Success = false; break; } } } } else // Dark Wizard, Dark Knight, Dark Lord, Elf, Summoner (All Set) { for ( int k=2;k<=6;k++) { if ( lpObj->pInventory[k].m_Type == -1 ) { Success = false; break; } if ( lpObj->pInventory[k].m_IsValidItem == false ) { Success = false; break; } } } int Level11Count = 0; int Level10Count = 0; int Level12Count = 0; int Level13Count = 0; int Level14Count = 0; int Level15Count = 0; if ( Success != false ) { int in; if ( lpObj->Class == CLASS_MAGUMSA ) // Magic Gladiator (No Helmet) { in = Armor->m_Type % MAX_SUBTYPE_ITEMS; if ( in != ITEMGET(0,15) && in != ITEMGET(0,20) && in != ITEMGET(0,23) && in != ITEMGET(0,32) && in != ITEMGET(0,37) ) { Success = false; } else { Level15Count++; for (int m=3;m<=6;m++) { if ( in != ( lpObj->pInventory[m].m_Type % MAX_SUBTYPE_ITEMS) ) { Success = false; } if ( lpObj->pInventory[m].m_Level > 14 ) { Level15Count++; } else if ( lpObj->pInventory[m].m_Level > 13 ) { Level14Count++; } else if ( lpObj->pInventory[m].m_Level > 12 ) { Level13Count++; } else if ( lpObj->pInventory[m].m_Level > 11 ) { Level12Count++; } else if ( lpObj->pInventory[m].m_Level > 10 ) { Level11Count++; } else if ( lpObj->pInventory[m].m_Level > 9 ) { Level10Count++; } } } } if ( lpObj->Class == CLASS_FIGHTER ) // Rage Fighter (No Gloves) { in = Boots->m_Type % MAX_SUBTYPE_ITEMS; if ( in != ITEMGET(0,59) && in != ITEMGET(0,60) && in != ITEMGET(0,61) ) { Success = false; } else { Level15Count++; for (int m=2;m<=6;m++) { if (m != 5) { if ( in != ( lpObj->pInventory[m].m_Type % MAX_SUBTYPE_ITEMS) ) { Success = false; } if ( lpObj->pInventory[m].m_Level > 14 ) { Level15Count++; } else if ( lpObj->pInventory[m].m_Level > 13 ) { Level14Count++; } else if ( lpObj->pInventory[m].m_Level > 12 ) { Level13Count++; } else if ( lpObj->pInventory[m].m_Level > 11 ) { Level12Count++; } else if ( lpObj->pInventory[m].m_Level > 10 ) { Level11Count++; } else if ( lpObj->pInventory[m].m_Level > 9 ) { Level10Count++; } } } } } else // Dark Knight, Dark Wizard, Elf, Dark Lord, Summoner (All Set) { in = lpObj->pInventory[2].m_Type % MAX_SUBTYPE_ITEMS; for (int m=2;m<=6;m++) { if ( in != ( lpObj->pInventory[m].m_Type % MAX_SUBTYPE_ITEMS) ) { Success = false; } if ( lpObj->pInventory[m].m_Level > 14 ) { Level15Count++; } else if ( lpObj->pInventory[m].m_Level > 13 ) { Level14Count++; } else if ( lpObj->pInventory[m].m_Level > 12 ) { Level13Count++; } else if ( lpObj->pInventory[m].m_Level > 11 ) { Level12Count++; } else if ( lpObj->pInventory[m].m_Level > 10 ) { Level11Count++; } else if ( lpObj->pInventory[m].m_Level > 9 ) { Level10Count++; } } } if ( Success != false ) // #warning unuseful if { lpObj->m_SuccessfulBlocking += lpObj->m_SuccessfulBlocking / 10; } } // ---------------------------------------- // Character Defense // ---------------------------------------- switch ( lpObj->Class ) { case CLASS_WIZARD: lpObj->m_Defense = Dexterity / 4; break; case CLASS_KNIGHT: lpObj->m_Defense = Dexterity / 3; break; case CLASS_ELF: lpObj->m_Defense = Dexterity / 10; break; case CLASS_MAGUMSA: lpObj->m_Defense = Dexterity / 4; break; case CLASS_DARKLORD: lpObj->m_Defense = Dexterity / 7; break; case CLASS_SUMMONER: lpObj->m_Defense = Dexterity / 4; break; case CLASS_FIGHTER: lpObj->m_Defense = Dexterity / 4; break; } if ( lpObj->Class == CLASS_MAGUMSA ) // Magic Gladiator (No Helm) { lpObj->m_Defense += Armor->ItemDefense(); lpObj->m_Defense += Pants->ItemDefense(); lpObj->m_Defense += Gloves->ItemDefense(); lpObj->m_Defense += Boots->ItemDefense(); lpObj->m_Defense += Left->ItemDefense(); lpObj->m_Defense += Wings->ItemDefense(); } else if ( lpObj->Class == CLASS_FIGHTER ) // Rage Fighter (No Gloves) { lpObj->m_Defense += Helm->ItemDefense(); lpObj->m_Defense += Armor->ItemDefense(); lpObj->m_Defense += Pants->ItemDefense(); lpObj->m_Defense += Boots->ItemDefense(); lpObj->m_Defense += Left->ItemDefense(); lpObj->m_Defense += Wings->ItemDefense(); } else // Dark Wizard, Dark Knight, Elf, Dark Lord, Summoner (All Set) { lpObj->m_Defense += Helm->ItemDefense(); lpObj->m_Defense += Armor->ItemDefense(); lpObj->m_Defense += Pants->ItemDefense(); lpObj->m_Defense += Gloves->ItemDefense(); lpObj->m_Defense += Boots->ItemDefense(); lpObj->m_Defense += Left->ItemDefense(); lpObj->m_Defense += Wings->ItemDefense(); } if ( Helper->IsItem() != FALSE ) { if ( Helper->m_Type == ITEMGET(13,4) && Helper->m_Durability > 0.0f ) // Dark Horse { lpObj->m_Defense += INT( Dexterity / 20 + 5 + Helper->m_PetItem_Level * 2 ); } } if ( (Level15Count + Level14Count + Level13Count + Level12Count + Level11Count + Level10Count) >= 5 ) { if ( Success != false ) { if ( Level15Count == 5 ) { lpObj->m_Defense += lpObj->m_Defense * 30 / 100; } else if ( Level14Count == 5 || (Level14Count + Level15Count) == 5 ) { lpObj->m_Defense += lpObj->m_Defense * 25 / 100; } else if ( Level13Count == 5 || (Level13Count + Level14Count + Level15Count) == 5 ) { lpObj->m_Defense += lpObj->m_Defense * 20 / 100; } else if ( Level12Count == 5 || (Level12Count + Level13Count + Level14Count + Level15Count) == 5 ) { lpObj->m_Defense += lpObj->m_Defense * 15 / 100; } else if ( Level11Count == 5 || (Level11Count + Level12Count + Level13Count + Level14Count + Level15Count) == 5 ) { lpObj->m_Defense += lpObj->m_Defense * 10 / 100; } else if ( Level10Count == 5 || (Level10Count + Level11Count + Level12Count + Level13Count + Level14Count + Level15Count) == 5) { lpObj->m_Defense += lpObj->m_Defense * 5 / 100; } } } lpObj->m_Defense = lpObj->m_Defense * 10 / 20; // ---------------------------------------- // Transformation Rings // ---------------------------------------- if ( lpObj->m_Change == 9 ) // Thunder Lich Change { // Add Magic Power Here } else if ( lpObj->m_Change == 41 ) // Death Cow Change { lpObj->AddLife = ((int)(lpObj->MaxLife * 20.0f))/100; } else if ( lpObj->m_Change == 372 ) // Don't Know { lpObj->m_Defense += lpObj->m_Defense / 10; lpObj->AddLife += lpObj->Level; } // ---------------------------------------- // Pets // ---------------------------------------- if ( Helper->m_Type == ITEMGET(13,0) ) // Guardian Angel { lpObj->AddLife += 50; } else if ( Helper->m_Type == ITEMGET(13,1) ) // Imp { //Add 30% to Attack lpObj->m_AttackDamageMinLeft += (lpObj->m_AttackDamageMinLeft*30)/100; lpObj->m_AttackDamageMaxLeft += (lpObj->m_AttackDamageMaxLeft*30)/100; lpObj->m_AttackDamageMinRight += (lpObj->m_AttackDamageMinRight*30)/100; lpObj->m_AttackDamageMaxRight += (lpObj->m_AttackDamageMaxRight*30)/100; //Add 30% to Magic Attack lpObj->m_MagicDamageMin += (lpObj->m_MagicDamageMin*30)/100; lpObj->m_MagicDamageMax += (lpObj->m_MagicDamageMax*30)/100; } else if ( Helper->m_Type == ITEMGET(13,3) ) // Dinorant { //Helper->PlusSpecial(&lpObj->AddBP, 103 ); //Add 15% to Attack lpObj->m_AttackDamageMinLeft += (lpObj->m_AttackDamageMinLeft*15)/100; lpObj->m_AttackDamageMaxLeft += (lpObj->m_AttackDamageMaxLeft*15)/100; lpObj->m_AttackDamageMinRight += (lpObj->m_AttackDamageMinRight*15)/100; lpObj->m_AttackDamageMaxRight += (lpObj->m_AttackDamageMaxRight*15)/100; //Add 15% to Magic Attack lpObj->m_MagicDamageMin += (lpObj->m_MagicDamageMin*15)/100; lpObj->m_MagicDamageMax += (lpObj->m_MagicDamageMax*15)/100; } else if ( Helper->m_Type == ITEMGET(13,64) ) // Demon { //Add 40% to Attack lpObj->m_AttackDamageMinLeft += (lpObj->m_AttackDamageMinLeft*40)/100; lpObj->m_AttackDamageMaxLeft += (lpObj->m_AttackDamageMaxLeft*40)/100; lpObj->m_AttackDamageMinRight += (lpObj->m_AttackDamageMinRight*40)/100; lpObj->m_AttackDamageMaxRight += (lpObj->m_AttackDamageMaxRight*40)/100; //Add +10 to Attack Speed lpObj->m_MagicSpeed += 10; lpObj->m_AttackSpeed += 10; //Add 40% to Magic Attack lpObj->m_MagicDamageMin += (lpObj->m_MagicDamageMin*40)/100; lpObj->m_MagicDamageMax += (lpObj->m_MagicDamageMax*40)/100; } else if ( Helper->m_Type == ITEMGET(13,65) ) // Spirit Guardian { lpObj->AddLife += 50; } else if ( Helper->m_Type == ITEMGET(13,80) ) // Pet Panda { lpObj->m_Defense += 50; } else if ( Helper->m_Type == ITEMGET(13,123) ) // Skeleton Pet { //Add 20% to Attack lpObj->m_AttackDamageMinLeft += (lpObj->m_AttackDamageMinLeft*20)/100; lpObj->m_AttackDamageMaxLeft += (lpObj->m_AttackDamageMaxLeft*20)/100; lpObj->m_AttackDamageMinRight += (lpObj->m_AttackDamageMinRight*20)/100; lpObj->m_AttackDamageMaxRight += (lpObj->m_AttackDamageMaxRight*20)/100; //Add +10 to Attack Speed lpObj->m_MagicSpeed += 10; lpObj->m_AttackSpeed += 10; //Add 20% to Magic Attack lpObj->m_MagicDamageMin += (lpObj->m_MagicDamageMin*20)/100; lpObj->m_MagicDamageMax += (lpObj->m_MagicDamageMax*20)/100; } int addlife = 0; int addmana = 0; Wings->PlusSpecial(&addlife, 100); Wings->PlusSpecial(&addmana, 101); Wings->PlusSpecial(&AddLeadership, 105); lpObj->AddLeadership = AddLeadership; lpObj->AddLife += addlife; lpObj->AddMana += addmana; if ( lpObj->Type == OBJ_USER ) { gDarkSpirit[lpObj->m_Index].Set(lpObj->m_Index, &lpObj->pInventory[1]); } Amulet->PlusSpecialPercentEx(&lpObj->AddBP, lpObj->MaxBP, 173); Ring01->PlusSpecialPercentEx(&lpObj->AddMana, lpObj->MaxMana, 172); Ring02->PlusSpecialPercentEx(&lpObj->AddMana, lpObj->MaxMana, 172); CItem * rItem[3]; int comparecount = 0; rItem[0] = &lpObj->pInventory[10]; rItem[1] = &lpObj->pInventory[11]; rItem[2] = &lpObj->pInventory[9]; #define GET_MAX_RESISTANCE(x,y,z) ( ( ( ( (x) > (y) ) ? (x) : (y) ) > (z) ) ? ( ( (x) > (y) ) ? (x) : (y) ) : (z) ) lpObj->m_Resistance[1] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[1], rItem[1]->m_Resistance[1], rItem[2]->m_Resistance[1]); lpObj->m_Resistance[0] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[0], rItem[1]->m_Resistance[0], rItem[2]->m_Resistance[0]); lpObj->m_Resistance[2] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[2], rItem[1]->m_Resistance[2], rItem[2]->m_Resistance[2]); lpObj->m_Resistance[3] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[3], rItem[1]->m_Resistance[3], rItem[2]->m_Resistance[3]); lpObj->m_Resistance[4] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[4], rItem[1]->m_Resistance[4], rItem[2]->m_Resistance[4]); lpObj->m_Resistance[5] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[5], rItem[1]->m_Resistance[5], rItem[2]->m_Resistance[5]); lpObj->m_Resistance[6] = GET_MAX_RESISTANCE(rItem[0]->m_Resistance[6], rItem[1]->m_Resistance[6], rItem[2]->m_Resistance[6]); g_Item380System.ApplyFor380Option(lpObj); g_kJewelOfHarmonySystem.SetApplyStrengthenItem(lpObj); gItemSocket.ApplyEffect(lpObj); gSkillTree.ApplyEffect(lpObj); GObjExtItemApply(lpObj); gObjSetItemApply(lpObj); gObjNextExpCal(lpObj); if ( (Left->m_Type >= ITEMGET(4,0) && Left->m_Type < ITEMGET(4,7) ) || Left->m_Type == ITEMGET(4,17) || Left->m_Type == ITEMGET(4,20) || Left->m_Type == ITEMGET(4,21) || Left->m_Type == ITEMGET(4,22) || Left->m_Type == ITEMGET(4,23) || Left->m_Type == ITEMGET(4,24) ) { if ( Right->m_Type == ITEMGET(4,15) && Right->m_Level == 1 ) { lpObj->m_AttackDamageMinLeft += (WORD)(lpObj->m_AttackDamageMinLeft * 0.03f + 1.0f); lpObj->m_AttackDamageMaxLeft += (WORD)(lpObj->m_AttackDamageMaxLeft * 0.03f + 1.0f); } else if ( Right->m_Type == ITEMGET(4,15) && Right->m_Level == 2 ) { lpObj->m_AttackDamageMinLeft += (WORD)(lpObj->m_AttackDamageMinLeft * 0.05f + 1.0f); lpObj->m_AttackDamageMaxLeft += (WORD)(lpObj->m_AttackDamageMaxLeft * 0.05f + 1.0f); } } else if ( (Right->m_Type >= ITEMGET(4,8) && Right->m_Type < ITEMGET(4,15) ) || (Right->m_Type >= ITEMGET(4,16) && Right->m_Type < ITEMGET(5,0)) ) { if ( Left->m_Type == ITEMGET(4,7) && Left->m_Level == 1 ) { lpObj->m_AttackDamageMinRight += (WORD)(lpObj->m_AttackDamageMinRight * 0.03f + 1.0f); lpObj->m_AttackDamageMaxRight += (WORD)(lpObj->m_AttackDamageMaxRight * 0.03f + 1.0f); } else if ( Left->m_Type == ITEMGET(4,7) && Left->m_Level == 2 ) { lpObj->m_AttackDamageMinRight += (WORD)(lpObj->m_AttackDamageMinRight * 0.05f + 1.0f); lpObj->m_AttackDamageMaxRight += (WORD)(lpObj->m_AttackDamageMaxRight * 0.05f + 1.0f); } } if ( lpObj->Class == CLASS_KNIGHT || lpObj->Class == CLASS_MAGUMSA || lpObj->Class == CLASS_DARKLORD || lpObj->Class == CLASS_FIGHTER ) { if ( Right->m_Type != -1 && Left->m_Type != -1 ) { if ( Right->m_Type >= ITEMGET(0,0) && Right->m_Type < ITEMGET(4,0) && Left->m_Type >= ITEMGET(0,0) && Left->m_Type < ITEMGET(4,0) ) { lpObj->m_AttackDamageMinRight = lpObj->m_AttackDamageMinRight * 55 / 100; lpObj->m_AttackDamageMaxRight = lpObj->m_AttackDamageMaxRight * 55 / 100; lpObj->m_AttackDamageMinLeft = lpObj->m_AttackDamageMinLeft * 55 / 100; lpObj->m_AttackDamageMaxLeft = lpObj->m_AttackDamageMaxLeft * 55 / 100; } } } if ( lpObj->m_iItemEffectValidTime > 0 ) { g_ItemAddOption.NextSetItemLastEffectForHallowin(lpObj); } gObjCalcShieldPoint(lpObj); if ( lpObj->iShield > ( lpObj->iMaxShield + lpObj->iAddShield ) ) { lpObj->iShield = lpObj->iMaxShield + lpObj->iAddShield ; GCReFillSend(lpObj->m_Index, lpObj->Life, 0xFF, 0, lpObj->iShield); } GCReFillSend(lpObj->m_Index, lpObj->MaxLife + lpObj->AddLife, 0xFE, 0, lpObj->iMaxShield + lpObj->iAddShield); GCManaSend(lpObj->m_Index, lpObj->MaxMana + lpObj->AddMana, 0xFE, 0, lpObj->MaxBP + lpObj->AddBP); }
UINT16 CGoods::UseRateBox(DT_ITEM_DATA_LIST_CLI2& stBoxItemInfo) { SGoodsProp* pstGoodsProp = GetGoodsProp(); if(NULL == pstGoodsProp) { RETURN_OTHER_ERR; } stBoxItemInfo.byItemNum = 0; SItemComposeProp* pstItemComposeProp = CItemComposePropMgr::Instance()->GetProp(pstGoodsProp->wKindID); if(NULL == pstItemComposeProp) { SYS_CRITICAL(_SDT("[%s: %d]: pstItemComposeProp is NULL!"), MSG_MARK); RETURN_OTHER_ERR; } CItemRateMap& mapComposeItem = pstItemComposeProp->mapComposeItem; if(0 == mapComposeItem.size()) { SYS_CRITICAL(_SDT("[%s: %d]: mapComposeItem[%d] is 0!"), MSG_MARK, pstGoodsProp->wKindID); RETURN_OTHER_ERR; } //计算随机值 CRandomVec vecRandom; for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++) { vecRandom.push_back(itr->second.wRate); } //随机 INT32 nRandomHitIdx = GetRandomIdxMustHit(vecRandom); if(RANDOM_UNHIT == nRandomHitIdx) { //随机不到物品也算使用成功 return ERR_GOODS_USE::ID_SUCCESS; } stBoxItemInfo.byItemNum = 0; UINT8 byIdx = 0; for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++, byIdx++) { if(byIdx == nRandomHitIdx) { //若是系统可以直接使用的物品,则使用 if(CItemMgr::Instance()->SysUseGoods(m_poOwner, itr->first, itr->second.wItemNum)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum++]); } else { UINT16 wItemKindID = itr->first; ECreateItemRet eRet; CItem* poItem = CItemMgr::Instance()->CreateItemIntoBag(m_poOwner, wItemKindID, itr->second.wItemNum, eRet, 0, CRecordMgr::EAIT_BOX, m_stDT_GOODS_DATA.wKindID ); if(NULL == poItem) { if(ECIR_FAILED_BAG_FULL == eRet) { return ERR_GOODS_USE::ID_BAG_FULL; } else { //异常 SYS_CRITICAL(_SDT("[%s: %d]: CreateItemIntoBag failed[%d]!"), MSG_MARK, wItemKindID); RETURN_OTHER_ERR; } } //内部礼包,返回的是礼包的物品 SGoodsProp* pstGoodsProp = CGoodsPropMgr::Instance()->GetPropByPrimaryKey(itr->first); if((pstGoodsProp) && (EGMK_INNERBOX == pstGoodsProp->byMainKindID)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(poItem->GetItemKindID(), 1, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum++]); } else { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum++]); } } break; //只爆出1个物品 } } return ERR_GOODS_USE::ID_SUCCESS; }
bool CInArchive::ReadHeaderReal(const Byte *p, unsigned size, CItem &item) { const Byte *pStart = p; item.Clear(); item.Flags = m_BlockHeader.Flags; const unsigned kFileHeaderSize = 25; if (size < kFileHeaderSize) return false; item.PackSize = Get32(p); item.Size = Get32(p + 4); item.HostOS = p[8]; item.FileCRC = Get32(p + 9); item.MTime.DosTime = Get32(p + 13); item.UnPackVersion = p[17]; item.Method = p[18]; unsigned nameSize = Get16(p + 19); item.Attrib = Get32(p + 21); item.MTime.LowSecond = 0; item.MTime.SubTime[0] = item.MTime.SubTime[1] = item.MTime.SubTime[2] = 0; p += kFileHeaderSize; size -= kFileHeaderSize; if ((item.Flags & NHeader::NFile::kSize64Bits) != 0) { if (size < 8) return false; item.PackSize |= ((UInt64)Get32(p) << 32); item.Size |= ((UInt64)Get32(p + 4) << 32); p += 8; size -= 8; } if (nameSize > size) return false; ReadName(p, nameSize, item); p += nameSize; size -= nameSize; /* // It was commented, since it's difficult to support alt Streams for solid archives. if (m_BlockHeader.Type == NHeader::NBlockType::kSubBlock) { if (item.HasSalt()) { if (size < sizeof(item.Salt)) return false; size -= sizeof(item.Salt); p += sizeof(item.Salt); } if (item.Name == "ACL" && size == 0) { item.IsAltStream = true; item.Name.Empty(); item.UnicodeName = L".ACL"; } else if (item.Name == "STM" && size != 0 && (size & 1) == 0) { item.IsAltStream = true; item.Name.Empty(); for (UInt32 i = 0; i < size; i += 2) { wchar_t c = Get16(p + i); if (c == 0) return false; item.UnicodeName += c; } } } */ if (item.HasSalt()) { if (size < sizeof(item.Salt)) return false; for (unsigned i = 0; i < sizeof(item.Salt); i++) item.Salt[i] = p[i]; p += sizeof(item.Salt); size -= sizeof(item.Salt); } // some rar archives have HasExtTime flag without field. if (size >= 2 && item.HasExtTime()) { Byte aMask = (Byte)(p[0] >> 4); Byte b = p[1]; p += 2; size -= 2; Byte mMask = (Byte)(b >> 4); Byte cMask = (Byte)(b & 0xF); if ((mMask & 8) != 0) { READ_TIME(mMask, item.MTime); } READ_TIME_2(cMask, item.CTimeDefined, item.CTime); READ_TIME_2(aMask, item.ATimeDefined, item.ATime); }
int32 startSynth(CCharEntity* PChar) { PROFILE_FUNC(); uint16 effect = 0; uint8 element = 0; uint16 crystalType = PChar->CraftContainer->getItemID(0); switch(crystalType) { case 0x1000: case 0x108E: effect = EFFECT_FIRESYNTH; element = ELEMENT_FIRE; break; case 0x1001: case 0x108F: effect = EFFECT_ICESYNTH; element = ELEMENT_ICE; break; case 0x1002: case 0x1090: effect = EFFECT_WINDSYNTH; element = ELEMENT_WIND; break; case 0x1003: case 0x1091: effect = EFFECT_EARTHSYNTH; element = ELEMENT_EARTH; break; case 0x1004: case 0x1092: effect = EFFECT_LIGHTNINGSYNTH; element = ELEMENT_LIGHTNING; break; case 0x1005: case 0x1093: effect = EFFECT_WATERSYNTH; element = ELEMENT_WATER; break; case 0x1006: case 0x1094: effect = EFFECT_LIGHTSYNTH; element = ELEMENT_LIGHT; break; case 0x1007: case 0x1095: effect = EFFECT_DARKSYNTH; element = ELEMENT_DARK; break; } PChar->CraftContainer->setType(element); if (!isRightRecipe(PChar)) { return 0; } // удаляем кристалл charutils::UpdateItem(PChar, LOC_INVENTORY, PChar->CraftContainer->getInvSlotID(0), -1); uint8 result = calcSynthResult(PChar); uint8 invSlotID = 0; uint8 tempSlotID = 0; uint16 itemID = 0; uint32 quantity = 0; for(uint8 slotID = 1; slotID <= 8; ++slotID) { tempSlotID = PChar->CraftContainer->getInvSlotID(slotID); if ((tempSlotID != 0xFF) && (tempSlotID != invSlotID)) { invSlotID = tempSlotID; CItem* PItem = PChar->getStorage(LOC_INVENTORY)->GetItem(invSlotID); if (PItem != NULL) { PItem->setSubType(ITEM_LOCKED); PChar->pushPacket(new CInventoryAssignPacket(PItem, INV_NOSELECT)); } } } PChar->animation = ANIMATION_SYNTH; PChar->pushPacket(new CCharUpdatePacket(PChar)); if(PChar->loc.zone->GetID() != 255 && PChar->loc.zone->GetID() != 0) { PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE_SELF, new CSynthAnimationPacket(PChar,effect,result)); } else { PChar->pushPacket(new CSynthAnimationPacket(PChar, effect, result)); } return 0; }
void CUIHelper::PaintItemEntry (CG16bitImage &Dest, CSpaceObject *pSource, const CItem &Item, const RECT &rcRect, DWORD dwOptions) const // PaintItemEntry // // Paints an item entry suitable for an item list. { const CVisualPalette &VI = m_HI.GetVisuals(); const CG16bitFont &LargeBold = VI.GetFont(fontLargeBold); const CG16bitFont &Medium = VI.GetFont(fontMedium); WORD wColorTitle = VI.GetColor(colorTextHighlight); WORD wColorRef = VI.GetColor(colorTextHighlight); WORD wColorDescSel = CG16bitImage::RGBValue(200,200,200); WORD wColorDesc = CG16bitImage::RGBValue(128,128,128); bool bSelected = ((dwOptions & OPTION_SELECTED) == OPTION_SELECTED); bool bNoIcon = ((dwOptions & OPTION_NO_ICON) == OPTION_NO_ICON); bool bTitle = ((dwOptions & OPTION_TITLE) == OPTION_TITLE); // Item context CItemCtx Ctx(&Item, pSource); CItemType *pItemType = Item.GetType(); // Calc the rect where we will draw RECT rcDrawRect = rcRect; rcDrawRect.left += ITEM_TEXT_MARGIN_X; rcDrawRect.right -= ITEM_TEXT_MARGIN_X; rcDrawRect.top += ITEM_TEXT_MARGIN_Y; // Paint the image if (!bNoIcon) { DrawItemTypeIcon(Dest, rcRect.left, rcRect.top, pItemType); rcDrawRect.left += ICON_WIDTH; } // Paint the item name DWORD dwNounPhraseFlags = nounNoModifiers; if (bTitle) dwNounPhraseFlags |= nounTitleCapitalize | nounShort; else dwNounPhraseFlags |= nounCount; int cyHeight; RECT rcTitle = rcDrawRect; LargeBold.DrawText(Dest, rcTitle, wColorTitle, Item.GetNounPhrase(dwNounPhraseFlags), 0, CG16bitFont::SmartQuotes | CG16bitFont::TruncateLine, &cyHeight); rcDrawRect.top += cyHeight; if (bTitle) rcDrawRect.top += ITEM_TITLE_EXTRA_MARGIN; // Paint the display attributes TArray<SDisplayAttribute> Attribs; if (Item.GetDisplayAttributes(Ctx, &Attribs)) { FormatDisplayAttributes(Attribs, rcDrawRect, &cyHeight); PaintDisplayAttributes(Dest, Attribs); rcDrawRect.top += cyHeight + ATTRIB_SPACING_Y; } // Stats CString sStat; int iLevel = pItemType->GetApparentLevel(); CString sReference = pItemType->GetReference(Ctx); DamageTypes iDamageType; CString sDamageRef; int iDamageAdj[damageCount]; int iHP; if (Item.GetReferenceDamageType(pSource, -1, 0, &iDamageType, &sDamageRef)) { // Paint the damage type reference PaintReferenceDamageType(Dest, rcDrawRect.left + DAMAGE_ADJ_SPACING_X, rcDrawRect.top, iDamageType, sDamageRef); rcDrawRect.top += Medium.GetHeight(); // Paint additional reference in the line below if (!sReference.IsBlank()) { Medium.DrawText(Dest, rcDrawRect, wColorRef, sReference, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } } else if (Item.GetReferenceDamageAdj(pSource, 0, &iHP, iDamageAdj)) { // Paint the initial text sStat = strPatternSubst("hp: %d ", iHP); int cxWidth = Medium.MeasureText(sStat, &cyHeight); Medium.DrawText(Dest, rcDrawRect, wColorRef, sStat, 0, 0, &cyHeight); // Paint the damage type array PaintReferenceDamageAdj(Dest, rcDrawRect.left + cxWidth + DAMAGE_ADJ_SPACING_X, rcDrawRect.top, iLevel, iHP, iDamageAdj); rcDrawRect.top += cyHeight; // Paint additional reference in the line below if (!sReference.IsBlank()) { Medium.DrawText(Dest, rcDrawRect, wColorRef, sReference, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } } else { Medium.DrawText(Dest, rcDrawRect, wColorRef, sReference, 0, 0, &cyHeight); rcDrawRect.top += cyHeight; } // Description CString sDesc = Item.GetDesc(); Medium.DrawText(Dest, rcDrawRect, (bSelected ? wColorDescSel : wColorDesc), sDesc, 0, CG16bitFont::SmartQuotes, &cyHeight); rcDrawRect.top += cyHeight; }
int32 doSynthResult(CCharEntity* PChar) { PROFILE_FUNC(); uint8 m_synthResult = PChar->CraftContainer->getQuantity(0); if (m_synthResult == SYNTHESIS_FAIL) { doSynthFail(PChar); }else{ uint16 itemID = PChar->CraftContainer->getItemID(10 + m_synthResult); uint8 quantity = PChar->CraftContainer->getInvSlotID(10 + m_synthResult); // к сожалению поле quantity занято uint8 invSlotID = 0; uint8 nextSlotID = 0; uint8 removeCount = 0; invSlotID = PChar->CraftContainer->getInvSlotID(1); for(uint8 slotID = 1; slotID <= 8; ++slotID) { nextSlotID = (slotID != 8 ? PChar->CraftContainer->getInvSlotID(slotID+1) : 0); removeCount++; if (invSlotID != nextSlotID) { if (invSlotID != 0xFF) { #ifdef _DSP_SYNTH_DEBUG_MESSAGES_ ShowDebug(CL_CYAN"Removing quantity %u from inventory slot %u\n" CL_RESET,removeCount,invSlotID); #endif PChar->getStorage(LOC_INVENTORY)->GetItem(invSlotID)->setSubType(ITEM_UNLOCKED); charutils::UpdateItem(PChar, LOC_INVENTORY, invSlotID, -(int32)removeCount); } invSlotID = nextSlotID; nextSlotID = 0; removeCount = 0; } } // TODO: перейти на новую функцию AddItem, чтобы не обновлять signature ручками invSlotID = charutils::AddItem(PChar, LOC_INVENTORY, itemID, quantity); CItem* PItem = PChar->getStorage(LOC_INVENTORY)->GetItem(invSlotID); if (PItem != NULL) { if ((PItem->getFlag() & ITEM_FLAG_INSCRIBABLE) && (PChar->CraftContainer->getItemID(0) > 0x1080)) { int8 encodedSignature [12]; PItem->setSignature(EncodeStringSignature((int8*)PChar->name.c_str(), encodedSignature)); int8 signature_esc[31]; //max charname: 15 chars * 2 + 1 Sql_EscapeStringLen(SqlHandle,signature_esc,PChar->name.c_str(),strlen(PChar->name.c_str())); int8 fmtQuery[] = "UPDATE char_inventory SET signature = '%s' WHERE charid = %u AND location = 0 AND slot = %u;\0"; Sql_Query(SqlHandle,fmtQuery,signature_esc,PChar->id, invSlotID); } PChar->pushPacket(new CInventoryItemPacket(PItem, LOC_INVENTORY, invSlotID)); } PChar->pushPacket(new CInventoryFinishPacket()); if(PChar->loc.zone->GetID() != 255 && PChar->loc.zone->GetID() != 0) { // Don't send this packet to the zone it does funky stuff. //PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE_SELF, new CSynthMessagePacket(PChar, SYNTH_SUCCESS, itemID, quantity)); PChar->pushPacket(new CSynthMessagePacket(PChar, SYNTH_SUCCESS, itemID, quantity)); } else { PChar->pushPacket(new CSynthMessagePacket(PChar, SYNTH_SUCCESS, itemID, quantity)); } } doSynthSkillUp(PChar); return 0; }
void CLaserBeam::FixAttachment(IEntity* pLaserEntity) { m_usingEntityAttachment = false; IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem(); CItem* pOwnerItem = static_cast<CItem*>(pItemSystem->GetItem(m_ownerEntityId)); if (pOwnerItem) { IEntity* pOwnerEntity = pOwnerItem->GetEntity(); IEntity* pAttachedEntity = pOwnerEntity; const char* attach_helper = "laser_term"; Vec3 offset = pOwnerItem->GetSlotHelperPos(m_geometrySlot, attach_helper, false); if(m_geometrySlot == eIGS_FirstPerson) { if(pOwnerItem->IsAccessory()) { EntityId parentId = pOwnerItem->GetParentId(); if(parentId) { if(CItem* pParentItem = static_cast<CItem*>(pItemSystem->GetItem(parentId))) { const SAccessoryParams* pParams = pParentItem->GetAccessoryParams(pAttachedEntity->GetClass()); attach_helper = pParams->attach_helper.c_str(); pAttachedEntity = pParentItem->GetEntity(); } } } if(pAttachedEntity) { ICharacterInstance *pCharacter = pAttachedEntity->GetCharacter(eIGS_FirstPerson); if (pCharacter) { IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager(); IAttachment *pLaserAttachment = pAttachmentManager->GetInterfaceByName(LASER_ATTACH_NAME); if(!pLaserAttachment) { IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(attach_helper); if(pAttachment) { const char* pBone = pCharacter->GetICharacterModel()->GetICharacterModelSkeleton()->GetJointNameByID(pAttachment->GetJointID()); pLaserAttachment = pAttachmentManager->CreateAttachment(LASER_ATTACH_NAME, CA_BONE, pBone); if(pLaserAttachment) { QuatT relative = pAttachment->GetAttRelativeDefault(); if(pOwnerItem->GetEntity() != pAttachedEntity) { Matrix34 mtx(relative); relative.t = relative * offset; } pLaserAttachment->SetAttRelativeDefault(relative); } } } if(pLaserAttachment) { CEntityAttachment* pEntAttach = new CEntityAttachment; pEntAttach->SetEntityId(m_laserEntityId); pLaserAttachment->AddBinding(pEntAttach); pLaserAttachment->HideAttachment(0); m_usingEntityAttachment = true; } } } } if(!m_usingEntityAttachment && pOwnerEntity) { pOwnerEntity->AttachChild(pLaserEntity); pLaserEntity->SetLocalTM(Matrix34::CreateTranslationMat(offset)); } } }
////*---------------------------------------------------------------------------// ///// @param iIndex - Slot Index ///// @brief 구입리스트에서 특정 물품을 리턴한다. ////*---------------------------------------------------------------------------// //CItem* CPrivateStore::GetItemBuyList( int iIndex ) //{ // if( iIndex >= 0 && iIndex < m_BuyItems.size() ) // return m_BuyItems[iIndex]; // // return NULL; //} //*---------------------------------------------------------------------------// /// @param bSendPacket - 서버에 추가사항을 알려주는가? /// @brief 찜리스트에 특정 item을 추가한다. //*---------------------------------------------------------------------------// void CPrivateStore::AddItemWishList( tagITEM& Item , bool bSendPacket ,int iSlotIndex ) { if( IsOpened() ) return; if( Item.IsEmpty() ) return; if( !Item.IsEnableExchange() ) { g_itMGR.AppendChatMsg(STR_DONT_EXCHANGE_ITEM, IT_MGR::CHAT_TYPE_SYSTEM); return; } if( !Item.IsEnableSELL() ) { g_itMGR.AppendChatMsg(STR_DONT_SELL_ITEM, IT_MGR::CHAT_TYPE_SYSTEM ); return; } if( iSlotIndex >= 0 ) { assert( iSlotIndex < MAX_WISH_ITEMS ); if( iSlotIndex < MAX_WISH_ITEMS ) { CItem* pItem = new CItem; pItem->SetIndex( iSlotIndex ); pItem->SetUnitPrice(0); pItem->SetItem( Item ); m_WishItems[iSlotIndex] = pItem; CTEventPrivateStore Event; Event.SetID( CTEventPrivateStore::EID_ADD_WISHLIST ); Event.SetIndex( iSlotIndex ); Event.SetItem( pItem ); SetChanged(); NotifyObservers( &Event ); } } else { int iIndex = 0; for( iIndex = 0; iIndex < MAX_WISH_ITEMS; ++iIndex ) { if( m_WishItems[iIndex] == NULL ) { CItem* pItem = new CItem; pItem->SetIndex( iIndex ); tagITEM TempItem = Item; if( TempItem.IsEnableDupCNT() ) TempItem.m_uiQuantity = 0; pItem->SetItem( TempItem ); m_WishItems[iIndex] = pItem; CTEventPrivateStore Event; Event.SetID( CTEventPrivateStore::EID_ADD_WISHLIST ); Event.SetIndex( iIndex ); Event.SetItem( pItem ); SetChanged(); NotifyObservers( &Event ); if( bSendPacket ) g_pNet->Send_cli_SET_WISHITEM( iIndex, TempItem ); return; } } g_itMGR.AppendChatMsg(STR_CANT_ADDITEM2BUYLIST, IT_MGR::CHAT_TYPE_SYSTEM ); } }
void do_PremiumChar_Use_Item(CPC* ch, CNetMsg::SP& msg) { RequestClient::premiumChar_UseItem* packet = reinterpret_cast<RequestClient::premiumChar_UseItem*>(msg->m_buf); if (ch->m_inventory.isValidNormalInventory(packet->tab, packet->invenIndex) == false) { LOG_ERROR("HACKING? : invalid packet. char_index[%d] tab[%d] invenIndex[%d]", ch->m_index, packet->tab, packet->invenIndex); ch->m_desc->Close("invalid packet"); return; } // 아이템 찾기 CItem* pItem = ch->m_inventory.getItem(packet->tab, packet->invenIndex); if (pItem == NULL) { LOG_ERROR("HACKING? : not found item. char_index[%d] tab[%d] invenIndex[%d]", ch->m_index, packet->tab, packet->invenIndex); ch->m_desc->Close("not found item"); return; } if (pItem->getVIndex() != packet->virtualIndex) { LOG_ERROR("HACKING? : invalid virtual index. char_index[%d] tab[%d] invenIndex[%d]", ch->m_index, packet->tab, packet->invenIndex); ch->m_desc->Close("invalid virtual index"); return; } // 실제 사용 if (ch->m_premiumChar.isActive()) { CNetMsg::SP rmsg(new CNetMsg); ResponseClient::makePremiumCharUseItem(rmsg, ERR_PREMIUM_CHAR_ALREADY_USED); SEND_Q(rmsg, ch->m_desc); return; } ch->m_premiumChar.reset(); switch (pItem->getDBIndex()) { case PREMIUM_CHAR_ITEM_INDEX: { ch->m_premiumChar.setPremiumType(PREMIUM_CHAR_TYPE_FIRST); ch->m_premiumChar.setExpireTime(gserver->getNowSecond() + (30 * 86400)); ch->m_premiumChar.sendInfo(); } break; default: { LOG_ERROR("HACKING? : invalid item index. char_index[%d] tab[%d] invenIndex[%d]", ch->m_index, packet->tab, packet->invenIndex); ch->m_desc->Close("invalid item index"); } return; } { CNetMsg::SP rmsg(new CNetMsg); ResponseClient::makePremiumCharUseItem(rmsg, ERR_PREMIUM_CHAR_NONE); SEND_Q(rmsg, ch->m_desc); } ch->m_premiumChar.setActive(); // 아이템 지우기 ch->m_inventory.decreaseItemCount(pItem, 1); ch->m_premiumChar.saveNow(); ch->m_premiumChar.saveSetLog(); ch->SendStatus(); }
void LoadItemList() { PROFILE_FUNC(); memset(g_pItemList,0,sizeof(g_pItemList)); memset(g_pDropList,0,sizeof(g_pDropList)); const int8* Query = "SELECT " "b.itemId," // 0 "b.name," // 1 "b.stackSize," // 2 "b.flags," // 3 "b.aH," // 4 "b.BaseSell," // 5 "b.subid," // 6 "u.validTargets," // 7 "u.activation," // 8 "u.animation," // 9 "u.animationTime," // 10 "u.maxCharges," // 11 "u.useDelay," // 12 "u.reuseDelay," // 13 "u.aoe," // 14 "a.level," // 15 "a.jobs," // 16 "a.MId," // 17 "a.shieldSize," // 18 "a.scriptType," // 19 "a.slot," // 20 "a.rslot," // 21 "w.skill," // 22 "w.subskill," // 23 "w.delay," // 24 "w.dmg," // 25 "w.dmgType," // 26 "w.hit," // 27 "w.unlock_index," // 28 "f.storage," // 29 "f.moghancement," // 30 "f.element," // 31 "f.aura," // 32 "p.slot," // 33 "p.element " // 34 "FROM item_basic AS b " "LEFT JOIN item_usable AS u USING (itemId) " "LEFT JOIN item_armor AS a USING (itemId) " "LEFT JOIN item_weapon AS w USING (itemId) " "LEFT JOIN item_furnishing AS f USING (itemId) " "LEFT JOIN item_puppet AS p USING (itemId) " "WHERE itemId < %u;"; int32 ret = Sql_Query(SqlHandle, Query, MAX_ITEMID); if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0) { while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) { CItem* PItem = CreateItem(Sql_GetUIntData(SqlHandle,0)); if(PItem != NULL) { PItem->setName(Sql_GetData(SqlHandle,1)); PItem->setStackSize(Sql_GetUIntData(SqlHandle,2)); PItem->setFlag(Sql_GetUIntData(SqlHandle,3)); PItem->setAHCat(Sql_GetUIntData(SqlHandle,4)); PItem->setBasePrice(Sql_GetUIntData(SqlHandle,5)); PItem->setSubID(Sql_GetUIntData(SqlHandle,6)); if (PItem->isType(ITEM_GENERAL)) { } if (PItem->isType(ITEM_USABLE)) { ((CItemUsable*)PItem)->setValidTarget(Sql_GetUIntData(SqlHandle,7)); ((CItemUsable*)PItem)->setActivationTime(Sql_GetUIntData(SqlHandle,8)*1000); ((CItemUsable*)PItem)->setAnimationID(Sql_GetUIntData(SqlHandle,9)); ((CItemUsable*)PItem)->setAnimationTime(Sql_GetUIntData(SqlHandle,10)*1000); ((CItemUsable*)PItem)->setMaxCharges(Sql_GetUIntData(SqlHandle,11)); ((CItemUsable*)PItem)->setCurrentCharges(Sql_GetUIntData(SqlHandle,11)); ((CItemUsable*)PItem)->setUseDelay(Sql_GetUIntData(SqlHandle,12)); ((CItemUsable*)PItem)->setReuseDelay(Sql_GetUIntData(SqlHandle,13)); ((CItemUsable*)PItem)->setAoE(Sql_GetUIntData(SqlHandle,14)); } if (PItem->isType(ITEM_PUPPET)) { ((CItemPuppet*)PItem)->setEquipSlot(Sql_GetUIntData(SqlHandle,33)); ((CItemPuppet*)PItem)->setElementSlots(Sql_GetUIntData(SqlHandle,34)); } if (PItem->isType(ITEM_ARMOR)) { ((CItemArmor*)PItem)->setReqLvl(Sql_GetUIntData(SqlHandle,15)); ((CItemArmor*)PItem)->setJobs(Sql_GetUIntData(SqlHandle,16)); ((CItemArmor*)PItem)->setModelId(Sql_GetUIntData(SqlHandle,17)); ((CItemArmor*)PItem)->setShieldSize(Sql_GetUIntData(SqlHandle,18)); ((CItemArmor*)PItem)->setScriptType(Sql_GetUIntData(SqlHandle,19)); ((CItemArmor*)PItem)->setEquipSlotId(Sql_GetUIntData(SqlHandle,20)); ((CItemArmor*)PItem)->setRemoveSlotId(Sql_GetUIntData(SqlHandle,21)); if (((CItemArmor*)PItem)->getValidTarget() != 0) { ((CItemArmor*)PItem)->setSubType(ITEM_CHARGED); } } if (PItem->isType(ITEM_WEAPON)) { ((CItemWeapon*)PItem)->setSkillType(Sql_GetUIntData(SqlHandle,22)); ((CItemWeapon*)PItem)->setSubSkillType(Sql_GetUIntData(SqlHandle,23)); ((CItemWeapon*)PItem)->setDelay((Sql_GetIntData(SqlHandle,24)*1000)/60); ((CItemWeapon*)PItem)->setDamage(Sql_GetUIntData(SqlHandle,25)); ((CItemWeapon*)PItem)->setDmgType(Sql_GetUIntData(SqlHandle,26)); ((CItemWeapon*)PItem)->setMaxHit(Sql_GetUIntData(SqlHandle,27)); ((CItemWeapon*)PItem)->setUnlockable(Sql_GetUIntData(SqlHandle,28)); } if (PItem->isType(ITEM_FURNISHING)) { ((CItemFurnishing*)PItem)->setStorage(Sql_GetUIntData(SqlHandle,29)); ((CItemFurnishing*)PItem)->setMoghancement(Sql_GetUIntData(SqlHandle,30)); ((CItemFurnishing*)PItem)->setElement(Sql_GetUIntData(SqlHandle,31)); ((CItemFurnishing*)PItem)->setAura(Sql_GetUIntData(SqlHandle,32)); } g_pItemList[PItem->getID()] = PItem; } } } ret = Sql_Query(SqlHandle,"SELECT itemId, modId, value FROM item_mods WHERE itemId IN (SELECT itemId FROM item_basic LEFT JOIN item_armor USING (itemId))"); if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0) { while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) { uint16 ItemID = (uint16)Sql_GetUIntData(SqlHandle,0); uint16 modID = (uint16)Sql_GetUIntData(SqlHandle,1); int16 value = (int16) Sql_GetIntData (SqlHandle,2); if ((g_pItemList[ItemID] != NULL) && g_pItemList[ItemID]->isType(ITEM_ARMOR)) { ((CItemArmor*)g_pItemList[ItemID])->addModifier(new CModifier(modID,value)); } } } ret = Sql_Query(SqlHandle,"SELECT itemId, modId, value, latentId, latentParam FROM item_latents WHERE itemId IN (SELECT itemId FROM item_basic LEFT JOIN item_armor USING (itemId))"); if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0) { while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) { uint16 ItemID = (uint16)Sql_GetUIntData(SqlHandle,0); uint16 modID = (uint16)Sql_GetUIntData(SqlHandle,1); int16 value = (int16) Sql_GetIntData (SqlHandle,2); uint16 latentId = (uint16) Sql_GetIntData(SqlHandle,3); uint16 latentParam = (uint16) Sql_GetIntData(SqlHandle,4); if ((g_pItemList[ItemID] != NULL) && g_pItemList[ItemID]->isType(ITEM_ARMOR)) { ((CItemArmor*)g_pItemList[ItemID])->addLatent(new CLatentEffect((LATENT)latentId, latentParam, 0, modID, value)); } } } }
int32 doSynthFail(CCharEntity* PChar) { uint8 carrentCraft = PChar->CraftContainer->getInvSlotID(0); double synthDiff = getSynthDifficulty(PChar, carrentCraft); double moghouseAura = 0; if (PChar->getZone() == 0) // неправильное условие, т.к. аура действует лишь в собственном доме { // Проверяем элемент синтеза switch (PChar->CraftContainer->getType()) { case ELEMENT_FIRE: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_FIRE); break; case ELEMENT_EARTH: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_EARTH); break; case ELEMENT_WATER: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_WATER); break; case ELEMENT_WIND: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_WIND); break; case ELEMENT_ICE: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_ICE); break; case ELEMENT_LIGHTNING: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_LIGHTNING); break; case ELEMENT_LIGHT: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_LIGHT); break; case ELEMENT_DARK: moghouseAura = 0.05 * charutils::hasKeyItem(PChar,MOGHANCEMENT_DARK); break; } if (moghouseAura == 0) { switch (carrentCraft) { case SKILL_WDW: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_WOODWORKING); break; case SKILL_SMT: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_SMITHING); break; case SKILL_GLD: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_GOLDSMITHING); break; case SKILL_CLT: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_CLOTHCRAFT); break; case SKILL_LTH: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_LEATHERCRAFT); break; case SKILL_BON: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_BONECRAFT); break; case SKILL_ALC: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_ALCHEMY); break; case SKILL_COK: moghouseAura = 0.075 * charutils::hasKeyItem(PChar,MOGLIFICATION_COOKING); break; } } if (moghouseAura == 0) { switch (carrentCraft) { case SKILL_WDW: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_WOODWORKING); break; case SKILL_SMT: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_SMITHING); break; case SKILL_GLD: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_GOLDSMITHING); break; case SKILL_CLT: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_CLOTHCRAFT); break; case SKILL_LTH: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_LEATHERCRAFT); break; case SKILL_BON: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_BONECRAFT); break; case SKILL_ALC: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_ALCHEMY); break; case SKILL_COK: moghouseAura = 0.1 * charutils::hasKeyItem(PChar,MEGA_MOGLIFICATION_COOKING); break; } } } uint8 invSlotID = 0; uint8 nextSlotID = 0; uint8 lostCount = 0; double random = 0; double lostItem = 0.15 - moghouseAura + (synthDiff > 0 ? synthDiff/20 : 0); invSlotID = PChar->CraftContainer->getInvSlotID(1); for(uint8 slotID = 1; slotID <= 8; ++slotID) { if (slotID != 8) nextSlotID = PChar->CraftContainer->getInvSlotID(slotID+1); random = WELL512::drand(); #ifdef _DSP_SYNTH_DEBUG_MESSAGES_ ShowDebug(CL_CYAN"Lost Item: %g Random: %g\n" CL_RESET, lostItem, random); #endif if(random < lostItem) { PChar->CraftContainer->setQuantity(slotID, 0); lostCount++; } if(invSlotID != nextSlotID) { CItem* PItem = PChar->getStorage(LOC_INVENTORY)->GetItem(invSlotID); if (PItem != NULL) { PItem->setSubType(ITEM_UNLOCKED); if(lostCount > 0) { #ifdef _DSP_SYNTH_DEBUG_MESSAGES_ ShowDebug(CL_CYAN"Removing quantity %u from inventory slot %u\n" CL_RESET, lostCount, invSlotID); #endif charutils::UpdateItem(PChar, LOC_INVENTORY, invSlotID, -(int32)lostCount); lostCount = 0; }else{ PChar->pushPacket(new CInventoryAssignPacket(PItem, INV_NORMAL)); } } invSlotID = nextSlotID; nextSlotID = 0; } if(invSlotID == 0xFF) break; } if(PChar->loc.zone->GetID() != 255 && PChar->loc.zone->GetID() != 0) { PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, new CSynthResultMessagePacket(PChar, SYNTH_FAIL)); PChar->pushPacket(new CSynthMessagePacket(PChar, SYNTH_FAIL)); } else { PChar->pushPacket(new CSynthMessagePacket(PChar, SYNTH_FAIL)); } return 0; }
uint8 CTreasurePool::AddItem(uint16 ItemID, CBaseEntity* PEntity) { uint8 SlotID; uint8 FreeSlotID = -1; uint32 oldest = -1; switch (ItemID) { case 1126: //beastmen seal case 1127: //kindred seal case 2955: //kindred crest case 2956: //high kindred crest for (uint32 i = 0; i < members.size(); ++i) { members[i]->PRecastContainer->Add(RECAST_LOOT, 1, 300); //300 = 5 min cooldown } break; } for (SlotID = 0; SlotID < 10; ++SlotID) { if (m_PoolItems[SlotID].ID == 0) { FreeSlotID = SlotID; break; } } if (FreeSlotID > TREASUREPOOL_SIZE) { //find the oldest non-rare and non-ex item for (SlotID = 0; SlotID < 10; ++SlotID) { CItem* PItem = itemutils::GetItemPointer(m_PoolItems[SlotID].ID); if (!(PItem->getFlag() & (ITEM_FLAG_RARE | ITEM_FLAG_EX)) && m_PoolItems[SlotID].TimeStamp < oldest) { FreeSlotID = SlotID; oldest = m_PoolItems[SlotID].TimeStamp; } } if (FreeSlotID > TREASUREPOOL_SIZE) { //find the oldest non-ex item for (SlotID = 0; SlotID < 10; ++SlotID) { CItem* PItem = itemutils::GetItemPointer(m_PoolItems[SlotID].ID); if (!(PItem->getFlag() & (ITEM_FLAG_EX)) && m_PoolItems[SlotID].TimeStamp < oldest) { FreeSlotID = SlotID; oldest = m_PoolItems[SlotID].TimeStamp; } } if (FreeSlotID > TREASUREPOOL_SIZE) { //find the oldest item for (SlotID = 0; SlotID < 10; ++SlotID) { if (m_PoolItems[SlotID].TimeStamp < oldest) { FreeSlotID = SlotID; oldest = m_PoolItems[SlotID].TimeStamp; } } if (FreeSlotID > TREASUREPOOL_SIZE) { //default fallback FreeSlotID = 0; } } } } if (SlotID == 10) { m_PoolItems[FreeSlotID].TimeStamp = 0; CheckTreasureItem(gettick(), FreeSlotID); } m_count++; m_PoolItems[FreeSlotID].ID = ItemID; m_PoolItems[FreeSlotID].TimeStamp = gettick() - 2500; for (uint32 i = 0; i < members.size(); ++i) { members[i]->pushPacket(new CTreasureFindItemPacket(&m_PoolItems[FreeSlotID], PEntity)); } if (m_TreasurePoolType == TREASUREPOOL_SOLO) { CheckTreasureItem(gettick(), FreeSlotID); } return m_count; }