Force Idle animations?

Post » Wed Sep 14, 2011 12:18 am

I'm fairly new to Obliv modding (and I'm praying what I learn here will apply to Skyrim) so forgive me if this is a noob question, but how do I force an actor to perform a certain idle over and over?

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? =)
User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Tue Sep 13, 2011 8:43 pm

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.


I feel your pain :)

1- yes you can. Not on the actor itself but on a gameMode script attached to a quest. you can then check the variable using "GetQuestVariable" instead of "GetItemCount" on the idle animations conditions menu. You should also use "GetIsId NPC:player == 1" so only the player can perform the animation. If you need NPCS to play the animation you could add an ability called "dance" or whatever and add it to the actor you want , then check for it using "IsSpellTarget"

To modify quests variables from any script outside the quest, use the quest name as reference e.g: set myQuestName.MyVarOnThatQuest to 1. It is also possible to create global variables, these are under Gameplay/Globals

2- I don't think so.

3- you can use the "playGroup" function http://cs.elderscrolls.com/constwiki/index.php/PlayGroup But I think that "animPathIncludes" http://cs.elderscrolls.com/constwiki/index.php/AnimPathIncludes would be more appropriate to check if the actor is playing a certain animation you don't want to interrupt then use pickidle, after it finishes.

4- Basic Concepts may be applicable.
User avatar
~Sylvia~
 
Posts: 3474
Joined: Thu Dec 28, 2006 5:19 am

Post » Tue Sep 13, 2011 6:25 pm

Ok. If I understand correctly, you're trying to get a single or limited number of actors to do one of 20 dance moves?

The way I would do it runs something like this:

- Create one single token. The way the tutorial did it is fine.

- Create a quest and give it a quest script. It's mostly just going to sit around, but you do want to create a short type variable, call it DanceState or something.

- I usually use AI packages to make people do idles, but the way the tutorial has you doing things with the short pickidle script is fine too.

- Create your 20 dance idles. In addition to the GetItemCount condition, add in a GetQuestVariable condition pointed at that DanceState variable.

- In your script, however you want to do it, when the time comes to pick a new move, instead of adding and removing tokens, set the DanceState variable instead.

It's kind of wonky with multiple actors, unless you want them to synchronize. You could presumably add more variables, though I haven't thought all that hard about it.

As to your various other questions and parenthetical side notes:

- OBSE may have loops, but I don't use it enough to know.

- Only way to loop that I know of is just to let the script run around again. Yeah, it's kind of brain dead, but does work after a fashion. You get good with flow control variables after a time.

- Dynamic refs...OBSE, perhaps? Dunno.

- Variables in quest scripts can basically be treated as globals. It's not uncommon to have dummy quests filled with variables while most of the real work gets done in object scripts, which don't process globally like quests do, so save the poor player a bit of processing.

- I think I answer your question 1 above. So far as I know you can't really set variables in an actor's script like that, and have to use quest variables. Quest variables are wonderful things that do work, however.

- Re: question 2, maybe OBSE can, but again, I dunno. Also sort of superfluous in this context.

- Re: question 3, I don't know. Not that I'm aware of. In theory if you knew the exact length of the idle you could set the timer to something different each time, but I don't know of a function to do it for you.

- I don't think we know how Skyrim's scripting language will work exactly, but since the line from Morrowind -> Oblivion -> Fallout 3 -> Fallout: New Vegas is pretty consistent, I'd say there's hope.

Hope that helps.
User avatar
Tracy Byworth
 
Posts: 3403
Joined: Sun Jul 02, 2006 10:09 pm


Return to IV - Oblivion