• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

hero id in condistions

Status
Not open for further replies.
Level 5
Joined
Jan 19, 2020
Messages
102
i want for my save load the hero id in condistions

for example

Player - Player 1 (Red) types a chat message containing -save as An exact match

Conditions
(matching unit) Equal to hf00

but i can only select a hero on the map

actually i need it in actions to get it work

like

Actions
Custom script: if (matching unit) Equal to hf00 then
Custom script: if (matching unit) Equal to hrif then
....
save Trigger
Custom script: endif
 
Last edited:
That would be

  • Custom Script: if GetUnitTypeId(GetFilterUnit()) == 'hf00' then
GetFilterUnit would be (matching unit) in GUI, and GetUnitTypeId is a function that returns the unit's type id (rawcode). This type id is always understood to be an integer, so must be enclosed with ' ' quotes.

For example, a peasant's type of is "hpea" and GetUnitTypeId will return "hpea" for the peasant.
 
Level 39
Joined
Feb 27, 2007
Messages
5,031
Matching unit does not work here; it only works for "pick units in <group> matching <condition where matching unit works>". Why do you want these filters/conditions to be in JASS custom scripts? You can do a unit-type comparison in GUI just fine.
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
Matching unit does not make sense here, you should rather use Entered chat string since you are referring to a player chat event. Your trigger should look like this :

Player - Player 1 (Red) types a chat message containing -save as A substring

If Substring(Entered chat string, 7, 11) Equal to hf00

Save trigger.
 
Level 5
Joined
Jan 19, 2020
Messages
102
i just need a trigger that will test if the player who types save, has the hero.

and i got a trigger for save, and need to add this somehow.
 
Level 6
Joined
Dec 31, 2017
Messages
138
Straightforward solution would be
  • Set TempGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Footman) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
  • Unit Group - Pick every unit in TempGroup and do (Actions)
    • Loop - Actions
Or
  • Set TempGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Footman) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (TempGroup is empty) Equal to False
    • Then - Actions
    • Else - Actions
But selecting all units in playable map area isn't recommended.

But you can have a global group you add all units of interest to.
For example:
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • (Unit-type of (Trained unit)) Equal to Footman
  • Actions
    • Unit Group - Add (Trained unit) to TempGroup
 
Last edited:
Level 5
Joined
Jan 19, 2020
Messages
102
guess 2nd would work best, because they also can load them, and another thing is, the units are not placed at the map, so a function for hero selecting on map is not that good, thats why i would need a function with hero id, but 2nd option should work i guess.
 
Status
Not open for further replies.
Top