RMS effects bugs/requests

The January update added RMS effect functionality that has some bugs.

1: effect_percent does not work properly. This is supposed to divide the value parameter by 100 (which it does), but it incorrectly truncates the value. For example:

#const TRIBUTE_INEFFICIENCY 46
effect_percent MOD_RESOURCE TRIBUTE_INEFFICIENCY ATTR_SET 50  /* sets inefficiency to 0%, should be 50% */
effect_percent MOD_RESOURCE TRIBUTE_INEFFICIENCY ATTR_SET 100  /* sets inefficiency to 100% */
effect_percent MOD_RESOURCE TRIBUTE_INEFFICIENCY ATTR_SET 150  /* sets inefficiency to 100%, should be 150% */

2: some effects for modifying technologies do not work. This is not super critical since there are alternative ways to achieve the same effect:

#const R_XBOW 100
#const R_ESKIRM 98
/* this code doesn't work in DE, but works in UP */
effect_amount SET_TECH_COST R_XBOW AMOUNT_FOOD 175 /* Increased cost for crossbow upgrade (was 125f, 75g) */
effect_amount SET_TECH_COST R_XBOW AMOUNT_GOLD 125
effect_amount SET_TECH_COST R_ESKIRM AMOUNT_WOOD 250 /* Increased cost for elite skirm upgrade (was 230w, 130g) */
effect_amount SET_TECH_COST R_ESKIRM AMOUNT_GOLD 150
/* This code works in DE */
effect_amount MODIFY_TECH R_XBOW ATTR_SET_FOOD_COST 175
effect_amount MODIFY_TECH R_XBOW ATTR_SET_GOLD_COST 125
effect_amount MODIFY_TECH R_ESKIRM ATTR_SET_WOOD_COST 250
effect_amount MODIFY_TECH R_ESKIRM ATTR_SET_GOLD_COST 150

3: request for RMS constants to be able to modify unit charge attack attributes

4: request for guard_state functionality to have win conditions and/or resource trickles associated with a specific object

5: the ENABLE_TECH effect can only disable, using ATTR_FORCE will disable a specified tech (this is a bug). Using ATTR_ENABLE will have no effect (this does reflect the behavior in UP, but it still leaves ENABLE_TECH as a useless effect in the context of RMS).

#const TECH_FORTWALL 194
effect_amount ENABLE_TECH TECH_FORTWALL ATTR_ENABLE 194 /* this does not enable fortified walls for civs that don't have the tech available */
effect_amount ENABLE_TECH TECH_FORTWALL ATTR_FORCE 194 /* this removes fortified wall as a tech for civs that would otherwise be able to research it */
3 Likes

Added some extra items for guard_state and enable tech.

Setting a value for an attack or armor class that a unit doesn’t already have won’t do anything, it would be nice of it did. For example, Cavalry armor is index 8, so 256*8+10=2058 would give a unit 10 cavalry armor, but currently it does nothing because the unit doesn’t already have a cavalry armor class.
effect_amount SET_ATTRIBUTE TEUTONIC_KNIGHT ATTR_ARMOR 2058

In DE, ATTR_HERO_STATUS is an all or nothing attribute that gives a unit fixed regeneration, puts it on defensive stance, and disallows conversions. There’s no way to give a unit regeneration only (109 is an attribute that says regeneration rate, but modding that in RMS does nothing) in UP, ATTR_HERO_STATUS could be used to configure the hero attributes individually.

  • Set flag to 2 to disable Conversions.
  • Set flag to 4 to enable hero heal rate. (then use attribute 45 to configure the rate)
  • Set flag to 8 to force Defensive stance.
  • Set flag to 16 to force the unit to use a Protective Formation.
  • Set flag to 32, with Attribute 14 as 1 or 2 to enable Suicide attacks. (The unit does damage and instantly dies.)
    If Attribute 14 is set to 1, Unit IDs 440, 527, 528 and 706 are hard-coded to check this flag.
  • Set flag to 64 to enable blast radius, but I don’t think you need this as you can just add Blast Radius itself.
  • Set flag to -128 to disable Attack Ground.
  • Set flag to 256 to clear all flags.

Also it would be nice to change cost types for techs.

/* this doesn't do anything since loom has no food cost type */
#const LOOM 22 
effect_amount MODIFY_TECH LOOM ATTR_ADD_FOOD_COST 50

There’s probably a reason you can’t change a unit’s class, but it would be cool if that was possible. The below code upgrades Coustilliers into Flemish Militia (basically switching out the unique unit for the civ). Everything works fine except the fact that the unit benefits from cavalry upgrades instead of infantry.

#const R_FLEMISH_REVOLUTION 755
#const U_FLEMISH_MILITIA1 1663
#const U_FLEMISH_MILITIA2 1699
#const U_COUSTILLIER 1655
#const U_ELITECOUSTILLIER 1657

effect_amount UPGRADE_UNIT U_COUSTILLIER U_FLEMISH_MILITIA1 0
effect_amount UPGRADE_UNIT U_ELITECOUSTILLIER U_FLEMISH_MILITIA2 0
effect_amount SET_ATTRIBUTE U_FLEMISH_MILITIA2 ATTR_TRAIN_LOCATION 0
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_TRAIN_LOCATION 82
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_TRAIN_BUTTON 1
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_CREATION_TIME 14
effect_amount MUL_ATTRIBUTE U_COUSTILLIER ATTR_GOLD_COST -1
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_GOLD_COST 25
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_HITPOINTS 60 
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_ATTACK 1034 /* 10 melee attack */
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_ATTACK 2058 /* 10 cavalry attack */
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_ATTACK 4102 /* 6 ship attack */
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_ATTACK 7686 /* 6 camel attack */
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_ATTACK 1380 /* 6 elephant attack */
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_SHOWN_ATTACK 10
effect_amount SET_ATTRIBUTE U_ELITECOUSTILLIER ATTR_TRAIN_LOCATION 82
effect_amount SET_ATTRIBUTE U_ELITECOUSTILLIER ATTR_TRAIN_BUTTON 1
effect_amount DISABLE_TECH R_FLEMISH_REVOLUTION ATTR_DISABLE 755

So if it was possible to change a unit’s class it would look like this I imagine.
effect_amount SET_ATTRIBUTE U_COUSTILLIER ATTR_CLASS 6 /* change the unit to be infantry class */

In theory it should be possible, because if I did the opposite thing and upgraded Flemish Militia into Coustillier, then I have a cavalry unit that inherits the infantry class (6). I just want to change only the class, instead of everything but the class.