ChooseRandom issue:
I'm having problems getting this to work properly, and was hoping to catch a pointer from someone who would know. My intention is to create an aggro message chosen randomly from a list. I wanted to use the ChooseRandom feature and store all the possible phrases in variables, but I don't believe that you can store anything in a variable that isn't from the specific list found here.
The reason for all of this is to get the NPCs of the world saying the things they used to as you would aggro them. For example, each time a Guk froglok is aggro'd, he'll say 'Frrroooaaakkk!' along with another random phrase. ('I shall rid the land of another infamous villain.', 'Your foul deeds have earned my contempt.', etc.) I know that this code is wrong, but it's the best that I could think of trying. Like I said, I believe that the problem is that those variables aren't in the list of defined ones, so I can't use them. Is there another way to go about this? I'm kind of embarrassed to show my crappy attempt at this, but I want to at least show that I've tried banging my head against the wall for awhile on it :( Code:
sub EVENT_AGGRO { (Note: I know that in the code block above there's an inexplicable space in the middle of $Phrase4 on line 2, but it's correct when I type the post and I can't get rid of it for some reason. It's correct in my code as well, some odd sort of display error on the boards here.) |
assuming rand/srand dont work, you can do something like create "global variables" in the perl script of the
quest, something like: Code:
$SEED = int( $npc->GetX() ); Code:
sub Code:
sub Code:
@PHRASE = |
Thank you for the idea. I'll see what I can do with it.
|
NPNP
keep us posted on what you find (if srand/rand work or not) and stuff. i'm always eager to learn more about what the quest engine can handle. == sfisque |
In my quest editor there's an example where an npc walks around the zone randomly and returns to original spot. This is like a patrol, but is generated in a random manner. See the script example
GeorgeS |
Thank you GeorgeS :) I wound up looking through most of the quest files included with that, and came across one (#28) that gave me an idea. I realized that I was perhaps putting too much thought into this.
I used a ChooseRandom with numbers 1-10, and just wrote ifs for each number. I stored the chosen value in the $a variable (since I wanted to test it with one that I knew would be recognized). Well, I went a little further than that, and found that it will in fact let me use variables that I create myself (and thus aren't in the list here). I'm still new to writing in PERL, so I thought there were limitations from somewhere on what variables you could work with. Anyway, here's what I wound up with, and it works pretty well. I'll be using this for every mob that I have aggro /say for, and it will have them give their standard aggro message along with a second one roughly 2/3 of the time. If they have a standard one that goes off each time (Frrroooaaakkk!), I'll just drop that at the top. Thank you so much for the help, both of you :) Code:
sub EVENT_AGGRO{ |
The way you had it written first works fine. You need to declare your variables first though. So if you write it like this:
Code:
sub EVENT_AGGRO { |
Haha, F. I didn't think about that =) No wonder all the /says were coming up as empty, it's because the variables were empty with the order it was executing. Doh =X
Okay, I think I'll go back to the way I was trying it originally, just because it's more compact. Thanks so much for all the help and ideas, all of you =) |
if you stuff them into a list, and just randomize the index, the code would be more modular and reusable across other mobs (you could even turn it into a plugin.pl type mod).
== sfisque |
Quote:
Code:
sub EVENT_AGGRO { |
The method above looks even more compact but you gotta write it as
Code:
sub EVENT_AGGRO { |
Dammit. I had all of Guk working fine until I upgraded to the 1002 build, now I'm getting errors and no response from the frogs. Here's what I'm seeing in the error log:
Quote:
|
Seems to be some differances in how you declare a parameter in te new version.
Check out how it has been changed in the changelog. Maybe the string declaration (or what it now is) has ben changed to $phrase8 := "yada yada"; Or similar. Check it out. There is the trouble it seems anyway since it errors on each of those code snipps... |
I checked the changelog, and there wasn't anything listed that would indicate these ever being changed. This is especially annoying, as I recently uploaded the whole batch for Upper and Lower Guk to PEQ's quest repository. Grrr. I think that when I have time (work is picking up; probably won't get the chance until next week at the earliest), I'll sit down and see if one of the other methods here will do the job without throwing me errors.
EmanonCow's code with Budaworm's correction looks like what I'll probably go with, but hopefully their version of things won't meet with the same errors that what I settled on did. |
Not part of the thread
|
All times are GMT -4. The time now is 08:13 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.