Jump to content

Scripting question. How to setup incremental condition?


AtomsChosen

Recommended Posts

https://imgur.com/9G1iQOz

 

 

My goal here is that I want to make a resistance buff that scales depending on how many enemies the actor is facing. I already know how to get the condition setup so it can check enemy targets. However I want to have an incremental x value for the number of enemy targets that can be checked. And for each enemy target,multiply resist by x amount. I could do this by repeating entries over and over, but I want to keep the structure of this as simple as possible in case I want to go in there and change something. So the way it looks I need to do some scripting. Currently I am looking up videos on how to script, but I would appreciate any tips on how to set this up.

 

Hopefully my explanation of this was not too confusing. The picture shows the main condition I am using in the perk.

Edited by RayoftheSun
Link to comment
Share on other sites

How going to determine/update overall amount of enemies in real time? Attacker::GetCombatGroupMemberCount could work for multiple preset ModIncomingWeaponDamage entries, perhaps, without a need of anything else but a perk, although surrounding enemies may not belong to a single Combat Group.

 

Mod Spell Magnitude fires when a spell hits/casts, so it won't modify ongoing effect.

Edited by hereami
Link to comment
Share on other sites

How going to determine/update overall amount of enemies in real time? Attacker::GetCombatGroupMemberCount could work for multiple preset ModIncomingWeaponDamage entries, perhaps, without a need of anything else but a perk, although surrounding enemies may not belong to a single Combat Group.

 

Mod Spell Magnitude fires when a spell hits/casts, so it won't modify ongoing effect.

 

Okay. It appears I made a mistake. You see I tried this out on a spell instead of a perk and it seemed to be updating continuously. As seen here.

 

https://imgur.com/qz3MYyC

 

I thought this would work just fine since it was working on the spell. I was suing"GetgroupTargetCount"However it doesn't seem to be working here. So let me explain exactly what I am trying to do and see if you may have any ideas for how to get this to work.

 

I am trying to make a resistance buff for workshop robots that multiplies the resistance by around 1.5 for each enemy the robot is fighting. I want the resistance to be multiplied based on the armor resistance the robot currently has from their armor. When I tested this out using a spell it was updating constantly. The problem is that it doesn't seem possible to use spells to multiply resistance values based on the existing base value of an actors resistance. Magnitude just adds it. Though I suppose there is workarounds.

 

A few ideas:

 

1. Maybe there is a way to make the spell fire again every enemy targets have been checked for?

2. Maybe I need to apply the perk and spell another way?

3. Maybe I can use a spell to check for group targets then apply or remove a perk based on certain things happening.

 

EDIT: Just adding that I double checked the method of using spells to add resistance. And it does update dynamically. However I have not figured out how to multiply it based on an existing resistance value yet. I think there is probably a way to do this. Still investigating.

Edited by RayoftheSun
Link to comment
Share on other sites

GetGroupTargetCount looks more suitable condition indeed, so it works or not?

 

Well, it would be best still, if done with a script processing everything. There appears to be a function Actor.GetAllCombatTargets() which solves all troubles with counting, didn't know it existed. I'd advise to start here instead of vids https://www.creationkit.com/index.php?title=Landing_page , also digging in vanilla scripts. Would be easy enough.

 

Untill then, could invite you into amazing undergrounds of ps4 mods.

- Have an Ability on the Actor, conditioned to IsInCombat. MGEF_0 applies the perk. Use Hardcore:HC_EncumbranceEffect_CastScript to periodically cast a Spell_1 FireForget/Self. Timer interval should be slightly shorter than duration of Spell_2. Optionally, Spell_1 may be cast at start of Effect by CastSpellOnEffectScript;

- Mgef_1 should cast Spell_2, but first it needs to dispel previous instance of Spell_2 to keep value modification consistent. Unless we insert Dispel() before Cast in timer script, then we need this intermediate Spell with Dispel keyword. Use CastSpellOnEffectScript for Spell_2;

- Mgef_2 is ValueModifier for Resistance, Mag == 0, doesn't matter;

 

Now the perk. Multiple entries ModIncomingSpellMagnitude, Set AV Mult, AV==DamageResistance, Spell::EPMagic_SpellHasKeyword to check for our Spell_2. I'd suggest there be reasonable number of entries, like 3~9 (or lower) and >9 (or corresponding max value), using Owner::GetGroupTargetCount and having respective Mult. Perk uses Current value for AV, not Base, but that's how it works.

 

Unfortunately, there is only ModTargetDamageResistance, so here we can't use arbitrary AV as a mult along the Resistance value, thus having a single Mod entry.

 

Regarding Mod Magnitude entry in general, i'd suggest it be used with care on important Characters and probably for very short-timed effects only, meself had negative experience with detrimental Health on Player, all the extra amount gets lost unrecoverably after game reload.

 

I dunno, would offer ModIncomingDamage still, then we can have AV representing combatants number as Mult, although better it be specified by a timer script anyway - while multiple conditioned mgef are doable, they wouldn't be so efficient, probably.

Link to comment
Share on other sites

Ok, have nothing better to do, something to tinker with at start. Would appreciate if somebody tells me how to create Spoiler blocks

Scriptname ToughRobosEffect extends ActiveMagicEffect
{Spell should be conditioned by IsInCombat}

Group Data

float Property TimerInterval = 5.0 const auto
{How often should we update}
float Property Fraction = 1.0 const auto
{Amount of extra Resistance per Enemy}
ActorValue Property avDamageResistance const auto
{ActorValue to update}

EndGroup

; Local vars
Actor ActorRef
Float fBaseValue		; won't change after effect starts
Float fModAmount		; dynamic
Float fFraction		; must be positive

Event OnEffectStart(Actor akTarget, Actor akCaster)
	ActorRef = akTarget
	fBaseValue = ActorRef.GetBaseValue(avDamageResistance)
	fFraction = Math.abs(Fraction)	; failproof
	fModAmount = 0
	DoStuff()
EndEvent

Function DoStuff()
	if IsBoundGameObjectAvailable() ; is effect still running on a legit object?
		Float fNumOfEnemies = ActorRef.GetAllCombatTargets().Length as Float
	; whatever formula here
		Float fNew = (fBaseValue * fFraction) * fNumOfEnemies
	; update AV
		if (fNew != fModAmount)
			ActorRef.ModValue(avDamageResistance, (fNew - fModAmount))	; apply delta
			fModAmount = fNew					; remember new value
		EndIf
		startTimer(TimerInterval)
	endif
EndFunction

Event OnTimer(int aiTimerID)
	DoStuff()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	if (fModAmount)
		ActorRef.ModValue(avDamageResistance, (- fModAmount))	; subtract added value
	EndIf
EndEvent
Edited by hereami
Link to comment
Share on other sites

GetGroupTargetCount looks more suitable condition indeed, so it works or not?

 

Well, it would be best still, if done with a script processing everything. There appears to be a function Actor.GetAllCombatTargets() which solves all troubles with counting, didn't know it existed. I'd advise to start here instead of vids https://www.creationkit.com/index.php?title=Landing_page , also digging in vanilla scripts. Would be easy enough.

 

Untill then, could invite you into amazing undergrounds of ps4 mods.

- Have an Ability on the Actor, conditioned to IsInCombat. MGEF_0 applies the perk. Use Hardcore:HC_EncumbranceEffect_CastScript to periodically cast a Spell_1 FireForget/Self. Timer interval should be slightly shorter than duration of Spell_2. Optionally, Spell_1 may be cast at start of Effect by CastSpellOnEffectScript;

- Mgef_1 should cast Spell_2, but first it needs to dispel previous instance of Spell_2 to keep value modification consistent. Unless we insert Dispel() before Cast in timer script, then we need this intermediate Spell with Dispel keyword. Use CastSpellOnEffectScript for Spell_2;

- Mgef_2 is ValueModifier for Resistance, Mag == 0, doesn't matter;

 

Now the perk. Multiple entries ModIncomingSpellMagnitude, Set AV Mult, AV==DamageResistance, Spell::EPMagic_SpellHasKeyword to check for our Spell_2. I'd suggest there be reasonable number of entries, like 3~9 (or lower) and >9 (or corresponding max value), using Owner::GetGroupTargetCount and having respective Mult. Perk uses Current value for AV, not Base, but that's how it works.

 

Unfortunately, there is only ModTargetDamageResistance, so here we can't use arbitrary AV as a mult along the Resistance value, thus having a single Mod entry.

 

Regarding Mod Magnitude entry in general, i'd suggest it be used with care on important Characters and probably for very short-timed effects only, meself had negative experience with detrimental Health on Player, all the extra amount gets lost unrecoverably after game reload.

 

I dunno, would offer ModIncomingDamage still, then we can have AV representing combatants number as Mult, although better it be specified by a timer script anyway - while multiple conditioned mgef are doable, they wouldn't be so efficient, probably.

 

 

 

Okay. I have a few questions. First let me clarify two things. The first thing is that I am trying to get this to work on npcs rather then the player. Specifically the npc"DLC01CompWorkbenchBot". It is the base robot built in Robot Workbenches. I am trying to get this mod working because I have provisioners marked non essencial or protected and I frequently use GCM to ramp up damage throughout my playthroughs. The second thing is that GetGroupTargetCount is working yes, but only for spells. The problem is that magnitude does not let me specify a multiplicative value rather then an additive value. And I need the value for this to be multiplicative because I want all the armor pieces on robots to matter. Since what will happen is that if I suddenly crank up the damage in my playthrough to x10 the armor on robots won't matter much. My questions:

 

1. Don't perks casted by Mgefs only effect the player?

 

It says this in the wiki. Thats why I haven't been doing this so far.

 

2. That link you gave me. Should I look up info on scripting?

 

3. By ability do you mean spell or enchant or something else?

 

4. Where exactly do I place the script itself? I found that script you pointed out.

 

5. Also yes I would like an invite to this place you mentioned. About PS4 mods? If it will help. I am a PC player though.

 

6. For the last part. This is meant to be used exclusively with settlers and workshop robot npcs. So maybe it might not be as much of an issue?

 

EDIT: Just finished post. Reading the script you posted.

 

EDIT2: Still studying the script. I guess one of the main problems with trying to do this without scripting is having it constantly updated.

Edited by RayoftheSun
Link to comment
Share on other sites

1. No. Skyrim wiki still covers the holy grounds, while some things might've been changed, expanded or ruined in Fallout;

2. Well, sometimes folks don't know it exists;

3. Specifically, Ability is type of Spell, ConstantEffect/Self Armor Enchantment is basically the same;

4. Those scripts suggested are for MagicEffect. Script affiliation can be seen in header - Extends ActiveMagicEffect, our case;

5. Hah, already there, no external assets, custom scripts etc., while trying to accomplish something advanced. Best handled with XEdit;

6. Probably so;

 

Guess we need it be constantly updated but not persistent, as the Perk needs be induced to update Magnitude. Nah, assuming demands, i wouldn't bother with emulation effects anymore.

Try the script and expand as you learn more. Copy code into Data/Scripts/Source/User/ToughRobosEffect.psc and run CK > Gameplay > Compile, then add to the MagicEffect.

 

NB. Again, the script requires Condition IsInCombat == 1 on Spell side, since i wanted it be most simple. Also it might be reasonable to use GetValue() instead of GetBaseValue(), depends.

 

PS. Some variation of magic, mostly same as initial and maybe is optimal.

- Ench host effect with Perk, which does AddSpell()/RemoveSpell() as combat starts/ends (PA_StealthScript);

- Spell should have numerous effects GetCombatGroupTarget with corresponding Magnitudes 2, 3, etc.;

- Perk updates Magnitude * DR * Mult just once as the spell is added, then conditions do switching. Downside - lots of effects with condtions and still we can't process unlimited number of hostiles. Although what is realistic count? Something 1 ~ 5;

Edited by hereami
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...