Jump to content

Script doesn't work


Recommended Posts

So.. I've never scripted before. I've got an idea for a mod that I want to put together, but it requires the use of a small and very simple script that I did manage to write, however, it doesn't seem to be working in game. For testing purposes, I'm trying to attach my script to a blue mountain flower that when consumed adds +10 to the PC's health permanently (like leveling up). Here's what I've got for the script:

 

Scriptname BlueFlowerHealth extends ObjectReference
Event OnActivate(ObjectReference akActionRef)
Game.GetPlayer().ModActorValue("health", 10.0)
EndEvent
The script compiled in CK without any errors, but it doesnt work in game. I did not edit the properties because I wasn't sure if that was required or not and if so, did not know what to put there. I appreciate any insight given.
Link to comment
Share on other sites

Looking at this script there ARE no properties, so thats fine.

 

What have you put the script on? The flora/tree? Or the ingredient?

 

I believe Flora/Tree forms are activated so the OnActivate event should fire when you harvest the flora/tree, if that is where the script is. Personally I would put a debug.messagebox(I have been harvested) line of code into the script to check its firing. I would also add a check to see if it is the player activating the plant, if you only want the script to effect the PC (in case on a rare occasion an npc goes picking flowers)

 

If akActionRef == Game.GetPlayer()

;the rest of your script

EndIf

EndEvent

; for example

 

If you want it to happen when eaten I feel that will require a different approach. Something along the lines of creating your own ingredient and setting it as the harvestable of a certain flower. This would also negate the need for a script I think.

Edited by TyburnKetch
Link to comment
Share on other sites

Harvested ingredients such as 00077E1C <MountainFlower01Blue> do not have a script section. You cannot add scripts to them and if you manage to do so with some third party utility, they probably will not be recognized or possibly cause the game to crash. These ingredients have four effects attached to them that can be learned when consumed. How many depends on the number of perks in the Experimenter star. The known effects should always be applied each time the ingredient is consumed. Restore Health is the first effect of the ingredient. It should already be applying a boost to health when consumed. However, the default magnitude is 5 so it may not be that noticeable. You could change the magnitude of the 0003EB15 <AlchRestoreHealth> from 5 to 10 or even 15. However, that will also affect everything else that uses that effect (i.e. other ingredients, potions, foods, etc). Thankfully, it is a different magic effect than the one used by healing spells and scrolls, so those will not be affected.

Link to comment
Share on other sites

Thank you both for responding. The script was attached to the ingredient, and not the flora/tree from where it originated. What I'd like to do is create items that appear to be alchemical ingredients, but don't behave as typical ingredients do (with the four properties). The item I tested this script on was a duplicate of the vanilla blue mountain flower ingredient that was still of the ingredient classification with it's four properties.

 

I figured the script would fire when the PC ate the flower, which is how I would like the final result to look like. The new item will not be tied to alchemy at all(offering no alchemical properties), so it would be changed to a food item or misc or something.

 

Inspiration for this actually came from 3 items in Vicn's Vigilant mod that behave exactly how I'm trying to make this work. One of them is called the Bone of Jhunal I believe and when consumed, it adds a permanent +10 to magicka. From what I can tell, Vicn did that with the use of a script that is not able to be viewed in CK unfortunately.

 

Thanks again for taking the time to help!

Link to comment
Share on other sites

Duplicating a food item and changing the name and the nif to look like the flower ingredient might be a decent approach. Not near PC atm to look at a food form, but theoretically it wouldnt need a script as food gives bonuses anyway. Edited by TyburnKetch
Link to comment
Share on other sites

Duplicating a food item and changing the name and the nif to look like the flower ingredient might be a decent approach. Not near PC atm to look at a food form, but theoretically it wouldnt need a script as food gives bonuses anyway.

That's about what I was aiming for, yes. I'll take a look at the food and magic effects again. I didn't think the options for the bonuses that food gives included permanent attribute boosts.

 

EDIT: ok, so it looks like duplicating a food item, changing it's model, and then assigning it a new magic effect is about 90% of the way there, but there doesn't appear to be a magical effect that increases the attributes permanently. So I could do like a fortify health effect that just lasts for a million seconds to make it seem permanent. If I wanted to not go the route of using a magic effect however, would it require script use? As if you used the "modav" console command to increase health, stamina, etc..

Edited by KWRMF197
Link to comment
Share on other sites

"Inspiration for this actually came from 3 items in Vicn's Vigilant mod that behave exactly how I'm trying to make this work. One of them is called the Bone of Jhunal I believe and when consumed, it adds a permanent +10 to magicka. From what I can tell, Vicn did that with the use of a script that is not able to be viewed in CK unfortunately."
If i remember correctly (it's been some years since i played it), Vicn's Vigilant assets are set up as "Potions" and not as ingredients, but in any case even if i'm not right, setting up your item as 'Potion' will be an appropriate way to do it and the simplier, you just need to create and add to your 'Potion Item' a magic effect that will run this:
Event OnEffectStart(Actor akTarget, Actor akCaster)
          akTarget.ModActorValue("health", 10.0)
EndEvent

EDIT: As food can also work.

Edited by maxarturo
Link to comment
Share on other sites

 

"Inspiration for this actually came from 3 items in Vicn's Vigilant mod that behave exactly how I'm trying to make this work. One of them is called the Bone of Jhunal I believe and when consumed, it adds a permanent +10 to magicka. From what I can tell, Vicn did that with the use of a script that is not able to be viewed in CK unfortunately."
If i remember correctly (it's been some years since i played it), Vicn's Vigilant assets are set up as "Potions" and not as ingredients, but in any case even if i'm not right, setting up your item as 'Potion' will be an appropriate way to do it and the simplier, you just need to create and add to your 'Potion Item' a magic effect that will run this:
Event OnEffectStart(Actor akTarget, Actor akCaster)
          akTarget.ModActorValue("health", 10.0)
EndEvent

EDIT: As food can also work.

 

Yes, I believe you are right about them being potions technically. Thanks for writing that for me, also I didnt know it needed to be attached to a magic effect and not the item itself. Makes sense now lol

Link to comment
Share on other sites

  • Recently Browsing   0 members

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