Author Topic: adding nightime attributes to units  (Read 2752 times)

Zoythrus

  • Guest
adding nightime attributes to units
« on: 7 May 2011, 18:39:55 »
recently, i was attempting to mess with the engine so that the day/night cycle could affect units. i have a pretty good idea of how to do it, too, but the only thing in my way is trying to figure out where the stuff i need is. (NOTE: im new to the GAE code, so forgive me for noobiness)

here's what im wondering about the code:
in the unit_type.cpp, where is the code that governs the HP, EP, sight, armor, and time (and etc) values? i can only find the armor type.

ive realized that i cant just change the unit_type.cpp, im going to have to create stuff in the other files. what all will i have to modify?

----------------------------------------

oh yeah, do you guys want me to go over how i plan on implementing my idea?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: adding nightime attributes to units
« Reply #1 on: 7 May 2011, 19:28:06 »
ive realized that i cant just change the unit_type.cpp, im going to have to create stuff in the other files. what all will i have to modify?
You're gonna have to learn more c++. There is header files for each cpp file, and all the cpp files basically get combined together, so may be used or referenced in other files. The different files basically serves to make the code easier to read (they could do it all on the same file if they wanted, but that'd be pretty crowded and messy).
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #2 on: 7 May 2011, 19:34:01 »
well, my idea is pretty localized to the unit_type.cpp/.h files. i dont think that other files will need to know what the units are like at night anyways.

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #3 on: 7 May 2011, 23:56:56 »
Quote from: Zoythrus
oh yeah, do you guys want me to go over how i plan on implementing my idea?
Sure. It can help to share thoughts when working out how to code.

These are the files I would be looking at when starting:
- for day/night info - game\world\time_flow.h/cpp
- for reading in xml info (look at base classes too) - game\prototypes\unit_type.h/cpp
- for modifying a unit entity (look at base classes too) - game\entities\unit.h/cpp

Then depending on what you want to do:
- graphical representation you would need rendering of some kind (user_interface, renderer, etc)
- a command would need to go in a command_type class in game\prototypes

Keep in mind that a lot of code will be changing soon so anything you do might not be compatible.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #4 on: 8 May 2011, 00:08:30 »
Keep in mind that a lot of code will be changing soon so anything you do might not be compatible.
well, should i wait, then? (or will you even be touching what i plan on working with?)

so, about my implementation plan:

i was planning on creating a new child in the properties node in the unit_type.cpp called "night cycle". then, i would say (in english) "when not daytime add or subtract the static or multiplier stats below." that's when i would add optional stat increase/decrease things in the night node (much like an upgrade), so you can state what changes at night, instead of hard coding it.

see what im saying?

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #5 on: 9 May 2011, 10:44:15 »
Keep in mind that a lot of code will be changing soon so anything you do might not be compatible.
well, should i wait, then? (or will you even be touching what i plan on working with?)
Don't wait, coding is only part of it so even if it needs to be reimplemented you'll have a better understanding of the challenges. It might be good to create a new local branch in Git so it doesn't get affected by mainline development.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #6 on: 15 May 2011, 20:29:12 »
wont i need permission from you guys before i make any changes?

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #7 on: 15 May 2011, 21:56:40 »
Only to push to the sourceforge repository. If it's local or if you make another repository somewhere else, you can make as many changes as you like.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #8 on: 15 May 2011, 22:00:42 »
is it possible to have my work viewable by everyone else but not actually a part of the master source?

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #9 on: 16 May 2011, 22:37:36 »
You can create a diff with git format-patch and upload it, then someone can apply it to their local copy. This article takes you through the process for making changes without needing write permissions.
« Last Edit: 16 May 2011, 22:45:18 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #10 on: 25 May 2011, 17:32:38 »
hey, now that im out of school, i actually have time to work on this!

but i have hit a snag, i cant seem to find the connection between unit_types.cpp and unit_stats.cpp. how did you guys get the stats from unit_stats.cpp into unit_types.cpp?

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #11 on: 26 May 2011, 02:59:08 »
How did you guys get the stats from unit_stats.cpp into unit_types.cpp?
Using inheritance. Learn the OOP concepts if you haven't already.

Code: (unit_stats_base.h) [Select]
/** Base stats for a unit type, upgrade, effect or other enhancement. */
class UnitStats {

Code: (unit_type.h) [Select]
class UnitType : public ProducibleType, public UnitStats {
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #12 on: 26 May 2011, 04:05:13 »
 :-[ d'oh! now i feel like an idiot....

thank you, hailstone....

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #13 on: 9 June 2011, 14:16:05 »
How are you going with this?
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Zoythrus

  • Guest
Re: adding nightime attributes to units
« Reply #14 on: 10 June 2011, 04:44:51 »
sorry, my summer just got busy with job hunting right after i committed to this.

EDIT: after reviewing the code and how the engine operates, i can now say that im baffled and utterly confused. apparently i need to learn more about C++ before i can write any new code for GAE. sorry for getting all of your hopes up.....

(that means that i am not going to be doing this....until i can get a better grasp on C++....)

-Zoy
« Last Edit: 14 June 2011, 06:04:39 by Zoythrus »

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: adding nightime attributes to units
« Reply #15 on: 14 June 2011, 06:20:31 »
That's ok. It's as much about understanding how the program is built as it is about understanding the language. Let me know if want help understanding something.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

 

anything