Jump to content

Script guidance needed- how to make a SPECIAL attribute a condition


Recommended Posts

Hello again,

 

in the context of my last topic (Adamantium perk should require adamantium) in this forum, i think i´ve found a good solution, but only half.

I´m a complete noob when it comes to scripting, but i managed to get basically the results i was looking for.

I made a potion-type item (adamantium) which contains 3 custom magic effects, which in turn are using 3 different scripts.

Each magic effect and script adds another rank of the perk (under some conditions) and shows a little message- so far so good (yeah i know this could be achieved with only one script and effect, but i couldn´t manage to get it to work that way;)

 

But i can´t figure out how exactly i should set up the script, so, that if a SPECIAL attribute (endurance) isn´t high enough, the perk will get removed and the potion will be given back to the player. Because the thing is, i basically can use the potion anytime i want, without being forced to have the SPECIAL requirement at all. Of course, i could simply add this condition to the effects, but this way i would "consume" the potion, without getting the perk- that´s not what i want.

So i need to know exactly, how to write a script-internal condition, which would force the player to have the right SPECIAL value and if he hasn´t, the perk gets removed and the potion will be given back to the player.

 

This seems to be an easy task for people with scripting experience, but it is definitely above my knowledge.

So could please someone tell my how to get this to work?

 

Thanks in advance

 

Here is an example of the first of the three scripts i use:

 

Scriptname AAA_AdamantiumPerkScript01 extends activemagiceffect

Perk Property Adamantium01 Auto Const

Message Property AdamantiumPerkReceived01 Auto Const

Event OnEffectStart(Actor akTarget, Actor akCaster)
Game.GetPlayer().AddPerk(Adamantium01)
AdamantiumPerkReceived01.Show()
EndEvent

Link to comment
Share on other sites

Try something like this. Note the clearly typed unique naming conventions to avoid future issues;

 

 

 


Scriptname AAA_AdamantiumPerkScript01 extends activemagiceffect

ActorValue Property pEndurance 		          Auto Const Mandatory

Perk       Property pAAA_AdamantiumPerk01 	  Auto Const Mandatory
Potion 	   Property pAAA_AdamantiumPotion         Auto Const Mandatory
Message    Property pAAA_AdamantiumPerkReceived01 Auto Const Mandatory

Event OnEffectStart(Actor akTarget, Actor akCaster)

Actor PlayerREF = Game.GetPlayer()

If (akTarget == PlayerREF) 
   If (PlayerREF.GetValue(pEndurance) > 5)
      PlayerREF.AddPerk(pAAA_AdamantiumPerk01)
      pAAA_AdamantiumPerkReceived01.Show()
   Else
      PlayerREF.AddItem(pAAA_AdamantiumPotion, aiCount = 1, abSilent = true)
   EndIf
EndIf

EndEvent

 

 

Link to comment
Share on other sites

Thank you very much, this script concept works absolutely flawless-

except the fact, that the number of the respective actor value in the script does not represent the real requirement ingame, instead it´s shifted by one. To be clear, if i want ENDURANCE requirement to be 7 for taking the perk, it has to be 6 in the actual script- very weird. But nevertheless, it works like a charm and now i can finally complete this little project of mine. Thanks again for helping me out!
Link to comment
Share on other sites

If you only want base value, not including modifier effects like chems, armor & such change:

If (PlayerREF.GetValue(pEndurance) > 5)

to

If (PlayerREF.GetBaseValue(pEndurance) > 5) 
Link to comment
Share on other sites

Then its a fundamental understanding of math operators.

 

Equal to == 7

 

Greater than > 7

 

Greater than or equal to >= 7

 

You need to pick the maths opperator that works for the specific logic requirments which you have not explained. Its a vignette on why software development most often goes wrong.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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