[XP] Advance Wars Engine

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

Previous topic - Next topic

KK20

Looks fine right there to me. I'll have to test it out when I'm on my computer.

EDIT: Oh, I see. Unit doesn't have an @officer variable. You should be using @army.officer instead.
Which is kinda funny since I'm sure you have seen that syntax used throughout the Unit class.

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

March 20, 2014, 05:05:44 pm #81 Last Edit: March 20, 2014, 05:57:08 pm by Gears
Degree of Derp: Derpin'


Welp, managed to make something new today. Anyone know the Harkonnen? Nope?

I managed to differ damage calculations for a particular CO, so he ignores his own Unit's health during his SCOP, effectively, this means that any and all units act as 10 HP units! I also managed to differ his calculations a bit during his COP and day to day power, lowering the effect the unit HP has by calculating the loss gain trough (20-unit_hp)/20 or (15-unit_hp)/15, this makes units hits slightly more then they should, and i did the same for defence!

kinda funky, really.

KK20

I actually had an idea like that. I was planning on making that one of the starting COs in my campaign.

D2D:

  • Damage reduction of damaged units is reduced

  • +10% power during counters


Power:

  • Every lost HP equates to +2% luck (from 10HP to 1HP: 5, 7, 8, 10, 11, 13, 14, 16, 17, 19) - Yes, that reads as a 1HP infantry can possibly do 2HP damage to a Megatank out of nowhere

  • Additional 20% power during counters


Super:

  • Greatly reduces damage reduction from damaged units

  • Improves defenses of damaged units (maybe like +5% for each difference in HP; don't forget the innate +20% defense bonus from a SCOP)
  • Additional 40% power during counters



For a CO with no weakness, I think it balances out nicely. If I make him a "Never give up!" kind of guy, it all fits well. I did contemplate making the super do full damage regardless of HP, but I'll need to test play that idea first.

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

Spoiler: ShowHide
### If this unit can attack another unit directly
if (unit.max_range == 1 and (unit.ammo > 0 or unit.secondary)) and (unit.army.officer.class == !CO_Renteria)
ranges = calc_pos(unit, "direct", cursor.x, cursor.y) #$game_map.get_nearby_units(cursor.x, cursor.y)
     
    ranges.each{|r|
next unless valid?(r[0],r[1])
# Get the unit and tile at this spot
u = $game_map.get_unit(r[0], r[1], false)
tile = $game_map.get_tile(r[0], r[1])
# If no unit exists at this spot
if !u.is_a?(Unit)
# If this is a tile that can be destroyed
if tile.is_a?(Structure) and tile.hp > 0 and unit.can_attack?(tile)
commands.push("Fire")
break
else
next
end
# If enemy unit (will need edit for allied armies)
elsif u.army != unit.army and unit.can_attack?(u)
commands.push("Fire")
break
end
}
     
   elsif unit.max_range == 2 and (unit.ammo > 0 or unit.secondary) and unit == $game_map.get_unit(cursor.x, cursor.y) and (unit.army.officer.class == CO_Renteria  and (unit.max_range == 2 and (unit.ammo > 0 or unit.secondary)))

     ranges = calc_pos(unit, "attack")

     
     
     ranges.each{|r|
next unless valid?(r[0],r[1])
# Get the unit and tile at this spot
u = $game_map.get_unit(r[0], r[1], false)
tile = $game_map.get_tile(r[0], r[1])
# If no unit exists at this spot
if !u.is_a?(Unit)
# If this is a tile that can be destroyed
if tile.is_a?(Structure) and tile.hp > 0 and unit.can_attack?(tile)
commands.push("Fire")
break
else
next
end
# If enemy unit (will need edit for allied armies)
elsif u.army != unit.army and unit.can_attack?(u)
commands.push("Fire")
break
end
}
### If this unit can attack indirectly
elsif unit.max_range > 1 and (unit.ammo > 0 or unit.secondary) and ((unit.army.officer.class == !CO_Renteria) and unit.max_range == !2)
unit == $game_map.get_unit(cursor.x, cursor.y) and
    # Get ranges by calling calc_pos. Then evaluate each spot.
# If it finds an enemy, push "Fire". Else, push "Fire " (can't fire).
ranges = calc_pos(unit, "attack")
ranges.each{|r|
next unless valid?(r[0],r[1])
u = $game_map.get_unit(r[0], r[1], false)
tile = $game_map.get_tile(r[0], r[1])
if !u.is_a?(Unit)
if tile.is_a?(Structure) and tile.hp > 0 and unit.can_attack?(tile)
commands.push("Fire")
break
else
next
end
elsif u.army != unit.army and unit.can_attack?(u)
commands.push("Fire")
break
end
}
     elsif unit.max_range > 2 and (unit.ammo > 0 or unit.secondary) and ((unit.army.officer.class == CO_Renteria))
unit == $game_map.get_unit(cursor.x, cursor.y) and
    # Get ranges by calling calc_pos. Then evaluate each spot.
# If it finds an enemy, push "Fire". Else, push "Fire " (can't fire).
ranges = calc_pos(unit, "attack")
ranges.each{|r|
next unless valid?(r[0],r[1])
u = $game_map.get_unit(r[0], r[1], false)
tile = $game_map.get_tile(r[0], r[1])
if !u.is_a?(Unit)
if tile.is_a?(Structure) and tile.hp > 0 and unit.can_attack?(tile)
commands.push("Fire")
break
else
next
end
elsif u.army != unit.army and unit.can_attack?(u)
commands.push("Fire")
break
end
}
commands.push("Fire ") if !commands.include?("Fire")
end


Quite obviously this pile of useless code isn't going anywhere. Can you guide me to the exact part of code that stops indirect units from firing after they moved?

KK20


### If this unit can attack indirectly
elsif unit.max_range > 1 and (unit.ammo > 0 or unit.secondary) and
unit == $game_map.get_unit(cursor.x, cursor.y)  #<====== If unit is currently positioned where the cursor is at AKA unit hasn't moved

If you're going for a "indirect units can move and attack on the same turn" thing, you should probably do

### If this unit can attack indirectly
elsif unit.max_range > 1 and (unit.ammo > 0 or unit.secondary) and
(unit == $game_map.get_unit(cursor.x, cursor.y) || unit.army.officer.class == CO_Renteria)

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

March 20, 2014, 07:39:02 pm #85 Last Edit: March 20, 2014, 07:48:00 pm by Gears
that Does allow the option, though it states it can't fire. now to somehow actually allow it to fire. I'll try some different stuff tommorow.


Random thought: what if i change all instances of range (such as
unit.max_range > 1
)to unit type variables? You dd make those groups after all.

like this:
if unit.unit_type == INDIRECT 

KK20

Then wouldn't you have to do a bunch of if-else statements for all those different types of units?
And I realize what I did. You will have to modify the calc_pos method for getting attack ranges. I'll be sure to consider that in the current build.

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

March 20, 2014, 08:03:51 pm #87 Last Edit: March 21, 2014, 09:53:33 am by Gears
But doesn't the unit group variable cover all the indirects? Why would i need multiple if else statements?

Edit: I managed to make it refer to the unit groups, and it works, slightly. Indirect units act as normal, and direct units with added range do say they can attack, they just don't find targets. They can find targets if they haven't moved yet (In other words, they act like indirects, but say that they can fire)

Edit 2: I also found a slight bug in my mind controlling code. it appears to crash due to the unit index not responding properly once the unit is killed. I imagine i must somehow reset it's listing.

KK20

March 24, 2014, 01:13:11 pm #88 Last Edit: March 24, 2014, 01:38:44 pm by KK20
Yeah, that's still a problem with calc_pos and determine_unit_commands. You'll need to edit those (or wait for me to release the update).

I think you have to delete the unit from the enemy army's unit array and add it to the player's. Array#delete and Array#push should do the job.

EDIT: Meanwhile, I'm working on ripping the last of the tile sprites. It's a slow and painful process staring at each tile making sure I'm not putting the wrong frame of animation in each group--because I've done that like 5 times now. Since my tilemap rewrite works fine, I'll write an add-on for autotiles to function a bit differently from RMXP's. This will probably make mapping in the editor a bit difficult now. Or maybe upon loading the game I'll read in map files and modify the data table and save it. I'll eventually have a built-in map editor some point down the road--maybe after I finish the AI and finalized all my event commands (e.g. Show Message after X Days, volcano strikes here every X day, hidden lab map on this city, 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!

Gears

I tried using sensei's code to manipulate the arrays, but i think i'm using the wrong parameters for U. should i somehow make a new variable for that? so instead of


Spoiler: ShowHide
	def use_scop
super
   
    loc = $scene.find_best_missile_spot(0)
# Get all the spots where this missile hits
positions = $game_map.get_spaces_in_area(loc[0],loc[1],0)
positions.each{|pos|
# Get unit at this spot
u = $game_map.get_unit(pos[0],pos[1])
next if u.nil?
# Damage it and apply status effect
###########

      # u.army.units[index]
      @army.u.delete(u)
      u.army = @army
      u.sprite.refresh
      @army.u.push(u)
      #########################
     
}
$game_player.moveto(loc[0],loc[1], true)
   
add_status(3, $game_map.units - @army.units)
end
   


i would have
Spoiler: ShowHide
 [spoiler][code]@army.u.push(unit)
[/code][/spoiler] with unit somehow mimicking sensei?

KK20

March 25, 2014, 03:04:26 pm #90 Last Edit: March 25, 2014, 03:19:25 pm by KK20
I think it works like this:

u.army.units.delete(u)
u.army = @army
@army.units.push(u)

I'll eventually write something to make this process easier.

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

March 25, 2014, 03:23:23 pm #91 Last Edit: March 25, 2014, 04:56:14 pm by Gears
It's not exactly top priority yeah.

Huh. weird. I've been fooling around for some time now, and i have been using edited CO properties like perfect_movement without listing them in the  attr lists without problems. Is that list even needed?

KK20

The parent class CO has all those variables initialized. You don't need to copy-paste the attr_ stuff in every new CO.

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 05, 2014, 09:48:37 am #93 Last Edit: April 05, 2014, 12:56:02 pm by Gears
Hostile lake seems to have a small inconsistency where the blue player has one more city at the start. Also, are tanks supposed to be able to cross rivers? (they can in famicom wars, but not in advance wars or AW:BR)

Oh, and a question. is it possible to somehow leave a exact copy of a unit on it's original place after it moves? should be possible during an SCOP or something.

KK20

It's mainly for the first turn advantage that Orange Star has. Tournament players usually play maps that are symmetrical but still give Blue Moon some kind of advantage to stay balanced with Orange Star.

I did make Tread units cross over rivers. You can change the move cost of Rivers to disallow that if you want. I just felt it worked better and made maps like Lost River playable (no seriously, that map is so full of poop).

Not sure about that unit creation. I could probably figure it out, but it would be messy and unconventional. You'd have to make changes to the Scene_Map to even allow this to be possible.

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

On the tournament style, i´m not even sure being first in turn gives an advantage, as most maps i played on the gameboy-ds were all even and symmetrical. that´s where i base most of my knowledge off, same with the river issue. i can see why some maps would become more playable with passable rivers though, especially if it´s anything like ridge island with grit in the mountain passes.

As for the unit creation, drat. I guess i´ll have to see if i can write a loop using the APC code that randomly spawns copies near units. I´ve been messing in the unit files and scene map files for a while though, they allow for some funny things.

Laytruce

I made an account just so I could participate in this thread. I've been playing around with this a lot, and wanted to share my findings.
I'm very inexperienced with Ruby, so bear with me.

First, a few bugs:

- Joining 2 units when FOW is on crashes the game. There's some code in Spriteset_Map's update_fow method which looks like this:


$scene.player_turn.units.each{|unit|
      next if unit.loaded
      sight = $scene.calc_pos(unit, "vision")
      around = $game_map.get_spaces_in_area(unit.x, unit.y)
      sight.each{
      ...
}
     }


Apparently, both to-be joined units are still present in the units array, one of which is now nil. It tries to check unit.loaded, but can't.
On my end, I simply added a unit.nil? check on the 'next if' line to prevent this, but it might be cleaner to have the 'joined up' unit removed from the array sooner. Don't know how plausible this is, though.

- When using a vision-increasing power, the FOW isn't updated until after you move or attack. I simply added a call to $spriteset.update_fow to the use_(s)cop methods to fix it.

Right. Aside from that, I've been training some new recruits who decided to show up:
Anyone know these jokers?: ShowHide




I think I've given them some interesting abilities.

Check out Lin's hax intel skills!: ShowHide




Forsythe only has a normal CO Power!: ShowHide




Tasha's air units break the almighty 9 ammo barrier!: ShowHide




I'll leave all CO summaries here in case someone's interested.

CO summaries: ShowHide

################################################################################
# Class Will
#   Army: Orange Star           Power Bar: x x x X X X
#
# - 110/100 Direct Ground Units
# - 100/90 Indirect Ground Units
#
# Power: Rally Cry
# - Direct ground units gain +1 movement
# - All units gain +2 offense for each unit Will has (max. 40)
#
# Super Power: New Era
# - Direct ground units gain +2 movement
# - All units gain +3 offense (max. 80) and +1 defense for each unit Will has
#   
################################################################################
################################################################################
# Class Brenner
#   Army: Orange Star           Power Bar: x x X X X
#
# - All units who gain terrain defense gain +1 terrain star
#
# Power: Reinforce
# - 100/130 Units
#
# Super Power: Lifeline
# - 100/130 Units
# - All units are healed 3 HP
#   
################################################################################
################################################################################
# Class Lin
#   Army: Orange Star            Power Bar: x x X X X X
#
# - All cities are visible to Lin in Fog of War
#
# Power: Scout
# - Makes all spaces bordering cities visible to Lin (including woods and reefs)
# - Recons gain +1 movement
# - 130/130 Recons
#
# Super Power: Night Vision
# - Makes all spaces bordering cities visible to Lin (including woods and reefs)
# - Recons gain +2 movement
# - Gives all units +10 offense and defense for each space of vision they have
#   
################################################################################
################################################################################
# Class Isabella
#   Army: Orange Star           Power Bar: x x x X X X X
#
# - 50% chance to not spend primary weapon ammo when firing
# - Primary weapons +10% firepower
# - Secondary weapons -20% firepower
#
# Power: Deep Strike
# - Units will not use primary weapon ammo this turn
# - Primary weapons +10% additional firepower
# - Deals 1 damage to all enemy units on deployable properties
#
# Super Power: Overlord
# - Units will not use primary weapon ammo this turn
# - Primary weapons +20% additional firepower
# - All units gain +1 movement and +1 vision
# - All indirect units gain +1 range
#   
################################################################################
################################################################################
# Class Tasha
#   Army: Blue Moon            Power Bar: x x x X X X
#
# - 120/90 Air Units
# - Air units carry +3 ammo
#
# Power: Fox One
# - Air units gain +1 movement
# - All units gain +10 offense for each HP lost
#
# Super Power: Sonic Boom
# - Air units gain +2 movement
# - All units gain +20 offense for each HP lost
#   
################################################################################
################################################################################
# Class Gage
#   Army: Blue Moon           Power Bar: x x x X X X
#
# - 120/120 Indirect and Naval Units
# - 85/100 Direct Air Units and Direct Vehicles
#
# Power: Long Shot
# - Indirect units gain +1 range
# - Indirect units' vision becomes equal to their maximum range
#
# Super Power: Long Barrel
# - Indirect units gain +1 range
# - Indirect units' vision becomes equal to their maximum range
# - All indirect units that have carried out an action may move again
#   
################################################################################
################################################################################
# Class Forsythe
#   Army: Blue Moon           Power Bar: x x x x
#
# - 110/110 Units
# - No Super Power
#
# Power: Inspiration
# - 130/130 Units
# - Units with more than 1 HP are able to survive fatal hits with 1 HP
#
# Super Power: None
#   
################################################################################
################################################################################
# Class Waylon
#   Army: Green Earth           Power Bar: x x x X X X X
#
# - 100/130 Air Units
# - 100/80 Vehicle and Naval Units
# - Units are unaffected by sand
#
# Power: Wingman
# - 100/220 Air Units
# - Air units are resupplied
#
# Super Power: Bad Company
# - 130/410 Air Units
# - Air units are resupplied
# - Opponents' properties are made unable to repair HP
#   
################################################################################
################################################################################
# Class Greyfield
#   Army: Green Earth           Power Bar: x x X X X X X
#
# - 100/120 Naval Units and Copters
# - Naval units have 99 max fuel
# - 90/100 Vehicles
#
# Power: Supply Chain
# - All units are resupplied
# - APCs gain +2 movement
#
# Super Power: High Command
# - All units are resupplied
# - APCs gain +2 movement
# - Naval units gain +1 movement
# - Naval indirect units gain +1 range
# - Unit costs are lowered by 20%
# - Enemy units lose 25% of their ammo and fuel
#
################################################################################
################################################################################
# Class Penny
#   Army: Yellow Comet           Power Bar: x x x X X X X
#
# - Units are unaffected by weather
#
# Power: Enigma
# - Summons random weather for 1 turn
# - Makes a random ground unit appear on Penny's HQ (if it's unoccupied)
#
# Super Power: Stormfront
# - Summons random weather for 3 turns
# - Reduces HP of 3 random units of each enemy army to 1
#   
################################################################################
################################################################################
# Class Tabitha
#   Army: Yellow Comet           Power Bar: x x x x x X X X
#
# - 110/100 Units
# - The charge rate of her Power Bar starts off lower than normal
#   and decreases more quickly
#
# Power: Firestorm
# - Deals 3 damage to all enemy units
# - Deals 1 damage to all of Tabitha's units
#
# Super Power: Apocalypse
# - Drops 5 bombs on enemy units. Each bomb deals 4 damage and has a radius of 1.
#   
################################################################################
################################################################################
# Class Caulder
#   Army: Yellow Comet           Power Bar: X X X X X X X X
#
# - 120/120 Units
# - Can repair up to 5 HP at the start of each turn
# - When 2 units are joined, the resulting unit gains 2 extra HP
#
# Super Power: Grand Mutation
# - Direct units are able to attack at range (2)
# - Newly built units are immediately able to move
# - All units heal 2 HP
#   
################################################################################


I didn't playtest these guys for balance much yet, so there's probably some issues there.
And yes, I went nuts with Caulder.

ShadeHunter

Hello KK20!  :haha:  just brought rpg maker xp and it is incredible.

I also found this engine was really surprised how interesting game system this is.

:???:  have few questions about this engine. :???:

1. You have said that in the original game there can be 4 teams. Is this possible to do so in the engine?

2. How the fog of war can be turn on?

3. I do not really understand how those special CO powers work.

4. Is it possible to create more buildings in engine? Different nations could have different troops?

I only ask because I'm intending to create a game about World War 2 and especially about Winter War.

Thank you.  ;)

Gears

April 06, 2014, 11:45:25 am #98 Last Edit: April 06, 2014, 01:38:00 pm by Gears
@Laytruce: You're late in breaking the ammo barrier, i did that a  week ago! i did not manage to make the descriptions nice however, i simply bungled the ammuntion code for the unitfiles to include a extra multiplier, which resulted in me needing to make some extra pictures for the numbers 10 to 20. i'd be interested in learning how you made those numbers show up nicely.
Spoiler: ShowHide
 
Spoiler: ShowHide
Totally not OP


I've got to give you proper applause though, you managed to make direct units hit a space further? Can you share how you've done that? And also how you managed to resupply for example only air units while not supplying all army units?

@ShadeHunter: I'm not KK20, but i can answer question 1 & 3: KK20 has a build which allows 4 player combat, i don't know if he's made some form of teamup yet (which would allow 2 VS 2 and 1 VS 2), but 4 players is a yes as far as i've heard.

The COP powers work rather quaintly. A COP generally has either buffs, an effect on activation or a "other" effect. Buffs are handled by the modifiers he made, you simply use the IF statements to determine how much a unit would gain from a specific stat during either the COP, SCOP, or day-to-day. a activation effect is used by the use_cop and use_scop definition. it's really just a case of looking into the vanilla CO's to see how it's generally done.

Also: traffic!

Laytruce

April 06, 2014, 03:07:07 pm #99 Last Edit: April 06, 2014, 03:31:04 pm by Laytruce
Quote from: ShadeHunter on April 06, 2014, 08:57:39 am
2. How the fog of war can be turn on?


Go to scripts, and look for the Game_Map script under [Engine]. Around line 70, you'll find a line which says @fow = false. Simply replace false with true.

Quote from: Gears on April 06, 2014, 11:45:25 am
@Laytruce: You're late in breaking the ammo barrier, i did that a  week ago! i did not manage to make the descriptions nice however, i simply bungled the ammuntion code for the unitfiles to include a extra multiplier, which resulted in me needing to make some extra pictures for the numbers 10 to 20. i'd be interested in learning how you made those numbers show up nicely.


Very simple, actually. I looked at how fuel was displayed and applied that to ammo. Fuel takes the tens and ones digits separately and places the two number graphics next to each other. The engine assumes ammo is a single digit by default, so I had to modify the code a bit so it does the same for ammo. It can go up to 99 now, but that would be crazy.

Quote from: Gears on April 06, 2014, 11:45:25 am
I've got to give you proper applause though, you managed to make direct units hit a space further? Can you share how you've done that?


Err...much trial and error, I'm afraid. I mostly made edits in the determine_unit_commands and calc_pos methods, so they could support units which can fire both directly and indirectly. Modifying calc_pos in particular is tricky, since it has multiple functions. It's hard to modify one of its functions without screwing up another.

Quote from: Gears on April 06, 2014, 11:45:25 am
And also how you managed to resupply for example only air units while not supplying all army units?


It's just a matter of passing only air units to the full_supplies method. In Jess's case, it says full_supplies(@army.units).
You can use the select method to pass only units which satisfy a certain condition. In Waylon's case, it's full_supplies(@army.units.select {|unit| AIR.include?(unit.unit_type)})