Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: Mod Help - Deselect Stack with ERM
Thread: Mod Help - Deselect Stack with ERM
error3
error3

Tavern Dweller
posted April 18, 2015 07:20 PM
Edited by error3 at 21:01, 18 Apr 2015.

Mod Help - Deselect Stack with ERM

I would like to know how to deselect a stack with ERM.

I have written an ERM script which grants a hero a specialty to transform units into skeletons (like the skeleton transformer) and I want to be able to use it by double clicking on a unit in the Hero Screen and Heroes visiting screen. The 1st click selects the unit and a subsequent click grants the dialog box I created asking if the player wishes to transform. If they cancel, the regular unit information dialog is shown, if they accept, the unit is turned into skeletons.

Currently, accepting will also show the regular unit information (for the new skeletons) which is undesirable (they probably didn't want the info and just wanted to transform). By using !!CM:R0 I can disable the interaction on the 2nd click, however this still leaves the stack selected (and also doesn't update the graphic to reflect that the stack is now a skeleton until another action updates it).

Is there a way to either deselect the stack or perhaps automatically close the unit information which pops up? Or maybe disable only the unit info and not the deselecting aspect?

Any advice or insight into solving this issue is appreciated.

Edit: On a related note, does anyone know how to check if a stack is selected? I've been keeping track, but when using the HD mod various additional troop movement options can deselect without a click being registered on my CM receivers.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted April 18, 2015 09:06 PM

A stack is selected when you click on, so if CM:I returns a hero stack, means is selected. Show the code for upgrade please.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
error3
error3

Tavern Dweller
posted April 19, 2015 05:57 PM

Salamandre said:
A stack is selected when you click on, so if CM:I returns a hero stack, means is selected. Show the code for upgrade please.


Here are the relevant snippets of code from the hero meeting screen (if you want the full files to test etc. let me know and I will post them somewhere):

!?CM3&v779=1; [This code runs for the hero visiting screen if only 1 human player]
!!CM:S?y3; [Store flag for mouse press or relese] [left mouse push = 12]
!!CM:H?y-1/?y1; [Get IDs of left and right heros]
!!CM:I?y2; [Set y2 to area clicked by mouse]
!!VRy5:S0;
!!VRy5&v778=y1:S1;
!!VRy5&v778=y-1:S1; [y5 is true if Paul is on left or right]

!!if&y5=1/y3=12:; [If Paul is present and left-click happens...]
   !!VRy2&y2>=65/y2<=78:Sy2-52; [Allows clicking troop number as well]
   !!if&y2>=13/y2<=26:; [Selected creature]
       !!IF:Wv778; [Hero variables now targetting Lord Paul]
       !!if&y2=w19:; Clicked same spot!
           !!if&y2<=19; [If left unit double-clicked]
               !!VRw19:Sw19-13;  [set w19 to Stack index, left creature]
               !!FU115&y-1=v778;
           !!el;  [Right unit was double-clicked]
               !!VRw19:Sw19-20;  [set w19 to Stack index, right creature]
               !!FU115&y1=v778; [If Paul's unit, Call Skeleton Transformer Function]
           !!en:;
           !!VRw19:S-1; [Clear double click value]
       !!el:;Clicked a new spot!
           !!VRw19&w19=-1:Sy2;
           !!VRw19&w19<>y2:S-1;
       !!en:;
   !!el:;
   !!en:;
!!el:;
!!VRw19&y2=30720:S-1; [If the check is clicked, then clear what we were doing]
!!en:;

!?FU115; [Call Skeleton Transformer Dialog for stack at w19
!!HEv778:C0/w19/?y3/d0; [set y3 to type of creatures]
!!if&y3<>26/y3<>27/y3<>82/y3<>83/y3<>132/y3<>133/y3<>134/y3<>135/y3<>168/y3<>110/y3<>111:;
   !!IF&y3<>-1/y3<>56:Q1/21/56/21/y3/2^Transform stack to Skeletons?^;
   !!HEv778&y3<>-1/1:C0/w19/56/d0; [Transform stack to Skeletons - Checks if Flag 1 is positive
!!el:;
   !!IF:Q1/21/68/21/y3/2^Transform stack to Bone Dragons?^;
   !!HEv778&1:C0/w19/68/d0; [Transform stack to Bone Dragons - Checks if Flag 1 is positive
!!en:;

----------------------------------------
So this code actually works fine for the hero-meeting screen upgrade unless a unit gets selected and then someone with HD mod presses one of the movement arrows, which deselects the stack, but my code still thinks its selected. While I would like to know how to get around this, it's kinda a fringe case, and the upgrades will still work, they'll just occur on the 1st click until the window is closed.
If I could get a trigger that picked up the HD mod arrow clicks that would be nice, or I could painstakingly count the units before and after a click and clear my variable if there is a difference, but I don't think it's worth the effort to do that.

My main area of interest is being able to disable the troop info popup in some fashion when transforms occur as it adds an extra click to all stack upgrades, and I would like to streamline use of transforming.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted April 19, 2015 06:59 PM

Uh, thats a very simple thing you did in a very complicated way :)

Example for hero screen:

!?CM2;
;ALT + left click on hero slots, don't use simple left click because then you won't be able to move troops anymore.
!!CM:I?y1 F?y2;
!!FU|y1<68/y1>74:E;
!!FU&y2<>32:E;
!!VRy2:Sy1-68; get slot clicked
!!HE-1:C0/y2/?y3/?y4/?y5; get creature ID, number and experience
!!FU&y3<0:E; exit if slot empty
!!EX-1/y2:R?y6/?y7/?y8/?y9; get warlord banners (if any)
!!IF:Q1^Do you want to change this stack into skeletons?^;
!!CM&-1:R0;
!!FU&-1:E;
!!HE-1:C0/y2/56/y4/y5;
!!EX-1/y2:Ry6/y7/y8/y9;
!!UN:R3/-1; redraw hero screen
!!CM:R0;

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
error3
error3

Tavern Dweller
posted April 21, 2015 01:53 AM

Thanks for the response Salamandre. The 1st 2 lines "!!CM:I?y1 F?y2;" and "!!FU|y1<68/y1>74:E; " are very helpful, I will use those techniques to write more compact code.

Your idea for using an alt-modifier is a good, but not perfect solution. It does greatly simplify the code by not having to keep track of whether a stack is selected or not. However, I feel using an alt-modifier is less-intuitive for players as the existing hero specialties to modify troops are accessed by a double click (i.e. Gelu and Dracon), also it does conflict with the merge-stack functionality in the HD mod. That being said I think it may be the best option, especially if it is not possible to code it the way I desire with a double-click.

I assume there is no way to check whether a selection is active or to clear a selected stack with ERM then?

Thanks again.    

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted April 21, 2015 07:21 AM

I don't use HD mod anymore since I implemented the exact same key shortcuts in era, mainly because HD mod, while being great for vanilla, is not optimal for era and conflicts in some scripts.

So if alt conflicts, you can use another key, or simply, when certain hero is active, push keys 1-7 to transform corresponding stacks into skeletons, ask if you need hint on this code.

As I tested first your script, it displayed skeletons transformer question, every time I wanted to select a stack. This may look okay early game when indeed all you do is transform, but late game when most you do is rearrange stacks for battles, having that pop up at each click is very annoying IMO.

And HD mod also uses key press for a lot of actions, that's the price to pay for advanced functionalities.

error3 said:
the existing hero specialties to modify troops are accessed by a double click (i.e. Gelu and Dracon)


But then why don't you script it as master of upgrades then? When click on creature ID = #, hero becomes master of upgrades and that creature is "upgraded" to skeletons, of course at no cost, considering their low level.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
error3
error3

Tavern Dweller
posted April 21, 2015 10:22 PM
Edited by error3 at 04:02, 22 Apr 2015.

Salamandre said:

your script, it displayed skeletons transformer question, every time I wanted to select a stack


O, I see. For me my script only prompts on a double-click (i.e. if the stack was already selected). Single click would be too often. This is probably because I only posted a snippet for you, I guess.

update3: Salamandre, I think I figured out why you were getting the dialog popup with 1 click. Check with !!CM:S of 12 for a left-click-push. Using !!CM:F of 0 will run the code once when it is pressed, and once when it is released. This results in a single click bring up the dialog instead of the desired 2 clicks.

Salamandre said:

But then why don't you script it as master of upgrades then? When click on creature ID = #, hero becomes master of upgrades and that creature is "upgraded" to skeletons, of course at no cost, considering their low level.


I really like this idea. As long as I can change the cost of the monster to equal the cost of the skeleton or bone dragon for the few cases where the cost would be non-zero, which I think i can with !!MA:C, then I should be able to replicate the skeleton transformer functionality exactly. I'll update this post when I have it working.

Thanks again.

Update:
I rewrote the ERM for the hero information screen handling to make use of the master of upgrades specialty as suggested. I set the cost of skeletons and bone dragons to 1 and then return them to 60 and 1800 respectively when the hero information screen is closed, so transformations are free.

The only thing I don't like about this solution is the dialog that pops up to perform the transformation is misleading; it states that a gold cost will need to be paid and shows an image of gold resource. I would like to be able to either edit the text and image for the upgrade or simply disable the default behavior and have an interface I specify used. Unfortunately, I have tried all CM triggers and cannot intercept any clicks when clicking on the stack information, such as the upgrade button.

Does anyone know if changing this is a possibility?

The ERM code I use for Necromancer Transformer via master of upgrades is shown below.

;This code runs when someone clicks on the hero information screen
!?CM2;
!!OW:A-1/?y1; [Store active hero's ID number in y1]
!!FU&y1<>v778:E; [Exit if Lord Paul isn't active hero]

!!CM:I?y2; [Set y2 to area clicked by mouse]
;Exit if check is left-clicked, perform cleanups
!!if&y2=30720:; [return skeletons costs, return default specialty, exit function]
   !!MA:C56/6/60;  [set skeleton cost back]
   !!MA:C68/6/1800; [set bone dragon cost back]
   !!HEv778&y2=30720:X0/2; [set specialty back to logistics if exitting]
   !!FU:E; [Exit function when check is read]
!!el:;
!!en:;
!!FU|y2<68/y2>74:E; [Exit if slot clicked isn't a troop]

!!CM:S?y3; [Store flag for mouse press or relese] [left mouse push = 12]
!!FU&y3<>12:E; [Exit if left-mouse wasn't clicked]

!!VRy2:Sy2-68; [set y2 to stack targeted]
!!HEv778:C0/y2/?y1/?y3; [Set y1 to monster type and y3 to # of monsters]

;Change gold cost of skeletons and bone dragons to 1 so Skeleton Transformation will be free
!!MA:C56/6/1;
!!MA:C68/6/1;

!!VRy2:S68; [Set y2 to 56 (skeletons)]
!!VRy2&y1<>26/y1<>27/y1<>82/y1<>83/y1<>132/y1<>133/y1<>134/y1<>135/y1<>168/y1<>110/y1<>111:S56; [If hydra or dragons, set value to bone dragons]
!!HEv778&y1<>56:X6/y1/y1/y2; [Set hero specialty to upgrade targeted unit to skeletons or bone dragons]

Update2: After further implementation, I realized this method does not work within a town as it hinders the ability to upgrade a purchased unit. (Also, when in-town further protections are needed to prevent 1 gold purchasing of skeletons and bone dragons, but that is something that can be solved). I don't believe this is a deal-breaker though, as a player could just do the conversions outside of town relatively easily.

Update4: After more testing, I realize I like the double-click method best. It is faster than master of upgrades and allows me to use a custom dialog, and is more intuitive for the user and conflicts less then an alt-modifier (imo). However, I still use the master of specialties method for the hero-meeting screen as I had no way to check whether the buttons added with the HD mod are being used and they could throw off what my script thought was selected.
If anyone has a way to overcome any of the limitations discussed with the double-click or master of upgrades methods it would be nice to know, if not then I am probably going to consider this feature of my mod good-enough as-is.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0585 seconds