Author Topic: [Solved] Trying to setup an "Acid" script to remove armor from effected units.  (Read 1425 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
(Goal)
I've been trying to modify Yankes "Poison Script" into one that reduces all armor on an effected unit instead.

(Problem)
. The mod is producing an "End of map not found." error.
Code: [Select]
ERROR: failed to load 'Testing Mod: Acid Script'; mod disabled
./user/mods/TestModAcid/Ruleset/scriptAcid.rul: yaml-cpp: error at line 70, column 13: end of map not found

(What I've tried so far)
So far I've check that:
. All the code is indented via two spaces.
. All IF statements have a corresponding end; command.
. All lines end in a ; to close them.


(Example Mod)
For convenience I've attached the mod I'm working with that contains the modified script to this post:
TestModAcid V0-1.zip


Last time I was working with a script and it produced an "End of map not found." the error was an IF statement without an end; command.

This time all IF statements appear to be properly closed with an end; and if I remove the section of code that is referenced by the error message it just changes the line that is producing the error to be later in the .rul file.



I'm at a loss with this.





I tried removing sections of the code that had the "error at line" message but the error continued to occur:

Code: [Select]
scriptAcid.rul: yaml-cpp: error at line 70, column 13: end of map not found.
As line 70 is this block of code:
Code: [Select]
# Make sure Armor is not Less than 0
            if lt frontarmor 0;
              set frontarmor 0;
            end;

            if lt leftarmor 0;
              set leftarmor 0;
            end;

            if lt reararmor 0;
              set reararmor 0;
            end;

            if lt rightarmor 0;
              set rightarmor 0;
            end;

            if lt underarmor 0;
              set underarmor 0;
            end;


my first thought was that perhaps you cannot nest IF statements, example:
Code: [Select]
            if lt X 0;
              if lt Y 0;
                set underarmor 0;
              end;
            end;

However I've seen scripts with nested IF statements so I don't think that is the problem.

When I removed the section of code that was mentioned in the error message a new one was produced:
Code: [Select]
scriptAcid.rul: yaml-cpp: error at line 90, column 13: end of map not found.
Line 90 is the following code:
Code: [Select]
            Unit.setArmor 0 frontarmor;
            Unit.setArmor 1 leftarmor;
            Unit.setArmor 2 reararmor;
            Unit.setArmor 3 rightarmor;
            Unit.setArmor 4 underarmor;


From what I've read in the openxcom.log with verboseLogging: true the BattleUnit.setArmor variable requires two variables.

The first is the direction of the armor to be effected and the second is a variable with the value to give the selected armor.

I've noticed that in other scripts the "BattleUnit." part is abbreviated to "Unit." if I'm using the wrong command please let me know.



I tried removing that section of code as well. I need it for the script to work but I wanted to see if it would load without an error.

Unfortunately this caused the same error but with a different line referenced:
Code: [Select]
scriptAcid.rul: yaml-cpp: error at line 96, column 13: end of map not found.
Line 96 is:
Code: [Select]
            sub frontarmor acid;
            sub leftarmor acid;
            sub reararmor acid;
            sub rightarmor acid;
            sub underarmor acid;

These commands should be simple subtraction of the "acid" value from each of the five "armor" variables.

Again I tried removing the code section and again the error appeared:
Code: [Select]
scriptAcid.rul: yaml-cpp: error at line 102, column 13: end of map not found.
Line 102 is:
Code: [Select]
            sub duration 1;
            unit.setTag Tag.ACID_REMAINING duration;


After removing the code around line 102 the error directed me to line 105:
Code: [Select]
scriptAcid.rul: yaml-cpp: error at line 105, column 13: end of map not found.
Line 105 is an end; command for an IF statement earlier in the code so it shouldn't be a problem.

I checked the indentation and it should match the IF statement that it belongs to so I'm not sure why it is throwing the error.



I could keep removing lines of code but it seems like that would created additional problems as the IF end; code block would be broken.


What am I missing?
« Last Edit: February 12, 2023, 03:05:38 pm by Meridian »

Offline Nord

  • Commander
  • *****
  • Posts: 1625
  • The Gate is open.
    • View Profile
Re: Trying to setup an "Acid" script to remove armor from effected units.
« Reply #1 on: October 03, 2021, 09:08:12 am »
Hi. You can use my example, if you want. It is in TWoTS mod. Tags marked as "acid" in "extended.rul".

Offline Buscher

  • Colonel
  • ****
  • Posts: 167
    • View Profile
Re: Trying to setup an "Acid" script to remove armor from effected units.
« Reply #2 on: October 04, 2021, 12:26:35 am »
After a quick look, two things.

You need to add white space at the same indentation level as your script even for comments

Code: [Select]
# comment here will not work

            # Make sure Armor is not Less than 0 # comment with enough white space in front

And you need to pay attention to capitalization
Code: [Select]
            # correct variable is 'unit' not 'Unit'
            Unit.setArmor 0 frontarmor;
            Unit.setArmor 1 leftarmor;
            Unit.setArmor 2 reararmor;
            Unit.setArmor 3 rightarmor;
            Unit.setArmor 4 underarmor;

Attached your rul file which will not generator ERRORs in the openxcom.log

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Trying to setup an "Acid" script to remove armor from effected units.
« Reply #3 on: October 07, 2021, 12:45:22 pm »
I've altered the script so that it now can reduce the value of several stats: (No need for a separate poison & acid script.)
. Health
. Energy
. Time Units
. Morale
. Stun
. Fatal Wounds
. Mana (I haven't tested it but I think It should work as coded.)


Here is the new version of it:
TestModStatusEffects V0-14.zip



Hi. You can use my example, if you want. It is in TWoTS mod. Tags marked as "acid" in "extended.rul".

After going over your extended.rul file I noticed that instead of unit.getHealth followed by unit.setHealth you use just a single line with unit.addHealth being passed a negative value.

I've adopted that method into the altered script. I think they are functionally identical, but I like the way it reads.

Thank you for the example.


After a quick look, two things.

You need to add white space at the same indentation level as your script even for comments

Code: [Select]
# comment here will not work

            # Make sure Armor is not Less than 0 # comment with enough white space in front

And you need to pay attention to capitalization
Code: [Select]
            # correct variable is 'unit' not 'Unit'
            Unit.setArmor 0 frontarmor;
            Unit.setArmor 1 leftarmor;
            Unit.setArmor 2 reararmor;
            Unit.setArmor 3 rightarmor;
            Unit.setArmor 4 underarmor;

Attached your rul file which will not generator ERRORs in the openxcom.log

Thank you for catching that I'll keep an eye on the white space and capitalization.
« Last Edit: October 07, 2021, 12:49:04 pm by The Martian »