Help with Scripting, etc.

Post » Fri Jan 28, 2011 4:05 am

Hi, I'm new to modding Oblivion. I am (attempting to) create a helmet that svcks health from nearby actors. My scripts so far:

scn JMVampScriptbegin ScriptEffectStart  messagebox "Attempting Vampirism"  modav health -2  player.modav health 2  messagebox "Done"end 


and

scn JMVampScriptActfloat timerref meref Sourcebegin scripteffectstart  messagebox "Equipped"  label 1  if ( timer < 1 )    set timer to timer + getSecondsPassed    Messagebox "Timer"  else                                                                    Set me to getself    Set Source to JMVampAct1    Messagebox "Moving Activator"    Source.moveto me 0, 0, 0    Messagebox "Casting spell"    Source.cast JMVampSpell me  endif  if(player.getequipped JMVampHelmet==1)    messagebox "Looping"    goto 1  endifend


I have created a spell JMVampSpell that has the JMVampScript effect.
I have created an Enchantment JMVampirisim that has the script JMVampScriptAct.
I have created a helmet JMVampHelmet that has the JMVampirism enchantment.
I made an activator JMVampAct1 that is in a blank cell and is a persistent referencce and is initially disabled.

None of it works. My debug messages do not run, and there are no effects anywhere. I added the spell to myself and the spell works properly. What am I doing wrong? Any help would be appreciated.

[/firstpost]
User avatar
Mariana
 
Posts: 3426
Joined: Mon Jun 12, 2006 9:39 pm

Post » Fri Jan 28, 2011 4:58 am

Most likely ScriptEffectStart for an enchantment won't work.
Then the "Label 1 -> Goto 1" combination in this form will make it loop infinitely as long as the helmet is equipped.
It will never pass control to any other elements of the game unless the helmet gets unequipped, which can't happen because the game will not react to input during this loop.

You could put the JMVampScriptAct into a GameMode block and make it an Object Script put onto the helmet.
Then put this "if(player.getequipped JMVampHelmet==1)"-condition around the whole contents, so they're only executed while the helmet is equipped and get rid of the loop. GameMode blocks are repeated each frame, so you won't need it to loop from the end of a script to the start again, when this will happen anyways in a couple of milliseconds later.
User avatar
I love YOu
 
Posts: 3505
Joined: Wed Aug 09, 2006 12:05 pm

Post » Fri Jan 28, 2011 11:44 am

Hi. An update. I have done what you suggested and it seems to have helped get past the first problem.

new JMVampScriptAct
scn JMVampScriptActfloat timerref meref Sourceshort dooncebegin GameMode  if(player.getequipped JMVampHelmet==1)  if(doonce==0)    placeatme JMVampAct1    set doonce to 1  endif    if ( timer < 1 )      set timer to timer + getSecondsPassed    else      set Timer to 0                                                         Set me to getself      Set Source to JMVampAct1        if(Source==JMVampAct1)          Messagebox "Success!"        endif      Source.moveto me 0, 0, 0      Source.cast JMVampSpell me    endif  endifend

It is also now an object script that the JMVampHelmet uses. I think the new problem is that the Activator:
A) Is not created
B)I s not moved to me
C) Is not casting the spell correctly

Again, any help or insight would be helpful.

Thanks in advance,
cr101
User avatar
Spaceman
 
Posts: 3429
Joined: Wed May 23, 2007 10:09 am

Post » Fri Jan 28, 2011 11:27 am

Hmm, well the only thing obvious coming into mind would be the "placeatme JMVampAct1" line.
If JMVampAct1 as a "persistent" reference to an instance of your activator placed in a remote cell already, as you described in your first post, then I don't think placeAtMe will do anything, maybe even crash the script at this line. If it's the EditorID of your activator though, i.e. a base object, then placeAtMe will create another instance of it and place it at your location (might also be the location of the helmet though, which then wouldn't work when it's in inventory or worn, don't know). However, if JMVampAct1 is a base object and not a persistent reference to an activator actually placed somewhere in the world, then the else-part of the "if ( timer < 1 )"-condition won't work, because you can't call moveTo on a base object or make it cast a spell.
User avatar
Darrell Fawcett
 
Posts: 3336
Joined: Tue May 22, 2007 12:16 am

Post » Thu Jan 27, 2011 11:22 pm

Ok, I actually added that placeatme line just to try something new. It doesn't work with or without it. I have tried putting JMVampAct1 both in a remote cell and in the cell where you get the JMVampHelmet. I have made it both a persistent reference and a non-persistent reference, a quest object and not a quest object, an both initially disabled and initially enabled. I don't think the activator is being moved. Or maybe it is being moved and it isn't casting the spell properly. Also I realized thatI forgot to give the activator a referenceeditorid. I gave it JMSourceID as the referenceeditorid and updated my script. However the activator still is either not being moved to me or is not casting the spell.

scn JMVampScriptActfloat timerref mebegin GameMode  if(player.getequipped JMVampHelmet==1)    if ( timer < 1 )      set timer to timer + getSecondsPassed    else      set Timer to 0                                                         Set me to getself      JMSourceID.moveto me 0, 0, 0      JMSourceID.cast JMVampSpell me    endif  endifend


Again, any help/insight would be appreciated. I'm making progress!

Thanks again,
cr101

EDIT: Yes! I figured it out! Once I attached the JMVampScriptAct to the helmet, the getself function was returning the referenceID of the helmet instead of the player, and was therefor moving the activator to the wrong place! Now the helmet works perfectly. Thank you so much for your help I couldn't have done this without your help.

Success!
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm


Return to IV - Oblivion

cron