Aller au contenu

Photo

Making floaty text appear above a creature & other stuff - a custom magic item


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

#1
Clyordes

Clyordes
  • Members
  • 300 messages
Hi folks,

I thought I'd got this cracked after a trawl around the Lexicon & the NWN2 wiki, and it compiles, but isn't working right.

I wanted a script that fired when a particular item is 'used' via its unique power.

It needs to:
1. Generate a floaty text above the PC to let them know some kind of dweomer's being generated
2. Make the PC do the 'greet' animation
3. Apply a paralysis effect to a creature tagged "the_sussurus", lasting 10 seconds
4. After a moment, create a floaty text above the creature that advises the PC that its paralysed
5. When the effect is about to wear off, create floaty text above the PC, advising that the dweomer's fading
6. A moment later, more floaty text above the creature advising that its starting to move again

This is the script I've got so far:


void main()
{
object oPC;

oPC = GetItemActivator();

FloatingTextStringOnCreature("A strange vibration starts in the air around you, what affect could it be having?", oPC);

AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_GREETING));

object oTarget;
oTarget = GetObjectByTag("the_sussurus");

effect eEffect;
eEffect = EffectParalyze();

eEffect = SupernaturalEffect(eEffect);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 10.0f);

DelayCommand(1.0, FloatingTextStringOnCreature("The Sussurus seems to be transfixed by the strange Dweomer!", oTarget));

DelayCommand(8.0, FloatingTextStringOnCreature("The strange vibration is fading now...", oPC));

DelayCommand(9.0, FloatingTextStringOnCreature("The Sussurus is starting to move once more!", oTarget));

}

The paralysis effect is working fine, text above the PC is working fine (although I'm not sure if the delays are right as the last two floaty texts seem to be appearing after the paralysis has worn off), BUT nothing's appearing above the old Sussurus - poor fellow.  Any ideas what I'm missing here?

I was also trying to get a visual effect to play over the PC on triggering the device, say a SoundBurst effect or similar, to simulate the device creating a magical effect, but I've completely failed to get anything scripted that works.

If anyone has any ideas, I'd be really grateful - in theory, this is the last thing to fix before I can upload my mini module - so you'd really be helping out!

Cly.

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
FloatingTextStringOnCreature() only works on the PC, I believe. For the Sussurus, you want to use the command:
SpeakString()
or ActionSpeakString()


For the visual effect, you will probably want to use the function
EffectNWN2SpecialEffectFile()

Get the PowerBar plugin and then use the browse function to find the names of the different effects.

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
Floating text should work on NPCs, although there is an additional variable that controls whether the message is visible only to those in the same faction or not. It is TRUE by default, meaning that only creatures in the same faction as the floaty-text beasty will see it. You can try this:

DelayCommand(1.0, FloatingTextStringOnCreature("The Sussurus seems to be transfixed by the strange Dweomer!", oTarget, FALSE));

#4
Clyordes

Clyordes
  • Members
  • 300 messages
Hi Dann - that's the impression I got from looking around, but even adding the 'FALSE' note, there's still no floaty text appearing over the poor Sussurus. Just in case distance from the 'speaker' makes a difference, I was nice & close when I triggered the device that fires the script.

M. - I thought I'd tried SpeakString & ActionSpeakString, but I'll try them again. The visual effect part I'll take a look at & see if I can work out - thanks.

Cly.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
When you use speakstring make sure the parameters are set so that you will be able to hear them. There is a distance on and maybe (I'm not sure off the top of my head) one that controls what factions can hear it too. That could affect whether or not you see the text.

#6
Clyordes

Clyordes
  • Members
  • 300 messages
Hi M. - haven't seen anything obvious in the speakstring function that's jumping out at me as affecting the distance away that the text can be seen, but remember, you're talking to the world's worst scripter <citation needed> whose idea of scripting is using Lilac Soul's Script Generator & was overjoyed when I saw how scripts were handled in conversations with those great little boxes & clear notes that told you exactly what information to put in them!

I guess what I need is examples - I was hoping I'd get some from the Lexicon site or NWN2 Script Directory, but none seemed particularly clear.

If anyone can point me at any examples, or paste any here, it'd help no end :-)

Cly.

#7
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Try using:

AssignCommand(oNPC, SpeakString ("Floaty text here"));

Pretty much any time the script is originally fired from some other object, to get a second/other object to do something you need to AssignCommand().

#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I wonder if the paralysis effect prevents the creature for having the floating text. Try commenting out the lines that add the paralysis effect and see if the text displays then.

Another note, when identifying oTarget, you may run into trouble by identifying it as the sussurus. If the PC tries to target something else with the item, it will still affect the sussurus which will appear strange. You can use the function:

object oTarget = GetItemActivatedTarget();

This identifies oTarget as the target of the activated item.

Then use the following code to make sure the activated item only works on the sussurus:

if (GetTag(oTarget)!="the_sussurus")
{
AssignCommand(oPC,ActionSpeakString("Nothing Happened"));
return;
}


that way, if the PC tries to target anything other than the sussurus, nothing will happen and the PC will get a little message.

#9
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
A couple notes about ActionSpeakString() vs SpeakString():

M. Rieder wrote...

I wonder if the paralysis effect prevents the creature for having the floating text. Try commenting out the lines that add the paralysis effect and see if the text displays then.


ActionSpeakString() makes the action get assigned to the action que, which then fire off in general order. some script commands and some scripts override or clear the action cue. So in this case the paralysis effect may prevent it. SpeakString() on the other hand is outside the action que. It fires/speaks immediately no matter what else is going on or what actions are qued up.

Then use the following code to make sure the activated item only works on the sussurus:

if (GetTag(oTarget)!="the_sussurus")
{
AssignCommand(oPC,ActionSpeakString("Nothing Happened"));
return;
}


that way, if the PC tries to target anything other than the sussurus, nothing will happen and the PC will get a little message.


Due to the above, use this as a check instead (though since it is a PC here, FloatingTextStringOnCreature() would work):

if (GetTag(oTarget)!="the_sussurus")
{
AssignCommand(oPC, SpeakString("Nothing Happened"));
return;
}

Modifié par _Knightmare_, 20 octobre 2011 - 12:01 .


#10
Clyordes

Clyordes
  • Members
  • 300 messages
Crikey - thanks folks! Off to a wedding in the English Lakes for the weekend, so won't get chance to try any of these ideas until next Monday/Tuesday, but hopefully one or another will work & I'll report back here.

Have a good weekend

Cly.

#11
Clyordes

Clyordes
  • Members
  • 300 messages
Good news! - at least in part.
The following script produces a nice floaty text above the old Sussurus on item activation:

void main()
{
object oPC;

if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_CREATURE)
){

SendMessageToPC(GetItemActivator(), "This item needs to be targeted at a creature");
return;}

oPC = GetItemActivator();

AssignCommand(GetObjectByTag("the_sussurus"), ActionSpeakString("This is a test string above the creature", TALKVOLUME_SHOUT));

}

Now I just need to get the paralysis effect working & I can run a final test of the entire adventure & upload to the vault.

What could possibly go wrong?

Cly.

#12
Clyordes

Clyordes
  • Members
  • 300 messages
Quick update before I head off to work.

The following script produces the initial speak string fine "This is a test string" above the sussurus, and the paralysis function works fine, but although the final text appears above the PC only - the one I was hoping would appear above the sussurus doesn't:

void main()
{
object oPC;

if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_CREATURE)
){

SendMessageToPC(GetItemActivator(), "This item needs to be targeted at a creature");
return;}

oPC = GetItemActivator();

AssignCommand(GetObjectByTag("the_sussurus"), SpeakString("This is a test string above the creature", TALKVOLUME_SHOUT));


object oTarget;
oTarget = GetObjectByTag("the_sussurus");

effect eEffect;
eEffect = EffectParalyze();

eEffect = SupernaturalEffect(eEffect);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 10.0f);

//DelayCommand(1.0, FloatingTextStringOnCreature("Bull Roarer 5: The Sussurus seems to be transfixed by the strange Dweomer!", oTarget, FALSE));

DelayCommand(8.0, FloatingTextStringOnCreature("The strange vibration is fading now...", oPC));

DelayCommand(11.0, FloatingTextStringOnCreature("The Sussurus is starting to move once more!", oTarget, FALSE));
}


I'm sure its easy to delay a second 'speak string' command so the sussurus 'speaks' to say the effect is wearing off it - but how do I do it? I've tried what looks obvious, but its refusing to compile.

Cly.

#13
Clyordes

Clyordes
  • Members
  • 300 messages
Thanks muchly folks, its all working perfectly now - for reference, final script is as follows:

void main()
{
object oPC;

if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_CREATURE)
){

//Send message if creature not targetted on activation
SendMessageToPC(GetItemActivator(), "Nothing happens, perhaps this item needs to be targeted at a creature");
return;}

oPC = GetItemActivator();

//Floaty text above Sussurus
AssignCommand(GetObjectByTag("the_sussurus"), SpeakString("A dweomer is generated as you whirl the device - the Sussurus appears to be transfixed!", TALKVOLUME_SHOUT));

//Animate PC to simulate device being whirled around
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_GREETING));

object oTarget;
oTarget = GetObjectByTag("the_sussurus");

//Paralyse Sussurus for 30 seconds
effect eEffect;
eEffect = EffectParalyze();

eEffect = SupernaturalEffect(eEffect);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 30.0f);

//Floaty text above PC advising the effect is ending
DelayCommand(25.0, FloatingTextStringOnCreature("The dweomer seems to be fading now...", oPC));

//Floaty text above Sussurus advising that its time to panic again
DelayCommand(29.0, AssignCommand(GetObjectByTag("the_sussurus"), SpeakString("The Sussurus is beginning to move once more!", TALKVOLUME_SHOUT)));

//Note to self - try & change item properties to limit number of uses of device / day
}