Question about creating an easy spell for adding items to th

Post » Mon Nov 19, 2012 7:53 pm

1.I've suceed add a new spell to the game.I want the spell has the follow functions
Choose some random clothes from a formlist and add to the person who was the target of my spell.


take a look at the script then

Scriptname MCSChangeClothEffect extends activemagiceffect


FormList Property MCSClothForChange Auto


Event OnEffectStart(Actor akTarget, Actor akCaster)
int FormListSize = MCSClothForChange.GetSize()
If akCaster == Game.GetPlayer()


akTarget.RemoveAllItems()
int nClothes = 0;
while(nClothes < 3)
ObjectReference newClothes= MCSClothForChange .GetAt( Utility.RandomInt(0, 41) ) As ObjectReference
akTarget.AddItem(newClothes, 1)
Game.GetPlayer().placeatme(newClothes)
nClothes+=1
endwhile



Debug.messagebox("come on!");
endif

EndEvent


the messagebox show the message and the target took off all her clothes :).

but no new clothes were add to them!!





question 1:I'v created a new formlist in ck.And was it enough to get it just by adding the property in the script like this.
question 2:The items which in the formlist is from another mod. so was it the reason it doesnt work.
question 3:I use the ' As ObjectReference' and 'additems' to any person in the game.Was it not right?



Thank you very much for help!
User avatar
James Smart
 
Posts: 3362
Joined: Sun Nov 04, 2007 7:49 pm

Post » Tue Nov 20, 2012 9:23 am

Scriptname MCSChangeClothEffect extends activemagiceffectFormList Property MCSClothForChange AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)int FormListSize = MCSClothForChange.GetSize()If akCaster == Game.GetPlayer()akTarget.RemoveAllItems()int nClothes = 0;while(nClothes < 3)ObjectReference newClothes= MCSClothForChange .GetAt( Utility.RandomInt(0, 41) ) As ObjectReferenceakTarget.AddItem(newClothes, 1)Game.GetPlayer().placeatme(newClothes)nClothes+=1endwhileDebug.messagebox("come on!");endifEndEvent
as done above, it makes it alot easyer for us to shift through the script code :)
its done with either [ code ], [ / code] or [ spoiler ], [ / spoiler ] tags.
User avatar
Raymond J. Ramirez
 
Posts: 3390
Joined: Sun Oct 14, 2007 8:28 am

Post » Tue Nov 20, 2012 12:50 am

question 1:I'v created a new formlist in ck.And was it enough to get it just by adding the property in the script like this.
well you'll also need to add the spell into the property, basicly anything you want the script to work with, it has to know about, if you havent defined the spell it can not work out what to do, and stops.

question 2:The items which in the formlist is from another mod. so was it the reason it doesnt work.
proberly, you have to have said mod loaded before it can work, and you need to make sure the player who in the end will use your mod, also gets it.

question 3:I use the ' As ObjectReference' and 'additems' to any person in the game.Was it not right?
I'm not to well into the scripting yet, so for this i have to say i'm not sure
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Mon Nov 19, 2012 11:25 pm

Thank you Treeki.
Upon your answer for me,I began to doubt it was the problem of the script.
Because I've created all the object needed and quite sure add the neccessary mod.

Because I doubt if the formlist should set some globle property before it can be used.
or the additem can not be used for adding something like objectferences.(I've suceeded placetatme a big another thing but the clothes not work.)
User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Tue Nov 20, 2012 4:00 am

Thank you Treeki.
Upon your answer for me,I began to doubt it was the problem of the script.
Because I've created all the object needed and quite sure add the neccessary mod.

Because I doubt if the formlist should set some globle property before it can be used.
or the additem can not be used for adding something like objectferences.(I've suceeded placetatme a big another thing but the clothes not work.)
It's not always enough to just create the item, you have to tell the script what items and spell it should look for.
User avatar
Jacob Phillips
 
Posts: 3430
Joined: Tue Aug 14, 2007 9:46 am

Post » Mon Nov 19, 2012 9:06 pm

int nClothes = 0;
Debug.messagebox("come on!");

Hee hee, you've been caught putting ; at the end of the line by habit. I do that too...

A few things:
1) Is the formlist holding base objects? I don't think you can just cast a base object to a reference, it doesn't really make sense, You should just add the base object instead. It's not so much that you can't add objectreferences to an actor, but you can't create a new objectreference by casting a base object.
2) Isn't the randomint supposed to be between 0 and the formlist size - 1? I don't see what else it would be for so I'll assume that.
3) If the clothes get added, I am not sure if Skyrim NPCs will equip them automatically... you might have to equip them in the script too, or kill / use the console to check their inventory

So I'd suggest trying this:
Scriptname MCSChangeClothEffect extends activemagiceffectFormList Property MCSClothForChange AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	If akCaster == Game.GetPlayer()		akTarget.RemoveAllItems()		int FormListSize = MCSClothForChange.GetSize()		int nClothes = 0		while(nClothes < 3)			;//Not sure if this is correct, so just putting it in the next line for now...			;//Form newClothes = MCSClothForChange.GetAt( Utility.RandomInt(0, FormListSize) ) as Form			akTarget.AddItem(MCSClothForChange.GetAt( Utility.RandomInt(0, FormListSize) ), 1)			nClothes+=1		endwhile	endifEndEvent
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Tue Nov 20, 2012 5:50 am

Thank you very much .

I tought the item was an armor.And I linked the propery with it.The formlist's uses property then shows 1.
But it doesnt work.
I tried to do like this.
Form  newClothes =  MCSClothForChange .GetAt( clothno )akTarget.AddItem(newClothes , 1)

It still doesn't work.
As you seen .I also have placeatme to test if the item was added but not just unwear it(altough I check the npc also)

But if I try
newClothes= (Game.GetForm(somegameclothes) );//somegameclothes is the origin clothes which the skyrim has it alreadyakTarget.AddItem(newClothes , 1)

This works. and also the npc wear it immediatlly.


So I though it was the formlist's wrong.



Thank you for tell me the randomsize problem.Althought I've already set it less than the array size to avoid crash. but your advice's good.I'll try.
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Tue Nov 20, 2012 3:23 am

Can you try something like:
Debug.MessageBox( MCSClothForChange.GetAt( 0 ) )

And say what the result is? It should give you the form id and type of object...

Also noticed this on the wiki:
In most cases, FormLists should contain just one type of base form ... If multiple types of base forms appear in the FormList, the system using the FormList may reject it.

Maybe it doesn't apply to you, but you can check anyway...
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Mon Nov 19, 2012 11:29 pm

Can you try something like: Debug.MessageBox( MCSClothForChange.GetAt( 0 ) ) And say what the result is? It should give you the form id and type of object... Also noticed this on the wiki: Maybe it doesn't apply to you, but you can check anyway...


something happened.
I open the ck but found the list content were all missing!
I added the items back to it.
and try the game.








Still not work...





but I can tell the trace message shows "none".
I don't know why the formlist would missing its list sometime.
But whether it have list or not the message is "none" the same.
User avatar
Marilú
 
Posts: 3449
Joined: Sat Oct 07, 2006 7:17 am


Return to V - Skyrim