I've been trying to create a trigger that creates an action that causes a unit to cast a spell, but the problem is it won't let the player choose the target like normal. You have to define the target in the action, instead of the player choosing a target in-game. I want the trigger to happen, then the player gets the spell targeting cursor, then clicks to cast the spell.
I essentially have a custom dialog button that is supposed to tell a unit to cast a spell when clicked, but I really need the player to be able to choose the target. Once I get this working there is a lot more to it, but if I can get this core idea to work then I can get started with everything else.
I've been going crazy over the past two days just looking in the XML files and all over forums trying to see if there's a way to do this. Any help would definitely be appreciated!
Can you create a unit variable, put that into your trigger definitions appropriately as the target, and then define that variable based on to the new player unit selection with a different trigger (pause your trigger while this happens)? You might be able to use mouse coordinates instead, but I don't know if that's more efficient.
I'm still playing with the editor, but that's how I would try to do it.
hey there, glad my first post could be to help someone. this is how i would do it. have the trigger give the unit you want casting the spell an ability(like a version of snipe or something)that does no damage or stun or anything like that., and force the player to press the hotkey for it. this will bring up the spell selection thingy, then have your current trigger's event be when X spell is cast so then it only starts when the spell is cast. at the end of your trigger add in something to remove the spell from the unit. also you might want to add in some kinda thing to failsafe it so the player can't just hit exc and then have the spell forever and never use it.
I've been trying to create a trigger that creates an action that causes a unit to cast a spell, but the problem is it won't let the player choose the target like normal. You have to define the target in the action, instead of the player choosing a target in-game. I want the trigger to happen, then the player gets the spell targeting cursor, then clicks to cast the spell.
I essentially have a custom display button that is supposed to tell a unit to cast a spell when clicked, but I really need the player to be able to choose the target. Once I get this working there is a lot more to it, but if I can get this core idea to work then I can get started with everything else.
I've been going crazy over the past two days just looking in the XML files and all over forums trying to see if there's a way to do this. Any help would definitely be appreciated!
Well, off the top of my head, heres a clever "solution" that avoids this problem. Rather then forcing the player to cast a spell, force the player to use a hidden submenu button, and attach a that to a respective command card that can't be accessed any other way. Then trigger effects onto the usage of said submenu ability, if you want any effects. The submenu command card would only have one ability, (the one you want the player to cast) and there would be periodic events to prevent the player from clicking on anything else. The submenu itself would lack a back button.
The only issue is that the player still has to click the submenu ability.
@Jetse124 - This is sort of what I'm doing as a work-around, when I click the dialog button it sets a variable, then when I click while the variable is set it tells the unit to cast the spell on that location and resets the variable to 0. This is awkward though because there's no aoe targeting cursor, or if it's a spell that's cast on a unit it selects the unit when I click on it, and all sorts of other weird problems.
@ErtydotJrPants - I can't find any actions that simulate a player pressing a key, I even checked the natives list. :(
@halfthought - I don't think I'm too knowledgeable about submenu buttons but it sounds like that solution wouldn't work completely since it requires an extra click.
From what I've seen here and other forums it seems like the actual spellcasting is somewhere in the actual engine code where it can't be seen, hopefully they'll add some more natives/actions for it or something, for now I'm probably going to work around it as best I can. Kinda ridiculous because you can't have very good custom spell buttons without this capability.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I've been trying to create a trigger that creates an action that causes a unit to cast a spell, but the problem is it won't let the player choose the target like normal. You have to define the target in the action, instead of the player choosing a target in-game. I want the trigger to happen, then the player gets the spell targeting cursor, then clicks to cast the spell.
I essentially have a custom dialog button that is supposed to tell a unit to cast a spell when clicked, but I really need the player to be able to choose the target. Once I get this working there is a lot more to it, but if I can get this core idea to work then I can get started with everything else.
I've been going crazy over the past two days just looking in the XML files and all over forums trying to see if there's a way to do this. Any help would definitely be appreciated!
Can you create a unit variable, put that into your trigger definitions appropriately as the target, and then define that variable based on to the new player unit selection with a different trigger (pause your trigger while this happens)? You might be able to use mouse coordinates instead, but I don't know if that's more efficient.
I'm still playing with the editor, but that's how I would try to do it.
best of luck!
@JohnnySmash: Go
hey there, glad my first post could be to help someone. this is how i would do it. have the trigger give the unit you want casting the spell an ability(like a version of snipe or something)that does no damage or stun or anything like that., and force the player to press the hotkey for it. this will bring up the spell selection thingy, then have your current trigger's event be when X spell is cast so then it only starts when the spell is cast. at the end of your trigger add in something to remove the spell from the unit. also you might want to add in some kinda thing to failsafe it so the player can't just hit exc and then have the spell forever and never use it.
Well, off the top of my head, heres a clever "solution" that avoids this problem. Rather then forcing the player to cast a spell, force the player to use a hidden submenu button, and attach a that to a respective command card that can't be accessed any other way. Then trigger effects onto the usage of said submenu ability, if you want any effects. The submenu command card would only have one ability, (the one you want the player to cast) and there would be periodic events to prevent the player from clicking on anything else. The submenu itself would lack a back button.
The only issue is that the player still has to click the submenu ability.
@Jetse124 - This is sort of what I'm doing as a work-around, when I click the dialog button it sets a variable, then when I click while the variable is set it tells the unit to cast the spell on that location and resets the variable to 0. This is awkward though because there's no aoe targeting cursor, or if it's a spell that's cast on a unit it selects the unit when I click on it, and all sorts of other weird problems.
@ErtydotJrPants - I can't find any actions that simulate a player pressing a key, I even checked the natives list. :(
@halfthought - I don't think I'm too knowledgeable about submenu buttons but it sounds like that solution wouldn't work completely since it requires an extra click.
From what I've seen here and other forums it seems like the actual spellcasting is somewhere in the actual engine code where it can't be seen, hopefully they'll add some more natives/actions for it or something, for now I'm probably going to work around it as best I can. Kinda ridiculous because you can't have very good custom spell buttons without this capability.