/// Adds a modifier to the stack and optionally executes it bool MainControler::AddModifier(Modifier_Constant modifier, bool execute) { SnowSim::Modifiers::Modifier * newModifier = NULL; if (modifier == Modifiers::MOD_Triangulate) { newModifier = new SnowSim::Modifiers::ModifierTriangulate(m_World); } else if (modifier == Modifiers::MOD_SubDivide) { newModifier = new SnowSim::Modifiers::ModifierSubDivide(m_World); } else if (modifier == Modifiers::MOD_CreateEdgeGroups) { newModifier = new SnowSim::Modifiers::ModifierCreateEdgeGroups(m_World); } else if (modifier == Modifiers::MOD_CreateLaunchSites) { newModifier = new SnowSim::Modifiers::ModifierCreateLaunchSites(m_World); } else if (modifier == Modifiers::MOD_AccumulateSnow) { newModifier = new SnowSim::Modifiers::ModifierAccumulateSnow(m_World); } else if (modifier == Modifiers::MOD_StabilizeSnow) { newModifier = new SnowSim::Modifiers::ModifierSnowStability(m_World); } else if (modifier == Modifiers::MOD_RegularSnow) { newModifier = new SnowSim::Modifiers::ModifierRegularStorm(m_World); } else if (modifier == Modifiers::MOD_ShadeSnow) { newModifier = new SnowSim::Modifiers::ModifierShadeSnowModel(m_World); } else if (modifier == Modifiers::MOD_ExtraBorderPoints) { newModifier = new SnowSim::Modifiers::ModifierAddAdditionalBorderPoints(m_World); } else return false; return AddModifier(newModifier, execute); }
void Test_ManaBuff() { const float BuffValue = 30.f; const float StartingMana = DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Mana; FActiveGameplayEffectHandle BuffHandle; // apply the buff { CONSTRUCT_CLASS(UGameplayEffect, DamageBuffEffect); AddModifier(DamageBuffEffect, GET_FIELD_CHECKED(UAbilitySystemTestAttributeSet, Mana), EGameplayModOp::Additive, FScalableFloat(BuffValue)); DamageBuffEffect->DurationPolicy = EGameplayEffectDurationType::Infinite; BuffHandle = SourceComponent->ApplyGameplayEffectToTarget(DamageBuffEffect, DestComponent, 1.f); } // check that the value changed TestEqual(SKILL_TEST_TEXT("Mana Buffed"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Mana, StartingMana + BuffValue); // remove the effect { DestComponent->RemoveActiveGameplayEffect(BuffHandle); } // check that the value changed back TestEqual(SKILL_TEST_TEXT("Mana Restored"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Mana, StartingMana); }
void InfoBox::AddModifier( const int value ) { const int BUFLEN = 16; char buffer[BUFLEN+1]; snprintf( buffer, BUFLEN, "%d", value ); AddModifier( buffer ); }
void InfoBox::GenerateAbilityString() { f_infoBuffer->insert_at_cursor( "Name: " ); f_infoBuffer->insert_at_cursor( f_char->name() ); f_infoBuffer->insert_at_cursor( " " ); Glib::RefPtr<Gtk::TextChildAnchor> refAnchor = f_infoBuffer->create_child_anchor(f_infoBuffer->end()); Gtk::Button* editBtn = Gtk::manage( new Gtk::Button("Edit") ); editBtn->signal_clicked().connect( sigc::mem_fun( *this, &InfoBox::OnEditCharacter ) ); //editBtn->set_sensitive( true ); add_child_at_anchor( *editBtn, refAnchor ); f_infoBuffer->insert_at_cursor( "\n" ); editBtn->show_all(); auto statMgr( GetStatMgr().lock() ); assert(statMgr); auto iter (statMgr->GetStats().begin()); const auto end (statMgr->GetStats().end() ); while( iter != end ) { Stat::pointer_t stat ( iter->second ); Value::pointer_t value ( f_char->getStat( stat->id() ) ); const bool last = (++iter == end); if( !stat->ability() ) continue; #if 0 if( stat->enabled() ) { #endif AddAttribute( stat->name(), value->total() ); AddModifier( Common::StatToMod( value->total() ) ); #if 0 } else { AddAttribute( stat->name(), "--" ); } #endif if( last ) { AddCR(); } else { AddComma(); } } }
void Test_PeriodicDamage() { const int32 NumPeriods = 10; const float PeriodSecs = 1.0f; const float DamagePerPeriod = 5.f; const float StartingHealth = DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health; // just try and reduce the health attribute { CONSTRUCT_CLASS(UGameplayEffect, BaseDmgEffect); AddModifier(BaseDmgEffect, GET_FIELD_CHECKED(UAbilitySystemTestAttributeSet, Health), EGameplayModOp::Additive, FScalableFloat(-DamagePerPeriod)); BaseDmgEffect->DurationPolicy = EGameplayEffectDurationType::HasDuration; BaseDmgEffect->DurationMagnitude = FGameplayEffectModifierMagnitude(FScalableFloat(NumPeriods * PeriodSecs)); BaseDmgEffect->Period.Value = PeriodSecs; SourceComponent->ApplyGameplayEffectToTarget(BaseDmgEffect, DestComponent, 1.f); } int32 NumApplications = 0; // Tick a small number to verify the application tick TickWorld(SMALL_NUMBER); ++NumApplications; TestEqual(SKILL_TEST_TEXT("Health Reduced"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health, StartingHealth - (DamagePerPeriod * NumApplications)); // Tick a bit more to address possible floating point issues TickWorld(PeriodSecs * .1f); for (int32 i = 0; i < NumPeriods; ++i) { // advance time by one period TickWorld(PeriodSecs); ++NumApplications; // check that health has been reduced TestEqual(SKILL_TEST_TEXT("Health Reduced"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health, StartingHealth - (DamagePerPeriod * NumApplications)); } // advance time by one extra period TickWorld(PeriodSecs); // should not have reduced further TestEqual(SKILL_TEST_TEXT("Health Reduced"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health, StartingHealth - (DamagePerPeriod * NumApplications)); // TODO: test that the effect is no longer applied }
void Test_InstantDamage() { const float DamageValue = 5.f; const float StartingHealth = DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health; // just try and reduce the health attribute { CONSTRUCT_CLASS(UGameplayEffect, BaseDmgEffect); AddModifier(BaseDmgEffect, GET_FIELD_CHECKED(UAbilitySystemTestAttributeSet, Health), EGameplayModOp::Additive, FScalableFloat(-DamageValue)); BaseDmgEffect->DurationPolicy = EGameplayEffectDurationType::Instant; SourceComponent->ApplyGameplayEffectToTarget(BaseDmgEffect, DestComponent, 1.f); } // make sure health was reduced TestEqual(SKILL_TEST_TEXT("Health Reduced"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health, StartingHealth - DamageValue); }
void Test_InstantDamageRemap() { const float DamageValue = 5.f; const float StartingHealth = DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health; // This is the same as GameplayEffectsTest_InstantDamage but modifies the Damage attribute and confirms it is remapped to -Health by UAbilitySystemTestAttributeSet::PostAttributeModify { CONSTRUCT_CLASS(UGameplayEffect, BaseDmgEffect); AddModifier(BaseDmgEffect, GET_FIELD_CHECKED(UAbilitySystemTestAttributeSet, Damage), EGameplayModOp::Additive, FScalableFloat(DamageValue)); BaseDmgEffect->DurationPolicy = EGameplayEffectDurationType::Instant; SourceComponent->ApplyGameplayEffectToTarget(BaseDmgEffect, DestComponent, 1.f); } // Now we should have lost some health TestEqual(SKILL_TEST_TEXT("Health Reduced"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Health, StartingHealth - DamageValue); // Confirm the damage attribute itself was reset to 0 when it was applied to health TestEqual(SKILL_TEST_TEXT("Damage Applied"), DestComponent->GetSet<UAbilitySystemTestAttributeSet>()->Damage, 0.f); }
static int exec_add(struct op_addmodifier *opam) { int i; int status; status = 0; for (i = 0; i < opam->count; i++) { int num_kcs; KeyCode *kcs; kcs = KeysymToKeycodes (dpy, opam->keysyms[i], &num_kcs); if (num_kcs == 0) status = -1; while (--num_kcs >= 0) { if (AddModifier (&map, *kcs++, opam->modifier) < 0) status = -1; } } return (status); }
/// Adds a modifier to the stack and executes it bool MainControler::AddModifier(Modifier* modifier) { return AddModifier(modifier, true); }
void LootRandomizer::ApplyModifier(psItemStats* baseItem, RandomizedOverlay* overlay, csArray<uint32_t> &modifierIds) { LootModifier mod; //set up default mod data mod.cost_modifier = 1; mod.name = baseItem->GetName(); csArray<ValueModifier> variableValues; //creates the full lootmodifier from the ids being applied. //0 should be left empty in the database as it acts as NO HIT. for(size_t i = 0; i < modifierIds.GetSize(); i++) { uint32_t modID = modifierIds.Get(i); if(modID) //0 means nothing to do, no need to search for the void. { LootModifier* partialModifier = GetModifier(modID); if(partialModifier) { overlay->active = true; AddModifier(&mod, partialModifier); } } } //all is done no modifiers where found. so we just get out if(overlay->active == false) return; overlay->name = mod.name; overlay->price = psMoney(baseItem->GetPrice().GetTrias() * mod.cost_modifier); if(mod.mesh.Length() > 0) overlay->mesh = mod.mesh; if(mod.icon.Length() > 0) overlay->icon = mod.icon; // Apply effect csString xmlItemMod; xmlItemMod.Append("<ModiferEffects>"); xmlItemMod.Append(mod.effect); xmlItemMod.Append("</ModiferEffects>"); // Read the ModiferEffects XML into a doc*/ csRef<iDocument> xmlDoc = ParseString(xmlItemMod); if(!xmlDoc) { Error1("Parse error in Loot Randomizer"); return; } csRef<iDocumentNode> root = xmlDoc->GetRoot(); if(!root) { Error1("No XML root in Loot Randomizer"); return; } csRef<iDocumentNode> topNode = root->GetNode("ModiferEffects");//Are we sure it is "Modifer"? if(!topNode) { Error1("No <ModiferEffects> in Loot Randomizer"); return; } csRef<iDocumentNodeIterator> nodeList = topNode->GetNodes("ModiferEffect"); // For Each ModiferEffect csRef<iDocumentNode> node; while(nodeList->HasNext()) { node = nodeList->Next(); //Determine the Effect csString EffectOp = node->GetAttribute("operation")->GetValue(); csString EffectName = node->GetAttribute("name")->GetValue(); float EffectValue = node->GetAttribute("value")->GetValueAsFloat(); //Add to the Attributes if(!SetAttribute(EffectOp, EffectName, EffectValue, overlay, baseItem, variableValues)) { // display error and continue Error2("Unable to set attribute %s on new loot item.",EffectName.GetData()); } } // Apply stat_req_modifier csString xmlStatReq; xmlStatReq.Append("<StatReqs>"); xmlStatReq.Append(mod.stat_req_modifier); xmlStatReq.Append("</StatReqs>"); // Read the Stat_Req XML into a doc xmlDoc = ParseString(xmlStatReq); if(!xmlDoc) { Error1("Parse error in Loot Randomizer"); return; } root = xmlDoc->GetRoot(); if(!root) { Error1("No XML root in Loot Randomizer"); return; } topNode = root->GetNode("StatReqs"); if(!topNode) { Error1("No <statreqs> in Loot Randomizer"); return; } nodeList = topNode->GetNodes("StatReq"); // For Each Stat_Req while(nodeList->HasNext()) { node = nodeList->Next(); //Determine the STAT ItemRequirement req; req.name = node->GetAttribute("name")->GetValue(); req.min_value = node->GetAttribute("value")->GetValueAsFloat(); //Add to the Requirements overlay->reqs.Push(req); } // Apply equip script if(!mod.equip_script.IsEmpty()) { csString scriptXML = GenerateScriptXML(mod.name, mod.equip_script, variableValues); overlay->equip_script = ApplicativeScript::Create(psserver->entitymanager, psserver->GetCacheManager(), scriptXML); } //clamp speed at 1.5s to keep consistency with item_stats if(!CS::IsNaN(overlay->latency) && overlay->latency < 1.5F) overlay->latency = 1.5F; }