这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@MaanooAk
Copy link
Contributor

@MaanooAk MaanooAk commented Nov 27, 2016

Repair of units based on the doc/reverse_engineering/repair.md (file in pull request).

In order to continue:

  • A data structure for multiple resource costs should be implemented (game_resource_bundle ?)
  • The cost of the unit should be stored somewhere (inside unt_type ?)

Can I implement these? or just leave as it is and revisit after the nyan revolution?

EDIT: Also game_resource_bundle should replace the game_resource type, int value couples all over the place.

this->entity->has_attribute(attr_type::owner) &&
this->entity->has_attribute(attr_type::attack) &&
this->entity->get_attribute<attr_type::attack>().stance != attack_stance::do_nothing) {
this->entity->has_attribute(attr_type::owner) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed these in the next commit

@MaanooAk
Copy link
Contributor Author

MaanooAk commented Nov 27, 2016

ResourceBoundle could be like this (gist). Check the main for how its used.

EDIT: Closed it by accident...

@MaanooAk MaanooAk closed this Nov 27, 2016
@MaanooAk MaanooAk reopened this Nov 27, 2016
@TheJJ TheJJ added lang: c++ Done in C++ code nice new thing ☺ A new feature that was not there before labels Dec 2, 2016
@MaanooAk
Copy link
Contributor Author

MaanooAk commented Dec 5, 2016

Implemented a ResourceBundle class and used it in player (kept old one with raw type and amount) and unit repair.

Next step is to add somewhere (unit type, unit attributes, ?) the cost of the unit. I have zero confidence implementing that so this is as far I can go (= removing WIP).

@MaanooAk MaanooAk changed the title [WIP] Repair action Repair action & resource bundle Dec 5, 2016
@TheJJ
Copy link
Member

TheJJ commented Dec 23, 2016

Sorry for the delay, university has kept me very busy (http://www.move2space.de/MOVE-II/)...

However, I just tested your code and I couldn't get my villagers to repair their town center or mill.

The resource bundle is a good idea, as it's capable of adding resource types at runtime easily. We'll need that in the future.

The cost of the unit is drawn from the gamedata of course, which is accessible through the std::vector<gamedata::empiresdat> gamedata; in libopenage/gamestate/game_spec.cpp. But this is all going to be replaced by nyan. But nyan is still quite far from being ready so adding just another dirty hardcoding for it is ok. You'll find the structure of that struct in openage/convert/gamedata where we extract it.

@MaanooAk
Copy link
Contributor Author

I added the repair ability, that should do the work. I added and some other missing abilities while I was there.
And I implemented the repair gui button.

Copy link
Member

@TheJJ TheJJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good apart from minor stuff.

As we have quite a few ...Ability and ...Action classes, i think it might be time to pack those together in a separate namespace, so we have names like ability::Heal and action::Repair. This should reduce the verbosity a bit.

}

void ConvertAbility::invoke(Unit &to_modify, const Command &cmd, bool play_sound) {
to_modify.log(MSG(dbg) << "invoke repair action");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypasta :)


/*
* initiates a repair action when given a valid target
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls write /** so it's parsed by doxygen


/*
* initiates a heal action when given a valid target
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

* initiates a research
* TODO implement
*/
class ResearchAbility: public UnitAbility {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

* initiates a patrol action when given a valid target
* TODO implement
*/
class PatrolAbility: public UnitAbility {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

/*
* initiates a convert action when given a valid target
*/
class ConvertAbility: public UnitAbility {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

float time;
float time_left;

ResourceBundle cost; // calculate and store the cost in the constructor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write /** stores the cost of the repair */ or whatever is more suitable above it so it's parsed by doxygen, too.

@MaanooAk
Copy link
Contributor Author

MaanooAk commented Dec 23, 2016

The separate namespace should be done with a refactoring tool.
However I think the way attribute classes are defined is nice too.

@TheJJ
Copy link
Member

TheJJ commented Dec 28, 2016

You mean templating the attributes? Yes, could also be done :)
Do whatever you like better and think suits us more.

Shall I merge your stuff before that or do you wanna integrate it also in this pull?

@MaanooAk
Copy link
Contributor Author

You should merge this (do you want me to rebase?)
I'm thinking of fixing the attributes first (more like #651) if that's ok.

@TheJJ
Copy link
Member

TheJJ commented Dec 28, 2016

No I don't think you need to rebase, it doesn't conflict with the master.
@ attributes, sure go ahead! It's another basic foundation for the game logic.

@MaanooAk
Copy link
Contributor Author

I just realized I'm creating a ton of conflicts in my new pr (#683) with this one...
Can you merge this or you are not sure yet, can I do something?

Copy link
Member

@TheJJ TheJJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still can't get it to work, and I think it is because you don't add the repair ability to the villagers. Or does it work for you some other way?

}

void HealAbility::invoke(Unit &to_modify, const Command &cmd, bool play_sound) {
to_modify.log(MSG(dbg) << "invoke repair action");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still the wrong message here

@MaanooAk
Copy link
Contributor Author

MaanooAk commented Dec 30, 2016

I see... Just leave it, I will investigate and come back to you.
(May take some time, I have some serious Ubuntu craziness happening right now)

@MaanooAk
Copy link
Contributor Author

MaanooAk commented Dec 30, 2016

Added the ability, added 1000 of each res to players (so they can repair) and made gaia the Gaia player (prev: name1 was Gaia and gaia was some civ)

screenshot from 2016-12-30 22-45-34

(I will start testing more extensively before removing the WIP)

@yani
Copy link

yani commented Dec 31, 2016

I'd like to add to this that there's a bug in the original game which still exists where you can repair (and garrison) a building from a diagonal location. It's called the wall corner glitch and I'm wondering if this bug also exists within openage and if it should either be fixed, or stay exactly the same.

@TheJJ
Copy link
Member

TheJJ commented Dec 31, 2016

@Yanikore I think we'll have the same problem right now because we don't have any blocking physics currently, the pathfinder is really stupid and doesn't account for that. Go and help out at #366 :)

@yani
Copy link

yani commented Dec 31, 2016

@TheJJ I'd love to help out but I'm not capable for the C++/python side of this. I'm more a PHP developer than anything so I'll probably help out in the future when a website gets made. Right now I can only add some conceptual ideas to the situation.

@TheJJ
Copy link
Member

TheJJ commented Dec 31, 2016

yay it works :)
thank you very much @MaanooAk !

@TheJJ TheJJ merged commit 4330be8 into SFTtech:master Dec 31, 2016
@MaanooAk MaanooAk deleted the repair branch December 31, 2016 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang: c++ Done in C++ code nice new thing ☺ A new feature that was not there before

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants