Need Help with spell giving spell books

ShadourazeR

New Member
Reaction score
0
Well, I'm working on a map which players can choose their own abilities. My plan was to make an unit with many spellbooks, such as "summon abilities, support abilties" etc, and when the player can choose the ability, by clicking it, and the hero would recieve that ability. But I can't find an easy way to make it, the only thing I tought was making an ability for each ability, and have a function for every single ability I want to add/level up... It must have a better way, please help!
 

ShadourazeR

New Member
Reaction score
0
Not solved yet... It explained how to make it, but I needed something different. I had to make those ability sections to restringe players, so they woudlnt get five summon skills and crush everyone...
 

ShadourazeR

New Member
Reaction score
0
That didn't helped at all...lol... Have you guys ever played WARLOCK? I was thinking of something like that: Basic Spell Spellbook, Advanced Spell Spellbook (in my case, summon, damage, buff, disable, misc. defensive and ultimate spellbooks), when you get the required gold (in my case lumber) you go to the unit and just buy it... =S
 

WilliamPa

Active Member
Reaction score
51
Make spells with the rawcode same kind, for ex learning spells use aL[2 random numers] and real spell aZ[2 random numbers]

Then using I2S take the last 2 numbers and give the real spell to hero using S2I

E: not possible if you cannot do rawcodes / jass
 

ShadourazeR

New Member
Reaction score
0
First: I can't do rawcodes/jass, that's why I'm asking for help...

Second: The main difference bteween what I'm trying to do and the existing tutorial is: you level up the skill INSIDE the shop, not after you get it, and level up etc. Also, it would be nice (not necessary) if I could have a spellbook for each kind of ability (as I said before) and a restriction to same-kind ailities (you can't get more than two summoning abilities, for example). =S Can't anyone try to post there for me?...
 

ShadourazeR

New Member
Reaction score
0
Actually, I understand that 2d array thing, but I only use it in Adobe CS3, no idea how to make it on we...
 

mr-death

Acolyte
Reaction score
51
Arrays may have 4 digits...

Array 1 digit 2d is just the same as Array 2 digit 1d.

Array[1][1] and Array[11]

But, you'll have to do some maths using mod and div.

For example;

Array[1][1]
Array[11]
11/10 = 1
11 mod 10 = 1

There you've got array 1 and array 2

Array[12][16]
Array[1216]
1216/100 = 12
1216 mod 100 = 16

There, you've got them again.
Quite simple with 2 lines of integer arithmetic and math.

Even These...

Array[0][20]
Array[20]
20/100 = 0 (first array)
20 mod 100 = 20

Array[20][0]
Array[2000]
2000/100 = 20
2000 mod 100 = 0 (second array)

Just dont forget, that if the 2 digits array contains 1 digit, it should be moved to the right>

[20][2] > [2002] (20 and 02)
[2][0] > [200] (02 and 00)
 

ShadourazeR

New Member
Reaction score
0
That means all I need to do is put the array with [Sife two] and put 1011 instead of [10],[11] ?! That sounds pretty cool... I tought of something like that :D

I'll try to get it... But if Zymoran (or any other mapmaker) wants to give me a finished code, I'd like it =p


Got a problem... I want the trigger to track the ability that was used (instead of using the buying item event, I used a unit using ability one) and check what ability was used (third and fourth digits) and which player used it (first and second). But, if I do it this way I can't do [(Player Number of (owner of (Triggering Unit))) + 01], that number one always stays without the zero... I'll tyr this: First player = Array slots 1000-1999, Second one = 2000-2999...


Here's what I got:

Trigger:
  • Storm Bolt
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt (Pick)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current lumber) Greater than (Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] + 1)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] Greater than 5
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: |cffff0000This abil...
            • Else - Actions
              • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
                • Loop - Actions
              • Set Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] = (Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] + 1)
              • Unit - Add Storm Bolt (Spellbook) to (Picked unit)
              • Unit - Set level of Storm Bolt - Engineering for (Picked unit) to Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)]
              • Player - Disable Storm Bolt (Spellbook) for (Owner of (Triggering unit))
              • Player - Set (Owner of (Triggering unit)) Current lumber to (((Owner of (Triggering unit)) Current lumber) - Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)])
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000Not enoug...


Should it work now? *-*...
Last thing (I guess): If I want it to level it up by picking the same skill again, I guess I must change the Storm Bolt - Engineering (It is like the tutorial) to... =S I'm confused now.
 

WilliamPa

Active Member
Reaction score
51
JASS:
function LearnSpell takes nothing returns nothing
    local integer i
    if SubString(I2S(GetSpellAbilityId()), 1,2) == 10 then
        set i = S2I(SubString(I2S(GetSpellAbilityId()), 3,4))
        call UnitAddAbility(GetTriggerUnit(), S2I("11" + I2S(i)))
        call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
    endif
endfunction


This will remove the old ability and add a new one with id 11+2 last digits of the casted ability.

JASS:
function LearnSpell takes ability a, integer 2digs, unit u returns nothing
    local integer i = S2I(SubString(I2S(GetSpellAbilityId()), 3,4))
    call UnitAddAbility(u, S2I(I2S(2digs) + I2S(i)))
endfunction


This will not remove the old spell, but will add a new one.

How to use this?
Trigger:
  • Custom Script: call LearnSpell(ability, 2digs, unit)


Value info:
ability: Casted ability
2digs: 2 first digits of the new spell(in your case, default 11)
unit: Unit who will get the spell


JASS:
function LevelUpAbil takes ability a, integer 2digs, unit u returns nothing
    local integer i = S2I(SubString(I2S(GetSpellAbilityId()), 3,4))
    local string s = I2S(2digs) + I2S(i)
    call SetUnitAbilityLevel(u, S2I(s), GetUnitAbilityLevel(u, S2I(s)) + 1)
    set s = null
endfunction


This trigger will level up a spell, same method as previous function.
 

ShadourazeR

New Member
Reaction score
0
See my last post... I can understand what you put in the JASS, but I still think it's something missing... what you wrote isn't going to level up the ability, it will do the same thing as the tutorial GUI trigger...
 

ShadourazeR

New Member
Reaction score
0
Well already did it by myself... take a look :

Trigger:
  • Storm Bolt
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt (Pick)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Number_of_Abilities[(Player number of (Owner of (Triggering unit)))] Less than 3
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True))) Less than 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Damage[(Player number of (Owner of (Triggering unit)))] Less than 2
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Triggering unit)) Current lumber) Greater than (Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] + 1)
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] Less than 6
                        • Then - Actions
                          • Set Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] = (Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] + 1)
                          • Set Number_of_Abilities[(Player number of (Owner of (Triggering unit)))] = (Number_of_Abilities[(Player number of (Owner of (Triggering unit)))] + 1)
                          • Player - Set (Owner of (Triggering unit)) Current lumber to (((Owner of (Triggering unit)) Current lumber) - Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)])
                          • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
                            • Loop - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)] Equal to 1
                                • Then - Actions
                                  • Set Damage[(Player number of (Owner of (Triggering unit)))] = (Damage[(Player number of (Owner of (Triggering unit)))] + 1)
                                  • Unit - Add Storm Bolt to (Picked unit)
                                • Else - Actions
                                  • Unit - Set level of Storm Bolt for (Picked unit) to Abilities[(((Player number of (Owner of (Triggering unit))) x 1000) + 1)]
                        • Else - Actions
                          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000This abil...
                    • Else - Actions
                      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000Not enoug...
                • Else - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000You alrea...
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000No hero f...
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffff0000Already h...
 

mr-death

Acolyte
Reaction score
51
Sorry, I was away for 3 or so days.

Why can't you?
Your problems' are

1.Tracking player
2.Tracking ability used

For now;
Array[1010] means player 10, ability 10
Array[110] means player 1, ability 10

Got a problem... I want the trigger to track the ability that was used (instead of using the buying item event, I used a unit using ability one) and check what ability was used (third and fourth digits) and which player used it (first and second). But, if I do it this way I can't do [(Player Number of (owner of (Triggering Unit))) + 01], that number one always stays without the zero... I'll tyr this: First player = Array slots 1000-1999, Second one = 2000-2999...

You mistook the concepts, you cannot add just "01".
See my code:
Trigger:
  • If - Conditions
    • (Owner of (Triggering unit)) Current lumber) Greater than Abilities[((1000 x ((Player number of (Owner of (Casting unit))) / 10)) + ((100 x ((Player number of (Owner of (Casting unit))) mod 10)) + ((10 x (1 / 10)) + (1 mod 10))))]



see the '/' and 'mod'. To get the 4 digits array, you would like to have a good basic on maths first...

1000 x A(the first digit)
100 x B(the second digit)
10 x C(the third digit)
1 x D(the fourth digit)

So that on the last result, you'll get
[ABCD]

Actually this code works just as the above,
Trigger:
  • If - Conditions
    • (Owner of (Triggering unit)) Current lumber) Greater than Abilities[((100 x (Player number of (Owner of (Casting unit)))) + 1)]


why? you should learn maths.

And on your system, it could only contain 7 players, because WE has limited the array cap to [8192]
 
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
    +1
  • 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