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

[Solved] Custom Script Error

Status
Not open for further replies.
Level 3
Joined
Feb 13, 2014
Messages
26
I have been practicing the use of spellbooks. At the moment im trying to fix a bug that happens when a hero morphs that makes the spells in the spellbook disapear.

The explanation of the bug and its fix is here

http://www.thehelper.net/threads/how-to-make-spellbooks.27637/


/////WHY DO MY SPELLS DISAPPEAR FROM THE SPELLBOOK AFTER TRANSFORMATION/METAMORPHISM ETC.

This is because the abilities inside the spellbook are not permanent; they are gained via a spellbook.

To fix this issue, you must make the ability permanent. The only way is to use a piece of custom script because the action is not accessible via GUI:

Jass:
call UnitMakeAbilityPermanent(whichUnit, true, abilCode)
Replace whichUnit with the unit who has the ability and abilCode with the raw code of the ability.
------
This assumes that the game re-adds abilities each time that a unit morphs. This is not true, because a specific unit's abilities are tied to the unit instance, which does not change upon morphing.
So, the MakeAbilityPermanent function is actually fighting the consequences, not the cause. What you really should do is making a copy of the spellbook for the morphed unit.
------
///


I’m learning the gui and well I can’t seem to get the ....

  • Custom script: call UnitMakeAbilityPermanent(whichUnit, true, abilCode)
to work

I’m using as unit
21rSIJQrJWrfptQgZOAcqY

And as Spell
6mMFmelSVdqGHfUPtJ2SvA

Which I’m not sure if i should use A003 or A003:AHfs
The final code looks like.
  • Custom script: call UnitMakeAbilityPermanent(gg_unit_Hmkg_0010, true,A003:AHfs)
But I can’t get it to work, i keep getting a "Expected a name" error .
Can anyone walk me through this error?
Ill also Attach the map file if its any help.
 

Attachments

  • SpellBook.w3x
    18.2 KB · Views: 48
Last edited by a moderator:
Level 20
Joined
Jul 14, 2011
Messages
3,213
A003 is the ability the custom one is based of. That's not part of the ability ID. Instead of using "A003:AHfs" use only "AHfs" inside single quotes

  • Custom script: call UnitMakeAbilityPermanent(gg_unit_Hmkg_0010, true, 'AHfs')
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
Instead of using "A003:AHfs" use only "AHfs" inside single quotes
Except AHfs is the base type, A003 is the custom object editor ability that extends from AHfs. You are making the wrong ability permanent.

Can anyone walk me through this error?
Every object editor entry is given a unique 32 bit identifier. To make this human friendly this is converted into 4 ASCII characters, where each character is 8 bits.

All object type references in JASS are of type integer (a 32 bit signed integer) which matches the type identifier integer. To make it easy to enter such integers the 'XXXX' construct is used where X is any ASCII character. Each of the 4 characters represents a byte of the 4 byte long object type identifier. All 4 characters have to be declared and they have to be in side single quotes (') to be interpreted correctly. The result is a constant representing an integer that is interpreted at map load time.

All you need to do is copy the 4 character identifier the object editor gives entries into the 4 character field of such a structure and you get a constant representing that object editor entry.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oomg... I confused the Id's. Dr Super Good is right, A003 is the ID, and AHfs is the ID of the base ability. Sorry!
 
Level 3
Joined
Feb 13, 2014
Messages
26
o.o I'm blown away by that explanation ,thanks . And I guess it makes more sense now why I was still losing the spell after metamorph.

but even with the correct spell ID
  • Custom script: call UnitMakeAbilityPermanent(gg_unit_Hmkg_0010, true,'A003')
I still cant manage to make the spell stay after transformation... I know is not the main topic of my question but does anyone knows why is not working?.
 
Level 3
Joined
Feb 13, 2014
Messages
26
Well to make it simple. Im adding the ability and making it permanent like this

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Player - Disable Spell Book2 for Player 1 (Red)
    • Unit - Add Spell Book2 to Mountain King 0010 <gen> //<----this contains A003
    • Custom script: call UnitMakeAbilityPermanent(gg_unit_Hmkg_0010, true,'A003')
And the transformation is made by just giving in object editor NightElf-Metamorphosis to the Mountain King.
6MT4BBxcK7FoejuhsICcbs


I start with spell on spellbook which should be permanent by then , click metamorphosis and its gone, even when metamorphosis goes off.

5UMQtE8BWWtWBsm3XiKQ7M



 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Why are you able to see the Spellbook if you're disabling it?

Try using 0.00 time elapsed event instead of map initialization
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,195
You forgot to make the spell book permanent. You made the flame strike ability inside the spell book permanent but that does not help when the containing spell book ability is lost as it is not permanent. Even though it is disabled, you need to make it permanent or the spell book ability will be lost during morphs.
 
Level 3
Joined
Feb 13, 2014
Messages
26
Why are you able to see the Spellbook if you're disabling it?

The Hero haves Spellbook1 which stays Enabled and its the one I'm opening, what I'm doing is adding a second one with the same ID which basically just merge both giving the ability in the spellbook2 to spellbook1 and because spellbook2 is disabled only one is showing.
Try using 0.00 time elapsed event instead of map initialization
also thought that , tried still didn't work I guess is not one of those actions that cant be done under map init event. :X

Dr. Super Good I made the spellbook permanent like you said and it worked perfectly thank you guys for the help :) +rep.
 
Status
Not open for further replies.
Top