Aller au contenu

Photo

ANIMATION_PLACEABLE_STOP! For crying out loud.


  • Veuillez vous connecter pour répondre
19 réponses à ce sujet

#1
Alupinu

Alupinu
  • Members
  • 528 messages
Hey is there any way to stop a heartbeat animation with a ga_script?  I have an animated trap that I want to be turned off by a lever. The trap (placeable) runs on a heartbeat script that I cannot figure out for the life me how to turn off without destroying the placeable.
Thank you

#2
kevL

kevL
  • Members
  • 4 061 messages
custom heartbeat?

just add an int_check to the HB code that runs the animation:


if (bRunAnim)
{
// run the anim
}
else
{
// stop the anim.
}

and set the int via the lever ... or convo ... put the int on the Area or the lever itself, i suggest [or right on the placeable]

Modifié par kevL, 16 juillet 2012 - 09:52 .


#3
kevL

kevL
  • Members
  • 4 061 messages
ps. it's easier to do backwards,

if (bStopAnim) return;

Modifié par kevL, 16 juillet 2012 - 09:53 .


#4
Alupinu

Alupinu
  • Members
  • 528 messages
I see where you're going with this, let me give it a try and I'll get back to you, thanks kevL

#5
Alupinu

Alupinu
  • Members
  • 528 messages
I’m sorry kevL, I just don’t understand, I thought I did but… How do you make the animation stop to begin with? “StopAnimation()”? That doesn’t compile. I can’t find any command that makes the animation stop.
Here’s the script that I have placed right on the animated placeable/heartbeat.

void main()
{

object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);

if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;

PlayAnimation(ANIMATION_PLACEABLE_OPEN);

}


I tried having the animation play from another source (lever) but that didn’t seem to work either.
And another thing, I have no idea what I’m doing.

#6
kamal_

kamal_
  • Members
  • 5 250 messages
ClearAllActions() ?

#7
kevL

kevL
  • Members
  • 4 061 messages
i don't know much about animations either, i just get 'em to do things every so often


but that looks like a one-shot animation that should be fired from a trigger's onEnter event:

//pseudo-code:
void main()
{
if (GetIsPC(GetEnteringObject()))
{
PlayAnimation(ANIMATION_PLACEABLE_OPEN);
}
}


- just open the chest/box/door when the PC walks into view, right?


[ edit ]

Alupinu wrote...

... I have an animated trap ...

zzzzzzzzz coffeeee

Modifié par kevL, 18 juillet 2012 - 12:21 .


#8
kevL

kevL
  • Members
  • 4 061 messages

kamal_ wrote...

ClearAllActions() ?

or, make it play its Idle_Animation

( Edit, half a coffee later )

going with the notion that the trap-placeable uses ANIMATION_PLACEABLE_OPEN to run a 6 second animation that gets looped on the heartbeat:

// heartbeat script on trap
void main()
{
int bStopAnim = GetLocalInt(OBJECT_SELF, "bStopAnim");
if (!bStopAnim)
{
PlayAnimation(ANIMATION_PLACEABLE_OPEN)
}
//else, by not looping the animation it should stop.
}


// and, lever onUsed or in convo script
SetLocalInt(GetObjectByTag("trap1"), "bStopAnim", TRUE);


That's the basics of what I was getting at earlier ...

Modifié par kevL, 18 juillet 2012 - 01:04 .


#9
Alupinu

Alupinu
  • Members
  • 528 messages
Well here’s my best attempt. I had to abandon the heartbeat script because I just didn’t see how it would be do-able. So I made a Enter-Trigger script that should be conditioned by my lever convo but of course it’s not and I can’t get the trigger script to work at all.
Can anybody see what is wrong with the script below and why it won’t work.

//Put this script OnEnter
//Set damage: d2, d3, d4, d6, d8, d10, d12, d20, d100
void main()
{

object oPC = GetEnteringObject();

//if (!GetIsPC(oPC)) return;
string sInt = GetLocalString(OBJECT_SELF, "Intel");
string sTrap = GetLocalString(OBJECT_SELF, "Trap");
string sSound = GetLocalString(OBJECT_SELF, "Sound");

if (GetLocalInt(oPC, sInt)!= 1)
return;

int nRandomNumber = d12();
effect eEffect;

SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

if (ReflexSave(oPC, 16, SAVING_THROW_TYPE_TRAP ))
{
}
else
{
eEffect = EffectDamage(d12(), DAMAGE_TYPE_SLASHING, DAMAGE_POWER_NORMAL);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
}

{

object oTarget;
oTarget = GetObjectByTag(sTrap);

PlayAnimation(ANIMATION_PLACEABLE_OPEN);

oTarget = GetObjectByTag(sSound);

SoundObjectPlay(oTarget);
}

}


Thank you.

Modifié par Alupinu, 18 juillet 2012 - 02:11 .


#10
Alupinu

Alupinu
  • Members
  • 528 messages

kevL wrote...

kamal_ wrote...

ClearAllActions() ?

or, make it play its Idle_Animation

( Edit, half a coffee later )

going with the notion that the trap-placeable uses ANIMATION_PLACEABLE_OPEN to run a 6 second animation that gets looped on the heartbeat:

// heartbeat script on trap
void main()
{
int bStopAnim = GetLocalInt(OBJECT_SELF, "bStopAnim");
if (!bStopAnim)
{
PlayAnimation(ANIMATION_PLACEABLE_OPEN)
}
//else, by not looping the animation it should stop.
}


// and, lever onUsed or in convo script
SetLocalInt(GetObjectByTag("trap1"), "bStopAnim", TRUE);

That's the basics of what I was getting at earlier ...



Wow kevL this looks like it might work. Certainly a lot cleaner then my bunch of Mickey-mouse and it works on HB!
Let me play around with this and hopefully it will solve my problem.
Thanks!

Modifié par Alupinu, 18 juillet 2012 - 02:15 .


#11
kevL

kevL
  • Members
  • 4 061 messages
i bet it depends on what ANIMATION_Constants are available to the model ( or whatever it is )

if _PLACEABLE_OPEN gets it goin' try _PLACEABLE_CLOSE to stop it

#12
Alupinu

Alupinu
  • Members
  • 528 messages

kevL wrote...

i bet it depends on what ANIMATION_Constants are available to the model ( or whatever it is )

if _PLACEABLE_OPEN gets it goin' try _PLACEABLE_CLOSE to stop it


Well that does make sense.

#13
Alupinu

Alupinu
  • Members
  • 528 messages
Good new kevL, got your script to work. Took me most of the day to get all the variables set up, sound, damage, ect. But using your script as a model, I got it to all work perfectly. Now my players can turn on and off the animated traps at will. Thank you again kevL, I’ll make sure you get a place in my credits. :D

#14
kevL

kevL
  • Members
  • 4 061 messages

Alupinu wrote...

Good new kevL, got your script to work. Took me most of the day to get all the variables set up, sound, damage, ect. But using your script as a model, I got it to all work perfectly. Now my players can turn on and off the animated traps at will.

cool :)


Thank you again kevL, I’ll make sure you get a place in my credits. :D.

whatver,

#15
Spectre-

Spectre-
  • Members
  • 7 messages
I am confused about how to get a character to sit down and stay sitting down. After the animation fires it seems they always jump straight back up again. Has someone already posted how to pause the animation at a specific time, so that I could keep an NPC sitting?

I would like to have characters wandering around way points and then sitting down everyonce in a while to take a rest. I thought it would add ambience. I am also wondering if I can get animals to sit.

#16
kevL

kevL
  • Members
  • 4 061 messages
kamal_ is the local pro on combining Heartbeats and animations,

but I bet that - if this is using scripted waypoints - there is a 'pause' function that those scripts/the HB will respect. Other than that, the onHeartBeat probaly has to be customized; and an if/then condition inserted that shorts the HB for a set duration ... similar to what Alupinu was looking at


now you want the sit animation to loop. If you look at 'nw_c2_default1' the NPC HB script, you may see sections for AMBIENT_ANIMATIONS just beneath a section for WalkWayPoints (personally i reversed those two sections, and added some conditions such that if POSTed do immobile_ambients). It's possible to add a CalmHB hook that runs a custom script above those sections, still in the NoEnemiesPerceived section tho -- that's where a looped sit anim can be added w/ timer.

- will post my default NPC HB script, note the CalmHB scope (and reversal of Ambients & WalkWayPoints). The Pia at the bottom is for micromanagers like myself ( see .sig ),

Modifié par kevL, 15 août 2012 - 09:43 .


#17
kamal_

kamal_
  • Members
  • 5 250 messages
Many animals probably don't have sitting animations.

#18
Dann-J

Dann-J
  • Members
  • 3 161 messages
Most creatures have a knockdown animation that should do for sitting. The waypoint script would have to check whether the creature using the waypoint is a playable race (which can use the proper sitting animations) or something else (which would need knockdown instead). A local variable on creatures that don't support player sitting animations would do the trick.

#19
kamal_

kamal_
  • Members
  • 5 250 messages

Spectre- wrote...

I am confused about how to get a character to sit down and stay sitting down. After the animation fires it seems they always jump straight back up again. Has someone already posted how to pause the animation at a specific time, so that I could keep an NPC sitting?

I would like to have characters wandering around way points and then sitting down everyonce in a while to take a rest. I thought it would add ambience. I am also wondering if I can get animals to sit.

In the following:        PlayCustomAnimation(oNpc, "sittalk01", 0, 1.0);

The 0 tells the npc not to loop the animation. You would set it to 1 to loop the animation. What's likely happening is your npc has it set to 0, so once the animation completes it ends the animation and continues it's business (walking waypoints). If you want an npc to sit for some period of time, you need to tell the npc how many times to play that animation. Since the npc is getting it's commands from the heartbeat, this is where you determine that.

If I wanted the npc to sit for 10 heartbeats (60 seconds), I would set an int on the npc (nSitTimeLength or something) when your npc determines it's time to sit. Then in the heartbeat, use GetLocalInt(OBJECT_SELF, "nSitTimeLength"). Something like the following

if (your condition for sitting)
{
if (GetLocalInt(OBJECT_SELF, "nSitTimeLength") > 0) //not first heartbeat of sitting
{
//sit command such as
PlayCustomAnimation(oNpc, "sittalk01", 0, 1.0);
int nLength =( GetLocalInt(OBJECT_SELF, "nSitTimeLength")-1);
SetLocalInt(OBJECT_SELF, "nSitTimeLength", nLength);
}
else  //first heartbeat of sitting
{SetLocalInt(OBJECT_SELF, "nSitTimeLength", 10)
//sit command such as
PlayCustomAnimation(oNpc, "sittalk01", 0, 1.0);
}
}

//standard disclaimer about my code possibly being broken. I just typed stuff in.

Modifié par kamal_, 16 août 2012 - 01:32 .


#20
kamal_

kamal_
  • Members
  • 5 250 messages
After thinking about this some more, probably the easiest thing to do would be to use my commoner ai and just add a new activity. The readme for the ai includes instructions on how to do so, the script for the activities includes templates, and there are a number of existing activities that select among multiple animations to compare against (for example woodsman or sitdinner). It already has a walk waypoints activity you can use as well. That way the framework of what you want to do is already set up and you can just concentrate on handling the activity itself.