Jump to content

Firing a magic effect with a condition


Recommended Posts

The condition on the spell effects list is only checked immediately when the spell is cast, so if the condition is not met the spell will be dispelled as soon as it is cast.

On the other hand, the condition on the Magic Effect is checked constantly and it won't dispel the spell. So you need to put the condition on the effect instead of the spell effect list.

 

Edit: it might be the other way around, I forget which is which.

Edited by steve40
Link to comment
Share on other sites

Well, I have a several spells with conditions so let me give an example. I have chameleon spell on npc with conditions and here it is:

 

First, I give actor in actor window a spell named xxxChameleonSpell.

 

Then xxxChameleonSpell is a Ability, Constant effect, self.

 

Conditions are:

Target: Subject. GetHealthPercentage >= 0.30 AND
Target: Subject. GetCombatState != 0 AND
Target: Subject. IsAttacking 0 AND

Then the magic effect is xxxChameleonEffect

 

Effect archetype Chameleon, Constant effect, self, recover(propaply not needed), No duration, no area, no magnitude <-- propably none of those needed.

 

Then, when this actor starts combat, it turns stealth boy style cloak on, when he attacks with melee it turns off, when his life is under 30%, it turns completely off. If he stops combat it turns completely off too.

 

Seems like the spell conditions are checked every second or so. In the magic effect I don't have any conditions.

 

For OP, seems like weaponout condition might not work like you want. For example: IsAttacking seems to work only for melee, not when someone is firing a gun.

Edited by vkz89q
Link to comment
Share on other sites

So I changed the condition to subject gethealthpercentage >0. Effect still didnt fire. Would there be any reason that the game cannot find my script? Where should be .pex and .psc files be saved? Looking at my scripts section I dont see any .pex files other then the one for my custom script.

Edited by erratichippo
Link to comment
Share on other sites

Hve you tried in spell window, changing spell to ability? The script will only run once, and that is when effects begins. And then again when the effect ends. Other than that, clean save needed I guess. I have a magic effect with script on it and condition gethealthpercentage <= 0.35 and it fires once when life goes under 35%, and then again when life goes over 35%. If you want your script to constantly do something while effect is active, you can register to actor events.

 

First it fires Event OnEffectStart and then Event OnEffectFinish.

 

Edit: Your scripts should be in:

C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\yournamespace

They should be in .pex there. CK should place them automatically everytime you compile them in ck(press save).

Edited by vkz89q
Link to comment
Share on other sites

SUCCESS. HAHA CREATIONKIT I WON THIS ONE! Only took me a week to figure out I had the wrong spell type selected.....I hate my life. In order to work as a constant effect the spell needs to be of type ability. I also had to make a few changes to my script. The in the variable declaration type needed to be auto mandatory const for the variables that reference stuff in the creation kit. Posted script below for future reference.

Scriptname _Civil_AmmoTypeCheckScript extends activemagiceffect

Ammo property WeaponAmmo auto
Ammo property Caliber38 auto mandatory const
Actor property Shooter auto
Perk property Caliber38Equip auto mandatory const
Weapon property WeaponEquipped Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
		Shooter = akTarget
		WeaponEquipped = Shooter.GetEquippedWeapon()
		WeaponAmmo = WeaponEquipped.GetAmmo()
		debug.messagebox("effect started" + WeaponAmmo +" " + Shooter + " " + WeaponEquipped) 
		if (WeaponAmmo == Caliber38)
			Shooter.addperk(Caliber38Equip)
			debug.messagebox(".38 ammo equipped")
		endif		
endevent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
        Shooter.removeperk(Caliber38Equip)
		debug.messagebox("perk removed")
endEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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