• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Displaying text

Status
Not open for further replies.
Level 4
Joined
Jul 25, 2007
Messages
71
Hey guys. I'm making an RPG map, and there are several NPCs in the game. When a player uses the "Interact" ability on an NPC, I would like some sort of text to display. Similar to this... "Villager: Oh hello there!". But I want it to be random. There will be 5 or 6 different lines, so it will be random each time the NPC is selected.

I succeeded in this. But sometimes there is no text displayed at all. Let's say I interact with the NPC 10 times. About 2 of those times he won't say anything. Are there any memory leaks with displaying text messages? This is quite annoying. I can't seem to fix it. Any ideas?
 
Level 4
Joined
Apr 20, 2009
Messages
106
How did you go about doing this? The easiest way I could think of would be a String Array, and then when Interact is cast on a villager, display:

  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: StringArray[(Random integer number between (Lower Bound) and (Upper Bound))]
The Player Group leaks, I believe, but that's an easy fix. Is that similar to how you went about it?
 
Level 4
Joined
Jul 25, 2007
Messages
71
  • If (All conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • FreshWaterQuestToggle[(Player number of (Owner of (Casting unit)))] equal to 1
      • (Random integer number between 1 and 2) Equal to 1
    • Then - Actions
      • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))) the text: Villager: Oh hello there!
      • Skip remaining actions
    • Else - Actions
      • Do nothing
But instead of the "Do nothing" else trigger, I'd nest another If Than Else statement, for if the random integer was 2. Instead of 1.
 
Level 4
Joined
Apr 20, 2009
Messages
106
I can see two possible problems. I don't know if either of them are right, there may be something I've completely missed.

1) Simple enough, one of the conditions isn't being met. Perhaps the FreshWaterQuestToggle isn't 1, but I'm pretty sure this isn't it. If eight of the ten ARE working, I'm almost positive this isn't it.

2) There's something going on in your nested If/Then/Else that's screwing it up. Can we see the rest of it?

My guess is it's somewhere in the nested If/Then/Else.
 
Level 4
Joined
Jul 25, 2007
Messages
71
Yeah I can. The trigger would take me 2 hours to type. Is there any way to copy / paste my whole trigger at once?
 
Level 4
Joined
Apr 20, 2009
Messages
106
You can right click each line and Copy as Text. May be a bit faster, but I believe each time you copy an If/Then/Else it copies everything that's nested inside of it, as well.
 
Level 4
Joined
Jul 25, 2007
Messages
71
  • QfreshWater
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Target unit of ability being cast) Equal to Guard (Merchant Cove) 0003 <gen>
      • (Ability being cast) Equal to Interact
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 0
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
          • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 0
              • (Random integer number between 1 and 3) Equal to 2
            • Then - Actions
              • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
              • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 0
                  • (Random integer number between 1 and 3) Equal to 3
                • Then - Actions
                  • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                  • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 1
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                      • (Random integer number between 1 and 2) Equal to 1
                      • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to False
                      • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of salt water) Equal to False
                    • Then - Actions
                      • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                          • (Random integer number between 1 and 2) Equal to 2
                          • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to False
                          • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of salt water) Equal to False
                        • Then - Actions
                          • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                              • (Random integer number between 1 and 2) Equal to 1
                              • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to False
                              • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of salt water) Equal to True
                            • Then - Actions
                              • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                                  • (Random integer number between 1 and 2) Equal to 2
                                  • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to False
                                  • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of salt water) Equal to True
                                • Then - Actions
                                  • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                                      • (Random integer number between 1 and 2) Equal to 1
                                      • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to True
                                    • Then - Actions
                                      • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                                      • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff696969You have ...
                                      • Item - Remove (Item carried by playerHero[(Player number of (Owner of (Casting unit)))] of type Bottle of fresh water)
                                      • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 2
                                      • Player - Add 10 to (Player((Player number of (Owner of (Casting unit))))) Current gold
                                      • Sound - Play ReceiveGold <gen> at 100.00% volume, attached to playerHero[(Player number of (Owner of (Casting unit)))]
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
                                          • (Random integer number between 1 and 2) Equal to 2
                                          • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to True
                                        • Then - Actions
                                          • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                                          • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff696969You have ...
                                          • Item - Remove (Item carried by playerHero[(Player number of (Owner of (Casting unit)))] of type Bottle of fresh water)
                                          • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 2
                                          • Player - Add 10 to (Player((Player number of (Owner of (Casting unit))))) Current gold
                                          • Sound - Play ReceiveGold <gen> at 100.00% volume, attached to playerHero[(Player number of (Owner of (Casting unit)))]
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 2
                                              • (Random integer number between 1 and 2) Equal to 1
                                            • Then - Actions
                                              • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                                            • Else - Actions
                                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                • If - Conditions
                                                  • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 2
                                                  • (Random integer number between 1 and 2) Equal to 2
                                                • Then - Actions
                                                  • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
                                                • Else - Actions
                                                  • Do nothing
 
Level 4
Joined
Apr 20, 2009
Messages
106
I'm going to throw out a guess right here, but it may be a bit... Difficult to explain, but I'll try. Say I'm going to turn in this quest, I've got my water (That's the purpose of the quest, isn't it?) and it's trying to pick which phrase to give me. It rolls a random integer and it gets 2, so it won't give me the first phrase and it will move on to the next Else. Then it's going to roll again. If it rolls 2, it will give me the second phrase, but what if it rolls a 1 there? It's already past the point where rolling a 1 does anything useful, so it doesn't do anything with the 1. See what I'm saying?

I think the best way to solve this would just be rehaul the entire quest trigger, using three main If/Then/Else structures, one for Doesn't Have Quest, one for Working on Quest, and one for Quest Completed (That's the purpose of the MERCHCOVE_freshWaterQ, is it not?) and then work from there. I think it would be much simpler in the end. If you'd like, I can try and assist you with that, but you seem to have a good handle on what you're doing.
 
Level 4
Joined
Jul 25, 2007
Messages
71
Yes you're completely right. That variable is either 0 (undiscovered), 1 (active) or 2 (complete). But I thought each "random #" condition generated a new random number?
 
Level 4
Joined
Apr 20, 2009
Messages
106
It does, which is where you run into problems, I didn't explain well enough, I guess. We'll use this part of the trigger to explain (I apologize for the weird spacing, nothing I am doing over here is making any effect on it. Weird <.<)

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
      • (Random integer number between 1 and 2) Equal to 1
      • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to True
      • Then - Actions
        • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
        • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff696969You have ...
          • Item - Remove (Item carried by playerHero[(Player number of (Owner of (Casting unit)))] of type Bottle of fresh water)
          • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 2
          • Player - Add 10 to (Player((Player number of (Owner of (Casting unit))))) Current gold
          • Sound - Play ReceiveGold <gen> at 100.00% volume, attached to playerHero[(Player number of (Owner of (Casting unit)))]
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] Equal to 1
            • (Random integer number between 1 and 2) Equal to 2
            • (playerHero[(Player number of (Owner of (Casting unit)))] has an item of type Bottle of fresh water) Equal to True
          • Then - Actions
            • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff00FF00Guard|r: ...
            • Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: |cff696969You have ...
            • Item - Remove (Item carried by playerHero[(Player number of (Owner of (Casting unit)))] of type Bottle of fresh water)
            • Set MERCHCOVE_freshWaterQ[(Player number of (Owner of (Casting unit)))] = 2
            • Player - Add 10 to (Player((Player number of (Owner of (Casting unit))))) Current gold
            • Sound - Play ReceiveGold <gen> at 100.00% volume, attached to playerHero[(Player number of (Owner of (Casting unit)))]
          • Else - Actions
Alright, so say I come to turn in my quest. It's going to roll a random integer between 1 and 2 to decide which message to use, right? If it rolls a 1, I will get a message and my reward and everything will be happy. If it rolls a 2, we move on to the Else. In the else, you do another If/Then/Else. It's going to roll AGAIN (This is the big part). If it rolls a 2, then I'll get my reward and a message and we'll all be happy. But if it rolls a 1, nothing happens at all. See how that's happening? A restructuring of your trigger is still the best solution, I'd say, but a temporary integer variable could get the job done.
 
Level 8
Joined
Jun 26, 2010
Messages
530
Why complicating that much?
You only need two triggers

[TRIGGER="INIT"]Events
Map Initialization
Conditions
Actions
Set StringVariableMerch[1] = Hello!
Set StringVariableMerch[2] = How can i help?
Set StringVariableMerch[3] = May i be of service?
Set StringVariableMerch[4] = Nice to see you!
Set StringVariableMerch[5] = Looking for a potion?
Set StringVariableMerch[6] = Good day!
Set StringVariableMerch[7] = I'm Deckard Cain, thanks for saving my sorry ass back there on Tristam LOL[/TRIGGER]

[TRIGGER="Speak"]Events
Unit - Starts the effects of an ability
Conditions
Ability Comparison - Ability being cast = interact
Actions
Game - Display to (Player group((Player((Player number of (Owner of (Casting unit))))))) the text: StringVariableMerch[randon integer between 1 and 7]
[INSERT YOUR OTHER EFFECTS HERE][/TRIGGER]
 
Level 4
Joined
Jul 25, 2007
Messages
71
Ah! You're right. Shoot. Hmmm.. How would you say I should re-construct it so it rolls once? A temporary integer variable?
 
Level 8
Joined
Jun 26, 2010
Messages
530
What do you mean rolls once? You mean only rolling for the first time and then never? If that's what you mean it's pretty simple, add an action in the end of the trigger that disables itself.
 
Status
Not open for further replies.
Top