If you don't like to have fun with your bot, please leave now.
Good, I'm glad to see your still here. This tutorial is a bit on the silly side, but I think it's enjoyable. The bot is going to learn how to say randomly generated sentences, specifically, taunts. Oooh, goodie.
Of course, these sentences will be quite rudimentary. However, for the player, it may seem like the bot is saying something different every time he plays. Basically these sentences will consist of a verb, adjective, and noun (so your bot won't be giving speeches any time soon).
Since this is rather easy to do, we shall just get straight to the Artificial Sentence Generation Engine, also known as, the following routine:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void() bot_generate_sentence = // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { local float verb, adj, noun; local entity plr; plr = find(world, classname, "player"); if (plr.frags < self.frags) { verb = floor(random() * 7); if (verb == 0) bprint("you're such a "); if (verb == 1) bprint("you're just a "); if (verb == 2) bprint("nothing but a "); if (verb == 3) bprint("i'm playing with a "); if (verb == 4) bprint("you look like a "); if (verb == 5) bprint("go home you "); if (verb == 6) bprint("what a "); adj = floor(random() * 8); if (adj == 0) bprint("stinking "); if (adj == 1) bprint("sucky "); if (adj == 2) bprint("horrible "); if (adj == 3) bprint("pathetic "); if (adj == 4) bprint("weak "); if (adj == 5) bprint("girlie "); if (adj == 6) bprint("dumb-ass "); if (adj == 7) bprint("frickin "); noun = floor(random() * 7); if (noun == 0) bprint("player\n"); if (noun == 1) bprint("llama\n"); if (noun == 2) bprint("loser\n"); if (noun == 3) bprint("buttmunch\n"); if (noun == 4) bprint("girl\n"); if (noun == 5) bprint("bonehead\n"); if (noun == 6) bprint("midget\n"); } if (plr.frags >= self.frags) { verb = floor(random() * 5); if (verb == 0) bprint("i respect your "); if (verb == 1) bprint("i admire your "); if (verb == 2) bprint("wish i had your "); if (verb == 3) bprint("how do you like his "); if (verb == 4) bprint("whoa, you've got "); adj = floor(random() * 6); if (adj == 0) bprint("wonderful "); if (adj == 1) bprint("mad "); if (adj == 2) bprint("world-class "); if (adj == 3) bprint("sharp "); if (adj == 4) bprint("awesome "); if (adj == 5) bprint("man-sized "); noun = floor(random() * 6); if (noun == 0) bprint("skills\n"); if (noun == 1) bprint("playing\n"); if (noun == 2) bprint("balls\n"); if (noun == 3) bprint("courage\n"); if (noun == 4) bprint("aim\n"); if (noun == 5) bprint("style\n"); } sound (self, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NONE); };Hehe, can you tell that I was laughing when I wrote this? The routine should result in some silly sentences. Now you'll know what your bot is really thinking.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void() bot_talk = // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { local float talk; if (random() < 0.5) { self.talk_subject = 0; self.talk_time = time + 60; return; }For the sake of simplicity, we will tell our bot to use the new routine on a random occasion. So, after the previous code, add this:
if (random() < 0.25) { bot_generate_sentence(); self.talk_time = time + 60; self.talk_subject = 0; return; }So, 25 perecent of the time he feels like talking, he will utter one of his elloquent new sentences. He resets his talking information, then leaves the routine. Everybody's happy.