AI Chatting

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Fierfek
High General
High General
Posts: 805
Joined: Wed Jul 01, 2009 4:38 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)

AI Chatting

Post by Fierfek »

In my map, I want to have a list of texts, that every 5 seconds or so, a random one appears on screen (eg. - every 5 seconds, scorch says something like "Look, fireworks!"), as if one of the AI is chatting. Is this possible, and if it is, how do I do it?
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: AI Chatting

Post by Frisbeetarian »

You just use the command ShowMessageText(). Put it on a timer and pick a string based on a random number. If you don't know how to use the function, search the assets; I already did that to find the function for you, it's not that hard.
User avatar
Fierfek
High General
High General
Posts: 805
Joined: Wed Jul 01, 2009 4:38 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)

Re: AI Chatting

Post by Fierfek »

Frisbeetarian wrote:You just use the command ShowMessageText(). Put it on a timer and pick a string based on a random number. If you don't know how to use the function, search the assets; I already did that to find the function for you, it's not that hard.
Okay, thanks!
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: AI Chatting

Post by Frisbeetarian »

User avatar
Fierfek
High General
High General
Posts: 805
Joined: Wed Jul 01, 2009 4:38 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)

Randomized Message Texts

Post by Fierfek »

Frisbeetarian wrote:It was also in the FAQ...
http://www.gametoast.com/forums/viewtop ... 04#p140204
Okay, reading that topic now. Thanks again!

-------------

I have a large list of strings in my localization, and I want to add in a script that displays a random one from level.RC1.texts. So far, I have this script to go from:

Code: Select all

math.random(1,10)
How do I implement that so it chooses a random string?

Topics merged. -Staff
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: AI Chatting

Post by kinetosimpetus »

(might be different syntax, but something like...)

Code: Select all

randChat = math.random(1,10)
if randChat == 1 then
    ShowMessageText(level.RC1.texts.1)
else if randChat == 2 then
    ShowMessageText(level.RC1.texts.2)
end
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: AI Chatting

Post by Maveritchell »

kinetosimpetus wrote:(might be different syntax, but something like...)

Code: Select all

randChat = math.random(1,10)
if randChat == 1 then
    ShowMessageText(level.RC1.texts.1)
else if randChat == 2 then
    ShowMessageText(level.RC1.texts.2)
end
You will need to put your string name in quotation marks, and your ShowMessageText should have a second argument mentioning the team it's being shown to.

Also, to refine that, it is easier to append a variable onto your strings (this is how the stock scripts do it, Felucia is a good example). Note that for the original poster, it will probably be easier to just do it as posted above.

Code: Select all

randChat = math.random(10)
    ShowMessageText("level.RC1.texts" .. randChat, 1)
Also note that if you want your random int to be between 1 and something else, you can just put math.random(number) instead of math.random(1, number).
Post Reply