[XP] Advance Wars Engine

Started by KK20, November 20, 2012, 08:51:57 pm

Previous topic - Next topic

Gears

April 18, 2014, 05:22:20 am #120 Last Edit: April 18, 2014, 12:01:52 pm by Gears
Well, if everything that's in advance wars is in, it should be good enough. One thing that might be handy is to have some form of trigger that will allow you to create a conversation regardless of what's currently going on. that would allow things like capturing maps in campaign, or perhaps having some form of gloating once you destroy a key enemy unit.

Edit: i managed to break one of my CO's somehow. he was working properly, but not anymore. The idea is that he damages his own units at the end of his CO, i did this by using a activator in the preturn code in the scenemap, like this:

Spoiler: ShowHide
def phase_preturn
# ////////////////////////////////////////////////////////////
# // Reset values (turn off powers, weather, music, graphics
# ////////////////////////////////////////////////////////////
if @preturn == 1
# Do not process preturn phase until wait timer finishes
return if @wait > 0
     
############################################################
     if @player_turn.officer.scop == true
     @player_turn.officer.Core_Overclock_endscop
     end
     ############################################################
     
# Disable the units that have a disabled flag
@player_turn.units.each{|u|
if u.disabled
u.acted = true
u.disabled = false
end
}
# Play the player's CO theme music
$game_system.bgm_play(@player_turn.officer.name)
# Turn off COP and SCOP flags

     
     @player_turn.officer.cop = false
@player_turn.officer.scop = false

which links to this in the officer class:

Spoiler: ShowHide
def Core_Overclock_endscop

   if @Core_overclock_penalty == true
      (@army.units).each{|unit|
unit.injure(8, true, false, true)
}
   end
end

with @Core_overclock_penalty being a legitimate extra:
Spoiler: ShowHide
def initialize(army)
   @name = ""
   @cop = false
   @scop = false
   @cop_name = ""
   @scop_name = ""
   @description = []
   @cop_stars = 0.0
   @scop_stars = 0.0
   @army = army

# Define bonus effects that COs may have

@repair = 2
@income_multiplier = 1
   @cost_multiplier = 1.0
@no_snow_penalty, @no_PoisonGas_penalty, @no_rain_penalty, @no_sand_penalty = false, false, false, false
@build_on_cities = false
@perfect_movement = false
@pierce_fow = false
@last_stand = false
   
   @APC_repair = false
   @Core_overclock_penalty = false
   @reconcapture = false
   
   @gain_dmg_as_HP = false
 end
and the CO in question having it as "true"

Any ideas what's gone wrong?


Also, i just noticed now for some reason, but why is the daily fuel depletion carried out before the fuel resupply? this would cause aircraft to crash even if they reached an airport. Repair and resupply is a bit wonky in general. I had a match today using teamviewer, and am going to see if i can somehow share the recording with you. you'll notice one stupid oversight in my CO and a lot of wonky/not-activating repairs.Repairs are probably fixed in your version, i don't really remember. Still was a fun match though.

KK20

That would really only apply if it was a campaign map. Of course, I'll make Campaign creation an available option along with being able to event in those messages wherever, whenever.

Just for a general rule of thumb, don't capitalize method and variable names; reserve those for classes and constants. If that didn't do anything, I'm not quite sure why it wouldn't be working. The game keeps running but the damage doesn't trigger?

And yes, you and I have mentioned that before. A long while ago.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Gears

April 19, 2014, 07:09:28 am #122 Last Edit: May 25, 2014, 05:57:28 am by Gears
I see. The capitalization is rampant within my script. it all works though, so i'm not really anxious to change that.

I've got a question again. I've been tinkering on a part of code that should allow me to do collateral damage, making it so that on certain conditions, a CO's artillery pieces will also hit (practically fire at), units next to the target unit. The code seems to work, as the enemy units indeed do get damaged. however, they always get damaged for 1HP, while i specifically coded it to vary the damage depending on whether you're in your COP, SCOP, or not. here's how i tried it:

this is in the firing script, triggering if the unit attacks:
Spoiler: ShowHide
if @army.officer.class == CO_Chumbeque
     if INDIRECT.include?(unit_type)
     chumbeque_collateral(target.x,target.y)
     end
   end


and this is the specific function i created it links to:
Spoiler: ShowHide
  def chumbeque_collateral(g,h) # target x and y
     
                     target1= $game_map.get_unit(g-1, h)
                     target2= $game_map.get_unit(g+1, h)
                     target3= $game_map.get_unit(g, h+1)
                     target4= $game_map.get_unit(g, h-1)
      initialized = true
     if target1.is_a?(Unit)
               target = $game_map.get_unit(g-1, h)
   
         
                  if  DamageChart::PriDamage[@unit_type][target.unit_type] == -1
                   damage = DamageChart::SecDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
                   @weapon_use = 2
                 else
                   damage = DamageChart::PriDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
                   @weapon_use = 1
                 end
     # Damage calculations
damage *= offense_power
damage += luck_bonus
damage /= target.defense_power
damage *= target.terrain_defense
damage -= target.def_luck_bonus
damage /= 10.0
     if @scop
     damage *= 10000000
     elsif @cop
      damage /= 2.0
     else
       damage /= 4.0
     end
# Drop any hundredths and beyond numbers (5.556 => 5.5)
damage = sprintf("%10.1f", damage).to_f

     
# Calculate last stand
if target.is_a?(Unit) and target.army.officer.last_stand
if target.unit_hp > 1 and target.health - damage <= 0.0
damage = (0.1 - target.health).abs
end
end

      target.injure(damage, false, initialized)
     
    destroy if unit_hp <= 0    
       
     target.destroy if target.unit_hp <= 0
   end
   
   
   
       if target2.is_a?(Unit)
         target = $game_map.get_unit(g+1, h)
   
         
              if  DamageChart::PriDamage[@unit_type][target.unit_type] == -1
damage = DamageChart::SecDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 2
               else
damage = DamageChart::PriDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 1
               end
     # Damage calculations
damage *= offense_power
damage += luck_bonus
damage /= target.defense_power
damage *= target.terrain_defense
damage -= target.def_luck_bonus
damage /= 10.0
  if @scop
     
     elsif @cop
      damage /= 2.0
     else
       damage /= 4.0
     end
# Drop any hundredths and beyond numbers (5.556 => 5.5)
damage = sprintf("%10.1f", damage).to_f

     
# Calculate last stand
if target.is_a?(Unit) and target.army.officer.last_stand
if target.unit_hp > 1 and target.health - damage <= 0.0
damage = (0.1 - target.health).abs
end
end

      target.injure(damage, false, initialized)
     
    destroy if unit_hp <= 0    
       
     target.destroy if target.unit_hp <= 0
   end
   
        if target3.is_a?(Unit)
          target = $game_map.get_unit(g, h+1)
   
         
          if  DamageChart::PriDamage[@unit_type][target.unit_type] == -1
damage = DamageChart::SecDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 2
    else
damage = DamageChart::PriDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 1
     end
     # Damage calculations
damage *= offense_power
damage += luck_bonus
damage /= target.defense_power
damage *= target.terrain_defense
damage -= target.def_luck_bonus
damage /= 10.0
  if @scop
     
     elsif @cop
      damage /= 2.0
     else
       damage /= 4.0
     end
# Drop any hundredths and beyond numbers (5.556 => 5.5)
damage = sprintf("%10.1f", damage).to_f

     
# Calculate last stand
if target.is_a?(Unit) and target.army.officer.last_stand
if target.unit_hp > 1 and target.health - damage <= 0.0
damage = (0.1 - target.health).abs
end
end

      target.injure(damage, false, initialized)
     
    destroy if unit_hp <= 0    
       
     target.destroy if target.unit_hp <= 0
   end
        if target4.is_a?(Unit)
          target = $game_map.get_unit(g, h-1)
   
         
          if  DamageChart::PriDamage[@unit_type][target.unit_type] == -1
damage = DamageChart::SecDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 2
    else
damage = DamageChart::PriDamage[@unit_type][target.unit_type].to_f * (unit_hp/10.0)
       @weapon_use = 1
     end
     # Damage calculations
damage *= offense_power
damage += luck_bonus
damage /= target.defense_power
damage *= target.terrain_defense
damage -= target.def_luck_bonus
damage /= 10.0
     if @scop
     
     elsif @cop
      damage /= 2.0
     else
       damage /= 4.0
     end
# Drop any hundredths and beyond numbers (5.556 => 5.5)
damage = sprintf("%10.1f", damage).to_f

     
# Calculate last stand
if target.is_a?(Unit) and target.army.officer.last_stand
if target.unit_hp > 1 and target.health - damage <= 0.0
damage = (0.1 - target.health).abs
end
end

      target.injure(damage, false, initialized)
     
    destroy if unit_hp <= 0    
       
     target.destroy if target.unit_hp <= 0
   end
   
 
 
 end


Note that the *10000 damage was changed to verify it worked, yet it didn't.

KK20

Oh my god dude, you should have posted another post or messaged me--didn't see this until now.

Have you tried putting print statements in between the code to see what numbers you're getting? For example:

      if @scop
      damage *= 10000000
      p(damage)


p(damage)
target.injure(damage, false, initialized)


I haven't looked at AWE in a while due to other programming projects I'm working on (which in the long run will benefit this project too) so I can't really see where the bug is happening. I should also inform you that you can push all those get_unit commands into an array and evaluate those one at a time rather than having 4 if statements.

targets = []
targets.push($game_map.get_unit(g-1, h))
...
targets.each{|target|
  if target.is_a?(Unit)
    # Continue with your code
  end
}

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

betman

Hi everyone.

Its great to see the success 8) of this and I will continue to support this with all my heart.
Just wanted to leave and error that I found when turning the Exe file on .


Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   Game.exe
  Application Version:   1.0.0.1
  Application Timestamp:   40d19497
  Fault Module Name:   StackHash_2264
  Fault Module Version:   0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Code:   c0000005
  Exception Offset:   026fb530
  OS Version:   6.1.7601.2.1.0.768.3
  Locale ID:   1033
  Additional Information 1:   2264
  Additional Information 2:   2264db07e74365624c50317d7b856ae9
  Additional Information 3:   875f
  Additional Information 4:   875fa2ef9d2bdca96466e8af55d1ae6e


If anyone can help me with this it would be great. Thanks.

KK20

Well, I can tell you that it's not the game's fault. Have you tried searching for solutions? A simple Google search for "Stackhash 2264" already led me to a bunch of solutions.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

betman

I just figured it out. Thanks anyway.

Looking forward to the addition of a 3rd and 4th player to this.

KK20

Thanks~
I believe it already works fine. Only thing I need to add are teams and that's done with. But for now, I am currently working on a Tilemap rewrite that I believe I need for this project--and at the same time for other people's RM projects (if you have seen the XPAce conversion thread). So I haven't really worked on much recently, but I hope that will change once I'm done.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Gears

Quote from: KK20 on July 09, 2014, 04:05:04 am
Oh my god dude, you should have posted another post or messaged me--didn't see this until now.

Have you tried putting print statements in between the code to see what numbers you're getting? For example:

      if @scop
      damage *= 10000000
      p(damage)


p(damage)
target.injure(damage, false, initialized)


I haven't looked at AWE in a while due to other programming projects I'm working on (which in the long run will benefit this project too) so I can't really see where the bug is happening. I should also inform you that you can push all those get_unit commands into an array and evaluate those one at a time rather than having 4 if statements.

targets = []
targets.push($game_map.get_unit(g-1, h))
...
targets.each{|target|
  if target.is_a?(Unit)
    # Continue with your code
  end
}



I've been a bit busy lately, i think we probably all have. Thanks for the info!  I'll look to see if it works real soon!

KK20

November 06, 2014, 05:28:29 am #129 Last Edit: November 06, 2014, 05:31:22 am by KK20
So I finally did a thing after all these months.
Spoiler: ShowHide
And I'm surprised it took only a couple of days to make this:

And the code to set up this message system?

       @win.set_window("Andy")
       @win.add_text("Hey Nell. You called me?")
       @win.set_window("Nell")
       @win.add_text("Oh Andy, it's a good thing you're here. I need help with something.")
       @win.add_text("See that man over there?")
       @win.set_window("Flak", 1, false)
       @win.add_text("Hah hah hah...lady looking fiiiiiiiiine today.")
       @win.set_window("Nell", 2)
       @win.add_text("He's a total creep.")
       @win.set_window("Andy", 2)
       @win.add_text("What's so wrong about that?")
       @win.set_window("", 1)
       @win.add_text("He's just giving you a compliment. I agree that you are looking fine today too.")
       @win.set_window("Nell", 2)
       @win.add_text("...")

The update method is being called every time Graphics.update is.


Besides that, I have gotten around to cleaning up the code a lot, so much so that you guys editing the engine (that is if you still visit here anyways) might have to write up entirely new changes. Thank god I finally finished that XPA Tilemap so I can use it in this engine as well as transition over to XPA. However, people have reported that FMod causes errors for them in XPA (which is odd because my laptop has no problems but my desktop does), so I might have to revert to a different looping audio script.

It feels so good to work on this again.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zexion

November 06, 2014, 05:19:13 pm #130 Last Edit: November 06, 2014, 05:22:05 pm by Zexion
wat a creep

edit: fricken 1338 i totes missed 1337. o well gf me

Also, you gonna add interpreter commands? or liek wat how u do this

KK20

Interpreter commands as in:

class Interpreter
  def add_text(string)
  # fancy code
  end
end

Cuz yeah, I'm going to do that. The way I did this is just load the commands into an array and fire them off one-by-one depending on the window's state:
MSG_IDLE = Nothing is happening. You can't see the message window at all.
MSG_RUN = Force the window to update and perform its commands.
MSG_DRAW = Currently drawing text.
MSG_WAIT = Stops the window from firing off the next command.
MSG_SWAP = Same as WAIT but this only occurs when the face graphic or the window itself are sliding on/off screen.

The instance you call 'add_text', the window will be put into the MSG_RUN state. On the next frame, Graphics.update is called, which in turn calls this window's update method. I use Array#shift to get the first command. If the command is a string, I can go right on ahead and draw the text. If it's an Array, I call another method that evaluates the array's contents, similar to how RMXP's Interpreter 2 works. From there, it's nothing but a bunch of other methods being called and variables keeping track of the animations (i.e. animation frame counters, if moving up/down, if closing window).

The main reason I aliased Graphics#update is so that I could create a global instance of this object and make calls to it regardless of the scene. And also to make it easier for development, not having to worry about creating an instance, having to remember to update it, etc.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zexion

I swear that I didn't add that last bit lol. At least not on purpose xD "or liek wat how u do dis". I might have typed what I was saying out loud rofl.

Gears

This poject is aiding me in ways i never saw coming.

Zexion


KK20

Glad that you're still following this despite my lack of progress.

School is almost over with this year, so I plan to work on things over break naturally. I've been writing documents upon documents on structuring a solid AI opponent, and it's baffling me immensely, especially when I'm trying to write for potential changes and additions. I've generated influence maps, but finding the right values to use is going to be a lot of work.

Meanwhile, I've cleaned up the main process immensely and wrote a glowing range tile DLL add-on to my tilemap rewrite. Still a number of other things to do (like menus and windows).
Collection of images: ShowHide

Glowy tiles are applied to the entire tilemap graphic and rendered pre-game

Glowy tiles in action (disregard the arrow path being drawn--fixed it)

Influence Map idea

WIP Unit Stat list


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Gears

December 22, 2014, 04:55:52 pm #136 Last Edit: January 10, 2015, 08:52:03 pm by Gears
Now that's some grade A stuff. I've been having a ball replacing various textures and ending up with some of the most goofball units in the history of advance wars.

Edit: Managed to make the collateral artillery damage work.

EDIT: After playing a bit in regular advance wars 2, it seems units die quicker in this emulator, i'm not entirely sure of it but where did the damage calculation come from?

KK20

Kind of a hybrid between the staple Advance Wars series and Days of Ruin. I didn't like how 200% defense equals perfect defense from attacks, down to the point where only luck damage can do anything. This made Javier impossible to play against. It also limits the amount of defense bonuses you can give to units. So I went with the Days of Ruin approach where 150% increased attack versus 150% increased defense negate each other out.

To keep terrain bonuses still a viable option, I kept it the same way as the original AW series; sitting on a mountain reduces maximum damage by 40%. It allows Lash to not be severely nerfed by the way how terrain defenses worked in DoR (yeah, she's still really good in the engine).

Luck was also balanced out to be applied BEFORE enemy defenses rather than AFTER. It just made Nell ridiculous to have infantry waltz up to Kanbei's SCOP'd Megatank and have a chance to instantly destroy it. Also, luck only does +5 rather than +10. This might change later.

The main contributor to quickly destroying units would have to be the damage chart though. Granted, I didn't really follow any game's table (cuz like Stealth Fighters and Bike Infantry didn't exist together, and Destroyers are an entirely new unit), but I tried fitting it close to what I'd expect the values to realistically be. You can also see how I nerfed the Medium Tank's power while making it cost slightly less (Tank units actually stand a chance against it now) and Recons do an extra 10 damage against infantry compared to the games (honestly, recons are almost as ignored as Missiles in non-FOW maps). It could also be that CO Powers are charging up faster than normal. AW:DS is known for it's pretty fast charge rates whereas AW2 filled up stars based on unit costs (1 star = 9000G = 1 Battle Copter destroyed on enemy's turn). The numbers I gave in the unit classes are, again, just made up values that haven't really been tested for balance.

One major goal of mine is to lower indirect unit damage and possibly defense. The fact that they can hit as hard as their direct-combat counterparts without fear of counters makes them too good (coughGritcough). I want them to be a support role, not a standalone sniper--except for Missiles... they need ridiculous damage to even be considered in battle.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Gears

I see. That explains some of the things I've been seeing. Another question entirely, did you disable the variations for fzero's weather script?

KK20

I shouldn't have. I'm pretty sure I didn't touch a thing with it. I was just looking for some weather system that had rain, snow, and sandstorm.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!