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.

      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