I'm trying to make an ability that requires keeping track of the unit types of units that die near the caster. After a few minutes the key would be erased. The end result would be that you choose a unit type that died near the caster within the past 60 seconds via a dynamically generated dialog box and the rest of the ability depends on what you choose.
The code would look something like this:
Event: Unit Dies
Store string name of unit type in section __ of bank _____
wait ___ seconds
Remove string *name of unit type* from bank ____
edit: A better implementation would probably be to store the elapsed time that each unit died but the iterating question stands.
The problem is that a quick look at the trigger editor didn't tell me how to iterate through a bank section when I want to load all those unit types, make a dialog box of them and do something based on which one you choose.
I suppose I might be able to do this with linked lists. If so can someone recommend a linked list implementation? Also if I need to do this with linked lists, how would you define a struct and make a linked list of such structs?
I would use a data table instead and a for each integer loop between1 and Number Of Data Table Values. You can then use Name Of Data Table Value to compare or just link them directly into your UI element.
Also your current trigger structure would not reset if a unit of the same type dies just before the 60 seconds timer ends. You probably need to use some kind of integer variable timer that you can reset for each unit type.
That way you could use integer data table values as both the timer and unit type by storing the time remaining as the integer and the unit type+player as the name of the value.
Is there a function to get the elapsed time since the map started? I see a few different time functions built in and am not sure which one is the one I want.
edit: I have another problem. I already use the global and local data tables for some spear of adun code I copied from single player. Would looping through the data table conflict with that?
The Time Elapsed event can do that but I would just use a Periodic Event.
If you have an If Then Else action you can be more selective as to which data table values you modify. This would conflict with using the loop index directly for your UI element. This can be overcome by having a separate variable for the UI that is modified to be +1 each time it finds a valid name. I would suggest for the name you add a prefix so that a Substring function can identify it. You then have a second If Then Else action that checks is the integer value is >1 and based on that sets a local variable to the value minus one and then saves it again or uses Remove Data Table Value to delete what would be 0.
Under this branch you also would add your UI stuff. If the value is >1 you set the UI element and add +1 to the UI variable while if it is deleted you do nothing.
Rollback Post to RevisionRollBack
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
I'm trying to make an ability that requires keeping track of the unit types of units that die near the caster. After a few minutes the key would be erased. The end result would be that you choose a unit type that died near the caster within the past 60 seconds via a dynamically generated dialog box and the rest of the ability depends on what you choose.
The code would look something like this:
Event: Unit Dies
Store string name of unit type in section __ of bank _____
wait ___ seconds
Remove string *name of unit type* from bank ____
edit: A better implementation would probably be to store the elapsed time that each unit died but the iterating question stands.
The problem is that a quick look at the trigger editor didn't tell me how to iterate through a bank section when I want to load all those unit types, make a dialog box of them and do something based on which one you choose.
I suppose I might be able to do this with linked lists. If so can someone recommend a linked list implementation? Also if I need to do this with linked lists, how would you define a struct and make a linked list of such structs?
I would use a data table instead and a for each integer loop between1 and Number Of Data Table Values. You can then use Name Of Data Table Value to compare or just link them directly into your UI element.
Also your current trigger structure would not reset if a unit of the same type dies just before the 60 seconds timer ends. You probably need to use some kind of integer variable timer that you can reset for each unit type.
That way you could use integer data table values as both the timer and unit type by storing the time remaining as the integer and the unit type+player as the name of the value.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
In reply to DrSuperEvil:
The Time Elapsed event can do that but I would just use a Periodic Event.
If you have an If Then Else action you can be more selective as to which data table values you modify. This would conflict with using the loop index directly for your UI element. This can be overcome by having a separate variable for the UI that is modified to be +1 each time it finds a valid name. I would suggest for the name you add a prefix so that a Substring function can identify it. You then have a second If Then Else action that checks is the integer value is >1 and based on that sets a local variable to the value minus one and then saves it again or uses Remove Data Table Value to delete what would be 0.
Under this branch you also would add your UI stuff. If the value is >1 you set the UI element and add +1 to the UI variable while if it is deleted you do nothing.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg