• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Need Info] Hero Mod

Status
Not open for further replies.
Level 2
Joined
Apr 9, 2012
Messages
23
So i'm looking to make a hero mod and I need a bit of advice. The design intention is adding a single hero of appropriate race to each player at the beginning of the game. The Hero has 20 levels, is resurrectable at the main structure ie Nexus/Hive etc. There will be no items. Now here is where it gets complicated.

I want to create a unit tree for the hero, one that will transfer abilities at the point filled level between units. You get 1 point to spend per level. For example Terran,

at level 1 you get a basic passive ability with no points to spend

at level 2 you get a point to spend and have 2 abilities, each with 3 levels, to spend points on, this continues until you hit level 5

at level 5 you choose between Marauder and Firebat and your hero transforms into that including the attack of the new unit, you also get 2 new abilities, but you keep your abilities from the previous form, and you keep the amount of points spent on abilities where they were.

at level 10 you choose between 1 of 3 units and keep all the previous abilities and points spent in those abilities.

The underlined part is the area i'm having trouble. I can follow guides to create heros and I can follow transformation guides but when transforming the Hero inevitably looses points spent. How do I carry them over?

it willl go
Marine-At level 5 choose Marauder or Firebat
Marauder- At level 10 choose Reaper or Ghost or Medic
Firebat- At level 10 choose Hellbat or Viking or Goliath

Level 1 has a base ability.
Level 2 gives 2 Marine abilities, each with 3 levels
Level 5 gives 2 abilities dependent on unit choice, each with 3 levels.
Level 10 gives 2 abilities dependent on unit choice, each with 3 levels.
Level 15 gies 1 ability dependent on unit choice, with only 1 level (ultimate).
So by level 20 you have all levels of all abilities for the unit tree you chose, but keeping the points spent is where i'm very confused.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The underlined part is the area i'm having trouble. I can follow guides to create heros and I can follow transformation guides but when transforming the Hero inevitably looses points spent. How do I carry them over?
Sample them, store them in variables, do the replacement, restore them. There should ne natives to measure ability level and amount of unspent points. The biggest problem is that abilities that are unlearnt and that are just learnt both report as level 0. Easiest solution is to store them as they learnt them.
 
Level 2
Joined
Apr 9, 2012
Messages
23
Sample them, store them in variables, do the replacement, restore them. There should ne natives to measure ability level and amount of unspent points. The biggest problem is that abilities that are unlearnt and that are just learnt both report as level 0. Easiest solution is to store them as they learnt them.

I've used triggers and variables with warcraft 3 so I understand the concept, but what do you mean about them being reported at level 0?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The first level of an ability you learn is actually level 0. It basically runs in index space from 0 to N-1 where N is the maximum level. This is logical because the level fields in the ability entry in the ability catalog are XML arrays which run using index space (first element is index 0).

However this causes a problem when it comes to detect if an ability is learnt. If it is unlearnt it will report as level 0 and if it has just been learnt it will also report back as level 0. Obviously above level 0 this is not a problem but at level 0 you have two possible states. This applies to non-hero abilities as well meaning that you cannot detect if a unit has a certain ability just by testing its level as it will report level 0 independent of if it has an ability or not however there are other ways to do such a test (I think you can enumerate a list of abilities a unit has).

The solution I used before was to detect if the ability was usable since unlearnt abilities are not usable. However I am not sure if this will always produce perfect results (eg if the unit was stunned at the time or if the ability is in cooldown).

In WC3 this was never a problem as unlearnt abilities reported as level 0 while learnt abilities started at level 1 and ran to N where N is the maximum level. I do not mind the swap to index space but they could have at least made the function return -1 (does not have) in the case of the unit not having the ability.
 
Level 2
Joined
Apr 9, 2012
Messages
23
The first level of an ability you learn is actually level 0. It basically runs in index space from 0 to N-1 where N is the maximum level. This is logical because the level fields in the ability entry in the ability catalog are XML arrays which run using index space (first element is index 0).

However this causes a problem when it comes to detect if an ability is learnt. If it is unlearnt it will report as level 0 and if it has just been learnt it will also report back as level 0. Obviously above level 0 this is not a problem but at level 0 you have two possible states. This applies to non-hero abilities as well meaning that you cannot detect if a unit has a certain ability just by testing its level as it will report level 0 independent of if it has an ability or not however there are other ways to do such a test (I think you can enumerate a list of abilities a unit has).

The solution I used before was to detect if the ability was usable since unlearnt abilities are not usable. However I am not sure if this will always produce perfect results (eg if the unit was stunned at the time or if the ability is in cooldown).

In WC3 this was never a problem as unlearnt abilities reported as level 0 while learnt abilities started at level 1 and ran to N where N is the maximum level. I do not mind the swap to index space but they could have at least made the function return -1 (does not have) in the case of the unit not having the ability.

so what your saying is that when a hero learns an ability on the back end it will be reported at level-1? IE level 2 shows as level 1 in the back end and level 1 shows as level 0 but 0 is also shown for unlearnt abilities? If thats the case why don't I make 4 ranks of an ability have a trigger that will auto advance a rank with the 1st rank learned then shut itself off, or; set each ability up with a trigger to auto advance its own integer variable when a rank is learned and just have the level report back as rank level -1? which would be easier?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
so what your saying is that when a hero learns an ability on the back end it will be reported at level-1? IE level 2 shows as level 1 in the back end and level 1 shows as level 0 but 0 is also shown for unlearnt abilities? If thats the case why don't I make 4 ranks of an ability have a trigger that will auto advance a rank with the 1st rank learned then shut itself off, or; set each ability up with a trigger to auto advance its own integer variable when a rank is learned and just have the level report back as rank level -1? which would be easier?
I am sure there is an easier way around this problem. Just I do not know of it.
 
Status
Not open for further replies.
Top