New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step State Damage: "Implement HP and SP decrease by a state on map" and "Prevent Terrain Damage" #1393

Merged
merged 2 commits into from Jul 8, 2018

Conversation

Projects
None yet
4 participants
@Albeleon
Member

Albeleon commented Jul 7, 2018

Depends on EasyRPG/liblcf#228

@Albeleon Albeleon changed the title from Step State Damage: "Implement HP and SP decrease by a state on map"and "Prevent Terrain Damage" to Step State Damage: "Implement HP and SP decrease by a state on map" and "Prevent Terrain Damage" Jul 7, 2018

}
}
//Terrain:

This comment has been minimized.

@Ghabry

Ghabry Jul 7, 2018

Member

whitespace after // and don't use these colons :
The comment isn't very useful in general

int terrain_id = Game_Map::GetTerrainTag(GetX(), GetY()); const RPG::Terrain* terrain = ReaderUtil::GetElement(Data::terrains, terrain_id);
these 2 lines belong to the terrain and should be moved down

}
} else {
Output::Warning("Player BeginMove: Invalid terrain ID %d at (%d, %d)", terrain_id, GetX(), GetY());
}
//Red Flash:

This comment has been minimized.

@Ghabry

Ghabry Jul 7, 2018

Member

this one is also of low value

Main_Data::game_party->ApplyDamage(terrain->damage, false);
for (auto hero : Main_Data::game_party->GetActors()) {
bool receive_damage = true;
for (auto object_id : hero->GetWholeEquipment()) {

This comment has been minimized.

@Ghabry

Ghabry Jul 7, 2018

Member

this complecated loop could be moved in a Game_Actor::IsImmuneToTerrainDamage function

// Step Damage for States:
for (auto hero : Main_Data::game_party->GetActors()) {
for (auto state_id : hero->GetInflictedStates()) {
RPG::State *state = ReaderUtil::GetElement(Data::states, state_id);

This comment has been minimized.

@Ghabry

Ghabry Jul 7, 2018

Member

This whole loop logic could be in a Game_Actor::ApplyStateDamage function.
About the state steps counter: Is this really global for all actors? I mean when one hero is poisoned and another is poisoned one step later, do they receive damage at the same time?

@Ghabry Ghabry referenced this pull request Jul 7, 2018

Open

A bunch of Vampires Dawn bugs #1128

5 of 5 tasks complete
@Albeleon

This comment has been minimized.

Member

Albeleon commented Jul 7, 2018

Changes pendent:

"Also should be checked if RPG_RT saves this. e.g. you make 3 steps and save. If the 4th step causes damage or if it is always 4 steps from loading, because we still haven't figured out all savegame fields"
In RPG_RT, yes, if you do this the next step causes damage. Which means the savefile saves the number of steps for each state before it does damage again. This means we should take this value from the savefile wherever it is.

}
if (state->hp_change_map_val > 0) {
if ((++state_steps_hp[state_id - 1]) >= state->hp_change_map_steps) {
state_steps_hp[state_id - 1] -= state->hp_change_map_steps;

This comment has been minimized.

@Ghabry

Ghabry Jul 7, 2018

Member

can't you simply set it to 0 instead of subtracting steps?

@Ghabry

Ghabry approved these changes Jul 7, 2018

Albeleon added some commits Jul 7, 2018

Implement HP and SP decrease by a state when walking on map each step.
Problem: When in a state that decreases HP or SP, is not implemented when walking on map.

Solution: We implement this in the same function as the movement:
 - We create in Game_Party the function GetInflictedStates, which returns a vector with the id of all the states the group has (filters duplicates).
 - We create in Game_Party two vectors: state_steps_hp and state_steps_sp. They save the steps made for each state. We differentiate between HP and SP because even in the same state they act independently.
 - We create in Game_Party the function ApplyStateDamage, which each time it's invoked it increases one step for each inflicted state on the group. If it hits the number of steps, the count is set to 0 and damage is generated to the actors that have that state. When there's damage it also return true to indicate it.
 - Since we only want one flash to be executed, after each damage function we set a bool "red_flash" true. If it is true at the end of BeginMove, it generates the red flash.
If actor = "Prevent Terrain Damage", they don't receive damage.
Problem: Every character receives damage in Terrain that does it regardless of that protection. That protection only affects that single character, not the group.

Solution: We create Game_Actor::PreventsTerrainDamage which check if they have a "Prevent Terrain Damage" protection. Then we check this when terrain damage is going to be done, and if they don't, suffer the damage for that character alone (and generate the red flash).

@carstene1ns carstene1ns added this to the 0.5.4 milestone Jul 8, 2018

@carstene1ns carstene1ns merged commit b8552f4 into EasyRPG:master Jul 8, 2018

7 checks passed

Android (armeabi-v7a) Build finished.
Details
GCW0 Build finished.
Details
GNU/Linux Build finished.
Details
OSX Build finished.
Details
Windows (x64) Build finished.
Details
Windows (x86) Build finished.
Details
web Build finished.
Details
* Applies damage to the game party based on their stats.
*
* @return Whether the actor suffered some damage.
*/

This comment has been minimized.

@Ghabry

Ghabry Jul 8, 2018

Member

You messed up the * again. This automatic formating is really annoying Visual Studio behaviour ^^'
Can be fixed as part of some other PR:

@Albeleon Albeleon deleted the Albeleon:step_state_damage branch Jul 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment