Converting oblivion scripts

Post » Sun Oct 03, 2010 10:17 am

I once wrote a script for oblivion allowing you to "light" your arrow on fire if you had a torch with you:
scn aaaArcherArrowsbegin onEquipref Arrow     set Arrow to player.GetEquippedObject 17     if IsTorchOut == 1		if Arrow.NameIncludes Iron == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns 01000cea 1				player.equipitemns 01000cea		elseif Arrow.NameIncludes Steel == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns  01000ceb 1				player.equipitemns 01000ceb		elseif Arrow.NameIncludes Elven == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns 01000cec 1				player.equipitemns 01000cec		elseif Arrow.NameIncludes Glass == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns 01000ced 1				player.equipitemns 01000ced		elseif Arrow.NameIncludes Ebony == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns 01000cee 1				player.equipitemns 01000cee		elseif Arrow.NameIncludes Daedric == 1				player.UnequipItemNS Arrow				player.removeitemns Arrow 1				player.additemns 01000cef 1				player.equipitemns 01000cef		endif     else player.removeitemns aaaLighter 1     endifend

Are these functions available in any of the script extenders, under a different name perhaps?
I'm also very interested in translating that mod which allows you to evade attacks by ducking ("sneaking")

P.S. Can you spot the fatal syntax error?
User avatar
Trevor Bostwick
 
Posts: 3393
Joined: Tue Sep 25, 2007 10:51 am

Post » Sun Oct 03, 2010 8:32 am

the syntax is different in morrowind scripts. for example you don't call a function on player with "player.function"
but with "player->function".
and afaik neither vanilla script nor MWSE features a function to unequip an item. but if you add a new arrow to the inventory and equip it to the PC, this function is obsolete anyway.

the "arrow. " functions do not exist in MW. Neither in vanilla nor in MWSE. with MWSE you can however check which kind of weapon the pleaer has equipped. but i don't know if

the other thing is you cannot compare IDs containing a specified string. you can check for the complete object id e.g. "steel_arrow" (and iirc even for the name, eg. "Ebony Arrow of Doozumthin"). but if you try to compare to the string "iron" you will never find anything, not even the wrong objects.

from my point of view this script could be easily converted to MW scripts even with vanilla script functions. the only thing is that you are only able to "ignite" the stock arrows or the arrows added by mods YOU know. since you have to adress them by ID/name seperately in the script (but as far as i can judge your script doesn't include mod added arrows anyway).

I'd suggest to read through http://planetelderscrolls.gamespy.com/View.php?id=6083&view=Mods.Detail and - if needed - http://www.tesnexus.com/downloads/file.php?id=20927.
since you already have some expereience in scripting, understanding MW syntax should be a walk in the park. :wink_smile:
User avatar
Nick Pryce
 
Posts: 3386
Joined: Sat Jul 14, 2007 8:36 pm

Post » Sun Oct 03, 2010 7:31 am

I see, thanks for clearing that up, now I don't have to waste time "looking for that function I need". I hate doing that, especially when you don't know if what you want is possible, and there are several methods to achieve the same thing. I have dabbled with oblivion and morrowind scripts before, but a long time apart from each other, and now I'm a long time apart from touching either of them!

What a shame! That was the main thing I needed,to search strings, now it's going to be very tedious, and won't work with mods :shakehead: I might not do it after all. I expected MWSE to have it having been around for so much longer. For example, I think OBSE has more features than the Fallout 3 one.

P.S. The syntax error is- the reference for nameincludes goes AFTER the word to search for (for any oblivion modders)

Edit: I remember my favourite tutorial was the one on scribd, no need to download!
User avatar
Gemma Woods Illustration
 
Posts: 3356
Joined: Sun Jun 18, 2006 8:48 pm

Post » Sun Oct 03, 2010 10:54 am

So was just reminded from another thread that "Protective guards" searches for the string 'guard' in NPC ids, now he did he do that? Hmm, may be time for some dissection
User avatar
Monika Fiolek
 
Posts: 3472
Joined: Tue Jun 20, 2006 6:57 pm

Post » Sun Oct 03, 2010 2:00 pm

Anyone?
User avatar
Neil
 
Posts: 3357
Joined: Sat Jul 14, 2007 5:08 am

Post » Sun Oct 03, 2010 3:49 am

I took a look at Fliggerty's ESP file really quickly... in Notepad. This segment stuck out to me.

Basically, every NPC in a cell gets checked by his script, and if the conditions are right, it gets to this part. First he gets the name of the NPC and stores it. Then he breaks that string out into pieces, and checks those individual pieces for the types of words that would indicate a guard ("guard", "ordinator", etc).

I've not used these functions (very new to MWSE myself) before as string operations seem particularly messy for Morrowind, but it looks to me like you can only see if two strings are exactly equal, not do any substring searches. Good luck!

	set call to 0	setx npcname to npcref->xGetName	setx match sval1 sval2 sval3 to xStringParse "%.0s %.0s %.0s" npcname	setx temp to xStringCompare sval1 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval2 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval3 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval1 "archer"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "archer"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "archer"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "ordinator"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "ordinator"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "ordinator"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval2 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval3 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval1 "Archer"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "Archer"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Archer"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Ordinator"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "Ordinator"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Ordinator"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Bounty"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Bounty"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval3 "Bounty"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval1 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval1 "Paladin"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Paladin"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Paladin"	if ( temp == 0 )		set call to 1	endif		ifx ( call )		npcref->xStartCombat tarref		xSetRef npcref		set state to 1	endif

User avatar
Sunnii Bebiieh
 
Posts: 3454
Joined: Wed Apr 11, 2007 7:57 pm

Post » Sun Oct 03, 2010 8:57 am

I took a look at Fliggerty's ESP file really quickly... in Notepad. This segment stuck out to me.

Basically, every NPC in a cell gets checked by his script, and if the conditions are right, it gets to this part. First he gets the name of the NPC and stores it. Then he breaks that string out into pieces, and checks those individual pieces for the types of words that would indicate a guard ("guard", "ordinator", etc).

I've not used these functions (very new to MWSE myself) before as string operations seem particularly messy for Morrowind, but it looks to me like you can only see if two strings are exactly equal, not do any substring searches. Good luck!

	set call to 0	setx npcname to npcref->xGetName	setx match sval1 sval2 sval3 to xStringParse "%.0s %.0s %.0s" npcname	setx temp to xStringCompare sval1 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval2 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval3 "guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval1 "archer"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "archer"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "archer"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "ordinator"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "ordinator"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "ordinator"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval2 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval3 "Guard"	if ( temp == 0 ) ;first word is guard		set call to 1	endif	setx temp to xStringCompare sval1 "Archer"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "Archer"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Archer"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Ordinator"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval2 "Ordinator"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Ordinator"	if ( temp == 0 ) 		set call to 1	endif	setx temp to xStringCompare sval1 "Bounty"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Bounty"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval3 "Bounty"	if ( temp == 0 )		set call to 1	endif	setx temp to xStringCompare sval1 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Legionary"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval1 "Paladin"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval2 "Paladin"	if ( temp == 0 )		set call to 1	endif		setx temp to xStringCompare sval3 "Paladin"	if ( temp == 0 )		set call to 1	endif		ifx ( call )		npcref->xStartCombat tarref		xSetRef npcref		set state to 1	endif


Thanks, I appreciate your taking the time to go through this. Ah well, guess I'm dropping it then.
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm

Post » Sun Oct 03, 2010 4:26 pm

Actually, if I understand what you are trying to do, it wouldn't be too difficult to control. Script flow would be something like this:

Torches have a particular set of IDs, and you can certainly check to see if the player has a torch. If any of the torch IDs are present, move to next segment.

If the player's weapon type is bow and the player has the bow drawn (and whatever other conditions you might want, I suppose -- if they needed to press a key to "light" the arrows, for instance), move to next segment.

For each arrow type in the base game, if they had that arrow type equipped, remove the proper quantity of that arrow, add a flaming version to inventory, and force equip it.

Finally, re-equip the old stack of arrows after the bowshot sound is heard from the player (so that they aren't stuck unable to shoot).


----

This method might be a little bit convoluted (due to needing to check each individual arrow type) but doesn't require MWSE so it is also simpler. Maybe I'm missing something (I thought through it only briefly), but I am fairly sure this type of script would get the job done.
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Sun Oct 03, 2010 4:57 am

There is no simple way to do a substring search, it's true. But as was pointed out, I do so by splitting the string up. Almost all IDs have an underscore (_) between words. So if you use xStringParse to split an ID into separate strings at the underscore, then you can use xStringMatch to compare each of those words with your needle.
User avatar
Joie Perez
 
Posts: 3410
Joined: Fri Sep 15, 2006 3:25 pm


Return to III - Morrowind