Author Topic: Arch3r OS: Terrain advantage  (Read 7153 times)

0 Members and 2 Guests are viewing this topic.

Arch3r

  • Grandmaster Knight
  • *
  • >:I
    • View Profile
  • Faction: Rhodok
  • MP nick: CoR_Arch3r
  • M&BWBNW
Arch3r OS: Terrain advantage
« on: June 26, 2009, 08:38:45 PM »
What this does: When simulating battles some troops get advantages. Mounted troops get more bonus on the steppe, desert or plain ground, infantry gets an advantage in forests while archers get a penalty. I used this for the mod Avarice of the Exiled, where I also checked for items that gave certain units advantages in snow or desert.

How this works: When a battle is simulated (with either the "Order your troops to attack without you" or AI battles) the script_game_event_simulate_battle is called. Inside the script it uses script_party_calculate_strength to see which party is stronger. I added terrain to this, to give Khergits for example a bonus on steppe.

How to implent it: Search for the script party_calculate_strength. Add the lines in the spoiler right above:

        (try_begin),
          (neg|troop_is_hero, ":stack_troop"),
          (party_stack_get_size, ":stack_size",":party",":i_stack"),
          (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"),
          (val_sub, ":stack_size", ":num_wounded"),
          (val_mul, ":stack_strength", ":stack_size"),
        (else_try),
          (troop_is_wounded, ":stack_troop"), #hero...
          (assign,":stack_strength",0),
        (try_end),
        (val_add,reg(0), ":stack_strength"),
      (try_end),
      (party_set_slot, ":party", slot_party_cached_strength, reg(0)),
  ]),


(click to show/hide)

That should do it, if I forgot something or this doesn't work, tell me.
« Last Edit: May 04, 2010, 12:10:34 PM by Arch3r »

I am Space Khergit, and above pyramids.

amade

  • Grandmaster Knight
  • *
  • Own up and take it like a man
    • View Profile
    • Studio Wossname
  • Faction: Neutral
Re: Open Source: Terrain advantage
« Reply #1 on: June 26, 2009, 09:02:33 PM »
Part of your code turned into a smiley. If I'm not mistaken it's suppose to be 
Code: [Select]
8-) I'm not code savvy but I think it's odd that there's a negative right after your number.

At any rate, very useful thing you've made here.

edit: Also, I note part of your code contains bits referring to items in your mod, so if I want to implement this into my own or another mod I just need to remove these bits or substitute them for mine?
« Last Edit: June 26, 2009, 09:05:16 PM by amade »

Don't you just love herding cattle?
*end.transmission - Studio Wossname*
___________________________________________________________________________________________________________________________

   .

Arch3r

  • Grandmaster Knight
  • *
  • >:I
    • View Profile
  • Faction: Rhodok
  • MP nick: CoR_Arch3r
  • M&BWBNW
Re: Open Source: Terrain advantage
« Reply #2 on: June 26, 2009, 09:03:29 PM »
Woops, I'll correct the smily, anyways its not 8-) but 8)

I am Space Khergit, and above pyramids.

Cruger

  • Guest
Re: Open Source: Terrain advantage
« Reply #3 on: June 26, 2009, 09:33:33 PM »
Thats pretty cool :)

Just a suggestion: Would'nt it be good if you added advantage for archers on plain, steppe and desert aswell, and then also gave the cavalry a penalty in forrests?

bjorne.

  • Sergeant Knight
  • *
  • I'm a nerd... deal with it..
    • View Profile
    • Age of Blackpowder - Realm of Revolution
  • Faction: Swadian
Re: Open Source: Terrain advantage
« Reply #4 on: June 26, 2009, 09:47:51 PM »
well this is a great idea.
But...

1. Doesn't the archers already have natural penalty in forests like I mean.. with all the trees in the way for their shooting. and the same with cavalry. That they get stuck in every tree.

2. How does your penalty system work? does it reduce stats or?

Arch3r

  • Grandmaster Knight
  • *
  • >:I
    • View Profile
  • Faction: Rhodok
  • MP nick: CoR_Arch3r
  • M&BWBNW
Re: Open Source: Terrain advantage
« Reply #5 on: June 26, 2009, 10:44:45 PM »

How this works: When a battle is simulated (with either the "Order your troops to attack without you" or AI battles) the script_game_event_simulate_battle is called. Inside the script it uses script_party_calculate_strength to see which party is stronger. I added terrain to this, to give Khergits for example a bonus on steppe.

@bjorne.: Might want to see this, its for simulated battles, for a more realistic battle simulation.

Thats pretty cool :)

Just a suggestion: Would'nt it be good if you added advantage for archers on plain, steppe and desert aswell, and then also gave the cavalry a penalty in forrests?
Cavalry already have a penalty in forests, well, archers and cavalry don't have a penalty, but infantry has an advantage. Also I can give archers a slight advantage on plain,steppe and desert ya.

I am Space Khergit, and above pyramids.