Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyCommandCenter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Starcraft AI Course
PyCommandCenter
Commits
deea9dde
Commit
deea9dde
authored
6 years ago
by
Sopi (sofab194)
Browse files
Options
Downloads
Patches
Plain Diff
added has_target to unit
returns true if unit has target
parent
ef7f04ae
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python-api-src/lib_unit.cpp
+1
-0
1 addition, 0 deletions
python-api-src/lib_unit.cpp
src/Unit.cpp
+19
-1
19 additions, 1 deletion
src/Unit.cpp
src/Unit.h
+2
-1
2 additions, 1 deletion
src/Unit.h
with
22 additions
and
2 deletions
python-api-src/lib_unit.cpp
+
1
−
0
View file @
deea9dde
...
@@ -27,6 +27,7 @@ void define_unit(py::module & m)
...
@@ -27,6 +27,7 @@ void define_unit(py::module & m)
.
def_property_readonly
(
"is_training"
,
&
Unit
::
isTraining
)
.
def_property_readonly
(
"is_training"
,
&
Unit
::
isTraining
)
.
def_property_readonly
(
"is_blip"
,
&
Unit
::
isBlip
)
.
def_property_readonly
(
"is_blip"
,
&
Unit
::
isBlip
)
.
def_property_readonly
(
"target"
,
&
Unit
::
getTarget
)
.
def_property_readonly
(
"target"
,
&
Unit
::
getTarget
)
.
def_property_readonly
(
"has_target"
,
&
Unit
::
hasTarget
)
.
def
(
"stop"
,
&
Unit
::
stop
)
.
def
(
"stop"
,
&
Unit
::
stop
)
.
def
(
"attack_unit"
,
&
Unit
::
attackUnit
)
.
def
(
"attack_unit"
,
&
Unit
::
attackUnit
)
.
def
(
"attack_move"
,
&
Unit
::
attackMove
)
.
def
(
"attack_move"
,
&
Unit
::
attackMove
)
...
...
This diff is collapsed.
Click to expand it.
src/Unit.cpp
+
19
−
1
View file @
deea9dde
...
@@ -301,6 +301,7 @@ bool Unit::isConstructing(const UnitType & type) const
...
@@ -301,6 +301,7 @@ bool Unit::isConstructing(const UnitType & type) const
Unit
Unit
::
getTarget
()
const
Unit
Unit
::
getTarget
()
const
{
{
BOT_ASSERT
(
isValid
(),
"Unit is not valid"
);
BOT_ASSERT
(
isValid
(),
"Unit is not valid"
);
BOT_ASSERT
(
hasTarget
(),
"Unit has no target"
);
//if unit has order, check tag of target of first order
//if unit has order, check tag of target of first order
if
(
getUnitPtr
()
->
orders
.
size
()
>
0
){
if
(
getUnitPtr
()
->
orders
.
size
()
>
0
){
...
@@ -310,7 +311,24 @@ Unit Unit::getTarget() const
...
@@ -310,7 +311,24 @@ Unit Unit::getTarget() const
return
m_bot
->
GetUnit
(
t_id
);
return
m_bot
->
GetUnit
(
t_id
);
}
}
return
Unit
();
//Unit* empty_unit = new Unit();
Unit
this_unit
=
Unit
(
m_unit
,
*
m_bot
);
return
this_unit
;
}
bool
Unit
::
hasTarget
()
const
{
BOT_ASSERT
(
isValid
(),
"Unit is not valid"
);
if
(
getUnitPtr
()
->
orders
.
size
()
>
0
)
{
if
(
getUnitPtr
()
->
orders
[
0
].
target_unit_tag
!=
NULL
)
{
CCUnitID
t_id
=
getUnitPtr
()
->
orders
[
0
].
target_unit_tag
;
//let IDAbot find the unit with this tag
return
m_bot
->
GetUnit
(
t_id
).
isValid
();
}
}
return
false
;
}
}
bool
Unit
::
isBlip
()
const
bool
Unit
::
isBlip
()
const
...
...
This diff is collapsed.
Click to expand it.
src/Unit.h
+
2
−
1
View file @
deea9dde
...
@@ -48,7 +48,8 @@ public:
...
@@ -48,7 +48,8 @@ public:
bool
isConstructing
(
const
UnitType
&
type
)
const
;
bool
isConstructing
(
const
UnitType
&
type
)
const
;
bool
isBlip
()
const
;
bool
isBlip
()
const
;
Unit
getTarget
()
const
;
bool
hasTarget
()
const
;
Unit
getTarget
()
const
;
void
stop
()
const
;
void
stop
()
const
;
void
attackUnit
(
const
Unit
&
target
)
const
;
void
attackUnit
(
const
Unit
&
target
)
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment