bool InjectActorValue(ClientEntity *ent,BYTE slot, INT16 value) { if(!ent) return false; TESObjectREFR * refr = GetRefrFromEntity(ent); if(!refr || !refr->IsActor()) return false; else { Actor * actor = (Actor *)refr; int CurrentVal = actor->GetActorValue(slot); //TODO: Sync health, fatigue, magicka unmodifiedvalues as well. In general sync all modifiers here switch(slot) { case AV_FATIGUE: case AV_HEALTH: case AV_MAGICKA: actor->ModActorBaseValue(slot,value - CurrentVal,0); //assert(actor->GetBaseActorValue(slot) == value); //TODO: Re-add this assertion here break; default: actor->ModActorValue(slot,value - CurrentVal,0); assert(actor->GetActorValue(slot) == value); break; } } }
Script::RefVariable* ScriptBuffer::ResolveRef(const char* refName) { Script::RefVariable* newRef = NULL; Script::RefListEntry* listEnd = &refVars; // see if it's already in the refList for (Script::RefListEntry* cur = &refVars; cur; cur = cur->next) { listEnd = cur; if (cur->var && !_stricmp(cur->var->name.m_data, refName)) return cur->var; } // not in list // is it a local ref variable? VariableInfo* varInfo = vars.GetVariableByName(refName); if (varInfo && GetVariableType(varInfo, NULL) == Script::eVarType_Ref) { newRef = (Script::RefVariable*)FormHeap_Allocate(sizeof(Script::RefVariable)); newRef->form = NULL; } else // is it a form or global? { TESForm* form = GetFormByID(refName); if (form) { TESObjectREFR* refr = DYNAMIC_CAST(form, TESForm, TESObjectREFR); if (refr && !refr->IsPersistent()) // only persistent refs can be used in scripts return NULL; newRef = (Script::RefVariable*)FormHeap_Allocate(sizeof(Script::RefVariable)); memset(newRef, 0, sizeof(Script::RefVariable)); newRef->form = form; } } if (newRef) // got it, add to refList { newRef->name.Set(refName); newRef->varIdx = 0; if (!refVars.var) refVars.var = newRef; else { Script::RefListEntry* entry = (Script::RefListEntry*)FormHeap_Allocate(sizeof(Script::RefListEntry)); entry->var = newRef; entry->next = NULL; listEnd->next = entry; } numRefs++; return newRef; } else return NULL; }
bool InventoryReference::DeferredRemoveAction::Execute(InventoryReference* iref) { TESObjectREFR* containerRef = iref->GetContainer(); const InventoryReference::Data& data = Data(); if (containerRef) { containerRef->RemoveItem(data.type, data.xData ? data.xData : NULL, iref->GetCount(), 0, 0, m_target, 0, 0, 1, 0); iref->SetRemoved(); iref->SetData(InventoryReference::Data(NULL, NULL, NULL)); return true; } return false; }
static bool GetQuantityMenuInfo_Execute(COMMAND_ARGS, UInt32 which) { QuantityMenu* menu = (QuantityMenu*)GetMenuByType(kMenuType_Quantity); if (menu) { switch (which) { case kQuantityMenu_Max: *result = menu->maxQuantity; DEBUG_PRINT("GetQMMaximum >> %d", menu->maxQuantity); return true; case kQuantityMenu_Cur: { if (menu->quantity_scroll) { Tile::Value* val = menu->quantity_scroll->GetValueByType(kTileValue_user7); if (val) { *result = val->num; DEBUG_PRINT("GetQMCurrent >> %.0f", val->num); } } } return true; case kQuantityMenu_Item: { TESForm* item = NULL; UInt32* refResult = (UInt32*)result; *refResult = 0; if (menu->itemTile) { Tile::Value* val = menu->itemTile->GetValueByType(kTileValue_user11); if (val) { UInt32 idx = val->num; // are we bartering? and what container is open? bool bMerchant = false; TESObjectREFR* container = *g_thePlayer; if (menu->unk44 == 0x33) { ContainerMenu* contMenu = (ContainerMenu*)GetMenuByType(kMenuType_Container); container = contMenu->isContainerContents ? contMenu->refr : container; bMerchant = contMenu && contMenu->isContainerContents && contMenu->isBarter; } item = container->GetInventoryItem(idx, bMerchant); *refResult = item ? item->refID : 0; DEBUG_PRINT("GetQMItem >> %s", GetFullName(item)); } } } return true; } } return true; }
bool Cmd_SetDoorTeleport_Execute(COMMAND_ARGS) { // linkedDoor x y z (rot). if omitted, coords/rot taken from linked ref *result = 0; if (!thisObj || thisObj->baseForm->typeID != kFormType_Door) return true; TESObjectREFR* linkedDoor = NULL; float x = 999; float y = 999; float z = 999; float rot = 999; if (GetByTypeCast(thisObj->extraDataList, RandomTeleportMarker)) return true; if (ExtractArgs(EXTRACT_ARGS, &linkedDoor, &x, &y, &z, &rot) && linkedDoor && linkedDoor->IsPersistent()) // ###TODO: necessary for linkedref to be door? { ExtraTeleport* tele = GetByTypeCast(thisObj->extraDataList, Teleport); if (!tele) { tele = ExtraTeleport::Create(); thisObj->extraDataList.Add(tele); } tele->data->linkedDoor = linkedDoor; if (x == 999 && y == 999 && z == 999) { x = linkedDoor->posX; y = linkedDoor->posY; z = linkedDoor->posZ; } if (rot == 999) rot = linkedDoor->rotZ; else rot *= kDegreeToRad; tele->data->x = x; tele->data->y = y; tele->data->z = z; tele->data->zRot = rot; *result = 1; } return true; }
bool InjectEquip( ClientEntity *ent,BYTE slot,UINT32 formid ) { return true; if(!ent) return false; TESObjectREFR * refr = GetRefrFromEntity(ent); if(!refr || !refr->IsActor()) return false; else { Actor * act= (Actor*)refr; if(formid && LookupFormByID(formid)) { feGetObject getObject; double itemResult; UInt32* itemRef = (UInt32 *)&itemResult; if (FindEquipped(act, slot, &getObject, &itemResult) ) // If we find nothing, there already is no equip { ent->AddUnequipItem(*itemRef); ent->AddRemoveItem(*itemRef); //UnEquipItemCommand(act,*itemRef); //RemoveOneItemQueue.push(pair<Actor *,UINT32>(act,*itemRef)); } //AddOneItemCommand(act,formid); ent->AddAddItem(formid); //ent->AddEquipItem(formid); } else { //Unequip the item in that slot. feGetObject getObject; double itemResult; UInt32* itemRef = (UInt32 *)&itemResult; if (FindEquipped(act, slot, &getObject, &itemResult) ) // If we find nothing, there already is no equip { ent->AddUnequipItem(*itemRef); //ent->AddRemoveItem(*itemRef); //UnEquipItemCommand(act,*itemRef); //RemoveOneItemQueue.push(pair<Actor *,UINT32>(act,*itemRef)); } } SafeAddUpdateQueue(ent); } return true; }
UInt32 TESRenderWindow::GetActiveCellObjects(TESObjectREFRArrayT& OutList, CellObjectListVisitorT Visitor) { OutList.clear(); if (_TES->currentInteriorCell) { for (TESObjectCELL::ObjectREFRList::Iterator Itr = _TES->currentInteriorCell->objectList.Begin(); !Itr.End(); ++Itr) { TESObjectREFR* Ref = Itr.Get(); if (Ref && Ref->IsTemporary() == false) { if (!Visitor || Visitor(Ref) == true) OutList.push_back(Ref); } } } else { GridCellArray* CellGrid = _TES->gridCellArray; for (int i = 0; i < CellGrid->size; i++) { for (int j = 0; j < CellGrid->size; j++) { GridCellArray::GridEntry* Data = CellGrid->GetCellEntry(i, j); if (Data && Data->cell) { for (TESObjectCELL::ObjectREFRList::Iterator Itr = Data->cell->objectList.Begin(); !Itr.End(); ++Itr) { TESObjectREFR* Ref = Itr.Get(); if (Ref && Ref->IsTemporary() == false) { if (!Visitor || Visitor(Ref) == true) OutList.push_back(Ref); } } } } } } return OutList.size(); }
static bool Cmd_SetPlayersLastRiddenHorse_Execute(COMMAND_ARGS) { TESObjectREFR* horseRef = NULL; *result = 0.0; // must be a persistent reference since game keeps a pointer to it if (ExtractArgs(PASS_EXTRACT_ARGS, &horseRef) && horseRef && horseRef->IsPersistent()) { Creature* horse = OBLIVION_CAST(horseRef, TESObjectREFR, Creature); // must be a creature if (horse && horse->baseForm) { TESCreature* horseBase = OBLIVION_CAST(horse->baseForm, TESForm, TESCreature); // base must be a horse-type creature if (horseBase && horseBase->type == TESCreature::eCreatureType_Horse) { (*g_thePlayer)->lastRiddenHorse = horse; *result = 1.0; } } } return true; }
bool InjectAnimation( ClientEntity *ent,BYTE slot ) { TESObjectREFR * refr = GetRefrFromEntity(ent); if(!refr || !refr->IsActor()) return false; else { ent->InjectAnim(slot); #if 0 //TODO: See CallCommandGeneric double result; // We wish to call PlayGroup. This has the parameters ( which are passed as flat array in arg1 ) // AnimGroup ( a UINT16) , and 1 Integer ( flag, which we want to be "1" ) UInt8 ParamData[sizeof(UINT16) + sizeof(UINT32)]; Actor * actor = (Actor *)refr; // create a Script object UInt8 scriptObjBuf[sizeof(Script)]; Script * tempScriptObj = (Script *)scriptObjBuf; ScriptEventList evlist; evlist.m_eventList = NULL; evlist.m_script = tempScriptObj; evlist.m_unk1 = 0; evlist.m_vars = NULL; void * scriptState = GetGlobalScriptStateObj(); tempScriptObj->Constructor(); tempScriptObj->MarkAsTemporary(); if(Playing) *((UINT16 *)ParamData) = slot; // Set parameter 1 ( aniom group) else *((UINT16 *)ParamData) = 0; // Play idle anim *((UINT32 *)(ParamData + 2)) = 1; // Flag to start immediately // Parameter list, parameters, thisOBj, arg3= param count, ScriptEventList ( what to put in there?) , Result ptr, and offset ( is 0 ok ? ) //Cmd_PlayGroup_Execute(kParams_CmdPlayGroup,ParamData,actor, 2,tempScriptObj,&evlist,&result,0); // NULL denotes incomplete params tempScriptObj->StaticDestructor(); #endif } return true; }
void CSEHallOfFameShadeMe::Initialize( UInt32 FormID ) { CSEHallOfFameEntry::Initialize(FormID); TESObjectREFR* shadeMeRef = CS_CAST(TESForm::CreateInstance(TESForm::kFormType_REFR), TESForm, TESObjectREFR); TheGreatEye = shadeMeRef; shadeMeRef->SetBaseForm(TESForm::LookupByEditorID(Name)); shadeMeRef->SetFormID(0x99); shadeMeRef->SetEditorID("TheShadeMeRef"); shadeMeRef->SetFromActiveFile(false); shadeMeRef->SetPersistent(true); }
bool TESForm::HasKeyword(BGSKeyword* keyword) const // 008FCCA0 { const BGSKeywordForm* keywordForm = nullptr; switch (this->formType) { case FormType::EffectSetting: keywordForm = cast_to_keywordform<EffectSetting>(this); break; case FormType::NPC: keywordForm = cast_to_keywordform<TESActorBase>(this); break; case FormType::Race: keywordForm = cast_to_keywordform<TESRace>(this); break; case FormType::Armor: keywordForm = cast_to_keywordform<TESObjectARMO>(this); break; case FormType::Weapon: keywordForm = cast_to_keywordform<TESObjectWEAP>(this); break; case FormType::Location: keywordForm = cast_to_keywordform<BGSLocation>(this); break; case FormType::Activator: case FormType::TalkingActivator: case FormType::Flora: case FormType::Furniture: keywordForm = cast_to_keywordform<TESObjectACTI>(this); break; case FormType::Enchantment: case FormType::Spell: case FormType::ScrollItem: case FormType::Ingredient: case FormType::Potion: keywordForm = cast_to_keywordform<MagicItem>(this); break; case FormType::Misc: case FormType::Apparatus: case FormType::Key: case FormType::SoulGem: keywordForm = cast_to_keywordform<TESObjectMISC>(this); break; case FormType::Ammo: keywordForm = cast_to_keywordform<TESAmmo>(this); break; case FormType::Book: keywordForm = cast_to_keywordform<TESObjectBOOK>(this); break; default: keywordForm = DYNAMIC_CAST<BGSKeywordForm*>(const_cast<TESForm*>(this)); break; } if (keywordForm) { return keywordForm->HasKeyword(keyword); } TESObjectREFR* ref = const_cast<TESForm*>(this)->GetReference(); if (ref) { return ref->HasKeyword(keyword); } return false; }
// this involves positioning of the hud elements so i'm assuming magicka and stamina // will need separate positions below the health bar. void ObjectWidget::UpdateComponent(GFxMovieView * view, float * depth) { TESForm * form = LookupFormByID(formId); if(form) { TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR); if(reference) { NiPoint3 markerPos; reference->GetMarkerPosition(&markerPos); markerPos.z += 25; float x_out = 0.0; float y_out = 0.0; float z_out = 0.0; GRectF rect = view->GetVisibleFrameRect(); WorldPtToScreenPt3_Internal(g_worldToCamMatrix, g_viewPort, &markerPos, &x_out, &y_out, &z_out, 1e-5); // Move component, update component stats y_out = 1.0 - y_out; // Flip y for Flash coordinate system y_out = rect.top + (rect.bottom - rect.top) * y_out; x_out = rect.left + (rect.right - rect.left) * x_out; *depth = z_out; bool isVisible = false; bool isFriendly = false; QueryState(reference, &isVisible, &isFriendly); if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideName) == HUDExtension::kFlags_HideName || (flags & ObjectWidget::kFlag_HideName) == ObjectWidget::kFlag_HideName) { params[kProperty_Name].SetString(""); UpdateText(); } else { const char * text = CALL_MEMBER_FN(reference, GetReferenceName)(); if (params[kProperty_Name].GetString() != text) { params[kProperty_Name].SetString(text); UpdateText(); } } if ((flags & ObjectWidget::kFlag_UseHostility) == ObjectWidget::kFlag_UseHostility) { bool nowFriendly = IsFriendly(); if (nowFriendly && !isFriendly) { // Turned hostile flags &= ~ObjectWidget::kFlag_Friendly; UpdateFlags(); UpdateColors(); } else if (!nowFriendly && isFriendly) { // Turned friendly flags |= ObjectWidget::kFlag_Friendly; UpdateFlags(); UpdateColors(); } } double scale = min(((100 - z_out * 100) * 10), 50);//(1.0 - z_out) * 100;//min(((100 - z_out * 100) * 10), 50); if(object.IsDisplayObject()) { GFxValue::DisplayInfo dInfo; dInfo.SetPosition(x_out, y_out); dInfo.SetScale(scale, scale); dInfo.SetVisible(isVisible); object.SetDisplayInfo(&dInfo); if((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent) UpdateValues(); } } } }