• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Custom Script - Trigger unit

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I have this trigger for an ability in my game:

  • Air Raid Improved
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Air Strike (New)
    • Actions
      • Set AirStrikeUnit[(Player number of (Owner of (Triggering unit)))] = (Casting unit)
      • Set AirStrikePoint[(Player number of (Owner of (Triggering unit)))] = (Target point of ability being cast)
      • Set TempPoint2 = (AirStrikePoint[(Player number of (Owner of (Triggering unit)))] offset by (-800.00, -800.00))
      • Unit - Create 1 Helicopter for (Owner of (Triggering unit)) at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
      • Set AirStrikeCopter[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Unit - Order (Last created unit) to Move To TempPoint2
      • Animation - Change (Last created unit) flying height to 1000.00 at 200.00
      • Unit - Create 1 Bomb for (Owner of (Triggering unit)) at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
      • Set AirStrikeBomb[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Animation - Change (Last created unit) flying height to 25.00 at 91.66
      • Custom script: call RemoveLocation (udg_TempPoint2)
      • Sound - Play AirStrikeLaunch <gen> at 90.00% volume, located at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00
      • Wait for (Last played sound) to be 1.50 seconds from finished playing
      • Set TempUnitGroup = (Units within 225.00 of AirStrikePoint[(Player number of (Owner of (Triggering unit)))] matching (((Matching unit) belongs to an enemy of (Owner of AirStrikeUnit[(Player number of (Owner of (Triggering unit)))])) Equal to True))
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause AirStrikeUnit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 225.00 damage of attack type Spells and damage type Normal
      • Custom script: call DestroyGroup (udg_TempUnitGroup)
      • Unit - Remove AirStrikeBomb[(Player number of (Owner of (Triggering unit)))] from the game
      • Sound - Play AirStrikeExplosion <gen> at 90.00% volume, located at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00
      • Special Effect - Create a special effect at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_AirStrikePoint[1])
      • Wait 2.00 seconds
      • Unit - Remove AirStrikeCopter[(Player number of (Owner of (Triggering unit)))] from the game
Near the bottom, there is a custom script. It is suppose to clear the memory leak that "AirStrikePoint" creates. Since, I have no knowledge of jass or custom script, how do I reference the (Player Number (Owner of (Triggering Unit)))?
 
Last edited:
Level 19
Joined
Aug 8, 2007
Messages
2,765
I have this trigger for an ability in my game:

  • Air Raid Improved
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Air Strike (New)
    • Actions
      • Set AirStrikeUnit[(Player number of (Owner of (Triggering unit)))] = (Casting unit)
      • Set AirStrikePoint[(Player number of (Owner of (Triggering unit)))] = (Target point of ability being cast)
      • Set TempPoint2 = (AirStrikePoint[(Player number of (Owner of (Triggering unit)))] offset by (-800.00, -800.00))
      • Unit - Create 1 Helicopter for (Owner of (Triggering unit)) at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
      • Set AirStrikeCopter[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Unit - Order (Last created unit) to Move To TempPoint2
      • Animation - Change (Last created unit) flying height to 1000.00 at 200.00
      • Unit - Create 1 Bomb for (Owner of (Triggering unit)) at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
      • Set AirStrikeBomb[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Animation - Change (Last created unit) flying height to 25.00 at 91.66
      • Custom script: call RemoveLocation (udg_TempPoint2)
      • Sound - Play AirStrikeLaunch <gen> at 90.00% volume, located at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00
      • Wait for (Last played sound) to be 1.50 seconds from finished playing
      • Set TempUnitGroup = (Units within 225.00 of AirStrikePoint[(Player number of (Owner of (Triggering unit)))] matching (((Matching unit) belongs to an enemy of (Owner of AirStrikeUnit[(Player number of (Owner of (Triggering unit)))])) Equal to True))
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause AirStrikeUnit[(Player number of (Owner of (Triggering unit)))] to damage (Picked unit), dealing 225.00 damage of attack type Spells and damage type Normal
      • Custom script: call DestroyGroup (udg_TempUnitGroup)
      • Unit - Remove AirStrikeBomb[(Player number of (Owner of (Triggering unit)))] from the game
      • Sound - Play AirStrikeExplosion <gen> at 90.00% volume, located at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] with Z offset 0.00
      • Special Effect - Create a special effect at AirStrikePoint[(Player number of (Owner of (Triggering unit)))] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_AirStrikePoint[1])
      • Wait 2.00 seconds
      • Unit - Remove AirStrikeCopter[(Player number of (Owner of (Triggering unit)))] from the game
Near the bottom, there is a custom script. It is suppose to clear the memory leak that "AirStrikePoint" creates. Since, I have no knowledge of jass or custom script, how do I reference the (Player Number (Owner of (Triggering Unit)))

GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
GetPlayerId(GetOwningPlayer(GetTriggerUnit()))

Thanks. It saved without errors so I assume it worked :)

Next time you can try to find out yourself by creating a new trigger, adding the respective actions and converting it to custom text.

Interesting. I tried it and the results are shown below:

[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]

However, I used the code that Arhowk suggested:

[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]

So whats up with the "Converted"?
 
Last edited:
Level 16
Joined
Mar 27, 2011
Messages
1,349
Oh I see. So basically a translation method from jass to GUI. Since my variables are previously stored via GUI methods, wouldn't that mean the array is being stored by 1, 2, and so on (not starting at 0)? In which case, I should add a converted into my custom script?
 
Status
Not open for further replies.
Top