Spellbook bug identified

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I've had a bug in my map for some time and I think I've finally isolated it. I'll need some help in fixing it though.

Here is a map with the bug demonstrated: http://www.hiveworkshop.com/forums/pastebin_data/9wods9/_files/Spellbook bug2.w3x

I'll explain it here though, as it's very easy to see. The map has 1 paladin for player 2 and 1 archmage for player 1 (you). The paladin has been given the spellbook ability (modified so it is not an item ability but rather a unit ability).

When you execute the trigger below as player 1 the custom script orders Paladin 0001 to open his spellbook. The result: the Archmage, even though he hasn't been ordered to do anything, has all his abilities removed (including move and hold position and such), as if he opened a spellbook with nothing in it.

  • test
    • Events
      • Player - Player 1 (Red) types a chat message containing test as An exact match
    • Conditions
    • Actions
      • Set tempUnit = Paladin 0001 <gen>
      • Custom script: call IssueImmediateOrderById (udg_tempUnit, 852608)
I'm new to custom scripts...am I reading something wrong there? I've tested it in other maps and the paladin given the order does indeed open his spellbook. In fact, if you give the archmage a spellbook he'll open it too even though he is not tempUnit.
 
Last edited:
Level 20
Joined
Jul 6, 2009
Messages
1,885
Interesting.
Doing it with local player would maybe be better, but i'm not sure if it might desync.

EDIT: I just noticed there's no "spellbook" order (which was currently selected). What ID did you use? o_O

EDIT2: Using a valid ID (I used avatar's as an example) worked properly. The Paladin played his spell animation without changing Archmage's ability UI.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
GetLocalPlayer() won't won't fix the problem if given hero is under your command too.
Meaby just use action: Selection - Clear selection for <given player> =)
If heroes without spellbook aren't selected problem is fixed =)
>> Don't bother adding them again via trigger, bug will occur anyways. Selecting manually provides somewhat of solution here.

EDIT: I've been testing it with valid id too, meaby I've chosen wrong order - I've used 'stomp' (changed id in trigger too) and paladin didn't want to open spellbook.
If I've missed it because of wrong order id I'm dumb ^^
 
Level 14
Joined
Aug 30, 2004
Messages
909
GetLocalPlayer() won't won't fix the problem if given hero is under your command too.
Meaby just use action: Selection - Clear selection for <given player> =)
If heroes without spellbook aren't selected problem is fixed =)
>> Don't bother adding them again via trigger, bug will occur anyways. Selecting manually provides somewhat of solution here.

EDIT: I've been testing it with valid id too, meaby I've chosen wrong order - I've used 'stomp' (changed id in trigger too) and paladin didn't want to open spellbook.
If I've missed it because of wrong order id I'm dumb ^^

Sorry guys you're getting ahead of me!

I would love to use GetLocalyPlayer() though desyncing would be terrible, it's a multiplayer map. Does anyone know if this would work or not, and if so, how do I do it? (please use custom script it's all I know). For my map everyone only has 1 non-hero that has a spellbook ability and 1 hero who does not.

I have no idea where the spellbook order came from... someone posted it on these forums: http://www.hiveworkshop.com/forums/triggers-scripts-269/spellbook-bug-abilities-gone-200130/

The spellbook order does work though... if you have the trigger issue the order to your own unit it will open the book. It just appears to issue that order to every other selected unit whether it's yours or not.


It's very interesting that you said that selecting via trigger will cause the bug! I've been having this bug for a while even without the custom script trigger. I have a unit with a spell book that stays open. When he dies, I select the player's hero (i.e. the ship blows up and the hero drops out). But when I do that the hero has no abilities, just like the archmage in this map. Even if I put in a wait before selecting the bug is still there...or if I have him select a few other units first and then the hero. The only thing that got around it was having the players manually select. That's the bug I was talking about in the above forum post.

So I appear to have two problems:

1. If I order a unit to open their spellbook it bugs any other hero that's selected.
2. If I select another unit via trigger after a spellbook unit dies while selected, it's bugged.

The second isn't fatal for my map, but it's annoying. The first is very difficult to get around. The only solution I've found is to order the spellbook owner's player to press Z via trigger (z is the hotkey for my spellbook). This works unless they're holding down CNTRL in which case it doesn't.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Just use OrderId("stomp"). It's same as if you got the ID and typed it.

This won't compile for me:

  • Custom script: call IssueImmediateOrderById (udg_tempUnit, stomp)
Am I understanding you correctly? I change the spellbook order in the object editor to be "stomp" and then issue an order with some script similar to what I put above, and the spellbook opens without screwing with the other people?
 
Level 14
Joined
Aug 30, 2004
Messages
909
'ById' tells you that you have to use integer here instead of string - but you can use string if you get rid of sufix 'ById' in function.
Id of stomp is 852127, but better use OrderId("stomp").

Thank you. I'm having the same problem you were though, he doesn't open his spellbook when you give him that command. I set the spellbook in the editor to use the "stomp" order.... No luck.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Thats why I was spceptic about that idea by Garfield. If I have done something wron and it's not what you proposed Gard - appologizes.

Try with normal spellbook order but before custom script use action 'Clear selection' for given player. Meaby thats not the best option but for now it works. I'll try to look for better solution than that.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Thats why I was spceptic about that idea by Garfield. If I have done something wron and it's not what you proposed Gard - appologizes.

Try with normal spellbook order but before custom script use action 'Clear selection' for given player. Meaby thats not the best option but for now it works. I'll try to look for better solution than that.

You are very kind.

Clearing selections for others would be okay as long as I can add them back. And I think you said that reselecting with triggers would cause the problem as well. I'm making a flying ship game, so if they aren't selecting their ship they could easily crash in a cliff if I didn't reselect them immediately. I'll play with the map a bit and see if I can get it to work.

+rep already
 
Level 14
Joined
Aug 30, 2004
Messages
909
Thats why I was spceptic about that idea by Garfield. If I have done something wron and it's not what you proposed Gard - appologizes.

Try with normal spellbook order but before custom script use action 'Clear selection' for given player. Meaby thats not the best option but for now it works. I'll try to look for better solution than that.

I think I found it! It's a bit odd, but it does work:

  • test Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing test2 as An exact match
    • Conditions
    • Actions
      • Unit - Add Spell Book to Archmage 0000 <gen>
      • Set tempUnit = Paladin 0001 <gen>
      • Custom script: call IssueImmediateOrderById (udg_tempUnit, 852608)
      • Unit - Remove Spell Book from Archmage 0000 <gen>
Basically, you give the spell book ability to the archmage, then when the paladin gets the order, the archmage will open his book. Then you remove the spell book ability from the archmage and he reverts to normal!

It's late here, so I think I'll try to integrate this into my main map tomorrow. Let me know if you see any problems though!
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
I don't know why doesn't stomp work for you, here's proof that it does though.
I guess you haven't set Base Order ID in object editor.
(When you test, once you type 'test', you'll see paladin playing spell animation which proves he performs the order)

EDIT: One problem, even though he performs the order (i can see by glowing border), the spellbook doesn't open :/
 

Attachments

  • Spellbook bug2.w3x
    11.9 KB · Views: 35
Level 14
Joined
Aug 30, 2004
Messages
909
I think I found it! It's a bit odd, but it does work:

  • test Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing test2 as An exact match
    • Conditions
    • Actions
      • Unit - Add Spell Book to Archmage 0000 <gen>
      • Set tempUnit = Paladin 0001 <gen>
      • Custom script: call IssueImmediateOrderById (udg_tempUnit, 852608)
      • Unit - Remove Spell Book from Archmage 0000 <gen>
Basically, you give the spell book ability to the archmage, then when the paladin gets the order, the archmage will open his book. Then you remove the spell book ability from the archmage and he reverts to normal!

It's late here, so I think I'll try to integrate this into my main map tomorrow. Let me know if you see any problems though!

I was a bit worried this would interrupt orders and such, but apparently it doesn't. In other words, I can have the Archmage cast blizzard. Then when the paladin is issued the order to open his spellbook, which he does, the Archmage will bug out. But when the spellbook is added and removed from the archmage he will be right back. It does not even interrupt his blizzard spell.
 
Status
Not open for further replies.
Top