Aller au contenu

Photo

Applying a permanent effect


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

#1
PJ156

PJ156
  • Members
  • 2 983 messages
I am trying to put an NPC on my module who is ill and may be cured by the PC. To do this I am applying the permanent effect sleep on the NPC in the on enter script for the area. When a cure is applied the effect is removed.

Problem is when the pc leaves the area and comes back the npc is standing and the effect is not reapplied. What can I do to keep the npc down without using the heartbeat. If I use the heartbeat then I cannot choreograph her rising with the time the cure is applied.

The script I use on enter is (note in this iteration I am trying knockdown but that does not work either):

void main()
{object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = GetObjectByTag("4002_dd_siobhan");
effect eEffect;
eEffect = EffectKnockdown();
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
}

The script is out of Lilac Souls generator.

Thanks

PJ

Modifié par PJ156, 11 juin 2011 - 08:10 .


#2
Shallina

Shallina
  • Members
  • 1 011 messages
Use the on enter area ? Apply the effect each time the player enter the area.

The problem is that the PC has the effect, but when you enter the area, the game make it stand up, and the condition since it's not altered, isn't checked, so the game let him in the default position.

Just apply the effect on the on enter area script might be enought.

#3
PJ156

PJ156
  • Members
  • 2 983 messages
Thanks for the response Shallina.

The script is placed in the area properties on enter sorry I did not make this clear before.

It works the first time on enter just fine but not if you go out and come in again. I just tried it in the oncliententer slot but with no improvement.

I think I see what you are saying though, the effect is not gone but he game is applying a default animation when the area is entered and ignoring the script since it has applied the effect already.

This is pretty frustrating :)

Just another day in the toolset I guess.

Modifié par PJ156, 11 juin 2011 - 11:51 .


#4
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
You could use a PlayCustomAnimation on the invalid's heartbeat script.

#5
PJ156

PJ156
  • Members
  • 2 983 messages
I'm leaning toward that now but how to remove it? I guess I could test a local int to see if she is cured but the animation will stop on the next heartbeat and not when she is cured. Hmmm

Thanks for the response,

PJ

#6
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
How could you remove the animation? Have them play a new one! Clear their actions, move them a little forward, and have them play a new animation, something like that. Just put the animation call on their heartbeat and you should be fine.

Example:

void main()
{
AssignCommand(OBJECT_SELF, ClearAllActions(TRUE));
PlayCustomAnimation(OBJECT_SELF, "*proneB",TRUE);
ExecuteScript("NW_C2_DEFAULT1", OBJECT_SELF);
}

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You could set a variable on the NPC after it is cured. And the in the HB script you could just check for the variable before doing the custom animation. If the NPC has a certain variable then don't do the animation. You could then remove the cured variable in some other event like the OnExit.

EDIT: Doh..just saw that you already thought of this. oops.;)

Modifié par GhostOfGod, 12 juin 2011 - 12:36 .


#8
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
Strange that the on enter script only applies the animation once. Do you have script in it that prevents it from applying the animation every time? Often in an area on enter script you would have a check at the top that determines if the script has been executed already and if so exits. But in this case you want the effect to be applied every time.

An alternative to using the heartbeat for the cure would be to take the eyes off the prize momentarily using a cutscene and then destroy the wounded npc and spawn in a healthy one in its place.

#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
Sorry. I see you posted the script and it is not exiting as I thought. Strange behavior with animations I guess. Personally I gave up on doing anything clever with animations a long time ago. Too little benefit for too much development time imo.

Regards

#10
Shaughn78

Shaughn78
  • Members
  • 637 messages
I was able to get looping animation on the client enter script. I loop through NPCs and apply the PlayCustomAnimation, the script is called for each time the player enters the area. I have had lots of difficulty (and failures) getting animations to fire with on enter and spawn scripts. To simplify the script I use a local string on the NPCs, if they have the string they do the animation the string calls for.

if(sAnimation != "")PlayCustomAnimation(oLoop,sAnimation);

Modifié par Shaughn78, 12 juin 2011 - 01:01 .


#11
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
I've never been able to get things to play animations off enter or spawn. It works like ~50% of the time, much to my disappointment. Heartbeat was the only way I could find to fix it, however much I detest using heartbeats if I could use something else instead.

#12
PJ156

PJ156
  • Members
  • 2 983 messages

Kaldor Silverwand wrote...

Sorry. I see you posted the script and it is not exiting as I thought. Strange behavior with animations I guess. Personally I gave up on doing anything clever with animations a long time ago. Too little benefit for too much development time imo.

Regards


Could not agree more, thanks for the supports guys. In the end I worked round it and found another issue. Despite being permanently applied the B******y woman stands up after 40 seconds or so.

So on the basis the script fires once I force the PC into a convo with the sick woman as the first event in the room. Not on enter but you dont have to move far to hit the trigger. Now in the convo she stands up as part of the convo which ever route you choose except watching her die.

Thus you expect her to be standing when you get back.
 
This lost me more than a day and it's a very small part of the mod. I echo KS's coments.

Now to script rats running away ......

#13
MasterChanger

MasterChanger
  • Members
  • 686 messages

PJ156 wrote...
Now to script rats running away ......


Check x0_i0_behavior. I've set NW_GENERIC_MASTER to NW_FLAG_BEHAVIOR_HERBIVORE before (I think you might also need to set NW_FLAG_BEHAVIOR_SPECIAL bitwise, so added together it would be NW_GENERIC_MASTER = 9). You just set this variable on the creature and it flees somewhat consistently.

#14
Kraegan

Kraegan
  • Members
  • 1 messages
I never liked putting stuff in heartbeat. I also tried an OnEnter area script for a knockdown effect on the PC with no results. So I simply modified the ga_play_custom_animation to default to the PC Speaker. And then added the prone animation to start when the conversation kicks in. Works well, as I needed the PC to be prone for the entire convo while the NPCs talk. Code below:
#include "ginc_param_const"

void PlayCustomAnimationWrapper(object oTarget, string sAnim, int bLoop) //so it returns a void
{
PlayCustomAnimation(oTarget,sAnim,bLoop);
}

void main(string sTarget, string sAnim, int bLoop=0, float fDelayUntilStart=0.0f)
{
object oPC = GetPCSpeaker();
string sTargetDefault;

if (oPC == OBJECT_INVALID)
{ // script is not being run from a conversation with a PC speaker so assume it is from a console command.
sTargetDefault = "$OBJECT_SELF";
}
else
{
sTargetDefault = "$PC";
}
object oTarget = GetTarget(sTarget, sTargetDefault);

if (GetIsObjectValid(oTarget))
{
if (fDelayUntilStart==0.0f)
PlayCustomAnimation(oTarget,sAnim,bLoop);
else
DelayCommand(fDelayUntilStart,PlayCustomAnimationWrapper(oTarget,sAnim,bLoop));//place the delaycommand on the creature as well
}
}