How do I make a hostile creature speak?
Moderators: Moderator, Developer, DM
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
How do I make a hostile creature speak?
How can I make a hostile creature speak? It doesn't have to be conversation, just floating text above its head. I tried a few things, but nothing shows up. FloatingTextStringOnCreature doesn't seem to do the job, regardless of the boolean flags I pass in.
Solution:
SpeakString() works
If you're spawning that creature from another object and it has to speak right as it's spawned, use AssignCommand(DelayCommand(SpeakString())), and give it a tiny delay.
Thanks, mreider79, Duster47, and NOT ENDELYON! (OK, and also Endelyon.)
Solution:
SpeakString() works
If you're spawning that creature from another object and it has to speak right as it's spawned, use AssignCommand(DelayCommand(SpeakString())), and give it a tiny delay.
Thanks, mreider79, Duster47, and NOT ENDELYON! (OK, and also Endelyon.)
Last edited by gedweyignasia on Fri Jul 24, 2015 8:29 pm, edited 4 times in total.
-
mrieder79
- Posts: 875
- Joined: Fri May 11, 2012 8:32 am
Re: How do I make a hostile creature speak?
The question is: What do you want this creature to do?
Do you want it to say something, then attack?
Are you trying to make it say things during battle the way other creatures on the server do?
If you want it to say something prior to attacking then you will want to start it out as neutral then script what you want to happen, then at the right time, you want to turn it hostile. Then AI takes over and you can hak hak hak.
If you want it to say stuff during battle, then you will probably want to ask Rasael how he scripted that. I've never messed with that sort of thing to my recollection.
Do you want it to say something, then attack?
Are you trying to make it say things during battle the way other creatures on the server do?
If you want it to say something prior to attacking then you will want to start it out as neutral then script what you want to happen, then at the right time, you want to turn it hostile. Then AI takes over and you can hak hak hak.
If you want it to say stuff during battle, then you will probably want to ask Rasael how he scripted that. I've never messed with that sort of thing to my recollection.
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
Yeah, that's what I'm aiming for.mrieder79 wrote:Are you trying to make it say things during battle the way other creatures on the server do?
-
Duster47
- Retired Staff
- Posts: 3727
- Joined: Mon Nov 16, 2009 7:57 pm
- Location: Florida, USA
Re: How do I make a hostile creature speak?
If this is something you want to do for a BG submittal, then I suggest you not spend time on it. We have scripts that do this. No need for re-inventing the wheel. Again.gedweyignasia wrote:Yeah, that's what I'm aiming for.mrieder79 wrote:Are you trying to make it say things during battle the way other creatures on the server do?
If you want it for your own use or elsewhere, then continue your inquiries here or elsewhere.
PC1 = Nerys, Emissary and Skald of the Greyfox tribe, last seen roaming north near Secomber
PC2 = Valqis Sanejmeh; far away cartographer, Oracle of Nut at chaltin QulDaq, former navigator of the Sea Seeker, Reader of Candlekeep and sometime performer.
PC2 = Valqis Sanejmeh; far away cartographer, Oracle of Nut at chaltin QulDaq, former navigator of the Sea Seeker, Reader of Candlekeep and sometime performer.
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
It's for something I'd like to submit, but at the same time I'd like to know how it works or one way to make it work. Don't worry, though! I haven't thrown a whole lot of time into it! It'd just be a nice aesthetic touch.
-
mrieder79
- Posts: 875
- Joined: Fri May 11, 2012 8:32 am
Re: How do I make a hostile creature speak?
There are hook-ins to the AI that runs NPCs. Tons of them. For many, all you have to do is store a variable with a particular name on the NPC with the appropriate information and the AI script will do what you want it to do.
Most likely, you simply have to save one or more string variables on the NPCs in question with the appropriate tag and the AI will do the rest. I can't say for sure that this is how it works because I've never done that before, but based on my experience scripting in NWN2, I wouldn't be surprised if this is how it's done.
Again, I believe Rasael would be able to clear things up here.
Most likely, you simply have to save one or more string variables on the NPCs in question with the appropriate tag and the AI will do the rest. I can't say for sure that this is how it works because I've never done that before, but based on my experience scripting in NWN2, I wouldn't be surprised if this is how it's done.
Again, I believe Rasael would be able to clear things up here.
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
I'd prefer to avoid hooking into the AI. I'm trying to make a general-purpose utility for spawning creatures if the caller has the right variables set so as to avoid making a whole bunch of scripts, since they're hard enough to organize as-is.
Code: Select all
for (ctr=0;ctr<num_spawns;ctr++) {
string sSpawnThis = "ged_spawn_" + IntToString(ctr);
sSpawnThis = GetLocalString(OBJECT_SELF,sSpawnThis);
object oSpawn = CreateObject(OBJECT_TYPE_CREATURE,sSpawnThis,lSpawn,FALSE);
AssignCommand(oSpawn,ClearAllActions());
if (bSafeSpawn == 1) {
newLoc = CalcSafeLocation(oSpawn,lSpawn,3.0f,FALSE,FALSE);
}
AssignCommand(oSpawn,ActionJumpToLocation(newLoc));
string sSpeak = GetLocalString(OBJECT_SELF,"ged_spawn_speak_"+IntToString(ctr));
if (sSpeak != "") {
AssignCommand(oSpawn,SpeakString(sSpeak,TALKVOLUME_TALK));
}
ChangeToStandardFaction(oSpawn,STANDARD_FACTION_HOSTILE);
}-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
The actual code it's set to is here, I just tidied it up and removed some attempted fixes that didn't work:
Code: Select all
int ctr = 0;
for (ctr=0;ctr<num_spawns;ctr++) {
string sSpawnThis = "ged_spawn_" + IntToString(ctr);
sSpawnThis = GetLocalString(OBJECT_SELF,sSpawnThis);
object oSpawn = CreateObject(OBJECT_TYPE_CREATURE,sSpawnThis,lSpawn,FALSE);
ChangeToStandardFaction(oSpawn,STANDARD_FACTION_COMMONER);
AssignCommand(oSpawn,ClearAllActions());
if (bSafeSpawn == 1) {
newLoc = CalcSafeLocation(oSpawn,lSpawn,3.0f,FALSE,FALSE);
}
AssignCommand(oSpawn,ActionJumpToLocation(newLoc));
string sSpeak = GetLocalString(OBJECT_SELF,"ged_spawn_speak_"+IntToString(ctr));
if (sSpeak != "") {
AssignCommand(oSpawn,ClearAllActions(TRUE));
AssignCommand(oSpawn,SpeakString(sSpeak,TALKVOLUME_TALK));
}
ChangeToStandardFaction(oSpawn,STANDARD_FACTION_HOSTILE);
}-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
Figured it out; need to AssignCommand(DelayCommand(SpeakString())). If you try to speak just as you spawn it doesn't work right.
-
Endelyon
- Posts: 3606
- Joined: Sun Jul 06, 2014 4:24 am
Re: How do I make a hostile creature speak?
I'll remember this.gedweyignasia wrote:NOT ENDELYON
(Okay no ILU pls bring Heather back)
-
gedweyignasia
- Custom Content
- Posts: 1353
- Joined: Sat Nov 23, 2013 11:27 pm
- Location: EST/UTC-4
Re: How do I make a hostile creature speak?
Banana. Peel. It's canon.Endelyon wrote:I'll remember this.gedweyignasia wrote:NOT ENDELYONNext time you need help I'm playing dumb.
(Okay no ILU pls bring Heather back)