Hey, everyone. Just started dabbling with SC2 Map Editing today, and had fair progress, but I got stuck in a small problem:
I need to get the Game Link - Effect of an unit's base attack (and if possible, of any other ability, etc.) It's something that must be done automatically, because it can be any unit, so it's no use just choosing the correct effect for it. You think this would be possible? How would I do it?
PS. I did use the search function, so sorry if that was already posted. The keywords I used were yielding a lot of unrelated results, found nothing of this.
Just to clear up,
In CatalogFieldValueGet() The first parameter is the data type to look in, the second is unit, or effect or whatever, the third is what field in that to look in. So for getting the damage effect from a weapon from a unit would be:
CatalogFieldValueGet(Weapons,(string to game link(CatalogFieldValueGet(Unit,Convert Game link to string(yourunittype), weapon))),damadge effect)
NOTE: There is no "string to game link" function, but the string is a game link, so entering the string as custom script works.
Thanks a lot, guys. This helped me progress, but I'm still stuck. While I (think) I've got the correct field path for Weapon (WeaponArray[0]) I can't find the field path for Damage Effect.
I think I got as close as I could, but I get a Syntax Error at the line where it tries to do
Effect2=EffectString
I'm pretty sure that's because the Effect2 is a GameLink-Effect variable, and EffectString is a String variable, and it won't convert. I just need to know how to convert it...
You could try to create a custom function to convert a game link to a string using custom script, like this:
New Function, called String to Gamelink
For this function:
Return type Game Link
New parameter, type String called InputString
New action, type Custom Script
Enter this line of code for the custom script:
returnlp_inputString;
Now you should be able to convert the string to a game link using this function.
its just a theory, though, I didn't test it.
There might even be pre-made conversion functions.
Got it right, now, removed "effect2" altogether and put "return StringToGameLink(effectString);" as the last action of the function. But I still can't get the effect.. Something's not right with one of the "CatalogFieldValueGet" functions...
I attached my example map. It contains a trigger, which reads the marine weapon's damage effect and saves it in a string variable. Then it is converted to a game link, which is then compared to the correct damage effect.
This part is working, now. My problem seems to be with getting WeaponUnitValue = CatalogFieldValueGet(Units, Unit To String(InputUnit), "WeaponArray[0]", Any Player) <String> to work... Unit To String takes a Unit and gives back a string based on it's UnitType. But ingame I get an error saying that "entry" wasn't found in the CatalogFieldValueGet, so there's something going wrong in that Unit To String
Just like the String to GameLink you provided, but with different value types.
Return type String
New parameter, type Unit called InputUnit
New Local Variable called Type = (Unit type of InputUnit) <Unit Type>
New action, type Custom Script (return lv_type;)
I think my version of the SC2 Editor is either bugged or outdated. It's 1.4.1, and I can't get Convert Game Link to String to work... When I check the generated code for the triggers, the function is empty. It's just a pair of parenthesis with the parameter in the middle, without calling the function before...
I think my version of the SC2 Editor is either bugged or outdated. It's 1.4.1, and I can't get Convert Game Link to String to work... When I check the generated code for the triggers, the function is empty. It's just a pair of parenthesis with the parameter in the middle, without calling the function before...
Well, script-wise Convert Game Link to String does nothing at all (since game links are just strings in script), so essentially, this is correct.
Okay, let me go through my findings:
StringToText(UnitToString(inputUnitB)) works. I set it to send a chat message, and I received the unit in question.
SetVariable(effectString, (CatalogFieldValueGet(c_gameCatalogWeapon, weaponUnitValue, "DisplayEffect", c_playerAny))) doesn't seem to work, though. When set to send a message, it says "no text found in parameter"...
Whats your weaponUnitValue? You currently try to access the weapons catalog, which will obviously result in errors, if your weaponUnitValue holds a unit's id.
Hey, I just found the solution. I used UnitWeaponGet instead of the catalog, and it worked wonders. I can get any unit's weapon now. Had to create a "WeaponToString" function though. I'll post the map when I'm done with it :D
Thanks a lot!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey, everyone. Just started dabbling with SC2 Map Editing today, and had fair progress, but I got stuck in a small problem: I need to get the Game Link - Effect of an unit's base attack (and if possible, of any other ability, etc.) It's something that must be done automatically, because it can be any unit, so it's no use just choosing the correct effect for it. You think this would be possible? How would I do it?
PS. I did use the search function, so sorry if that was already posted. The keywords I used were yielding a lot of unrelated results, found nothing of this.
Try CatalogFieldValueGet(). To learn, how to use it, search the forums.
@Kiloku: Go
Welcome to mapster.
Just to clear up, In CatalogFieldValueGet() The first parameter is the data type to look in, the second is unit, or effect or whatever, the third is what field in that to look in. So for getting the damage effect from a weapon from a unit would be:
CatalogFieldValueGet(Weapons,(string to game link(CatalogFieldValueGet(Unit,Convert Game link to string(yourunittype), weapon))),damadge effect)
NOTE: There is no "string to game link" function, but the string is a game link, so entering the string as custom script works.
Thanks a lot, guys. This helped me progress, but I'm still stuck. While I (think) I've got the correct field path for Weapon (WeaponArray[0]) I can't find the field path for Damage Effect.
@Kiloku: Go
Use table veiw on set to display raw data. So under weaponn, the UI: CWeapon_DisplayEffect is the correct field, so for the trigger put DisplayEffect
I think I got as close as I could, but I get a Syntax Error at the line where it tries to do
I'm pretty sure that's because the Effect2 is a GameLink-Effect variable, and EffectString is a String variable, and it won't convert. I just need to know how to convert it...
You could try to create a custom function to convert a game link to a string using custom script, like this:
New Function, called String to Gamelink
For this function:
Return type Game Link
New parameter, type String called InputString
New action, type Custom Script
Enter this line of code for the custom script:
Now you should be able to convert the string to a game link using this function.
its just a theory, though, I didn't test it.
There might even be pre-made conversion functions.
@Kueken531: Go
Didn't work. Syntax error when doing lv_effect2 = StringToGameLink(effectString);
And I searched, looks like there's only for GameLink to String, but not the inverse...
Let me try, maybe I did feed you false information ;)
€ It seems to work for me.
Did you do exactly, what I wrote? Note, that the InputString really translates into lp_inputString with a lower case i, I didn't typo it.
Also, the function should be available in Gui, no need to mess with galaxy script after you created it.
Got it right, now, removed "effect2" altogether and put "return StringToGameLink(effectString);" as the last action of the function. But I still can't get the effect.. Something's not right with one of the "CatalogFieldValueGet" functions...
I attached my example map. It contains a trigger, which reads the marine weapon's damage effect and saves it in a string variable. Then it is converted to a game link, which is then compared to the correct damage effect.
This part is working, now. My problem seems to be with getting WeaponUnitValue = CatalogFieldValueGet(Units, Unit To String(InputUnit), "WeaponArray[0]", Any Player) <String> to work... Unit To String takes a Unit and gives back a string based on it's UnitType. But ingame I get an error saying that "entry" wasn't found in the CatalogFieldValueGet, so there's something going wrong in that Unit To String
How does your Unit To String function look like? There is no native function called like this, so I assume you did build that one yourself?
Just like the String to GameLink you provided, but with different value types.
Return type String
New parameter, type Unit called InputUnit
New Local Variable called Type = (Unit type of InputUnit) <Unit Type>
New action, type Custom Script (return lv_type;)
For this, you could also use the native Convert Game Link to String function you mentioned earlier.
But, your function should work in theory, and it does work for me.
Try to print the return of the Unit to String call.
I think my version of the SC2 Editor is either bugged or outdated. It's 1.4.1, and I can't get Convert Game Link to String to work... When I check the generated code for the triggers, the function is empty. It's just a pair of parenthesis with the parameter in the middle, without calling the function before...
Well, script-wise Convert Game Link to String does nothing at all (since game links are just strings in script), so essentially, this is correct.
Okay, let me go through my findings: StringToText(UnitToString(inputUnitB)) works. I set it to send a chat message, and I received the unit in question.
SetVariable(effectString, (CatalogFieldValueGet(c_gameCatalogWeapon, weaponUnitValue, "DisplayEffect", c_playerAny))) doesn't seem to work, though. When set to send a message, it says "no text found in parameter"...
Whats your weaponUnitValue? You currently try to access the weapons catalog, which will obviously result in errors, if your weaponUnitValue holds a unit's id.
Hey, I just found the solution. I used UnitWeaponGet instead of the catalog, and it worked wonders. I can get any unit's weapon now. Had to create a "WeaponToString" function though. I'll post the map when I'm done with it :D Thanks a lot!