Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro-core
Commits
56ea6cf2
Commit
56ea6cf2
authored
Aug 21, 2018
by
DailyShana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update attacking process
parent
e09dd463
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
308 deletions
+123
-308
card.cpp
card.cpp
+8
-0
card.h
card.h
+1
-0
field.cpp
field.cpp
+70
-224
field.h
field.h
+1
-1
libcard.cpp
libcard.cpp
+4
-4
libduel.cpp
libduel.cpp
+13
-9
processor.cpp
processor.cpp
+26
-70
No files found.
card.cpp
View file @
56ea6cf2
...
...
@@ -60,6 +60,14 @@ void card::attacker_map::addcard(card* pcard) {
auto
pr
=
emplace
(
fid
,
std
::
make_pair
(
pcard
,
0
));
pr
.
first
->
second
.
second
++
;
}
uint32
card
::
attacker_map
::
findcard
(
card
*
pcard
)
{
uint16
fid
=
pcard
?
pcard
->
fieldid_r
:
0
;
auto
it
=
find
(
fid
);
if
(
it
==
end
())
return
0
;
else
return
it
->
second
.
second
;
}
void
card_data
::
clear
()
{
std
::
memset
(
this
,
0
,
sizeof
(
card_data
));
}
...
...
card.h
View file @
56ea6cf2
...
...
@@ -105,6 +105,7 @@ public:
class
attacker_map
:
public
std
::
unordered_map
<
uint16
,
std
::
pair
<
card
*
,
uint32
>
>
{
public:
void
addcard
(
card
*
pcard
);
uint32
findcard
(
card
*
pcard
);
};
struct
sendto_param_t
{
void
set
(
uint8
p
,
uint8
pos
,
uint8
loc
,
uint8
seq
=
0
)
{
...
...
field.cpp
View file @
56ea6cf2
This diff is collapsed.
Click to expand it.
field.h
View file @
56ea6cf2
...
...
@@ -429,7 +429,7 @@ public:
uint32
get_field_counter
(
uint8
self
,
uint8
s
,
uint8
o
,
uint16
countertype
);
int32
effect_replace_check
(
uint32
code
,
const
tevent
&
e
);
int32
get_attack_target
(
card
*
pcard
,
card_vector
*
v
,
uint8
chain_attack
=
FALSE
);
int32
get_attack_target
(
card
*
pcard
,
card_vector
*
v
,
uint8
chain_attack
=
FALSE
,
bool
select_target
=
true
);
bool
confirm_attack_target
();
void
attack_all_target_check
();
int32
check_synchro_material
(
card
*
pcard
,
int32
findex1
,
int32
findex2
,
int32
min
,
int32
max
,
card
*
smat
,
group
*
mg
);
...
...
libcard.cpp
View file @
56ea6cf2
...
...
@@ -1325,10 +1325,10 @@ int32 scriptlib::card_is_direct_attacked(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
bool
ret
=
false
;
if
(
pcard
->
attacked_cards
.
find
(
0
)
!=
pcard
->
attacked_cards
.
end
())
ret
=
true
;
lua_pushboolean
(
L
,
ret
);
if
(
pcard
->
attacked_cards
.
findcard
(
0
))
lua_pushboolean
(
L
,
1
);
else
lua_pushboolean
(
L
,
0
);
return
1
;
}
int32
scriptlib
::
card_set_card_target
(
lua_State
*
L
)
{
...
...
libduel.cpp
View file @
56ea6cf2
...
...
@@ -1414,13 +1414,13 @@ int32 scriptlib::duel_change_attacker(lua_State *L) {
duel
*
pduel
=
attacker
->
pduel
;
if
(
pduel
->
game_field
->
core
.
attacker
==
attacker
)
return
0
;
card
*
attack_target
=
pduel
->
game_field
->
core
.
attack_target
;
pduel
->
game_field
->
core
.
attacker
->
announce_count
++
;
pduel
->
game_field
->
core
.
attacker
->
announced_cards
.
addcard
(
attack_target
);
pduel
->
game_field
->
core
.
attacker
=
attacker
;
attacker
->
attack_controler
=
attacker
->
current
.
controler
;
pduel
->
game_field
->
core
.
pre_field
[
0
]
=
attacker
->
fieldid_r
;
if
(
!
ignore_count
)
{
card
*
attack_target
=
pduel
->
game_field
->
core
.
attack_target
;
attacker
->
announce_count
++
;
attacker
->
announced_cards
.
addcard
(
attack_target
);
if
(
pduel
->
game_field
->
infos
.
phase
==
PHASE_DAMAGE
)
{
attacker
->
attacked_count
++
;
attacker
->
attacked_cards
.
addcard
(
attack_target
);
...
...
@@ -1447,25 +1447,29 @@ int32 scriptlib::duel_change_attack_target(lua_State *L) {
}
field
::
card_vector
cv
;
pduel
->
game_field
->
get_attack_target
(
attacker
,
&
cv
,
pduel
->
game_field
->
core
.
chain_attack
);
auto
turnp
=
pduel
->
game_field
->
infos
.
turn_player
;
if
(
target
&&
std
::
find
(
cv
.
begin
(),
cv
.
end
(),
target
)
!=
cv
.
end
()
||
!
target
&&
!
attacker
->
is_affected_by_effect
(
EFFECT_CANNOT_DIRECT_ATTACK
))
{
||
!
target
&&
!
attacker
->
is_affected_by_effect
(
EFFECT_CANNOT_DIRECT_ATTACK
))
{
pduel
->
game_field
->
core
.
attack_target
=
target
;
pduel
->
game_field
->
core
.
attack_rollback
=
FALSE
;
pduel
->
game_field
->
core
.
opp_mzone
.
clear
();
for
(
uint32
i
=
0
;
i
<
pduel
->
game_field
->
player
[
1
-
turnp
].
list_mzone
.
size
();
++
i
)
{
card
*
pcard
=
pduel
->
game_field
->
player
[
1
-
turnp
].
list_mzone
[
i
];
uint8
turnp
=
pduel
->
game_field
->
infos
.
turn_player
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
1
-
turnp
].
list_mzone
)
{
if
(
pcard
)
pduel
->
game_field
->
core
.
opp_mzone
.
insert
(
pcard
->
fieldid_r
);
}
pduel
->
game_field
->
attack_all_target_check
();
pduel
->
write_buffer8
(
MSG_ATTACK
);
pduel
->
write_buffer32
(
attacker
->
get_info_location
());
if
(
target
)
{
pduel
->
game_field
->
raise_single_event
(
target
,
0
,
EVENT_BE_BATTLE_TARGET
,
0
,
REASON_REPLACE
,
0
,
1
-
turnp
,
0
);
pduel
->
game_field
->
raise_event
(
target
,
EVENT_BE_BATTLE_TARGET
,
0
,
REASON_REPLACE
,
0
,
1
-
turnp
,
0
);
pduel
->
game_field
->
process_single_event
();
pduel
->
game_field
->
process_instant_event
();
}
else
pduel
->
write_buffer32
(
target
->
get_info_location
());
}
else
{
pduel
->
game_field
->
core
.
attack_player
=
TRUE
;
pduel
->
write_buffer32
(
0
);
}
lua_pushboolean
(
L
,
1
);
}
else
lua_pushboolean
(
L
,
0
);
...
...
@@ -1478,7 +1482,7 @@ int32 scriptlib::duel_calculate_damage(lua_State *L) {
card
*
attacker
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
attack_target
;
if
(
lua_isnil
(
L
,
2
))
attack_target
=
NULL
;
attack_target
=
0
;
else
{
check_param
(
L
,
PARAM_TYPE_CARD
,
2
);
attack_target
=
*
(
card
**
)
lua_touserdata
(
L
,
2
);
...
...
processor.cpp
View file @
56ea6cf2
...
...
@@ -2784,7 +2784,6 @@ int32 field::process_idle_command(uint16 step) {
}
return
TRUE
;
}
// core.attack_state_count: Duel.GetActivityCount()
int32
field
::
process_battle_command
(
uint16
step
)
{
switch
(
step
)
{
case
0
:
{
...
...
@@ -2979,14 +2978,7 @@ int32 field::process_battle_command(uint16 step) {
core
.
units
.
begin
()
->
step
=
5
;
return
FALSE
;
}
for
(
auto
cit
=
player
[
1
-
infos
.
turn_player
].
list_mzone
.
begin
();
cit
!=
player
[
1
-
infos
.
turn_player
].
list_mzone
.
end
();
++
cit
)
{
if
(
*
cit
)
{
add_process
(
PROCESSOR_SELECT_YESNO
,
0
,
0
,
0
,
infos
.
turn_player
,
31
);
return
FALSE
;
}
}
returns
.
ivalue
[
0
]
=
-
2
;
core
.
units
.
begin
()
->
step
=
5
;
add_process
(
PROCESSOR_SELECT_YESNO
,
0
,
0
,
0
,
infos
.
turn_player
,
31
);
return
FALSE
;
}
// no target and not direct attackable
...
...
@@ -3039,8 +3031,10 @@ int32 field::process_battle_command(uint16 step) {
}
case
6
:
{
if
(
returns
.
ivalue
[
0
]
==
-
1
)
{
//cancel attack manually
if
(
core
.
units
.
begin
()
->
arg1
)
core
.
chain_attack
=
FALSE
;
if
(
core
.
units
.
begin
()
->
arg1
)
{
core
.
units
.
begin
()
->
step
=
12
;
return
FALSE
;
}
core
.
units
.
begin
()
->
step
=
-
1
;
return
FALSE
;
}
...
...
@@ -3063,23 +3057,19 @@ int32 field::process_battle_command(uint16 step) {
}
core
.
attack_state_count
[
infos
.
turn_player
]
++
;
check_card_counter
(
core
.
attacker
,
5
,
infos
.
turn_player
);
core
.
attacker
->
announce_count
++
;
if
(
!
core
.
units
.
begin
()
->
arg3
)
core
.
attacker
->
announced_cards
.
addcard
(
core
.
attack_target
);
}
if
(
core
.
units
.
begin
()
->
arg3
)
{
core
.
attacker
->
announce_count
++
;
core
.
chain_attack
=
FALSE
;
core
.
units
.
begin
()
->
step
=
-
1
;
}
return
FALSE
;
}
case
8
:
{
bool
evt
=
false
;
attack_all_target_check
();
pduel
->
write_buffer8
(
MSG_ATTACK
);
pduel
->
write_buffer32
(
core
.
attacker
->
get_info_location
());
if
(
core
.
attack_target
)
{
evt
=
true
;
raise_single_event
(
core
.
attack_target
,
0
,
EVENT_BE_BATTLE_TARGET
,
0
,
0
,
0
,
1
-
infos
.
turn_player
,
0
);
raise_event
(
core
.
attack_target
,
EVENT_BE_BATTLE_TARGET
,
0
,
0
,
0
,
1
-
infos
.
turn_player
,
0
);
pduel
->
write_buffer32
(
core
.
attack_target
->
get_info_location
());
...
...
@@ -3087,23 +3077,19 @@ int32 field::process_battle_command(uint16 step) {
pduel
->
write_buffer32
(
0
);
core
.
attack_rollback
=
FALSE
;
core
.
opp_mzone
.
clear
();
for
(
uint32
i
=
0
;
i
<
player
[
1
-
infos
.
turn_player
].
list_mzone
.
size
();
++
i
)
{
card
*
pcard
=
player
[
1
-
infos
.
turn_player
].
list_mzone
[
i
];
for
(
auto
&
pcard
:
player
[
1
-
infos
.
turn_player
].
list_mzone
)
{
if
(
pcard
)
core
.
opp_mzone
.
insert
(
pcard
->
fieldid_r
);
}
//core.units.begin()->arg1 ---> is rollbacked
if
(
!
core
.
units
.
begin
()
->
arg1
)
{
evt
=
true
;
raise_single_event
(
core
.
attacker
,
0
,
EVENT_ATTACK_ANNOUNCE
,
0
,
0
,
0
,
infos
.
turn_player
,
0
);
raise_event
(
core
.
attacker
,
EVENT_ATTACK_ANNOUNCE
,
0
,
0
,
0
,
infos
.
turn_player
,
0
);
}
core
.
attacker
->
attack_controler
=
core
.
attacker
->
current
.
controler
;
core
.
pre_field
[
0
]
=
core
.
attacker
->
fieldid_r
;
if
(
evt
)
{
process_single_event
();
process_instant_event
();
}
process_single_event
();
process_instant_event
();
core
.
hint_timing
[
infos
.
turn_player
]
=
TIMING_ATTACK
;
add_process
(
PROCESSOR_POINT_EVENT
,
0
,
0
,
0
,
0
,
0
);
return
FALSE
;
...
...
@@ -3134,66 +3120,33 @@ int32 field::process_battle_command(uint16 step) {
return
FALSE
;
}
case
11
:
{
uint8
rollback
=
core
.
attack_rollback
;
bool
atk_disabled
=
false
;
uint32
acon
=
core
.
attacker
->
attack_controler
;
uint32
afid
=
core
.
pre_field
[
0
];
if
(
core
.
attacker
->
is_affected_by_effect
(
EFFECT_ATTACK_DISABLED
))
{
core
.
attacker
->
reset
(
EFFECT_ATTACK_DISABLED
,
RESET_CODE
);
atk_disabled
=
true
;
pduel
->
write_buffer8
(
MSG_ATTACK_DISABLED
);
core
.
attacker
->
set_status
(
STATUS_ATTACK_CANCELED
,
TRUE
);
}
effect
*
peffect
=
is_player_affected_by_effect
(
infos
.
turn_player
,
EFFECT_SKIP_BP
);
if
(
peffect
)
{
core
.
units
.
begin
()
->
step
=
41
;
core
.
units
.
begin
()
->
arg1
=
2
;
if
(
is_player_affected_by_effect
(
infos
.
turn_player
,
EFFECT_BP_TWICE
))
core
.
units
.
begin
()
->
arg2
=
1
;
else
core
.
units
.
begin
()
->
arg2
=
0
;
reset_phase
(
PHASE_DAMAGE
);
if
(
core
.
attacker
->
fieldid_r
==
afid
&&
!
atk_disabled
)
{
core
.
attacker
->
attacked_cards
.
addcard
(
core
.
attack_target
);
}
if
(
!
peffect
->
value
)
{
reset_phase
(
PHASE_BATTLE_STEP
);
adjust_all
();
infos
.
phase
=
PHASE_BATTLE
;
add_process
(
PROCESSOR_PHASE_EVENT
,
0
,
0
,
0
,
PHASE_BATTLE
,
0
);
}
else
{
core
.
hint_timing
[
infos
.
turn_player
]
=
0
;
reset_phase
(
PHASE_BATTLE
);
adjust_all
();
}
return
FALSE
;
}
if
(
atk_disabled
||
!
core
.
attacker
->
is_capable_attack
()
||
core
.
attacker
->
is_status
(
STATUS_ATTACK_CANCELED
)
||
core
.
attacker
->
current
.
controler
!=
acon
||
core
.
attacker
->
fieldid_r
!=
afid
)
{
core
.
chain_attack
=
FALSE
;
if
(
core
.
attacker
->
fieldid_r
==
afid
&&
!
atk_disabled
)
{
core
.
attacker
->
attacked_cards
.
addcard
(
core
.
attack_target
);
}
core
.
units
.
begin
()
->
step
=
-
1
;
reset_phase
(
PHASE_DAMAGE
);
adjust_all
();
if
(
is_player_affected_by_effect
(
infos
.
turn_player
,
EFFECT_SKIP_BP
)
||
!
core
.
attacker
->
is_capable_attack
()
||
core
.
attacker
->
is_status
(
STATUS_ATTACK_CANCELED
)
||
core
.
attacker
->
current
.
controler
!=
core
.
attacker
->
attack_controler
||
core
.
attacker
->
fieldid_r
!=
core
.
pre_field
[
0
])
{
core
.
units
.
begin
()
->
step
=
12
;
return
FALSE
;
}
uint8
rollback
=
core
.
attack_rollback
;
if
(
!
confirm_attack_target
())
rollback
=
true
;
rollback
=
TRUE
;
// go to damage step
if
(
!
rollback
)
{
core
.
attacker
->
announce_count
++
;
core
.
attacker
->
announced_cards
.
addcard
(
core
.
attack_target
);
attack_all_target_check
();
core
.
units
.
begin
()
->
step
=
18
;
return
FALSE
;
}
// attack canceled
card_vector
cv
;
get_attack_target
(
core
.
attacker
,
&
cv
,
core
.
chain_attack
);
if
(
!
cv
.
size
()
&&
!
core
.
attacker
->
direct_attackable
)
{
core
.
chain_attack
=
FALSE
;
core
.
units
.
begin
()
->
step
=
-
1
;
reset_phase
(
PHASE_DAMAGE
);
adjust_all
();
core
.
units
.
begin
()
->
step
=
12
;
return
FALSE
;
}
// replay
...
...
@@ -3211,8 +3164,12 @@ int32 field::process_battle_command(uint16 step) {
core
.
units
.
begin
()
->
arg3
=
FALSE
;
core
.
attack_cancelable
=
TRUE
;
core
.
units
.
begin
()
->
step
=
3
;
return
FALSE
;
}
return
FALSE
;
}
case
13
:
{
core
.
attacker
->
announce_count
++
;
core
.
attacker
->
announced_cards
.
addcard
(
core
.
attack_target
);
core
.
chain_attack
=
FALSE
;
core
.
units
.
begin
()
->
step
=
-
1
;
reset_phase
(
PHASE_DAMAGE
);
...
...
@@ -5370,8 +5327,7 @@ int32 field::adjust_step(uint16 step) {
if
(
core
.
attack_rollback
)
return
FALSE
;
std
::
set
<
uint16
>
fidset
;
for
(
uint32
i
=
0
;
i
<
player
[
1
-
infos
.
turn_player
].
list_mzone
.
size
();
++
i
)
{
card
*
pcard
=
player
[
1
-
infos
.
turn_player
].
list_mzone
[
i
];
for
(
auto
&
pcard
:
player
[
1
-
infos
.
turn_player
].
list_mzone
)
{
if
(
pcard
)
fidset
.
insert
(
pcard
->
fieldid_r
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment