Problems adding custom ability to unit

Zurtrogx

Active Member
Reaction score
24
Problem status: SOLVED

______________________________________________________________

In my map, there are three races, x, l, and b. There are three unit types, m, a, and r. And, there are three building types, l, m, and h.
When you build you building and select your unit type, the building will gain two abilities depending on what you race is, what unit type you selected, and what type of building it is.

For example, lets say you are race x, have building m, and choose unit type r.
The raw codes for the abilities will be:
Xmrd and Xmrd

In order to do this, I've made a function that converts the string into an Ability ID (10 digit number) and then add the ability with UnitAddAbilityBJ.

However, I seem to be having some problems.

The ability doesn't add properly; it instead adds an ability similar to it (For example, I want to add Xmrd, it will add XmaD). It also lags for a few seconds when I try to add these abilities.
However, if I add another custom ability, such as XbaS it works, or Ak02 will also work. The strange thing is that it won't lag when I try to add these abilities.

Using the Display Text to All players, I have discovered that the Raw Code generated in the string matches that of the ability I want to add AND the Ability Id also matches that of the ability I want to add. However, it still continues to add the wrong ability.

EDIT: I've created a map that allows you to see what's happening. Use "-a<raw code>" to add an ability and "-r<raw code>" to remove an ability. Try add Bhaa (which won't work) and then Bh99 or Bhat (which are identical copies of Bhaa) which do work. I think it might have something to do with the raw code that is causing it to malfunction. I reccommend using windowed mode so you can Alt+Tab between the object editor (to see the raw codes) and Warcraft 3. I have used newgen to make this map.

Here are the two triggers I am using to make this work. I've cropped out some of the unneccesary information to make it easier for you to view.

Trigger:
  • setup variables
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set character_value_string[0] = ABCDEFGHIJKLMNOPQRSTUVWXYZ
      • For each (Integer setup_loop) from 0 to 9, do (Actions)
        • Loop - Actions
          • Set character_value_string[(setup_loop + 48)] = (String(setup_loop))
      • For each (Integer setup_loop) from 1 to 26, do (Actions)
        • Loop - Actions
          • Set character_value_string[(setup_loop + 64)] = (Substring(character_value_string[0], setup_loop, setup_loop))
          • Set character_value_string[(setup_loop + 96)] = (String((Substring(character_value_string[0], setup_loop, setup_loop))) as Lower case)



The trigger below also does other functions but they have been removed since they are not necessary for adding the ability. Remove this has problem reduced the length of this trigger by 60%+. If you do wish to view the WHOLE trigger, please let me know and I will post it.
Trigger:
  • Unit Type upgrade
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Melee
          • (Ability being cast) Equal to Ranged
          • (Ability being cast) Equal to Magic
    • Actions
      • Unit - Order (Triggering unit) to Stop
      • Set US_structure_type = (Substring((String((Unit-type of (Triggering unit)))), 10, 10))
      • Set US_unit_type_selected = (Substring((String((Name of (Ability being cast))) as Lower case), 1, 2))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • US_unit_type_selected Equal to ma
        • Then - Actions
          • Set US_upgrade_string_unit_type = a
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • US_unit_type_selected Equal to me
        • Then - Actions
          • Set US_upgrade_string_unit_type = m
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • US_unit_type_selected Equal to ra
        • Then - Actions
          • Set US_upgrade_string_unit_type = r
        • Else - Actions
      • Set US_upgrade_string = (((String(US_race_type[(Player number of (Owner of (Triggering unit)))]) as Upper case) + US_structure_type) + (US_upgrade_string_unit_type + a))
      • Set US_upgrade_AbilID = 0
      • Set US_upgrade_power = 3.00
      • For each (Integer US_upgrade_check_loop1) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer US_upgrade_check_loop2) from 48 to 122, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(US_upgrade_string, US_upgrade_check_loop1, US_upgrade_check_loop1)) Equal to character_value_string[US_upgrade_check_loop2]
                • Then - Actions
                  • Set US_upgrade_AbilID = (US_upgrade_AbilID + (US_upgrade_check_loop2 x (Integer((Power(256.00, US_upgrade_power))))))
                  • Set US_upgrade_power = (US_upgrade_power - 1.00)
                • Else - Actions
      • Custom script: call UnitAddAbilityBJ(udg_US_upgrade_AbilID, GetTriggerUnit() )
      • Set US_upgrade_string = (((String(US_race_type[(Player number of (Owner of (Triggering unit)))]) as Upper case) + US_structure_type) + (US_upgrade_string_unit_type + d))
      • Set US_upgrade_AbilID = 0
      • Set US_upgrade_power = 3.00
      • For each (Integer US_upgrade_check_loop1) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer US_upgrade_check_loop2) from 48 to 122, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(US_upgrade_string, US_upgrade_check_loop1, US_upgrade_check_loop1)) Equal to character_value_string[US_upgrade_check_loop2]
                • Then - Actions
                  • Set US_upgrade_AbilID = (US_upgrade_AbilID + (US_upgrade_check_loop2 x (Integer((Power(256.00, US_upgrade_power))))))
                  • Set US_upgrade_power = (US_upgrade_power - 1.00)
                • Else - Actions
      • Custom script: call UnitAddAbilityBJ( udg_US_upgrade_AbilID, GetTriggerUnit() )
      • Unit - Remove Melee from (Triggering unit)
      • Unit - Remove Ranged from (Triggering unit)
      • Unit - Remove Magic from (Triggering unit)
 

Attachments

  • AddRemove abilities.w3x
    143.8 KB · Views: 61

Zurtrogx

Active Member
Reaction score
24
I've noticed that when I do the following:

Custom script: call DisplayTimedTextToForce( GetPlayersAll(), 30, GetAbilityName(udg_US_upgrade_AbilID) )
Custom script: call UnitAddAbilityBJ( udg_US_upgrade_AbilID, udg_UNIT )


It seems to work fine. But, when I do this:

Custom script: call UnitAddAbilityBJ( udg_US_upgrade_AbilID, udg_UNIT )
Custom script: call DisplayTimedTextToForce( GetPlayersAll(), 30, GetAbilityName(udg_US_upgrade_AbilID) )


It adds the correct ability, but it doesn't show the Tooltip extended.


However, this solution only works sometimes. And, other times, when an ability is add to one unit it causes an ability to replace an existing ability on another unit that wasn't referred to in the trigger.

EDIT: I changed the Raw Code and it works fine now.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top