Well, i'm having problems with a feature of a map I'm making(actually this is the first part i'm doing because I consider it the most important >_<), I want a command like "-use xxxxxx" where xxxxx is the order string of a skill, for example if I used "-use thunderbolt" the unit with certain item will use Thunderbolt on the nearest unit , if I used "-use thunderclap" the unit with that item will use Thunderclap and the like, it should also work with "attack" "move" and (if it's possible) patrol.
So, Can you help me please?
(edit) Purely in Jass
Where did Aero's post went o.o (delete post or merge please)
Detect orders in chat messages?
Moderator: Cheaters
-
- Newcomer
- Posts: 7
- Joined: December 5th, 2007, 11:55 pm
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Detect orders in chat messages?
Note to any double-posting nazis (wierdone, Ozza), zerg-rush did not double post, I had posted before whether he wanted it in JASS or GUI but deleted the post because I was going to repost with a quote and additional questions. However, right after I deleted the post he had posted and I am too lazy to edit his post so I'm just including a note in this one.
//////////////////////
I don't have any tools with me where I am right now so I can't help that much.
Anyway, what you should do is have 2 different commands.
-use xxxxx (No target)
-usetarget xxxxx (Unit target--Nearest unit, attack could go here too)
For -use, use.. call IssueImmediateOrder and for the orderstring use SubString(GetEventPlayerChatString(),5,25)
For -usetarget, use call IssueTargetOrder and for the orderstring use SubString(GetEventPlayerChatString(),11,31); for the target, you would have to use a custom function that finds the nearest unit (I can post this later when I have my tools with me)
As for move and patrol, I don't know how you plan on using these commands so I can't offer any solutions.
If you could provide more information such as what you are using the system for it would be helpful.
//////////////////////
I don't have any tools with me where I am right now so I can't help that much.
Anyway, what you should do is have 2 different commands.
-use xxxxx (No target)
-usetarget xxxxx (Unit target--Nearest unit, attack could go here too)
For -use, use.. call IssueImmediateOrder and for the orderstring use SubString(GetEventPlayerChatString(),5,25)
For -usetarget, use call IssueTargetOrder and for the orderstring use SubString(GetEventPlayerChatString(),11,31); for the target, you would have to use a custom function that finds the nearest unit (I can post this later when I have my tools with me)
As for move and patrol, I don't know how you plan on using these commands so I can't offer any solutions.
If you could provide more information such as what you are using the system for it would be helpful.
-
- Newcomer
- Posts: 7
- Joined: December 5th, 2007, 11:55 pm
Re: Detect orders in chat messages?
Well, my main concern with getting strings (for example (GetEventPlayerChatString(),5,25)) was that I thought it detected "spaces" even if the string was shorter than 20 characters, but from what I can see in your post it will not consider the strings if the place where they should be is empty.
Just to be sure, will this return the same string?
GetEventPlayerChatString(),5,25 reacting to -use thunderclap and
GetEventPlayerChatString(),5,16 reacting to -use thunderclap
About move and patrol:
Now that I think about it move and patrol are not necessary (since their purpose was to keep the unit in a certain range) I think i'll use disable movement for that purpose =D
Thank you for all the help, I'll post here again if I have more questions.
Just to be sure, will this return the same string?
GetEventPlayerChatString(),5,25 reacting to -use thunderclap and
GetEventPlayerChatString(),5,16 reacting to -use thunderclap
About move and patrol:
Now that I think about it move and patrol are not necessary (since their purpose was to keep the unit in a certain range) I think i'll use disable movement for that purpose =D
Thank you for all the help, I'll post here again if I have more questions.
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Detect orders in chat messages?
Yes, if you type
-usetarget "thunderbolt"
And you get the SubString from 11-36, it will return "thunderbolt" and will not add any spaces.
Also, did you want the "GetClosestUnit" function?
(function GetClosestUnit takes unit whichUnit returns unit)
^^ Please state any restrictions you would want on this function (such as radius limits)
-usetarget "thunderbolt"
And you get the SubString from 11-36, it will return "thunderbolt" and will not add any spaces.
Also, did you want the "GetClosestUnit" function?
(function GetClosestUnit takes unit whichUnit returns unit)
^^ Please state any restrictions you would want on this function (such as radius limits)
-
- Newcomer
- Posts: 7
- Joined: December 5th, 2007, 11:55 pm
Re: Detect orders in chat messages?
The function should return the closest unit in a 600 AoE (with a check for a marker ability A003) ^^
Also, I have another question, if a unit has two abilities with the same orderstrings which one will he use? Is it random? (that could be helpful for a characteristic of my map).
Also, I have another question, if a unit has two abilities with the same orderstrings which one will he use? Is it random? (that could be helpful for a characteristic of my map).
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
-
- Newcomer
- Posts: 7
- Joined: December 5th, 2007, 11:55 pm
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Detect orders in chat messages?
Here you are--I just typed this up now (So there might be an error but unlikely)
Code: Select all
function NearestUnit_Filter takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(),'A003')==0
endfunction
function GetNearestUnit takes unit whichUnit returns unit
local group g=CreateGroup()
local real x=GetUnitX(whichUnit)
local real y=GetUnitY(whichUnit)
local real dx=0.
local real dy=0.
local real compareDist=0.
local real currDist=360000.
local unit compareUnit
local unit resultUnit
call GroupEnumUnitsInRange(g,x,y,600.,Condition(function NearestUnit_Filter))
loop
set compareUnit=FirstOfGroup(g)
exitwhen compareUnit==null
set dx=GetUnitX(compareUnit)-x
set dy=GetUnitY(compareUnit)-y
set compareDist=dx*dx+dy*dy
if compareDist<=currDist then
set currDist=compareDist
set resultUnit=compareUnit
endif
call GroupRemoveUnit(g,compareUnit)
endloop
call DestroyGroup(g)
set g=null
return resultUnit
endfunction
-
- Newcomer
- Posts: 7
- Joined: December 5th, 2007, 11:55 pm