How to see if a casting unit is within range, so that a custom ability be activated?

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,710
This is the code: (Can you see this secret message?)
Code:
Show
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Casting unit) Equal to Unit[(Player number of (Triggering player))]
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyCT 
            Then - Actions
                Dialog - Show Dialog[1] for (Owner of (Casting unit))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyT 
            Then - Actions
                Dialog - Show Dialog[2] for (Owner of (Casting unit))
            Else - Actions

This is what happens:
55816226gd6.gif


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

Okay, so I added these actions in the conditions. They are boldfaced and colored.

Unit[Integer(CTshop)] and Unit[Integer(Tshop)] are the coins in the picture.
Code:
Show
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Casting unit) Equal to Unit[(Player number of (Triggering player))]
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyCT
                [COLOR="RoyalBlue"](Distance between (Position of Unit[(Integer(CTshop))]) and (Position of (Casting unit))) Less than or equal to 700.00[/COLOR]
            Then - Actions
                Dialog - Show Dialog[1] for (Owner of (Casting unit))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyT 
                [COLOR="RoyalBlue"](Distance between (Position of Unit[(Integer(Tshop))]) and (Position of (Casting unit))) Less than or equal to 700.00[/COLOR]
            Then - Actions
                Dialog - Show Dialog[2] for (Owner of (Casting unit))
            Else - Actions

But it doesn't work like it used to be.
57952392zw6.gif



================

Question: How do you set it up, so that the custom ability can be activated only when the unit is near the coins?

Or

How do you set it up so that when someone presses the ability button, and that unit has an arrow above its head, it would pop up a prompt?
 

Alphabet

New Member
Reaction score
12
The only thing I can think of is the 'Unit[(Integer(CTshop))]' and 'Unit[(Integer(Tshop))]'. Try to replace them with the '(unitname) (number) <gen>' things (which you get by using the 'Select unit' button while determining the unit, and choosing the shops from the map).
 

Alphabet

New Member
Reaction score
12
I can't see a reason why that'd leak, and the reason I wanted you to to that was just so it'd show whether the 'Unit[(Integer (TShop))]' and 'Unit[(Integer (CTShop))]' are the problem or not. If it does work the way I suggested you to try, then you've just set the Unit and/or the TShop/CTShop variables wrong (or not at all). :p
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,710
Code:
Show
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Casting unit) Equal to Unit[(Player number of (Triggering player))]
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyCT
                (Distance between (Position of (Storage 0013 <gen>)) and (Position of (Casting unit))) Less than or equal to 700.00
            Then - Actions
                Dialog - Show Dialog[1] for (Owner of (Casting unit))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyT 
                (Distance between (Position of (Storage 0012 <gen>)) and (Position of (Casting unit))) Less than or equal to 700.00
            Then - Actions
                Dialog - Show Dialog[2] for (Owner of (Casting unit))
            Else - Actions

It doesn't work.
 

Psiblade94122

In need of sleep
Reaction score
138
instead of useing the ct shop thing, cant you change it to target of casting unit? <i dont know the base ability of your dummy skill>
 

Alphabet

New Member
Reaction score
12
Well, if you need to use that particular condition you could add an action to show a message which contains the distance between the units, and see what value it gives. Maybe there's some kind of problem with that range.

But there are also different ways of making this. Here's 3 I can think of right now:
1) Use a region and the boolean comparsion 'Unit - Unit In Region'.
2) Give the shops some dummy auras and use the boolean comparsion 'Unit - Unit Has Specific Buff'.
3) Change the terrain type at the area you want them to be able to use the skill at, and use the Terrain-type comparsion.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,710
instead of useing the ct shop thing, cant you change it to target of casting unit? <i dont know the base ability of your dummy skill>

There's no target of the casting ability. The dummy ability is just used to make the pop up menu appear.

Alphabet said:
But there are also different ways of making this. Here's 3 I can think of right now:
1) Use a region and the boolean comparsion 'Unit - Unit In Region'.
2) Give the shops some dummy auras and use the boolean comparsion 'Unit - Unit Has Specific Buff'.
3) Change the terrain type at the area you want them to be able to use the skill at, and use the Terrain-type comparsion.

1. I don't want a rectangle region for the Buying conditions to be activated. It seems unnatural.
2. Does the Arrow above the unit's head counts as a buff? If so, how do you suppose a trigger can be done like that, along with the dialog pop-up? I tried it once, and it doesn't seems to match my expectations.
3. That would definitely give away everything in the map. The coins were put there as a reference in the editor. The models will be changed to "NONE" once everything is finished.
 

Alphabet

New Member
Reaction score
12
2. Does the Arrow above the unit's head counts as a buff?
Well, it doesn't exactly count as a buff. However you can probably make a buff that attaches an arrow overhead the unit.

And figured out there's one more way that should do the job (it functions in the almost same way as your original one):
Code:
Optional
    Events
        Unit - A unit Finishes casting an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to BuyCT
            Then - Actions
                Unit Group - Pick every unit in (Units within 700.00 of (Position of Unit[(Integer(CTshop))]) matching ((Matching unit) Equal to (Triggering unit))) and do (Actions)
                    Loop - Actions
                        Dialog - Show Dialog[1] for (Owner of (Triggering unit))
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Ability being cast) Equal to BuyT
                    Then - Actions
                        Unit Group - Pick every unit in (Units within 700.00 of Unit[(Integer(Tshop))] matching ((Matching unit) Equal to (Triggering unit))) and do (Actions)
                            Loop - Actions
                                Dialog - Show Dialog[2] for (Owner of (Triggering unit))
                    Else - Actions
The leaks caused by making those unit groops should be easily fixed.
Uh, I start to feel like a spammer since I've written so many unuseful messages to this thread. <.<
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,710
It didn't work. Units inside the 700.00 range couldn't use the ability.
 

Alphabet

New Member
Reaction score
12
I just tested this:
Code:
Optional
    Events
        Unit - A unit Finishes casting an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to Flame Strike
            Then - Actions
                Unit Group - Pick every unit in (Units within 512.00 of (Position of Peasant 0000 <gen>) matching ((Matching unit) Equal to (Casting unit))) and do (Actions)
                    Loop - Actions
                        Game - Display to (All players) the text: s
            Else - Actions
It worked as I thought it would, displayed the text "s". So the problem probably is that you've mixed the units (so that CTShop is actually the TShop and vice versa) or the Dialog[1] is not working.
So try these two steps:
1) Replace the '(Position of Unit[(Integer(CTshop))])' with '(Position of Unit[(Integer(Tshop))])'.
2) Add an action to display a message after showing the dialog.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,710
No, it's none of those above. Figured there's a coding issue in NewGen, I moved the trigger to a new spot, disabled and turned it off initially. Then I created a new trigger and match it to look like the code above. Then it worked. Both outside and inside of the range given.

Okay, it looks like this:
a5920a782f.gif


So, I think it is working, not sure if it's going to be permanent. The text message is the distance between the unit and the coin.

So, if anything comes up, I'll post a new thread. Right now, +rep for your efforts.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top