Author Topic: [OSP][WB][S] Unit Upgrade Academy  (Read 4281 times)

0 Members and 1 Guest are viewing this topic.

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
[OSP][WB][S] Unit Upgrade Academy
« on: November 07, 2013, 09:37:54 AM »
This OSP script of the week fills in the functionality for the Military Academy from the previous combat modifier buildings. If you would rather not add in the framework some extra buildings, simply replace all references of slot_center_has_academy with slot_town_prosperity, which should limit the number of troops available for upgrade in a semi-reasonable fashion.

To use this, go through the party list on the left and select one of the two options below the troop's tableau. This is intended for usage in promoting troops to alternative branches (i.e. knighthood, bandits into faction recruits) but that implementation is left as an exercise for the reader. Holding shift/ctrl has the same effect as it would in the party menu, and up/down or mwheel goes through the stacks. There are also some gamepad buttons that you can experiment with, but are untested.
(click to show/hide)

This mesh used for the background requires a planar mesh and a duplicate material with the following settings - otherwise you get psychedelic transparency issues.
(click to show/hide)

To access the presentation drop this in the appropriate menu (the recommended being the default town in which buildings are probably present)
Code: (mnu_total) [Select]
    ("town_upgrade",
      [
         (party_get_slot, reg12, "$current_town", slot_center_has_academy),
         (is_between, "$g_encountered_party_faction", kingdoms_begin, kingdoms_end),
         (ge, reg12, 1), #this value is used later
         (eq, "$g_encountered_party_faction", "$players_kingdom"),
         (this_or_next|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
         (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"),
      ],"Enlist troops in the military academy ({reg12} available).",
      [
        (assign, "$g_cur_stack", -1),
        (start_presentation, "prsnt_upgrade_troops"),
      ]),

Credits for the original party stack interface go to rubik's Custom Commander - "Sort the Defender" presentation.

Efe Karacar

  • Duke
  • *
  • aka Belendor
    • Steam - Belendor
    • Twitch.tv - Belendorr
    • YouTube - Belendor
    • View Profile
    • Art of Efe Karacar
  • Faction: Swadian
  • MP nick: Belendor
  • WBWF&SNWVCM&B
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #1 on: November 07, 2013, 09:50:29 AM »
Wicked! That is such a presentation I needed for to examine on for a while. 

Rallix

  • Count
  • *
    • View Profile
  • Faction: Nord
  • M&BWBWF&SVC
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #2 on: November 08, 2013, 01:38:47 PM »
So... You pay extra money to upgrade units instantly?
I like it.

ThaneWulfgharn

  • Master Knight
  • *
  • ALL HAIL THE ALLFATHER!!!
    • View Profile
  • Faction: Nord
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #3 on: November 08, 2013, 01:57:22 PM »
Can you make more than 2 upgrade alternatives? Like 3???

Efe Karacar

  • Duke
  • *
  • aka Belendor
    • Steam - Belendor
    • Twitch.tv - Belendorr
    • YouTube - Belendor
    • View Profile
    • Art of Efe Karacar
  • Faction: Swadian
  • MP nick: Belendor
  • WBWF&SNWVCM&B
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #4 on: November 08, 2013, 10:25:45 PM »
Can you make more than 2 upgrade alternatives? Like 3???

That is quite unrelated to the subject.

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #5 on: November 09, 2013, 12:15:26 AM »
Yes, the presentation can be expanded for custom upgrade paths, as mentioned in the original post. This version is for Native-based mods and such fetch the successor from the original troop's upgrade.

fladin

  • Baron
  • *
    • Steam - infomatec
    • YouTube - UCJd5LBSuJabHUmwxD1eQe2w
    • View Profile
    • said.ovh
  • Faction: Neutral
  • MP nick: infomatec
  • WBNWVC
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #6 on: May 08, 2014, 12:57:27 PM »
with your permission of course , I will use your awesome code (with some modifications) in my mod ...

(click to show/hide)

Thanks

Heroes_Witch_King

  • Guest
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #7 on: May 08, 2014, 11:11:34 PM »
Wow, this is really great! I will definitely use this...

Garedyr

  • Sergeant Knight at Arms
  • *
  • fear the bonerlords
    • View Profile
  • Faction: Nord
  • WBVC
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #8 on: June 20, 2014, 07:45:39 PM »
Wow! Thank you man!  :D

wld427

  • Recruit
  • *
    • View Profile
  • Faction: Neutral
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #9 on: December 04, 2014, 07:41:28 PM »
Where exactly do i drop the last piece of code to get the menu action to show up in a specific castle?


EDIT: i thought i would elaborate a little....

What i have done is add a new castle in each factions territory. What i want to do is assign these new castles purpose as the military academy. So you can stop by there and if you are allowed entry to the castle then the player can upgrade his troops if he has enough money.

« Last Edit: December 04, 2014, 08:15:12 PM by wld427 »

Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #10 on: December 05, 2014, 12:56:18 AM »
Assign some arbitrary value to slot_center_has_academy for those castles at the start of the game, then inject some code to refresh it in one of the existing center maintenance scripts and/or triggers. I recommend one of the weekly triggers that process center wealth/reinforcement or the taxes one. Modify the conditions so that the player won't need to own it or be marshal if necessary.

aliemre461

  • Knight
  • *
  • Permanently Banned
    • View Profile
  • Faction: Nord
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #11 on: December 22, 2014, 03:23:35 PM »
 Where should i put this code please help me

 
Code: [Select]
  ("town_upgrade",
      [
         (party_get_slot, reg12, "$current_town", slot_center_has_academy),
         (is_between, "$g_encountered_party_faction", kingdoms_begin, kingdoms_end),
         (ge, reg12, 1), #this value is used later
         (eq, "$g_encountered_party_faction", "$players_kingdom"),
         (this_or_next|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
         (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"),
      ],"Enlist troops in the military academy ({reg12} available).",
      [
        (assign, "$g_cur_stack", -1),
        (start_presentation, "prsnt_upgrade_troops"),
      ]),


Somebody

  • Code Pope
  • Baron
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: [OSP][WB][S] Unit Upgrade Academy
« Reply #12 on: December 22, 2014, 07:29:11 PM »
In the town menu. You'll want to initialize the value of slot_center_has_academy, as per my above post. For example, you can refresh this amount weekly as follows
Code: (module_simple_triggers) [Select]
  #Adding net incomes to heroes (once a week)
  #Increasing debts to heroes by 1% (once a week)
  #Adding net incomes to centers (once a week)
  (24*7,
   [
       (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
         (troop_get_slot, ":cur_debt", ":troop_no", slot_troop_player_debt),#Increasing debt
         (val_mul, ":cur_debt", 101),
         (val_div, ":cur_debt", 100),
         (troop_set_slot, ":troop_no", slot_troop_player_debt, ":cur_debt"),
         (call_script, "script_calculate_hero_weekly_net_income_and_add_to_wealth", ":troop_no"),#Adding net income
       (try_end),
   
       (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
         #If non-player center, adding income to wealth
         (neg|party_slot_eq, ":center_no", slot_town_lord, "trp_player"), #center does not belong to player.
         (party_slot_ge, ":center_no", slot_town_lord, 1), #center belongs to someone.
         (party_get_slot, ":cur_wealth", ":center_no", slot_town_wealth),
         (party_get_slot, ":prosperity", ":center_no", slot_town_prosperity),
         (store_mul, ":added_wealth", ":prosperity", 15),
         (val_add, ":added_wealth", 700),
         (try_begin),
           (party_slot_eq, ":center_no", slot_party_type, spt_town),
           (val_mul, ":added_wealth", 3),
           (val_div, ":added_wealth", 2),
         (try_end),
         (val_add, ":cur_wealth", ":added_wealth"),
         (call_script, "script_calculate_weekly_party_wage", ":center_no"),
         (val_sub, ":cur_wealth", reg0),
         (val_max, ":cur_wealth", 0),
         (party_set_slot, ":center_no", slot_town_wealth, ":cur_wealth"),
         #add this stuff to refresh upgrade troop count
         (party_get_slot, ":cur_troops", ":center_no", slot_center_has_academy),
         (store_random_in_range, ":added_troops", 3, 8),
         (val_add, ":cur_troops", ":added_troops"),
         (val_min, ":cur_troops", ":prosperity"),
         (party_set_slot, ":center_no", slot_center_has_academy, ":cur_troops"),
       (try_end),
    ]),
The above trigger already exists, just add the few lines at the bottom then start off each walled center with an arbitrary value
Code: (script_game_start) [Select]
      (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),#add town garrisons
        #add this line
        (party_set_slot, ":center_no", slot_center_has_academy, 30),
        #Add initial center wealth
        (assign, ":initial_wealth", 2000),
        (try_begin),
...