Summon Merchant Spell - scripts optimisation

Post » Mon Aug 10, 2009 7:31 pm

I've created a mod, which adds a spell allowing us to summon a merchant in any time and any place. It works correctly for most of the time, but there are some certain flaws - I hope you can help me to fix them.

Download: http://planetelderscrolls.gamespy.com/View.php?view=OblivionMods.Detail&id=6155

Those problems are following:

1. Merchant wears every weapon, shield and torch that you'll sell to her, possibly also helmets. I've tried to prevent wearing stuff from player by adding functions, that checks does the Merchant wears something different than her default clothing and then immediately forces her to equip it again. It works for robe, boots and gloves, but not for hood, for some reason. I've don't added any functions preventing her from wearing shields, torches and weapons, but I want to add it too.

2. Sometimes Merchant begins to disappear before she's able to talk to you. Mostly it looks like that she needs some time to locate the player - no idea what makes that time longer or shorter - and after fully turning to him, then she forces the conversation. How can I fix the script to prevent her from disappearing before conversation, as long as player stands in at least 3 meters away from her?

3. The Merchant should reset her equipment after some time, destroying all the stuff that we've sold to her. But she doesn't, and all we sell to her lies in her stock forever - maybe it wouldn't be a big problem, but when we sell a lot of equipment to her, then entering the trading menu takes more and more time with every item on her stock. I want to force that sort of regular reset to prevent such problem.

4. And for last, maybe not a problem of scripts but still a problem I'd like to fix, the book that allows us to learn the spell doesn't show in places where it should be, at least as other users say. It should be in Rindir's stock from Market District, or in Mages Guild building in Skingrad, Anvil and Leyawiin (all on bookshelves). I'll be very thankful if someone can check why it doesn't appear in those places, because it works correctly for me and I don't know what's wrong.

I'll be very thankful for help with those problems. :)
User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Mon Aug 10, 2009 4:48 pm

Bump.

Help me, please.
User avatar
A Dardzz
 
Posts: 3370
Joined: Sat Jan 27, 2007 6:26 pm

Post » Mon Aug 10, 2009 2:58 pm

1,
http://cs.elderscrolls.com/constwiki/index.php/EquipItem


2, added the scripts for others to comment on without having to download ;).

3, give the merchant a merchants container that'll respawn... or resurrect the merchant every once in a while/every time.

4, they could have any other mods could tamper with the used cells, people simply can't find them, don't have the latest patch installed, etc..etc.. Don't forget these possibilities.

Merchant Spell Script
scn ZUMerchantSummonSpellSCRIPTfloat timershort returnEffect		; set to 1 when playedfloat xfloat yfloat anglebegin ScriptEffectStartif ( ZUMerchantREF.summoned == 0 )	set ZUMerchantREF.summoned to 1	; Move Merchant to player.	ZUMerchantSummonMarker.moveto player	; Get orientation of player.	; When we have math functions, we can do this:	set angle to player.getangle z	; TEMP: for now, just move on axis based on angle.	if angle <= 45 && angle >= -45		set y to 150	elseif angle >= 45 && angle <= 135		set x to 150	elseif angle >= 135 && angle <= 225		set y to -150	else		set x to -150	endif			ZUMerchantREF.moveto player x y 0	ZUMerchantREF.look player	ZUMerchantREF.pme STRP	; Merchant force-greet player.	ZUMerchantREF.addscriptpackage ZUMerchantSummonForcegreet	; Set variable on Merchant to prevent player from talking to him before he forcegreets.	set ZUgreetVAR to 1	set ZUFadeOnce to 3else	Message "Merchant has been summoned too recently."endifendbegin ScriptEffectUpdate	set timer to timer + ScriptEffectElapsedSeconds	if returnEffect == 0 && timer > 4.5		ZUMerchantREF.pme STRP		set returnEffect to 1	endifendbegin ScriptEffectFinish	if ( ZUMerchantREF.GetInSameCell Player == 0 ) && ( ZUMerchantREF.summoned == 1 )		set ZUMerchantSummonQuest.resetVAR to 1	endifend


Merchant Script
scn ZUMerchantScriptshort leaveVARfloat timershort doOncefloat fadetimerfloat MerchantAlphashort resetAlphashort summonedfloat summontimershort summonblockerbegin OnLoad		setghost 1endBegin OnActivate	if ( ZUgreetVAR == 0 )		Activate	endifEndBegin GameMode; This section makes it appear as if Merchant has activated a door and faded out.if ( leaveVAR == 2 ) && ( ZUFadeOnce == 0 )	Set MerchantAlpha to .9	Set FadeTimer to 4	SetActorAlpha MerchantAlpha	set ZUFadeOnce to 1endifif ( ZUFadeOnce == 1 )	if ( FadeTimer > 0 )		Set FadeTimer to ( FadeTimer - GetSecondsPassed )		Set MerchantAlpha to ( MerchantAlpha - .01 )		SetActorAlpha MerchantAlpha	elseif ( FadeTimer <= 0 )		Set MerchantAlpha to 0		Set ZUFadeOnce to 2		Set FadeTimer to 0		MoveTo ZUMerchantReturnMarker	endifendif; This chunk fades her out after summon.if ( ZUFadeOnce == 4 )	Set MerchantAlpha to 0.9	Set FadeTimer to 4	SetActorAlpha MerchantAlpha	set ZUFadeOnce to 5endifif ( ZUFadeOnce == 5 )	if ( FadeTimer > 0 )		Set FadeTimer to ( FadeTimer - GetSecondsPassed )		Set MerchantAlpha to ( MerchantAlpha - .01 )		SetActorAlpha MerchantAlpha	elseif ( FadeTimer <= 0 )		Set MerchantAlpha to 0		Set ZUFadeOnce to 2		Set FadeTimer to 0		MoveTo ZUMerchantReturnMarker		set resetAlpha to 1		set summoned to 0		set summontimer to 0		set summonblocker to 0	endifendifif ( resetAlpha == 1 )	setActorAlpha 1	set resetAlpha to 0endifif ( summoned == 1 )	set summontimer to ( summontimer + GetSecondsPassed )	if ( summontimer >= 5 )		if ( summonblocker == 0 )			; Send Merchant back where she came from.			ZUMerchantREF.pme STRP			ZUMerchantREF.removescriptpackage			ZUMerchantREF.stoplook			set ZUFadeOnce to 4			set ZUgreetVAR to 0			set summonblocker to 1		endif	endifendif; This part prevents Merchant from wearing items from player, or at least it should do that.if ( ZUMerchantREF.getequipped ZUMerchantClothingBoots == 0 )		ZUMerchantREF.equipitem ZUMerchantClothingBoots [color="#00FF00"]1[/color]endifif ( ZUMerchantREF.getequipped ZUMerchantClothingRobe == 0 )		ZUMerchantREF.equipitem ZUMerchantClothingRobe [color="#00FF00"]1[/color]endifif ( ZUMerchantREF.getequipped ZUMerchantClothingGauntlets == 0 )		ZUMerchantREF.equipitem ZUMerchantClothingGauntlets [color="#00FF00"]1[/color]endifif ( ZUMerchantREF.getequipped ZUMerchantClothingHood == 0 )		ZUMerchantREF.equipitem ZUMerchantClothingHood [color="#00FF00"]1[/color]endifEnd

ZUMerchantSummonQuest script
scn ZUMerchantSummonQuestScriptshort resetVARBegin GameModeif ( resetVAR == 1 )	Set ZUMerchantREF.MerchantAlpha to 0	Set ZUFadeOnce to 2	Set ZUMerchantREF.FadeTimer to 0	ZUMerchantREF.MoveTo ZUMerchantReturnMarker	set ZUMerchantREF.resetAlpha to 1	set ZUMerchantREF.summoned to 0	set ZUMerchantREF.summontimer to 0	set ZUMerchantREF.summonblocker to 0	set resetVAR to 0endifEnd

User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Mon Aug 10, 2009 7:45 pm

3, give the merchant a merchants container that'll respawn...

But does it would work even if she's far away from that chest?

Thanks for showing me NoUnequipItem function, it could be useful. :) But still remains a problem of weapon, shield and torch - I can't give her any item from these because it will be shown in her stock. As far as I know, because if adding a chest for her would work, maybe that problem will gone too.
User avatar
Jack Moves
 
Posts: 3367
Joined: Wed Jun 27, 2007 7:51 am

Post » Mon Aug 10, 2009 11:52 am

I believe that an item marked unplayable will not show in inventory. So an unplayable "null" weapon would block the slot, and not be for sale.

Since she doesn't actually have to travel to her chest to use it, distance is no problem. (the items just teleport, don't they?)
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Mon Aug 10, 2009 1:42 pm

I believe that an item marked unplayable will not show in inventory.

And that really happens, but weapons can't be marked as an unplayable. Although I've created a staff with "null" mesh, 0 weight and value, and marked as quest item and it's actually not showed in barter menu. :)

Since she doesn't actually have to travel to her chest to use it, distance is no problem. (the items just teleport, don't they?)

All right, I've tried to do so, but it seems to not work. So, I've tried a solution with making a weekly reset of Merchant's equipment, but for some reason game crashes after this time (game just stops and there's nothing more to do with it but CTRL+ALT+DEL or computer reset). I'll show you here my script - what I've made wrong? If it's unclear, I've didn't used Resurrect function, because it seems to not work (at least as I've tried in-game by using console).

scn ZUMerchantSummonQuestScriptshort resetVARBegin GameModeif ( resetVAR == 1 )	Set ZUMerchantREF.MerchantAlpha to 0	Set ZUFadeOnce to 2	Set ZUMerchantREF.FadeTimer to 0	ZUMerchantREF.MoveTo ZUMerchantReturnMarker	set ZUMerchantREF.resetAlpha to 1	set ZUMerchantREF.summoned to 0	set ZUMerchantREF.summontimer to 0	set ZUMerchantREF.summonblocker to 0	set resetVAR to 0endif; This part disallows player to have Merchant's staff, if he'll get it somehow.if ( player.getitemcount ZUMerchantStaff > 0 )	player.removeitem ZUMerchantStaff 1	message "You shouldn't have this staff."endif; This part makes Merchant's weekly reset of all equipment and items, restoring to her default stock.if ( ZUDaysReset == 0 )	ZUMerchantREF.removeallitems	ZUMerchantREF.additem ZUMerchantClothingHood 1	ZUMerchantREF.additem ZUMerchantClothingRobe 1	ZUMerchantREF.additem ZUMerchantClothingGauntlets 1	ZUMerchantREF.additem ZUMerchantClothingBoots 1	ZUMerchantREF.additem ZUMerchantStaff 1	ZUMerchantREF.equipitem ZUMerchantClothingHood 1	ZUMerchantREF.equipitem ZUMerchantClothingRobe 1	ZUMerchantREF.equipitem ZUMerchantClothingGauntlets 1	ZUMerchantREF.equipitem ZUMerchantClothingBoots 1	ZUMerchantREF.equipitem ZUMerchantStaff 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows1 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows2 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows3 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows4 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows5 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows6 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows7 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows8 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows9 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows10 1	ZUMerchantREF.additem ZUMerchantLeveledListOther1 1	ZUMerchantREF.additem ZUMerchantLeveledListOther2 1	ZUMerchantREF.additem ZUMerchantLeveledListOther3 1	ZUMerchantREF.additem ZUMerchantLeveledListOther4 1	ZUMerchantREF.additem ZUMerchantLeveledListOther5 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions1 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions2 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions3 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions4 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions5 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions6 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions7 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions8 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions9 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions10 1	set ZUDaysReset to GameDaysPassed	addtopic ZUMerchantBookTopic	addtopic ZUMerchantBookBuy	addtopic ZUMerchantBookCancelelseif ( ZUDaysReset > 0 && ZUDaysReset + 7 <= GameDaysPassed )	ZUMerchantREF.removeallitems	ZUMerchantREF.additem ZUMerchantClothingHood 1	ZUMerchantREF.additem ZUMerchantClothingRobe 1	ZUMerchantREF.additem ZUMerchantClothingGauntlets 1	ZUMerchantREF.additem ZUMerchantClothingBoots 1	ZUMerchantREF.additem ZUMerchantStaff 1	ZUMerchantREF.equipitem ZUMerchantClothingHood 1	ZUMerchantREF.equipitem ZUMerchantClothingRobe 1	ZUMerchantREF.equipitem ZUMerchantClothingGauntlets 1	ZUMerchantREF.equipitem ZUMerchantClothingBoots 1	ZUMerchantREF.equipitem ZUMerchantStaff 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows1 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows2 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows3 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows4 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows5 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows6 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows7 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows8 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows9 1	ZUMerchantREF.additem ZUMerchantLeveledListArrows10 1	ZUMerchantREF.additem ZUMerchantLeveledListOther1 1	ZUMerchantREF.additem ZUMerchantLeveledListOther2 1	ZUMerchantREF.additem ZUMerchantLeveledListOther3 1	ZUMerchantREF.additem ZUMerchantLeveledListOther4 1	ZUMerchantREF.additem ZUMerchantLeveledListOther5 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions1 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions2 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions3 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions4 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions5 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions6 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions7 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions8 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions9 1	ZUMerchantREF.additem ZUMerchantLeveledListPotions10 1	set ZUDaysReset to GameDaysPassedendifEnd

User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Mon Aug 10, 2009 6:01 am

Ok, I think you can call me stupid. Why?

Because during all this going by roundabout way, I've didn't noticed a "respawn" option in NPC's menu...

...

*Akhem* Well, thanks anyway for all your help. :) Now I only need an answer for my second question from first post and all will be fine.
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm


Return to IV - Oblivion