BattleFixes #826

Merged
merged 15 commits into from Mar 18, 2016

Projects

None yet

2 participants

@Tondorian
Contributor

#821

fixes #820
Items: Consuming SP
Items: crit
Items: Conditions
Items: Ignore Dogerate
Items: Attributes increase/decrease Damage
Defending/Charged: On Dead stoped
Interpreter: ConditionChange Dead reduces HP to 0 now
Spells: Attributes increase/decrease Damage
Conditions: Silence and Hit fixed

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_actor.cpp
@@ -114,6 +114,12 @@ bool Game_Actor::IsSkillUsable(int skill_id) const {
if (skill_id <= 0 || skill_id > (int)Data::skills.size()) {
return false;
}
+ for (auto inflectedState : this->GetInflictedStates()) {
+ if ((Data::states[inflectedState - 1].restrict_magic && Data::skills[skill_id].magical_rate > Data::states[inflectedState - 1].restrict_magic_level) || ((Data::states[inflectedState - 1].restrict_skill && Data::skills[skill_id].hit > Data::states[inflectedState - 1].restrict_skill_level))) {
+ return false;
+ }
+ }
+
@Ghabry
Ghabry Mar 17, 2016 Member

inflicted, not inflected :)
Because the data type is simple to write you can also use "int" instead of "auto".

skill_id is off-by-one, needs a -1

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_battlealgorithm.cpp
@@ -321,6 +321,12 @@ void Game_BattleAlgorithm::AlgorithmBase::Apply() {
int src_hp = std::min(target_hp, IsPositive() ? -hp : hp);
source->ChangeHp(src_hp);
}
+ if(source->GetType() == Game_Battler::Type_Ally) {
+ int weaponID = (static_cast<Game_Actor*>(source))->GetWeaponId() - 1;
+ if (weaponID != -1) {
+ source->SetSp(source->GetSp() - Data::items[weaponID].sp_cost);
+ }
+ }
@Ghabry
Ghabry Mar 17, 2016 Member

You can use ChangeSp here

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_enemy.cpp
@@ -68,6 +68,10 @@ int Game_Enemy::GetId() const {
return enemy_id;
}
+std::vector<uint8_t> Game_Enemy::GetAttributeRanks() const {
+ return Data::enemies[GetId()-1].attribute_ranks;
+}
+
@Ghabry
Ghabry Mar 17, 2016 Member

I see an off-by-one error in line 53. (needs a -1)

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_battlealgorithm.cpp
@@ -362,7 +362,7 @@ void Game_BattleAlgorithm::AlgorithmBase::Apply() {
if(source->GetType() == Game_Battler::Type_Ally) {
int weaponID = (static_cast<Game_Actor*>(source))->GetWeaponId() - 1;
if (weaponID != -1) {
- source->SetSp(source->GetSp() - Data::items[weaponID].sp_cost);
+ source->ChangeSp(-Data::items[weaponID].sp_cost);
@Ghabry
Ghabry Mar 17, 2016 Member

This will consume SP even if the attack was not with the sword

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_battlealgorithm.cpp
@@ -518,6 +518,7 @@ bool Game_BattleAlgorithm::Normal::Execute() {
hit_chance = weapon.hit;
crit_chance = crit_chance += weapon.critical_hit;
multiplier = GetAttributeMultiplier(weapon.attribute_set);
+ source->ChangeSp(source->GetSp() - Data::items[weaponID].sp_cost);
@Ghabry
Ghabry Mar 17, 2016 Member

You make a permanent change in Execute()

@Ghabry Ghabry commented on an outdated diff Mar 17, 2016
src/game_actor.cpp
@@ -114,6 +118,12 @@ bool Game_Actor::IsSkillUsable(int skill_id) const {
if (skill_id <= 0 || skill_id > (int)Data::skills.size()) {
return false;
}
+ for (int inflictedState : this->GetInflictedStates()) {
+ if ((Data::states[inflictedState - 1].restrict_magic && Data::skills[skill_id].magical_rate > Data::states[inflictedState - 1].restrict_magic_level) || ((Data::states[inflictedState - 1].restrict_skill && Data::skills[skill_id-1].hit > Data::states[inflictedState - 1].restrict_skill_level))) {
+ return false;
+ }
+ }
@Ghabry
Ghabry Mar 17, 2016 Member

This is still of-by-one for skill_id, you use it twice (it's btw hard to find changes after reviewing when you completely rewrite the history^)

@Tondorian Tondorian fixes index-shift
Execute is non Permanent again
Weapons consumes sp only if they are used
3ab0cdd
@Ghabry Ghabry commented on an outdated diff Mar 18, 2016
src/game_battlealgorithm.cpp
@@ -518,7 +512,7 @@ bool Game_BattleAlgorithm::Normal::Execute() {
hit_chance = weapon.hit;
crit_chance = crit_chance += weapon.critical_hit;
multiplier = GetAttributeMultiplier(weapon.attribute_set);
- source->ChangeSp(source->GetSp() - Data::items[weaponID].sp_cost);
+ sp = - Data::items[weaponID].sp_cost;
@Ghabry
Ghabry Mar 18, 2016 Member

This will not work because the "sp = " value is for the SP change of the target.

@Ghabry Ghabry commented on the diff Mar 18, 2016
src/game_battlealgorithm.cpp
@@ -764,7 +758,7 @@ void Game_BattleAlgorithm::Skill::Apply() {
}
else {
if (first_attack) {
- source->SetSp(source->GetSp() - source->CalculateSkillCost(skill.ID));
+ source->ChangeSp(- source->CalculateSkillCost(skill.ID));
@Ghabry
Ghabry Mar 18, 2016 Member

You can do it like here in the first_attack-if instead (but in Normal::Apply ^^)

@Ghabry
Member
Ghabry commented Mar 18, 2016

Otherwise your PR looks okay. I can't test it currently but by just looking over it is fine.

I'm curious how magic weapons behave in RPG_RT, have to test this ^^

@Ghabry Ghabry and 1 other commented on an outdated diff Mar 18, 2016
src/game_actor.cpp
@@ -119,7 +119,7 @@ bool Game_Actor::IsSkillUsable(int skill_id) const {
return false;
}
for (int inflictedState : this->GetInflictedStates()) {
- if ((Data::states[inflictedState - 1].restrict_magic && Data::skills[skill_id].magical_rate > Data::states[inflictedState - 1].restrict_magic_level) || ((Data::states[inflictedState - 1].restrict_skill && Data::skills[skill_id-1].hit > Data::states[inflictedState - 1].restrict_skill_level))) {
+ if ((Data::states[inflictedState - 1].restrict_magic && Data::skills[skill_id - 1].magical_rate > Data::states[inflictedState - 1].restrict_magic_level) || ((Data::states[inflictedState - 1].restrict_skill && Data::skills[skill_id-1].hit > Data::states[inflictedState - 1].restrict_skill_level))) {
@Ghabry
Ghabry Mar 18, 2016 Member

This code is already implemented in Game_Battler::IsSkillUsable. So I was wrong when I said that silence is not working yet. Sorry :(

@Tondorian
Tondorian Mar 18, 2016 Contributor

But i tested it befor i implement this and i was able to cast spells ..

@Ghabry
Ghabry Mar 18, 2016 Member

I didn't say that the code was wrong but that you should merge it with the restriction code of Game_Battler::IsSkillUsable ^^

@Tondorian
Contributor

I tested it .. my version of rpg2k3 says: you will not be able to attack if sp is to low but tests shows it consumes sp to 0 and attacks allways works ...

@Tondorian Tondorian closed this Mar 18, 2016
@Tondorian Tondorian reopened this Mar 18, 2016
@Ghabry
Member
Ghabry commented Mar 18, 2016

Imo it would be very stupid if you could not attack normally anymore when SP are 0 so this makes sense ^^

Tondorian added some commits Mar 18, 2016
@Tondorian Tondorian Fixed PR issues ad6d4b2
@Tondorian Tondorian Enemy only uses skill if it IsSkillUsable returns true
4916b3c
@Tondorian Tondorian commented on the diff Mar 18, 2016
src/game_enemy.cpp
@@ -193,6 +193,9 @@ int Game_Enemy::GetDropProbability() const {
}
bool Game_Enemy::IsActionValid(const RPG::EnemyAction& action) {
+ if(action.kind == action.Kind_skill) {
+ return IsSkillUsable(action.skill_id);
+ }
switch (action.condition_type) {
@Tondorian
Tondorian Mar 18, 2016 Contributor

Maybe this is not the best way to check
need feedback

@Ghabry Ghabry commented on an outdated diff Mar 18, 2016
src/game_battler.cpp
@@ -61,6 +61,10 @@ int Game_Battler::GetSignificantRestriction() {
return RPG::State::Restriction_normal;
}
+int Game_Battler::GetId() const {
+ return Game_Battler::GetId();
@Ghabry
Ghabry Mar 18, 2016 Member

warning C4717: "Game_Battler::GetId": Rekursiv für alle Steuerelementpfade. Die Funktion verursacht einen Stapelüberlauf zur Laufzeit.

@Ghabry Ghabry and 1 other commented on an outdated diff Mar 18, 2016
src/game_battler.cpp
@@ -128,6 +132,12 @@ bool Game_Battler::IsSkillUsable(int skill_id) const {
const RPG::Skill& skill = Data::skills[skill_id - 1];
+ for (int inflictedState : this->GetInflictedStates()) {
+ if ((Data::states[inflictedState - 1].restrict_magic && Data::skills[skill_id - 1].magical_rate > Data::states[inflictedState - 1].restrict_magic_level) || ((Data::states[inflictedState - 1].restrict_skill && Data::skills[skill_id - 1].hit > Data::states[inflictedState - 1].restrict_skill_level))) {
+ return false;
+ }
+ }
@Ghabry
Ghabry Mar 18, 2016 Member

Please provide a test case where your code works. Because for me it fails.

@Ghabry Ghabry added this to the 0.4.1 milestone Mar 18, 2016
@Tondorian Tondorian fixes compiler warning
fixes IsSkillUsable bug
4575ef3
@Ghabry
Member
Ghabry commented Mar 18, 2016

1st row RPG_RT
2nd row old code
3rd row your new code

unbenannt

@Tondorian Tondorian Reverting redundant silence check
sorry for stealing your time and delaying 0.4.1 :(
f8032d0
@Ghabry Ghabry merged commit 1bc6244 into EasyRPG:master Mar 18, 2016

5 checks passed

Android Build finished.
Details
Linux Build finished.
Details
OSX Build finished.
Details
Windows Build finished.
Details
web Build finished.
Details
@Tondorian Tondorian deleted the Tondorian:feature/Battle branch Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment