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 > Library of Enlightenment > Thread: New Spells Plugin, The
Thread: New Spells Plugin, The This thread is 13 pages long: 1 2 3 4 5 6 7 8 9 10 11 12 13 · «PREV / NEXT»
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted April 18, 2022 01:11 AM

Quote:
Btw, i also learn c++ to become kind of programmer, and ask advice or even help/suggestion.

The best way to learn C++ is to write things you are interested in personally. You cannot do something you really want -> you search how to do it learning new things in practice. This approach works 100% and cannot be replaced by reading any books (which is also important, of course, but your best teacher is your motivation).

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


Known Hero
posted April 18, 2022 06:47 AM
Edited by daemon_n at 06:48, 18 Apr 2022.

AlexSpl said:

The best way to learn C++ is to write things you are interested in personally. You cannot do something you really want -> you search how to do it learning new things in practice. This approach works 100% and cannot be replaced by reading any books (which is also important, of course, but your best teacher is your motivation).


Thanks! Gonna do that) anyway this is the reason i ve asked plugin sources, cause i really wanna handle with code understanding and adaptation plugin for ERA my own forces. Also my motivation is attract you to make plugins/mods for ERA , cause there we have much more modding opportunities and gameplay features than SoD has. Another words, i hope your h3 modding carrier will never end, cause i love this game so much and wanna its expansion and enhancement never end

Cheers!

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


Known Hero
posted April 18, 2022 03:37 PM

okay, downloaded the latest and found 2 issues

1st is - Captain's hat no more gives Summon Boat
2nd is - there is native ArtGiveSpell_Proc(_Hero_ *hero) at 0x4D9840, you have rewritten by UpdateSpellsFromArtifacts. Original function i ve hooked, but anyway it ll recompiled by me later, so my answer is idea is another, why not rewrite or at least expand ArtGiveSpell(_SpellsBitMask_ **a1, int a2) at 0x4D95C0, to allow any art with spell (_ArtInfo[doll_art[iSlot].id].new_spell) pass art id in order to later use not only predefined spells, cause in original there is switch for some arts with constant spell id's.
Anyway, appreciate your work!!!

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


Responsible
Supreme Hero
posted April 18, 2022 03:46 PM

Quote:
1st is - Captain's hat no more gives Summon Boat

Thanks for the info Later I will see why it is so.

Quote:
2nd is - there is native ArtGiveSpell_Proc(_Hero_ *hero) at 0x4D9840, you have rewritten by UpdateSpellsFromArtifacts. Original function i ve hooked, but anyway it ll recompiled by me later, so my answer is idea is another, why not rewrite or at least expand ArtGiveSpell(_SpellsBitMask_ **a1, int a2) at 0x4D95C0, to allow any art with spell (_ArtInfo[doll_art[iSlot].id].new_spell) pass art id in order to later use not only predefined spells, cause in original there is switch for some arts with constant spell id's.

Don't think I fully understand what you propose, but UpdateSpellsFromArtifacts had to be rewritten to work properly with the expanded array of spells. Now I store both states of spell in a single byte -

#define SPELL_MEMORIZED 1
#define SPELL_TEMPORARY 2

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


Known Hero
posted April 18, 2022 03:57 PM

I suggested also rewriting ArtGiveSpell(_SpellsBitMask_ **a1, int a2) at 0x4D95C0 to allow any artifact with a spell to give it to the hero, because the original function only has preset constant values.
For example:
    case 128:
      sub_004E67A0(&array, 26u, 1);
this is Armageddon's Blade, it only gives the spell of the same name, not ArtId.NewSpell;

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


Responsible
Supreme Hero
posted April 18, 2022 04:09 PM
Edited by AlexSpl at 16:15, 18 Apr 2022.

Quote:
it only gives the spell of the same name, not ArtId.NewSpell;

Yeah, now I see. But my task was to deal with the original game, so I didn't care about if there were non-standard artifacts introduced by mods. If you are able to/have skills to ensure compatibility with existing mods, then I'm all for it

Btw, Sea Captain's Hat gives you both Summon Boat and Scuttle Boat, it's Admiral's Hat that doesn't (seems to be an error in my function).

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


Known Hero
posted April 18, 2022 04:23 PM
Edited by daemon_n at 16:36, 18 Apr 2022.

AlexSpl said:


Btw, Sea Captain's Hat gives you both Summon Boat and Scuttle Boat, it's Admiral's Hat that doesn't (seems to be an error in my function).


ah, i see - for SoD adds both, but in ERA only scuttle.

Btw, what MSVS version you'd recommend to use? i have 2019, so it doesn't like stdafx.h

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


Responsible
Supreme Hero
posted April 18, 2022 04:35 PM
Edited by AlexSpl at 16:38, 18 Apr 2022.

I tried to stay as "classic" as possible, so it's VS2008. If you compile the plugin under newer MS VS, make sure to change pre-compiled headers to appropriate ones for your version of Visual Studio. Also note, that if you build plugins under newer versions of MS VS, you have to notify players they should have corresponding Visual C++ redistributables pre-installed. Once I couldn't understand why my plugin was not loaded on my new machine, and after almost an hour of curses I figured out that that plugin was built under MS VS 2012 and I hadn't corresponding redistributables pre-installed on my new PC. With VS2008 you can stay calm and shouldn't think about backward compatibility or prerequisites.

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


Known Hero
posted April 18, 2022 04:39 PM

AlexSpl said:
I tried to stay as "classic" as possible, so it's VS2008. If you compile the plugin under newer MS VS, make sure to change pre-compiled headers to appropriate ones for your version of Visual Studio. Also note, that if you build plugins under newer versions of MS VS, you have to notify players they should have corresponding Visual C++ redistributables pre-installed. Once I couldn't understand why my plugin was not loaded on my new machine, and after almost an hour of curses I figured out that that plugin was build under MS VS 2012 and I hadn't corresponding redistributables pre-installed on my new PC. With VS2008 you can stay calm and shouldn't think about backward compatibility or prerequisites.



for this there is "Use MFC in static library", then it adds all libraries and instructions into dll. Size is increased, yes - about +100 KB, but works well even on Win XP without any MCVCR's installed - i ve tested intentionally

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


Responsible
Supreme Hero
posted April 18, 2022 04:48 PM

Good info I used to include common libraries when programming on Delphi. But, you know, executables built with Delphi are just gigantic, so I decided to move away from such practices +100 KB is fair, I think.

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


Responsible
Supreme Hero
posted April 18, 2022 05:23 PM

For Admiral's Hat to give spells change the line #3013 to this one -

else if (o_ArtInfo[doll_art[iSlot].id].new_spell != ID_NONE)


After some extra testing I'll update the plugin to include this fix.

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


Responsible
Supreme Hero
posted April 18, 2022 05:36 PM
Edited by AlexSpl at 18:17, 18 Apr 2022.

Also I think about this one -

if (doll_art[iSlot].id == AID_SPELL_SCROLL)
{
if (doll_art[iSlot].mod < SPELLS_NUM && !spell[doll_art[iSlot].mod])
  spell[doll_art[iSlot].mod] = SPELL_TEMPORARY;
}


It seems !spell[doll_art[iSlot].mod] should be changed to spell[doll_art[iSlot].mod] != ID_NONE, as spells' ID start from 0.

So, potentially, scrolls with Summon Boat are not working currently as well, sorry. And thanks for the valuable bug report!

* * *
Updated the link in the first post.

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


Known Hero
posted April 19, 2022 09:02 AM
Edited by daemon_n at 09:03, 19 Apr 2022.

Thanks for update, fix confirmed (missed summon boat for ERA i will fix myself )

also, i found, plugin requires same name .lod file near at it's own (hd mod plugin style, where all files at the one catalog), so it doesn't allow to move files to sort of different types(mostly needed for ERA), anyway plugin checks just file names, but not resources i mean new def names and its content, so i can just create empty newspells.lod and it allows start game (btw game can't be started, if newspells.lod is not near at "newspells.dll".
if Claws.def,DeathBlow.def,GldTouch.def,HourOPow.def,Toughness.def are loaded && SpellInt.def,spells.def,SpellScr.def frames amount is >= spells amount. What do you think? Or at least notify user, that file newspells.lod is missed. I understand, that could be extra stuff, so don't mean it is necessary. I noticed the troubles, which i met, when tried plugin with ERA, but pretty sure no-one will make that, cause i will release as mod for ERA in ready to use state

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


Responsible
Supreme Hero
posted April 19, 2022 10:26 PM

Currently refactoring my code to correspond to the original classes as close as possible.

This is how the class hero looks now (thanks to void17 once again for the dump) -

class type_obscuring_object
{
public:
   short mapX;                     // 0x00
   short mapY;                     // 0x02
   short mapZ;                     // 0x04
   bool valid;                     // 0x06  
   type_point obscured_location;   // 0x08
   TAdventureObjectType type;      // 0x0C
   bool was_trigger;               // 0x10
   unsigned long extra_info;       // 0x14
                                   // 0x18
};

#pragma pack(push, 1)
class hero : public type_obscuring_object
{
public:
   short mana;                              // 0x018
   THeroID id;                              // 0x01A
   int map_editor_id;                       // 0x01E
   char playerOwner;                        // 0x022
   char name[13];                           // 0x023
   THeroClass hero_class;                   // 0x030
   unsigned char portrait;                  // 0x034
   int targetX;                             // 0x035
   int targetY;                             // 0x039
   short targetZ;                           // 0x03D
   short last_magic_school_level;           // 0x03F
   unsigned short target_distance;          // 0x041
   unsigned char target_is_critical;        // 0x043
   unsigned char patrolX;                   // 0x044
   unsigned char patrolY;                   // 0x045
   char patrolRadius;                       // 0x046
   unsigned char facing;                    // 0x047
   
   enum Formation : int {
      GroupedFormation = 1,
      PlacementFormation = 2
   };

   unsigned char formation;                 // 0x048
   int maxMobility;                         // 0x049
   int currMobility;                        // 0x04D
   int experience;                          // 0x051
   short Level;                             // 0x055
   unsigned long TrainingGroundFlags;       // 0x057
   unsigned long DefenseTowerFlags;         // 0x05B
   unsigned long GardenOfRevelationFlags;   // 0x05F
   unsigned long MercCampFlags;             // 0x063
   unsigned long PowerSchoolFlags;          // 0x067
   unsigned long TreeOfKnowledgeFlags;      // 0x06B
   unsigned long LibraryFlags;              // 0x06F
   unsigned long ArenaFlags;                // 0x073
   unsigned long MagicSchoolFlags;          // 0x077
   unsigned long WarSchoolFlags;            // 0x07B
   unsigned long UniversityFlags;           // 0x07F          
   unsigned long Shrine1Flags;              // 0x083
   unsigned long Shrine2Flags;              // 0x087
   unsigned long Shrine3Flags;              // 0x08B
   unsigned char iLevelSeed;                // 0x08F
   unsigned char lastWisdom;                // 0x090
   armyGroup heroArmy;                      // 0x091
   char SSLevel[28];                        // 0x0C9
   unsigned char SSOrder[28];               // 0x0E5                
   int numSSs;                              // 0x101
   unsigned long flags;                     // 0x105
   float turnExperienceToRVRatio;           // 0x109              
   char dWalkSpellsCast;                    // 0x10D
   TSkillMastery disguiseLevel;             // 0x10E
   TSkillMastery flightLevel;               // 0x112
   TSkillMastery waterWalkPower;            // 0x116
   char moraleBonus;                        // 0x11A
   char luckBonus;                          // 0x11B
   bool IsSleeping;                         // 0x11C
   long bounty;                             // 0x11D                              
   std::bitset<48> TownSpecialGrantedMask;  // 0x121
   TSkillMastery visionsPower;              // 0x129
   type_artifact equipped[19];              // 0x12D
   bool locked_slot[15];                    // 0x1C6
   type_artifact backpack[64];              // 0x1D4
   char backpack_count;                     // 0x3D4
   TSex sex;                                // 0x3D5                                
   bool IsBiographyCustomized;              // 0x3D9
   stdString customBiography;               // 0x3DA
   bool in_spellbook[140];                  // 0x3EA
   //bool in_spellbook[70];                 // 0x3EA
   //bool available_spells[70];             // 0x430
   char stats[4];                           // 0x476
   float aggression;                        // 0x47A
   long value_of_power;                     // 0x47E
   long value_of_duration;                  // 0x482
   long value_of_knowledge;                 // 0x486
   long value_of_spring;                    // 0x48A
   long value_of_well;                      // 0x48E
                                            // 0x492

   inline int get_spell_level(SpellID spell, int landModifier) {
      return CALL_3(int, __thiscall, 0x4E52F0, this, spell, landModifier);
   }
   inline int GetManaCost(int iWhichSpell, armyGroup* const enemy, int land_modifier) {
      return CALL_4(int, __thiscall, 0x4E54B0, this, iWhichSpell, enemy, land_modifier);
   }
   inline void UseSpell(int cost) {
      CALL_2(void, __thiscall, 0x4D9540, this, cost);
   }
   inline int GetHeroSpellBonus(SpellID spell_id, int target_level, int value) {
      return CALL_4(int, __thiscall, 0x4E6260, this, spell_id, target_level, value);
   }
   void AddSpell(int whichSpell);
   void UpdateSpellsFromArtifacts();
   int getBestMagicSchoolForSpell(SpellID spell);
   inline TAdventureObjectType get_special_terrain() {
      return CALL_1(TAdventureObjectType, __thiscall, 0x4E5210, this);
   }
};
#pragma pack(pop)


Pure beauty even already, without many methods

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


Famous Hero
posted April 20, 2022 03:39 PM

daemon_n said:


... Also my motivation is attract you to make plugins/mods for ERA , cause there we have much more modding opportunities and gameplay features than SoD has. Another words, i hope your h3 modding carrier will never end, cause i love this game so much and wanna its expansion and enhancement never end

Cheers!


Yes AlexSpl, join the ERA side!

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


Known Hero
posted April 22, 2022 02:43 PM

AlexSpl said:
Done with Golden Touch.

Quote:
non-upgrade/upgraded  

1 lvl creatures = 50/75 gold

2 lvl creature = 75/100gold

3 lvl creature = 100/200

4 lvl creature = 200/300

5 lvl creature = 300/400

6 lvl creature = 500/600

7 lvl creature = 1000/1500

I had thought that would be OP definitely, so I decided to implement another formula:

10%/10%/15%/20% of killed creature's cost in gold at None/Basic/Advanced/Expert.

NewSpells_Szaman_2.3


Big Thanks for making this spell. I very appreciate and admire your work Will test it, today..

Sorry for my week absence, caught a nasty disease and i was too ill to work/or even do some basic stuff around me... Every spring and autumn i always get very sick

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


Known Hero
posted May 08, 2022 01:02 AM
Edited by Szaman at 01:06, 08 May 2022.

@AlexSpl

If your still interested I have updated The "Hour of Power" Animations.

[gif]https://imgur.com/uZApg7m[/gif]


LINK TO THE NEW DEF.

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


Responsible
Supreme Hero
posted May 08, 2022 07:37 AM
Edited by AlexSpl at 08:29, 08 May 2022.

It would be good animation for Heroes 1. Think about the 2.5D style of most Heroes 3 spells and try to add that missing 0.5D part


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

Tavern Dweller
posted June 12, 2022 04:30 PM
Edited by sokie at 18:52, 12 Jun 2022.

Hi, I've tried to compile the source code myself and the game crashes when I try to use a spell, if I use dll from first thread everything works.
I've had to find `homm3.h` and `patcher_x86_commented.hpp` and add it since I didn't have them, so maybe they are not compatible.
I'm attaching the debug dll here and my source with included headers maybe someone can help me and check?
The hero struct seems to be wrong, but I'm not sure if it has to do with struct alignment?

[url=https://www38.zippyshare.com/v/kBt0fy6u/file.html]newspells_debug[/url]
[url=https://www6.zippyshare.com/v/DPN2mztZ/file.html]newspells_sourcecode[/url]

EDIT: NVM, struct packing was the issue, compile with /Zp1 and it will work

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


Responsible
Supreme Hero
posted June 12, 2022 08:58 PM
Edited by AlexSpl at 21:02, 12 Jun 2022.

homm3.h is actually a very old version of a HotA header which uses

#define NOALIGN __declspec(align(1))

to align structure members. And this doesn't do its job, so you have to manually set Struct Member Alignment to "1 Byte (/Zp1)" in your project properties.

My latest solution uses #pragma pack() directives to keep correct structure member alignments and introduces a new header HoMM3API.h* with some original classes instead of guessed ones from homm3.h, but you still have to compile it with /Zp1, as it uses some parts of legacy code from homm3.h.

*) Note, that HoMM3API.h's purpose, as of now, is solely to provide original class names and methods for the New Spells plugin, and I haven't checked for errors those classes which aren't used by my plugin yet. In other words, feel free to use fields and methods of hero and army classes to modify spells, but don't believe much to other classes and use them with caution.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 13 pages long: 1 2 3 4 5 6 7 8 9 10 11 12 13 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0930 seconds