• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Change unit ownership to npc ally and keep separate original unit upgrades

Status
Not open for further replies.
Level 1
Joined
Aug 16, 2018
Messages
3
Hi there I'm new to map making just made my first map in last few weeks.

It's team 1 vs team 2, each team has 5 human players and 1 npc (think castle fight).

Each player makes buildings, which create units every 30 sec. Change owner of last created unit to npc ally and then order unit to attack move to enemy base.

E.g. players 1-5 builds barracks, which creates footmen, change owner to player6 and retain color, atk move to enemy base.

PROBLEM
Each player has their own research center, where they can upgrade their own unit damage, armor, etc. I have been experimenting with diff ways but cannot make it so that your upgrades only affect your units when they transfer to the npc.

I think this can be solved easily with triggers but specifically the way I want to display upgrades is in the unit damage and armor section, show the little numbers increase from 0 to 1 etc.

upload_2018-8-17_10-27-8.png


Things I have tried:

A) in WE object editor upgrades section, if I set upgraded swords to apply to all units, it seems to do nothing, whether by itself or in combination with other settings.

upload_2018-8-17_10-30-55.png


B) if I set transfer with unit ownership to TRUE, then it applies the upgrade for other player's units that get transferred as well e.g. player 2's swordsmen will benefit from player1's upgraded swords as well. I want separate upgrades where your upgrades only benefit your own transferred units.

C) I tried looking in gameplay constants but I did not see anything related to share ally or global upgrades.

D) I previously had 1 npc for each human player and this way worked (think Survival Chaos) but it was really ugly with 10 extra npcs and I wanted to try combine them.

E) It's not hard to trigger this based on abilities e.g. item attack bonus level 1,2,3 etc and then add a buff showing the upgrade level, but ideally I would like to display the upgrades with the little 0s and 1s next to the sword and armor icon.

F) Currently the units are not being transferred, they stay under original owner but I made the units uncontrollable with ward classification and added an atk move override trigger, if human player tries to order them. The problem with this method is unit lag (if human player 'owns' too many units). The problem with the atk move override trigger is that it is making unit AI behave weirdly for things like autocast spells.

I am all ears for other methods but the main condition I am trying to retain is that it displays with the 0s and 1s in the unit card. However I understand there are more limitations with researches than abilities so if it's impossible I will probably end up going for E).

After solving this problem my next challenge will be getting the bounty to go to the correct player but that is another day e.g. player6 red color swordsman kills a unit, give bounty for killed unit to the original owner (player1)


Thank you for reading and thank you in advance! :)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,016
I do not think you can preferentially apply upgrades to some units and not others if they're all owned by the same player. Such is the nature of upgrades.

1 NPC ally per player is your best option imo. You could change all the NPC for 1 team to have the same color or change color of 2 npc's units to match the 3rd so it would look better in-game. But I think the AI will be wonky unless you have the computer slotted in during team select (you would see them in the pre-game lobby).
 
Level 1
Joined
Aug 16, 2018
Messages
3
Thank you Pyrogasm. I previously had that system but it was not very elegant (in the lobby having 10 extra npcs is ugly looking).

In the end I changed the gameplay so that players 1-5 share upgrades and all contribute to player 6 upgrades instead

Thank you
 
Level 12
Joined
Nov 3, 2013
Messages
989
I remember that @WaterKnight has shown in a thread somewhere how you can make upgrades for individual units somehow, iirc it had something to do with chaos/berserker upgrade ability or something. Though I can't seem to find it...


Anyway,
F) Currently the units are not being transferred, they stay under original owner but I made the units uncontrollable with ward classification and added an atk move override trigger, if human player tries to order them. The problem with this method is unit lag (if human player 'owns' too many units). The problem with the atk move override trigger is that it is making unit AI behave weirdly for things like autocast spells.
Won't this problem be even worse if you transfer the units to a single computer player? Since the cap is something like 100 units per player or whatever, if you have 5 players, you can have 500+ units in total, but if all 5 players' units are transferred to the same owner then 5 players will have to make do with a total of 100+ units before the unit pathing breaks.


F) Currently the units are not being transferred, they stay under original owner but I made the units uncontrollable with ward classification and added an atk move override trigger, if human player tries to order them.
The problem with the atk move override trigger is that it is making unit AI behave weirdly for things like autocast spells.

I'm not sure if this has been added yet, but at least you should be able to make it work soon if not already, Producer Update: Natives List

JASS:
function UnitDisableControl takes unit u boolean flag returns nothing
        //toggles whether a unit responds to player commands on or off. Can still respond to trigger commands.


And now with 24 player slots + neutrals, giving each player a computer AI player to control the units would work as well (this way the units will use most active abilities by the AI, which won't happen if they're player owned), though it gets a bit ugly with all the different colors tbh.

You can change the teamcolor on units, but they'll still show their original color on the minimap, which is unfortunate, because otherwise you could make it look like the units are all owned by the same player or their respective human player.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
I remember that @WaterKnight has shown in a thread somewhere how you can make upgrades for individual units somehow, iirc it had something to do with chaos/berserker upgrade ability or something. Though I can't seem to find it...
Ah that would do it. If you chaos morph a unit it retains certain stat bonuses it had before being chaos'd. For example heroes get permanently increased attack damage and armor from any bonuses active when you chaos morph. Presumably WaterKnight found a way to entangle that with unit upgrades. The thing with that is even if you managed to get the stats right it wouldn't show the upgrade number properly on the command card. You would see something like 2 footmen at upgrade level 3 with different attack values because one of their owners was actually at attack upgrade 5.

After solving this problem my next challenge will be getting the bounty to go to the correct player but that is another day e.g. player6 red color swordsman kills a unit, give bounty for killed unit to the original owner (player1)
Save the player that 'owns' the unit in a hashtable under a key of the unit itself when the unit is transferred to AI control, then load this information on unit death and flush its part of the hashtable to avoid unnecessary data storage. Option 2: put each spawned unit into a unit group to indicate who the 'owner' is (1 group per player), then check which group the killing unit is in; remove dead units from the groups.
 
Level 1
Joined
Aug 16, 2018
Messages
3
Thanks so much guys really good info :)

Originally I had 1 extra npc for each human slot and it worked well but the players complained the lobby was ugly and the minimap as u said. I even changed the name and color to mirror the human player.

I set unit cap of each side to 200 and it does not have any performance issues. Only sec of delay is when the periodic atk move reminder triggers but that is not very often.

In the end I made it a shared team research system so everyone can pitch in to upgrade player 6 and massively increased the upgrade costs. Simpler but maybe actually better for gameplay in the long term.

The units retain color but name is that of player 6.

The bounty is sent to prev owner with hash table.

Thanks so much!
 
Level 12
Joined
Nov 3, 2013
Messages
989
I am not 100% sure on that buy:
I believe you can have NPC players without adding them in the map settings.
Try changing ownership of units to NPC players that are not pre-set up.

They won't have any computer AI though, so they won't cast any spells without triggers (unless they're autocast abilities like bloodlust with auto-cast enabled).

Though at the same time there's some computer AI quirks that might be unwanted as well (like call for help & units focusing any unit that attack friendly hero)
 
Level 15
Joined
Aug 14, 2007
Messages
936
@Synegg regarding your first issue, I got a trick, you can first remove the converted unit and create another one of the same type which is now owned by the controlling player. This is a trick but it will also remove the upgrades that is carried over. Which means the footman or whatever will be entirely a new footman created for the controlling player.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,016
That doesn't really seem relevant or useful here. The OP wants multiple different upgrade levels for units owned by the same player, and what you suggested could only achieve <any upgrade level> + <upgrade level 0> for the same player.
 
Level 15
Joined
Aug 14, 2007
Messages
936
@Pyrogasm
Sorry I guess I was really drunk yesterday night, since you clear things up I suggest a system that I used for "Peasant Wars" map in the past. I used item ability "Item Damage Bonus" and added them to the unit, you should also change it to a unit ability, make sure you set levels to something like level 50, do not try to exceed 100 as the editor has problems loading that kind of numbers.
Once you are done, it should be fairly easy to do the rest through trigger editor, however there won't be cool numbers beside the attack icon though, your choice.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,016
Once you are done, it should be fairly easy to do the rest through trigger editor, however there won't be cool numbers beside the attack icon though, your choice.
In the OP's first post:
this can be solved easily with triggers but specifically the way I want to display upgrades is in the unit damage and armor section, show the little numbers increase from 0 to 1 etc.
 
Level 15
Joined
Aug 14, 2007
Messages
936
Since now I am briefed well on the situation at hand, again you might want to try not mess with the change of player units and focus on the system you are using right now, that when a change of player unit occurs you might want to use 2 player handlers for one player, for example for player 1 you might want to use player 2 and player 3 as your troop upgrades so that you have two different kinds of upgrade, but try not to use charm from dark ranger since you don't want complications to start appearing in this system. That said, with this method the maximum number of players available in game will be limited and not 24.
 
Last edited:
Status
Not open for further replies.
Top