I've been using the idle-token tutorial at http://cs.elderscrolls.com/constwiki/index.php/Forcing_Idle_Animations and, as a professional programmer, the approach makes me cringe. His method is to add an inventory item to the Actor and test in the idles to see if it exists. My problem is that I'm adding about 50 new idle animations, and these objects must be added and removed frequently, which I understand causes some kind of memory leak (Im using AddItem and RemoveItem). a sample script is below:
scn aaPJM66DancerScriptfloat timershort newDanceshort numDancesbegin onLoad set numDances to 20endbegin gamemode ; wait 15 seconds if ( timer > 15 ) ; do this again in 15 seconds... set timer to 0 ; add the token that tells NPC to begin dancing. Hopefully this improves efficiency ; since actors who lack the token will simply skip over the entire idle subgroup if (GetItemCount aaPJM66DanceToken <= 0) addItem aaPJM66DanceToken, 1 endif ; Remove any existing specific dance tokens. These tell the dancer which dance to perform. ; Does this lang REALLY not have arrays, loops, or at least a dynamic way to ref objects? ; and cant i just set this as a global on the main token? removeItem aaPJM66DanceToken1, 1 removeItem aaPJM66DanceToken2, 1 removeItem aaPJM66DanceToken3, 1 removeItem aaPJM66DanceToken4, 1 removeItem aaPJM66DanceToken5, 1 removeItem aaPJM66DanceToken6, 1 removeItem aaPJM66DanceToken7, 1 removeItem aaPJM66DanceToken8, 1 removeItem aaPJM66DanceToken9, 1 removeItem aaPJM66DanceToken10, 1 removeItem aaPJM66DanceToken11, 1 removeItem aaPJM66DanceToken12, 1 removeItem aaPJM66DanceToken13, 1 removeItem aaPJM66DanceToken14, 1 removeItem aaPJM66DanceToken15, 1 removeItem aaPJM66DanceToken16, 1 removeItem aaPJM66DanceToken17, 1 removeItem aaPJM66DanceToken18, 1 removeItem aaPJM66DanceToken19, 1 removeItem aaPJM66DanceToken20, 1 ; Pick a new groove - sequential or random, your choice... set newDance to 1 + GetRandomPercent * 6 / 100 ;set newDance to newDance + 1 if (newDance == 1) addItem aaPJM66DanceToken1, 1 elseif (newDance == 2) addItem aaPJM66DanceToken2, 1 elseif (newDance == 3) addItem aaPJM66DanceToken2, 1 elseif (newDance == 4) addItem aaPJM66DanceToken4, 1 elseif (newDance == 5) addItem aaPJM66DanceToken5, 1 elseif (newDance == 6) addItem aaPJM66DanceToken6, 1 elseif (newDance == 7) addItem aaPJM66DanceToken7, 1 elseif (newDance == 8) addItem aaPJM66DanceToken8, 1 elseif (newDance == 9) addItem aaPJM66DanceToken9, 1 elseif (newDance == 10) addItem aaPJM66DanceToken10, 1 elseif (newDance == 11) addItem aaPJM66DanceToken11, 1 elseif (newDance == 12) addItem aaPJM66DanceToken12, 1 elseif (newDance == 13) addItem aaPJM66DanceToken13, 1 elseif (newDance == 14) addItem aaPJM66DanceToken14, 1 elseif (newDance == 15) addItem aaPJM66DanceToken15, 1 elseif (newDance == 16) addItem aaPJM66DanceToken16, 1 elseif (newDance == 17) addItem aaPJM66DanceToken17, 1 elseif (newDance == 18) addItem aaPJM66DanceToken18, 1 elseif (newDance == 19) addItem aaPJM66DanceToken19, 1 elseif (newDance == 20) addItem aaPJM66DanceToken20, 1 endif ; if we are doing incremental, reset to 0 if(newDance >= numDances) set newDance to 0 endif ; pick an idle, regardless of what else we do. Assuming we have both the do-dance token ; and a which-dance token, we will dance! pickidle else set timer to timer + getSecondsPassed endifend
So my questions:
1) can't I just set a variable on the actor telling it which idle to perform or do I really have to go through this inventory-object malarky?
2) is there any way to create a dynamic reference to the objects, (eg addItem "aaPJM66DanceToken" + i, 1) so I dont have to make those endless if-then blocks?
3) I'd prefer to have the current idle run to finish rather than just stop cold-turkey when a new one is chosen... can I detect this? I think its possible in Fallout but i cannot find the equivalent commands in the TESCS.
4) Skyrim will be similar to program, yes? =)