[Scrit Request] Plz help!

Discussions and questions about the CS and mods for Oblivion
Locked
Oblis
Initiate
Initiate
Posts: 38
Joined: Fri May 18, 2007 2:07 pm
ES Games: Daggerfall, Morrowind, Oblivion
Platform: PC
Location: Greece

[Scrit Request] Plz help!

Post by Oblis »

Hello!
I m using Toaster Share/Recruit mod which allows me to have access to npcs inventory and give/take items from them.
I have made some companions with custom class which i want to change their skills in any way i want in game. For that reason i want to make skill bonus tokens.
So...
I want to make an generic item (a scull for example) to give +10 to a skill (Acrobatics for example) as long as an NPC has it in his inventory. When i remove the item from his inventory i want the +10 bonus to be removed and the npc goes at starting score.

For example i have an NPC with Acrobatics: 24 and i give him the item with the share/recruit method. As long he has the item in his inventory he will get 24+10=24 Acrobatics. After a period i want to remove the item from him (maybe to give it to an other npc/follower) so i take the item from his inventory. Asfter that time the NPC will have 34-10=24 again (as he started).

<<update>>
I have made it partially but with serious bug. The first time i give the itm to npc the skill not change. For example if he has 5 and i give him the item, the score remains 5. When i remove the item from him, he gets -5 normally. And the second time i add it to his inventory, he normally gets the +5.
BUT... I misst a +5 from the npc because.

At start he has 5. First I give him item and he gets +0 (Bug) so he stays 5 (he has to get 10). Then I remove the item and he gets -5 an dhe drops to o (he had to be 5). And second time i add the item he gets +5 and goes to 5 (he had to get 10). So I lose 5 points from this bug ;)

Im using the following script. But something is wrong.

ScriptName ScullBlade5

ref target
short npc1

Begin GameMode
set target to getcontainer
End

Begin OnAdd target
target.ModActorValue2 Blade 5
Message "Blade +5"
end

Begin OnDrop target
target.ModActorValue2 Blade -5
Message "Blade -5"
end


How can i remove this bug?
I someone can help i will be grateful
User avatar
Jeff
Grand Master
Grand Master
Posts: 4680
Joined: Wed Sep 06, 2006 2:35 pm
Status: Gone

Re: [Scrit Request] Plz help!

Post by Jeff »

You actually do not need to use a Script to give an NPC a Fortify Attribute/Skill Bonus. Just give them any type of equipment, that is of better quality than what they have (or remove the items you don't want them to have), with the Desired Spell Effect, and they will equip it. Example: If you want them to have a +10 Acrobatics, then give them shoes/boots, with an Enchantment of +10 Acrobatics.

I do this all of the time with Companion Share and Recruit. It is my favorite way to keep NPC's alive that I have to Escort. I take thier Weapon, and use a Transendant Sigil Stone to Enchant it to have a +20 Absorb Health.
Oblis
Initiate
Initiate
Posts: 38
Joined: Fri May 18, 2007 2:07 pm
ES Games: Daggerfall, Morrowind, Oblivion
Platform: PC
Location: Greece

Re: [Scrit Request] Plz help!

Post by Oblis »

Jeff wrote:You actually do not need to use a Script to give an NPC a Fortify Attribute/Skill Bonus. Just give them any type of equipment, that is of better quality than what they have (or remove the items you don't want them to have), with the Desired Spell Effect, and they will equip it. Example: If you want them to have a +10 Acrobatics, then give them shoes/boots, with an Enchantment of +10 Acrobatics.

I do this all of the time with Companion Share and Recruit. It is my favorite way to keep NPC's alive that I have to Escort. I take thier Weapon, and use a Transendant Sigil Stone to Enchant it to have a +20 Absorb Health.
Hehe in my Moded game its too hard to get those :)
If you use OOO you will understand me
BFG
Champion
Champion
Posts: 902
Joined: Sat Oct 18, 2008 3:00 am
ES Games: Morrowind, Oblivion
Platform: PC/Windows 7 x64, PS3
Status: Exhilarated
Location: Rebuilding the lost city of Sutch

Re: [Scrit Request] Plz help!

Post by BFG »

This is just a guess, but I believe the issue may have something to do with your target variable. I think that it is not the value expected the first time.
Let me give an example. Let's say that you have the Skull token in your (the PC's) inventory, and you're giving it to the NPC.
Your GameMode frame runs once every 5 seconds. Because of that, the target variable is only updated once every 5 seconds. So, when you first hand the Skull token to the NPC, target still = the PC because the GameMode frame hasn't run yet.
Because of that, the OnAdd frame does not run.
Then, five seconds later, when the NPC drops it, target has been updated, so the -5 attribute is applied.

Because of this, I would recommend instead:

ScriptName ScullBlade5
ref target

Begin OnAdd
set target to getcontainer
target.ModActorValue2 Blade 5
Message "Blade +5"
end

Begin OnDrop
set target to getcontainer
target.ModActorValue2 Blade -5
Message "Blade -5"
end
Image
Locked