• 🏆 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!

Detachments System

Status
Not open for further replies.
Level 13
Joined
Dec 3, 2005
Messages
501
Hello there! Was wondering if there's an easy way to do two things to improve this system:

First, A way to know how many units are in each detachments, perhaps like an item the leader has that goes up when you recruit units or goes down when soldiers in the detachments die.

Second, to add a secondary selection circle to all the soldiers when you select the leader of the detachment.

The creator of this system has been long since gone, I've tried reaching out to them.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I'm not too familiar with this type of Jass code using Structs and other systems, but it looks like you can create a new method under the Leader Struct which loops over the units of the Leader's squad:
vJASS:
        method DoSomethingToTheSoldiers takes nothing returns nothing
            local Soldier soldier = .first //Starting for first soldier in the list
            loop
                exitwhen soldier == 0 //When hitting the end of the list, the loop finishes

                // Put code here for interacting with the soldier
                // Put code here for interacting with the soldier
                // Put code here for interacting with the soldier

                set soldier = soldier.next
            endloop
        endmethod
Look at the method iterate1 for an example of this in action.

This appears to be the variable to get how many units are in a leader's squad:
vJASS:
integer memberCount = 0
Here's an example of displaying this number to Player 1 in a text message, I didn't test it but I think this works:
vJASS:
call DisplayTextToForce(GetForceOfPlayer(Player(0)), I2S(.memberCount))
For your Item idea, you can probably find a method that runs when a unit is added to a Leader's squad, and adjust the Item's charges then. Keep an eye out for the memberCount variable since you know wherever it's getting increased/decreased would probably be a good place to adjust the Item Charges.

The Special Effects for the selection circles could be created in the above loop as well, although you'll need to store them somehow so that you can Destroy them later on, like when the units become unselected or die. There is a method called death which I imagine is where you would want to get rid of them if they die.

So I would read through the code and try to find the important methods for when a unit gets added/removed from a squad, those would most likely be where you want to inject your new code for the Item Charges and Special Effects.
 
Last edited:
Status
Not open for further replies.
Top