Power army script

Official forum of the Wake of Gods mod to Heroes of Might and Magic III.

Moderator: Moderators

Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

Power army script

Postby Pollo2002 » May 17 2006, 6:40

I'm also building a script where a player can see the power of his army in gold and see also the power of an enemy hero possiblites bases on few , pack, etc.

It's very hard, First i should recognize that i'm clicking on enemy hero, it would be welcome a Mz reciever but for heroes.
it's also hard to make it trigger since there is no trigger for when you click on an enemy hero.
Maybe i should use the P command on the CM reciever , but it says in comment that it only works for items 1 and 37 and i don't know what that mean.And even if i recognize the place on the adventure map, i wouldn't know how to check if there is a hero or not.
Ideas welcome.
Making the script to check the power of one's player hero seems easy or but to check on an enemy heroes, seems impossible with the actual recievers.

User avatar
Fnord
Round Table Knight
Round Table Knight
Posts: 341
Joined: 27 Nov 2005
Location: Victoria, BC, Canada

Postby Fnord » May 17 2006, 21:08

1 and 37 are the adventure map and the mini map.

Check out the Enhanced Mysticism script for some ideas on how to check a hero with a click on the adventure map.

I haven't studied it myself, but in general, I think you could check the object type at the click location (OB:T command). The problem is that heroes are a little bit "special" so sometimes they don't show up when checked for and you get the information about the object underneath instead.

A way around this problem is to cycle through all heroes with a DO loop, checking the hero's position with HE:P and if the hero's owned (thus, alive) and its x/y/l position matches the x/y/l of the location clicked, that's your hero. The only place that might not work quite as well is in a town because its possible to have both a visiting and garrison hero there, so you would need to use the appropriate CA receiver to check this.

Looping through all heroes may sound slow but it's actually quite fast and should have no noticeable delay when used in this fashion.
- Fnord

Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

Postby Pollo2002 » May 18 2006, 8:56

thanks to comparing with the mysticism script, plus using some of the script and strings i finished my power script, but it has one problem that i couldn't identify, it doesn't work if i right click on the active hero, i don't know the reason :S if you find it , please tell me
PD:if you are going to use this script i suggest to remove Script 35 of your data folder if you have it there because i used the same FU numbers, but you can use them both at the same time if you want if you change my script fu number for others not claimed i think, i didn't test it

Edited: i found something really funny and strange if i alt-tab and come back to the game i can trigger the script with clicking with the current hero on itself and works perfectly, but it stops working if i change hero until the next alt-tab LOL
ZVSE
!?CM;
!!IF:V10/0;

!!IF&-1000:V10/1; (check if it's AI)
!!CM:I?y1;
!!IF&y1<>37:V10/1; (Check if clicked on Adventure Map)
!!CM&-10:P?v4/?v5/?v6; (Get location)
!!VRy52&-10:S-1; (assume no hero)
!!OW&-10:A-1/?y52; (get current Hero)
!!IF&-10/y52<0:V10/1; (abort if no current hero)

!!OBv4/v5/v6&-10:T?y55;
!!IF&-10/y55<>34:V10/1;(abort if not hero)

!!HEv4/v5/v6&-10:N?v1; (Get Hero nr)
!!HEv1&-10:O?y8;
!!HEy52&-10:O?y9;
!!IF&-10/y8=-1:V10/1; (check color of hero, abort if unowned )

!!HEy52&-10:B0/?z1; (Get Hero name)
!!HEv1&-10:B0/?z2; (Get Hero name)

!!VRv2&-10:S0; (setting to 0 the hero's slots occupied)

!!DO8158/0/6/1&-10:P; (count number of creatures slots occupied)

!!FU8159&-10/v2>0/y8<>y9:P;
!!FU8167&-10/v2>0/y8=y9:P;

!?FU8159; (Check creature slots)
!!VRz5:S^ ^; (initialize empty variable)
!!VRv114:S0;
!!VRv115:S0;
!!DO8164/0/6/1:P;
!!VRy-2:Sv114;
!!VRy-3:Sv115;
!!VRz-1:S^%Z2's army power is:^+^%Y-2^+^-^+^%Y-3^;
!!IF:L-1;
!!IF:V10/0;

!?FU8164; (Check which creatures)
!!HEv1&-10:C0/x16/?y1/?y10; (check slot x16 for creatures)
!!MA&y10>0:Cy1/6/?y17;
!!VRy15&y10=0:S0;
!!VRy15&y10>0/y10<5:S1;
!!VRy15&y10>4/y10<10:S5;
!!VRy15&y10>9/y10<20:S10;
!!VRy15&y10>19/y10<50:S20;
!!VRy15&y10>49/y10<100:S50;
!!VRy15&y10>99/y10<250:S100;
!!VRy15&y10>249/y10<500:S250;
!!VRy15&y10>499/y10<1000:S500;
!!VRy15&y10>999:S1000;

!!VRy16&y15=0:S0;
!!VRy16&y15=1:S4;
!!VRy16&y15=5:S9;
!!VRy16&y15=10:S19;
!!VRy16&y15=20:S49;
!!VRy16&y15=50:S99;
!!VRy16&y15=100:S249;
!!VRy16&y15=250:S499;
!!VRy16&y15=500:S999;
!!VRy16&y15=1000:S1999;

!!VRv112:S0;
!!VRv113:S0;
!!VRv112:Sy15 *y17; Get minimum power
!!VRv113:Sy16 *y17; Get maximum power

!!VRv114:Sv114 +v112;
!!VRv115:Sv115 +v113;
!!VRy10:S0;

!?FU8167;
!!VRz5:Sz135170; (initialize empty variable)
!!VRv112:S0;
!!VRv117:S0;
!!DO8169/0/6/1:P;
!!VRy-4:Sv117;
!!VRz-1:S^%Z2's army power is:^+^%Y-4^;
!!IF:L-1;
!!IF:V10/0;

!?FU8169;
!!HEv1&-10:C0/x16/?y1/?y10; (check slot x16 for creatures)
!!MA&y10>0:Cy1/6/?y17;

!!VRv112:S0;
!!VRv112:Sy10 *y17; Get Power

!!VRv117:Sv117 +v112;
!!VRy10:S0;


!?FU8158; (check number of creatures sacks)
!!HEv1:C0/x16/d0/?y1;
!!VRv2&y1>0:+1; (add 1 if stack is occupied)

Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

Postby Pollo2002 » May 18 2006, 10:04

I did some why that one can alter the script if you want it only to run with CTRL+Left click
you should replace everthing above
!!IF:V10/0;

With

ZVSE
!?CM5;
!!CM:F?y19;
!!FU&y19<>4:E;
!!IF:V12/0;
!!FU8228&11:P;
!!FU&12:E;
!!IF:V11/1;
!!CM:R0;

and now you will need the function 8228 wich is

!?FU8228&11;
!!IF:V11/0;
!!IF:V12/1;

The reason of the complicated flag thing i did with flags 11 and 12 where because the ctrl click was triggering the script twice and i needed to make it to trigger once.

User avatar
Fnord
Round Table Knight
Round Table Knight
Posts: 341
Joined: 27 Nov 2005
Location: Victoria, BC, Canada

Postby Fnord » May 19 2006, 17:58

Pollo2002 wrote:The reason of the complicated flag thing i did with flags 11 and 12 where because the ctrl click was triggering the script twice and i needed to make it to trigger once.


The reason this happens is that there's a mouse-click and a mouse-click-release. You can check the subtype of the click with CM:S to check for this and then exit (with a FU:E command) if it's not type 12.
- Fnord


Return to “Wake of Gods”

Who is online

Users browsing this forum: No registered users and 3 guests