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

Swaping spells

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2012
Messages
336
Hello everyone.
First i want to say that i tried everything i still have some ideas and ways to try i didn't do before but they will probably all fail as rest of them did.

What i want is:
Make a script in Jass so that when i type "-add #### #### #### #"
#### is Rawcode of the spell
# is the level of all three spells
I want when i type three diferent rawcodes and number on the end which marks their level of spell that next thing will happen.

In unit casting bar i will gain spell of first rawcode.When i press ESC that first spell is deleted and replaced with second spell of second rawcode.And when i press ESC again it is replaced with third rawcode but when i press ESC again it goes back to first rawcode so Three spells goes in circle in the same spot each time i press ESC (If you can't do it with ESC make it another button but say it which one).

And when i use that add command again with new three diferent rawcodes ESC thing will start replacing new spells of course.

If you manage to do this tell me what to put in global what in endglobal but if you don't want to you don't have to.
Questions:
Q:Does it have to be three diferent rawcodes/spells?
A:Yes.
Q:Does it need to be without any memory leak?
A:If you are skilled enough to do such thing i would really apreiciet it.But it isn't that much necessery since it wouldn't create much memory leaking i think.
Q:Do i need to test it before i post results?
A:Yes of course.

Note: When i press ESC the swaping spell action must occure when unit that has any of this three rawcodes on him.If unit is not selected or wrong unit is selected nothing happens.

If you need more information about this request feel free to ask and i will responde as soon as possible.
 
Last edited:
Level 8
Joined
Jun 13, 2012
Messages
336
Why would you need to do this, unless you are injecting code into the war3map.j?

That would be editing a protected map, and unfortunately that's against the rules here.

First of all don't you tell me what is against the rulle,have you looked at your sick twisted homesexual avatar? :vw_unimpressed:

Second of all no it is not for cheating nor i see how could this be for cheating it is simple spell space saver it saves a lot of space for more spells.I want to put it in my maps and also if i wanted it to use for cheats i could just request as anyway GUI,jass... and extract war3map.j open it with jasscraft and extract the script.The real purpose of this is to reduce the space of spell in casting bar without using no more than 1 bar. . :cwink:

Third if you don't want to say it what to put what in global and endglobal you don't have to =)

Forth don't double post the same exact comment. :thumbs_up:

Fifth If you are here only to bash and post negative double comments then please leave this section. :goblin_good_job:
 
Last edited:
Level 21
Joined
Mar 27, 2012
Messages
3,232
It's a long and complicated request.

Adding spells by rawcode is either extremely easy or very hard, depending on whether string2int can convert 'abcd' format codes to integers properly.

To disable a spell without messing with cooldowns you can use engineering upgrade.

I won't make this for you, but I say what needs to be done if you have specific enough questions.
So the main question is - What part of this can you not do?
 
First of all, this should be in Requests section.

Second of all, it's evident from previous threads like this, that your attitude will only invoke anger - no one will want to help you when you become offensive and no one wants your opinion as to what is twisted (and totally off-topic).

Thirdly, swapping spells can not generate memory leaks in the traditional fashion of e.g. location. You are dealing with integers, the rawcodes.

So, what you want here is 1 array global (with each array slot to be equal to your rawcodes, e.g. SPELL_ID[1] = 'A000', SPELL_ID[2] = 'A001', etc.) and then in your main function, you will loop from player(0) to player(11) and add to another function the event "call TriggerRegisterPlayerEventEndCinematic( functionName, Player(i)), where "i" is the loop variable.

Let's say you have 4 different spellsets; you can take that through MAX_ARRAY_SLOTS/3 (3 is static because you want 3 spells per spell-set).

In the functionName function, you will run an if/then/else statement and you will load (either from an array or a hashtable) a value that represents the current spell in use. This value will be stored on the respective player. Thus, the first line of the function is to load the value (e.g. LoadInteger (HASH, GetConvertedPlayerId(GetTriggeringPlayer()), 0).
"0" is representing how the value is stored. In this case it could be an integer number of 0. It could also be 1, you determine that.

Once loaded, loop from 1 to 12 array slots of the SPELL_ID[] and with an if/then/else statement check whether loadedValue == SPELL_ID[n] (where "n" is your loop variable). In the "then" branch, which returns true in this case, call UnitRemoveAbility (Unit, SPELL_ID[n]) and have another if/then/else; this serves to detect whether you need to repeat the cycle. Loop from 1 to (MAX_ARRAY_SLOTS/3) and check if "n" == 3*b (where "b" is the new loop variable), then call UnitAddAbility (Unit, SPELL_ID[n-2])
else
call UnitAddAbility (Unit, SPELL_ID[n+1])
Don't forget to re-save the "n" to the player via hashtable or array, whatever you find most convenient.

If you didn't control the raw id's manually, by chat command, the process would be different. Hopefully, I understood this correctly.
 
Maybe you could store the abilities into a hashtable and use StringId as key.

For the strings you could use your own intuitive spell names. That probably would be a lot of easier to remember them instead of looking up the rawcode each time.

For example, -add wind, fire, heal ...

Then you load the abilites of ouf hashtable with StringId of the three names "wind", "fire" and "heal".

The function is native StringHash takes string s returns integer
 
Level 8
Joined
Jun 13, 2012
Messages
336
First of all, this should be in Requests section.

Second of all, it's evident from previous threads like this, that your attitude will only invoke anger - no one will want to help you when you become offensive and no one wants your opinion as to what is twisted (and totally off-topic).

Thirdly, swapping spells can not generate memory leaks in the traditional fashion of e.g. location. You are dealing with integers, the rawcodes.

So, what you want here is 1 array global (with each array slot to be equal to your rawcodes, e.g. SPELL_ID[1] = 'A000', SPELL_ID[2] = 'A001', etc.) and then in your main function, you will loop from player(0) to player(11) and add to another function the event "call TriggerRegisterPlayerEventEndCinematic( functionName, Player(i)), where "i" is the loop variable.

Let's say you have 4 different spellsets; you can take that through MAX_ARRAY_SLOTS/3 (3 is static because you want 3 spells per spell-set).

In the functionName function, you will run an if/then/else statement and you will load (either from an array or a hashtable) a value that represents the current spell in use. This value will be stored on the respective player. Thus, the first line of the function is to load the value (e.g. LoadInteger (HASH, GetConvertedPlayerId(GetTriggeringPlayer()), 0).
"0" is representing how the value is stored. In this case it could be an integer number of 0. It could also be 1, you determine that.

Once loaded, loop from 1 to 12 array slots of the SPELL_ID[] and with an if/then/else statement check whether loadedValue == SPELL_ID[n] (where "n" is your loop variable). In the "then" branch, which returns true in this case, call UnitRemoveAbility (Unit, SPELL_ID[n]) and have another if/then/else; this serves to detect whether you need to repeat the cycle. Loop from 1 to (MAX_ARRAY_SLOTS/3) and check if "n" == 3*b (where "b" is the new loop variable), then call UnitAddAbility (Unit, SPELL_ID[n-2])
else
call UnitAddAbility (Unit, SPELL_ID[n+1])
Don't forget to re-save the "n" to the player via hashtable or array, whatever you find most convenient.

If you didn't control the raw id's manually, by chat command, the process would be different. Hopefully, I understood this correctly.

Thanks guys this is all great.But i fail to mention that when i say "I tried" i ment i tried in GUI form and covert it to jass(custom text) but things just didn't seem to work so i deleted all of it and made this thread.I know about jass like 2% not enough for basic things.So yeah please move it to request section my bad.
 
Status
Not open for further replies.
Top