Difference between revisions of "Adding a script to an ingredient"

m
imported>UDUN
(New page: I wanted to create a piece of poisoned cheese (clone of cheese wedge) with 4 alchemical effects neither of which would be deadly poison - but which when consumed by PC would be like a poi...)
 
imported>UDUN
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
I wanted to  create a piece of poisoned cheese (clone of cheese wedge) with 4 alchemical effects neither of which would be deadly poison - but which when consumed by PC would be like a poisoned apple - bye bye.Problem is when ingredient is consumed its script will terminate. I overcame this by creating a mute quest holding variables. I don't see if it can be done with no quest.
I wanted to  create a piece of poisoned cheese (clone of cheese wedge) with 4 alchemical effects neither of which would be deadly poison - but which when consumed by PC would be like a poisoned apple - bye bye. Problem is when ingredient is consumed its script will terminate. I overcame this by creating a mute quest holding variables. I don't see if it can be done with no quest. Probably checking for active effects then tracking them to the cheese but this is difficult - among other things because the ActiveEffectIndex doesn't seem to be chronological. Chm er and the script terminates.


Also of interest is the possibility to be extended to any actor, not only PC but also NPCs and creatures. Not sure if possible.
Also of interest is the possibility to be extended to any actor, not only PC but also NPCs and creatures. Not sure if possible.


Create a clone of CheeseWedge and name it something like PoisonCheese. Add a quest (not start game enabled) (UdunPoisonedCheeseQuest) and attach one script to it (UdunPoisonedCheeseQuestScript) and one script to the PoisonedCheese you created (mine had formId 01004547, which I use directly). Here are the scripts. I tested them with OBSE v0015.
Create a clone of CheeseWedge and name it something like PoisonCheese. Add a quest (not start game enabled) (UdunPoisonedCheeseQuest) and attach one script to it (UdunPoisonedCheeseQuestScript) and one script to the PoisonedCheese you created (mine had formId 01004547, which I use directly). Here are the scripts. I tested them with OBSE v0015, but probably these final versions don't require OBSE.


====object Script====
====object Script====
<pre>scn PoisonedCheeseScript
<pre>scn PoisonedCheeseScript
;requires OBSE v0015
;tested with OBSE v0015


Begin onAdd player
Begin onAdd player
set UdunPoisonedCheeseQuest.cheeses to UdunPoisonedCheeseQuest.cheeses + 1
if GetQuestRunning UdunPoisonedCheeseQuest == 0  
if GetQuestRunning UdunPoisonedCheeseQuest == 0  
StartQuest UdunPoisonedCheeseQuest
StartQuest UdunPoisonedCheeseQuest
set UdunPoisonedCheeseQuest.fQuestDelayTime to 0.05 ;0.01
set UdunPoisonedCheeseQuest.fQuestDelayTime to 0.05 ;0.01
endif
endif
set UdunPoisonedCheeseQuest.cheeses to UdunPoisonedCheeseQuest.cheeses + 1
end
end


Line 28: Line 28:
====quest Script====
====quest Script====
<pre>scn UdunPoisonedCheeseQuestScript
<pre>scn UdunPoisonedCheeseQuestScript
;requires OBSE v0015
;tested with OBSE v0015


short cheeses
short cheeses
Line 46: Line 46:
endif
endif
if (player.GetItemCount 01004547 != cheeses) && skippedframe==0
if (player.GetItemCount 01004547 != cheeses) && skippedframe==0
set skippedframe to 2
set skippedframe to 2     ;min 1
                ;debugging purposes, see limitations
return
return
elseif (player.GetItemCount 01004547 != cheeses) && skippedframe>1
elseif (player.GetItemCount 01004547 != cheeses) && skippedframe>1
Line 58: Line 59:
end
end
</pre>
</pre>
[[User:UDUN|UDUN]] 18:33, 13 October 2008 (EDT)
 
====Limitations====
 
If a large number of cheeses is dropped (shift+click) at once then the player ends up eating one of them - for me this occurs somewhere between 250 and 300 cheeses for ''skippedframe'' initially 2. Setting ''skippedframe'' to bigger values permits larger numbers being dropped simultaneously (I arbitrary set to 20 and was able to throw 3000 at once - caution : skippedframe for alchemy submenu set to 21 instead of 3 in both scripts).
 
[[User:UDUN|UDUN]] 11:28, 17 October 2008 (EDT)
 
[[Category:Solutions]]
Anonymous user