Those darned rats! - ID: 1566

From Silversword RPG Wiki
Revision as of 12:37, 9 March 2024 by en>sswikiadmin
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

FORUM: Gossip - The rusty dagger tavern

This topic was started by Visstar on 18/04/2019, 16:05:41

I was interested to read Mario's blog post about the trouble so many people had with the rats outside the armory ("Them!") and it made me curious. What was happening? I don't recall anything odd or unusual about the encounter. In fact, if you had asked me which one encounter in the hame was different from all the others, I would have said the one where you earn the Bandit's Brassard.

What was different about that encounter and what was the problem people were having?


Hi there,

players won't notice the difference.
The fight with the rats is the only one that was integrated directly into a quest (in the armoury).

Almost everything that happens on a map in Silversword is the result of a small script that runs whenever you step on a certain position.

The script for the rats goes like this:

01000:IF|GAME_VAR|castle_1_19_fight|1|01010 01005:IF|GAME_VAR|castle_1_19_fight|2|01090 01006:STOP 01010:WAIT|0 01020:COMBAT|INIT 01030:COMBAT|ADD|ForestRat|3 01040:COMBAT|BUILD|castle_1_19_fight|2 01050:COMBAT|SET_DESC|You can hardly believe that THESE fellows were the reason for the closed shop. Well - there's one way to find an answer. 01060:COMBAT|START 01070:IF|GAME_VAR|castle_1_19_fight|2|01090 01080:STOP 01090:OUTPUT|Some fellow runs a tiny armoury in this corner of the ruins. 01100:STOP

The critical command was:

01040:COMBAT|BUILD|castle_1_19_fight|2

because it means that if you defeat the rats, the variable "castle_1_19_fight" is set to "2".

Now in my code, I use the following lines to check if the current value of this variable equals the number in the command:

// does the COMBAT|BUILD command has additional arguments? if((int)cmd_array.fourth > 0) { // custom value to check against

        _value_to_check_against = (int)cmd_array.fourth;

}

Because (int) couldn't convert the 4th parameter in my command to a number, it returned always a 0 - that means, that even if you have defeated the rats, the quest couldn't continue because the quest variable contained 2, but was compared to 0. This means that the rats continued to appear and you were caught in an endless loop.

The right code now is:

// does the COMBAT|BUILD command has additional arguments? if([cmd_array.fourth integerValue] > 0) { // custom value to check against _value_to_check_against = [cmd_array.fourth integerValue]; }

This works because "integerValue" is the correct way of converting a string to a number.
Now the quest variable is checked against the number 2 at the end of the fight and the quest can continue when you have defeated the rats.

Coding is fun, isn't it... ;-)

kind regards
Mario


Coding can be fun -- when you find the error! I remember one of my first attempts when the program kept crashing and I finally saw that I was initializing a variable INSIDE a loop instead of before entering the loop. Never made that mistake again. :oops:


Ah, my children. My experience with coding, or programming as we called it then, was a semester of comp sci when I was a freshman in college, in the fall of 1974. Yes I'm rapidly approaching geezerhood. ;) Anyway, the programming language was Fortran, and the method of coding was punchcards, which were fed into a very large mainframe (like maybe 6' tall by 10' wide) by the grad student on duty. You got a paper printout of the results, and if you'd made an error the printout didn't specify where, so you had to go back and see which punchcard you'd made the error on. This resulted in more than one all-nighter at the computer lab. In this case, the good old days definitely weren't.


I never used punch cards, but remember them. Comp Sci students carried them around like babies, terrified of dropping them, because it could take hours to put them back in order! Hard to believe how primitive it was.

And then the Apple ][ happened.


The problem I had with this quest (which has been fixed through an update) was that the rats wouldn't appear at all. I would get the quest and then nothing would happen except that I wouldn't have access to the armory! Which I immediately found better gear so it wasn't a problem other than an annoyance. (When I did get into it, I was disappointed in how little the armory provided!)

Also, this problem was hit-or-miss for me. I would reset the game to experiment with different character combinations, and sometimes the rats would show up for the quest, sometimes not.

So I guess there were both spectrums, people having non-stop rat battles and people who had no rats at all!