• 🏆 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!

help with analyze ability

Status
Not open for further replies.
Level 7
Joined
Apr 3, 2007
Messages
293
I want to create an ability called "Scan" that can be casted anywhere and depending on where it is casted different text will appear, but I cant seem to get it to work. This is how i tried it:
  • Events - A unit Begins casting an ability
  • Conditions - Ability being cast Equal to Scan
  • Actions - Region - center Scan Area <gen> on Target point of ability being cast.
  • Events - A unit enters Scan Area <gen>
  • Conditions - Unit - type of Triggering unit Equal to Table
  • Actions - Cinematic - Send transmission to All Players from No Unit named "Scan Results:": Play No sound and display "Nothing".
I used a cinematic action instead of "Game text Message" because it is easier to customise.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I think that you will need a lot of triggers with your method (if I understand what you're trying to do).
This could be a better method:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- === Setting up Regions === --------
      • Set AreaCounter = (AreaCounter + 1)
      • Set AreaRegion[AreaCounter] = Regionactive1 <gen>
      • Set AreaString[AreaCounter] = There's a weak radiation field here, I should be careful.
      • Set AreaCounter = (AreaCounter + 1)
      • Set AreaRegion[AreaCounter] = Enter Park <gen>
      • Set AreaString[AreaCounter] = A park... here?
      • Set AreaCounter = (AreaCounter + 1)
      • Set AreaRegion[AreaCounter] = Regionactive2 <gen>
      • Set AreaString[AreaCounter] = This radiation field... I better get out quickly
      • Set AreaCounter = (AreaCounter + 1)
      • Set AreaRegion[AreaCounter] = Computer1 <gen>
      • Set AreaString[AreaCounter] = Someone left his computer on...
      • Set AreaCounter = (AreaCounter + 1)
      • Set AreaRegion[AreaCounter] = Outside <gen>
      • Set AreaString[AreaCounter] = It feels good to be outside again.
Required:
  • Variable: "AreaCounter" (integer, no array) - used for the loop later on.
  • Variable: "AreaRegion" (Region, array) - The area in which something will be displayed
  • Variable: "AreaString" (String, array) - The text which will be displayed.

Then we go to the next trigger:

  • Cast Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Scan
    • Actions
      • Cinematic - Clear the screen of text messages for (All players)
      • set loc[1] = (Position of (Target point of Ability being cast))
      • For each (Integer LoopInt) from 1 to AreaCounter, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AreaRegion[LoopInt] contains loc[1]) Equal to True
            • Then - Actions
              • Game - Display to (All players) for 7.00 seconds the text: AreaString[LoopInt]
            • Else - Actions
      • Custom script: call RemoveLocation(udg_loc[1])
Every time you cast the spell, it will search where it was cast (in the database you set up at map init), when the region matches the location where the spell was cast, it will display the message that belongs to that specific region.

Edit: this is a (modified) version of the system I've made for a map I am creating (and probably won't finish).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
That is a good method, but it would requires a lot of regions and a whole lot more triggers.


The region moved to the table.
How would you do it without regions then?
Your method also uses regions...

By the way: there's an easy way to copy/paste a trigger from the world editor to the hive:
above "Events", you see the trigger's name, right click it and select "Copy as text", then paste it here with trigger-tags (and perhaps hidden tags).
 
Level 7
Joined
Apr 3, 2007
Messages
293
Alright I figured it out! Kind of a mix between me and ap0calypses idea.
  • Scan
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Scan
    • Actions
      • Player Group - Add (Owner of (Casting unit)) to Scanning_Player[(Integer A)]
      • Set loc[1] = (Target point of ability being cast)
      • For each (Integer Int) from 1 to AreaCounter, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Kitchen Knifed soldier <gen> contains loc[1]) Equal to True
            • Then - Actions
              • Set AreaCounter = 1
              • Set AreaRegion[AreaCounter] = Kitchen Knifed soldier <gen>
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Casting unit)) Equal to Player 1 (Red)
                • Then - Actions
                  • Cinematic - Clear the screen of text messages for Scanning_Player[(Integer A)]
                  • Wait 1.10 seconds
                  • Game - Display to Scanning_Player[(Integer A)] the text: Analysis: The soldi...
                  • Player Group - Remove (Owner of (Casting unit)) from Scanning_Player[(Integer A)]
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Main Room Registry <gen> contains loc[1]) Equal to True
            • Then - Actions
              • Set AreaCounter = 1
              • Set AreaRegion[AreaCounter] = Kitchen Knifed soldier <gen>
              • Cinematic - Clear the screen of text messages for Scanning_Player[(Integer A)]
              • Wait 1.10 seconds
              • Game - Display to Scanning_Player[(Integer A)] the text: Analysis: The soldi...
              • Player Group - Remove (Owner of (Casting unit)) from Scanning_Player[(Integer A)]
            • Else - Actions
Basicly, instead of the game sorting everything out at the very beginning, it works it all out 1 at a time once you come to it so the slow computers wont lag out and what not at the very beginning, this also removes the string variable and a few regions, so you dont have to deal with them.
 
Last edited:
Level 7
Joined
Apr 3, 2007
Messages
293
  • Scan
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Scan
    • Actions
      • Player Group - Add (Owner of (Casting unit)) to Scanning_Player[(Integer A)]
      • Set loc[(AreaCounter + 1)] = (Target point of ability being cast)
      • For each (Integer Int) from 1 to AreaCounter, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Kitchen Knifed soldier <gen> contains loc[(AreaCounter + 1)]) Equal to True
            • Then - Actions
              • Set AreaCounter = (AreaCounter + 1)
              • Cinematic - Clear the screen of text messages for Scanning_Player[(Integer A)]
              • Wait 1.10 seconds
              • Game - Display to Scanning_Player[(Integer A)] the text: Analysis: The soldi...
              • Player Group - Remove (Owner of (Casting unit)) from Scanning_Player[(Integer A)]
            • Else - Actions
Ok, this is a better version, basicly the same thing but fixed lol. It's a long trigger, but all you have to do to add more scanable regions is copy and past the last "If, then, else..." and change the condition and the displayed text.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Oh, yeah... now I see it ^^ (I thought the Kitchen Knifed Soldier or something was a unit, not a region).
Anyhow, apart from the fact that this is going to be a huge trigger, what exactly are the advantages compared with my system? ^^ (I just saw someone who had troubles because a trigger was too huge - setting variables hardly requires any memory, so that doesn't create the delay, but a huge if/then/else-struct like this might).
 
Level 7
Joined
Apr 3, 2007
Messages
293
It is so much easier because all you have to do to add scannable regions is create the region and then copy/paste the last "If, then, else" action, and then set it to the new region.
You only have to deal with 2 variables that you never have to change.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It is so much easier because all you have to do to add scannable regions is create the region and then copy/paste the last "If, then, else" action, and then set it to the new region.
You only have to deal with 2 variables that you never have to change.
But for your method you do need to change the variable (to the region you want) + you need to set the string to the whatever you want, I just want to tell you that the trigger might not work properly if you do it your way, but you can always try... (not very long ago, there was a guy who's trigger stopped working about halfway through because it was too long, this happened when he added a lot of if/then/elses and loops).

Anyhow: with my 2 triggers (1 trigger doesn't need to be changed at all), you only need to change 2 variables as well, just like in your trigger: the string and the region.
And you only have to copy/paste 3 actions for my method, so what are you even trying to say?
 
Status
Not open for further replies.
Top