Skip to content
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

[READY] Effects Update 1 #9469

Merged
merged 127 commits into from Nov 22, 2014

Conversation

Projects
None yet
8 participants
@i2amroy
Copy link
Member

commented Oct 8, 2014

And it's ready for testing! Basically a huge background expansion to JSONize the effects system, as well as a near total migration from the old diseases system over to the new effects system. Don't be fooled by the line counts though, the majority of changes were simply replacing "X_disease(" with "X_effect(" on a huge number of lines. The important things to be looking at are the changes in effect.cpp, effect.h, and the process_effects(), has_effect(), add_effects(), and move_effects() functions. As such it should merge relatively painlessly.

The several effects that I wasn't able to convert over are now placed in "hardcoded_effects()", where they should function identically to how they did before the move. Overall there were a few small changes to comply with some of the limitations of the json fields, but the majority of effects remained identical in function to how they were before.

This is also a huge step towards having effects and diseases work on everything, players, monsters, and npc's included.

I've also drawn up some documentation for the way the new effects json file is formatted and included it in the PR. It can be found here.

There will probably be at least one bug that I missed somewhere, but I tried to squash as many as I could find, so hopefully it's not as bad as some other PR's have been.

Fixes #9101. Fixes #7449. Closes #7532.

src/json.h Outdated
start_object();
typename std::unordered_map<int, T>::const_iterator it;
for (it = m.begin(); it != m.end(); ++it) {
write(it->first);

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 8, 2014

Contributor

That writes an integer as key of the json object, but keys should be strings, can the parse read this back in?

Edit: I see you have overladed the read function, so it works. But the key of json objects should be string according to some json format definition.

This comment has been minimized.

Copy link
@i2amroy

i2amroy Oct 8, 2014

Author Member

Ah, that makes sense. I'll take a look at fixing it.

remove_effect( id );
} else {
++it;
remove_effect( rem_ids[i], rem_bps[i] );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 8, 2014

Contributor

The function modifies the effects map (if bp == num_bp), thereby invalidating the maps iterator, that you use here. You could change effects.erase( eff_id ); in remove_effects to only clear the map effects[eff_id].clear().

That would also be consistent with the other case (bp != num_bp) where it might leave an empty entry in the effects maps (effects[eff_id] still exists, but is an empty map, the iterator maps points to this empty map and is still valid).

Edit : this causes a crash on my build.

@@ -572,10 +578,10 @@ void Creature::add_effect(efftype_id eff_id, int dur, int intensity, bool perman
}
}
bool Creature::add_env_effect(efftype_id eff_id, body_part vector, int strength, int dur,
int intensity, bool permanent)
body_part bp, int intensity, bool permanent)

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 8, 2014

Contributor

Out of curiosity: why are there two body parts used here? One is used for the environmental protection check and the other is the actual effected body part. Why should it be possible for example to attack the left leg and (if it succeeds) infect the right arm?

This comment has been minimized.

Copy link
@i2amroy

i2amroy Oct 8, 2014

Author Member

The idea was so that, for example, you could create a poison that could get into your body through any given attack location, but then target a specific body part (or be generalized). This is already used for tons of things like smoke, where the protecting body part is the mouth but the effect itself actually targets num_bp.

@i2amroy i2amroy added the in progress label Oct 9, 2014

@i2amroy i2amroy changed the title Effects Update 1 [WIP] Effects Update 1 Oct 9, 2014

bool effect_mod_info::load(JsonObject &jsobj, std::string member) {
if jsobj.has_object(member) {
JsonObject j = jsobj.get_object(member);
if(j.has_member("str_mod")) {

This comment has been minimized.

Copy link
@kevingranade

kevingranade Oct 10, 2014

Member

This is begging to be pulled out into a helper:

void extract_effect( JsonObject &j, std::string mod_type,  std::pair<int, int> &mod_value)
{
    if(j.has_member(mod_type)) {
        JsonArray jsarr = j.get_array(mod_type);
        mod_value.first = jsarr.get_int(0);
        if (jsarr.size() >= 2) {
            mod_value.second = jsarr.get_int(1);
        } else {
            mod_value.second = mod_value.first;
        }
    }
}
@i2amroy

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2014

Updated the "effects" field in the item use JSON field and added a similar type of field for successful monster attacks (i.e., damaged the player successfully). I've updated one monster (the fungal fighter) as a proof of concept but don't plan to update any others in this PR (since it would just make testing/reviewing more difficult and merging compatibility harder to maintain for little gain). I've also updated the documentation to reflect this fact.

That was pretty much the last feature I wanted to get in in this PR (since part of having a modding system for effects is the ability to apply them), so unless someone sees a problem this will probably be identical to the final merged version (excepting occasional merges to the keep it up to date of course).

@i2amroy i2amroy changed the title [READY FOR TESTING] Effects Update 1 [READY] Effects Update 1 Nov 2, 2014

i2amroy added some commits Nov 2, 2014

Merge to mainline
Conflicts:
	src/game.cpp
	src/iuse.cpp
	src/player.cpp
Merge to mainline
Conflicts:
	src/creature.h
@Lain-

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2014

Pardon me pestering: New stable is out, let's get this in soon?

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2014

Sure, just needs updated and tested. Not sure where i2amroy is.

@i2amroy

This comment has been minimized.

Copy link
Member Author

commented Nov 18, 2014

I've been taking a bit of a break until the new stable hit. I'll look into updating this tonight.

Merge to mainline
Conflicts:
	src/disease.cpp
	src/game.cpp
	src/player.cpp
@i2amroy

This comment has been minimized.

Copy link
Member Author

commented Nov 18, 2014

And updated, just need someone to triple-check to make sure it works and merge it. :)

@KA101

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2014

Saw your name being pulled off the core-dev credit list and went D8 .

@i2amroy

This comment has been minimized.

Copy link
Member Author

commented Nov 18, 2014

To be fair I haven't exactly been exercising my privileges as a github manager recently. :P Don't worry though, I'm definitely still here and still planning on contributing now that the feature freeze is off. :D

@i2amroy i2amroy added the ready label Nov 21, 2014

Merge to mainline
Conflicts:
	src/game.cpp
@i2amroy

This comment has been minimized.

Copy link
Member Author

commented Nov 22, 2014

I'll just keep fixing merge conflicts every day or so on this till it get's merged. :P

Merge to mainline
Conflicts:
	src/iuse.cpp
	src/player.cpp

@kevingranade kevingranade merged commit 63bc5f1 into CleverRaven:master Nov 22, 2014

@i2amroy i2amroy deleted the i2amroy:healing branch Nov 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.