HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS Issue

08-09-2005, 11:03 AM#1
Tim.
Quote:
set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(GetUnitTypeId(GetFilterUnit()) == 'e001')))

Ahem, this is a horrible piece of script, but oh well. All I did basically was copy and paste some converted text. What I'm attempting to do is create a variable that I can use for a few more functions, then remove it. Normally I would just use a Global but I have to be able to have 9 of these 'tempWeapon' variables for each player.

Thanks.
08-10-2005, 01:21 PM#2
Zoxc

[quote]
// Add this function in front of the other one
function ConditionInAFunction takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'e001'
endfunction

// At top of function
local unit tempWeapon

set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(ConditionInAFunction)))
08-10-2005, 07:01 PM#3
Tim.
Quote:
Custom script: function ConditionInAFunction takes nothing returns boolean
Custom script: return GetUnitTypeId(GetFilterUnit()) == 'e001'
Custom script: endfunction
Custom script: local unit tempWeapon
Custom script: set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(ConditionInAFunction)))

Somthing must be wrong with that, I get warning for 'endif's for the first 4 lines, and a 'Expected name' for the final line.
08-10-2005, 08:05 PM#4
Vexorian
What the heck are you doing? cause it seems you are inserting a function inside a gui trigger, please learn JASS the real way.
08-10-2005, 09:14 PM#5
Tim.
I dont know JASS, I was just following what Zoxc suggested.
08-10-2005, 11:19 PM#6
Zoxc
Well you said you converted the trigger into JASS.........
08-10-2005, 11:23 PM#7
Tim.
Not really,
Quote:
All I did basically was copy and paste some converted text.
I guess that wasn't really clear. Anyway I try to stick with GUI, so if you would be so kind as to help in that format (With custom scripts of course).
08-11-2005, 10:51 AM#8
Zoxc
If youre using GUI you need to do this:

// Add this global script ( The trigger with the map name )
Quote:
function ConditionInAFunction takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'e001'
endfunction

// At top of the trigger
Quote:
local unit tempWeapon

// Then this where you want it
Quote:
set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(ConditionInAFunction)))

// At end of trigger
Quote:
set tempWeapon = null

Locals can only be used in the function its created in. It can't be used in conditions except custom script coditions. And Pick All Actions, cuz WE or creating a new function for that.
08-11-2005, 01:01 PM#9
Tim.


Lovely little Error list.

Here is what my trigger looks like;

Quote:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2)) Less than or equal to 11
Then - Actions
Custom script: local unit tempWeapon
Custom script: set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(ConditionInAFunction)))
Game - Display to (All players) the text: Pistol Ammo Added!
Item - Set charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2) to ((Charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2)) + (Integer((Life of (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol))))))))
Unit - Set mana of DummyUnit[(Integer A)] to ((Mana of DummyUnit[(Integer A)]) + (Mana of (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol))))))
Unit - Remove (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol)))) from the game
Custom script: set tempWeapon = null
Else - Actions
Do nothing

Once it works I'll replace all of those 'Random unit from..' with tempWeapon. Also, this If/Then/Else is one of 9 in this trigger, checking for 9 different unit types.
08-11-2005, 04:18 PM#10
Zoxc
Please do what I say:

Quote:
Custom script: local unit tempWeapon
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2)) Less than or equal to 11
Then - Actions
Custom script: set tempWeapon = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(70.00,GetUnitLoc(udg_Hero[GetForLoopIndexA()]), Condition(ConditionInAFunction)))
Game - Display to (All players) the text: Pistol Ammo Added!
Item - Set charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2) to ((Charges remaining in (Item carried by DummyUnit[(Integer A)] in slot 2)) + (Integer((Life of (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol))))))))
Unit - Set mana of DummyUnit[(Integer A)] to ((Mana of DummyUnit[(Integer A)]) + (Mana of (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol))))))
Unit - Remove (Random unit from (Units within 70.00 of (Position of Hero[(Integer A)]) matching ((Unit-type of (Matching unit)) Equal to Weapon Detector (Pistol)))) from the game
Else - Actions
Do nothing
Custom script: set tempWeapon = null
08-12-2005, 12:25 PM#11
Tim.
Yes, however this runs in a loop every .05 seconds and the local might be needed for all 9 If/Then/Else functions at the same time. If I place the scripts in those locations will it still work properly?