SRL Archive - MSI Archives

When adding a new script record...


Camaro'

2010-11-05 10:11:41

Simba decides to tell me theres an error on one something I didn't even add to Scripts.simba.

If I remove what I added it compiles fine, but when I add it, it gives me an error on for example the Draynor Fisher record :(

Someone should make a MSI Help forum


[Error] C:\Users\Aaron\Desktop\Simba\Includes\MSI/Scripts.simba(1042:42): Type mismatch at line 1041
Compiling failed.


//Line 1041 in Script_Db_Fisher
StartLoc := LOC_DB_BANK;

What I added


SCRIPT_FIGHTER:
with MSI_Scripts[whichScript] do
begin
Name := 'Combat Fighter';
Constant := SCRIPT_FIGHTER;
SkillName := 'Attack';
SkillConst := SKILL_ATTACK;
BankType := NoBank;
AutoObjects := @MSI_RepeatFight;
PlayerSetup := @MSI_SetupFighting;

with Defaults do
begin

Monsters := [

];

Items := [
TIntegerArray([FISH_COOKED_SHRIMP, FISH_COOKED_ANCHOVIE]),
TIntegerArray([FISH_COOKED_SARDINE, FISH_COOKED_HERRING, FISH_COOKED_PIKE]),
TIntegerArray([FISH_COOKED_TROUT, FISH_COOKED_SALMON]),
TIntegerArray([FISH_COOKED_LOBSTER]),
TIntegerArray([FISH_COOKED_TUNA, FISH_COOKED_SWORDFISH])
];
end;
end;

The reason why I didn't post this in the bugs section is because this isn't a MSI bug, because it compiles fine when I remove what I added.

TomTuff

2010-11-05 10:29:39

there's combat in MSI?

also, did you change all the array lengths you might have needed to?

Camaro'

2010-11-05 10:32:37

I'm adding combat, I think I changed all the arrays.

Coh3n

2010-11-05 12:06:51

I'm not sure why you're getting the error, I'll see if I can find that in a minute.

You aren't quite using the Items properly (understandable how one could get confused). The items array represents all the items associated with each object in the Tree/Rock/FishSpot/(in this case Monster) array. So, for your example, items wouldn't have the food, it would have the drop items for each monster in the Monster array.

That being said, if it's a fighter where the user chooses the monster (and not for example SCRIPT_FIGHT_GOBLIN, where the default monster would be a Goblin), you would leave both blank, and the items would automatically be filled in by MSI depending on which monster the user chose.

If you want to use food, you should add a "Food" attribute to the TScriptSetup record so the user can choose which food they want to use.

Oh, and I think I know where the error is. In the outline I gave you, for MSI_RepeatFight I had a parameter in it. Take it out so it's:

function MSI_RepeatFight: Boolean;
MSI_Fight should also be edited a little:

function MSI_Fight(Monsters: TIntegerArray): Boolean;

Camaro'

2010-11-05 12:17:13

Oh, but I made EatFood automatically detect what food to eat out of all the options, so I am not going to add the food attribute to the TScriptRecord.

So the Items := [ ] ; should only include the loot the script should pickup?
That means I should delete the Loot TIntArray I added to the TScriptRecord?

Also, I'm leaving the MSI_Fight(Monster: Int) the way it is because I use this somewhere, I think its in Repeat Fight, I don't remember.


for N := 0 to Length(Scripts[CurrentScript].Monsters) do
begin
if (MSI_Fight(Scripts[CurrentScript].Monsters[N])) then

And now it compiles :)

Coh3n

2010-11-05 12:22:42

[QUOTE=Camaro';747732]Oh, but I made EatFood automatically detect what food to eat out of all the options, so I am not going to add the food attribute to the TScriptRecord.

So the Items := [ ] ; should only include the loot the script should pickup?
That means I should delete the Loot TIntArray I added to the TScriptRecord?
[/QUOTE]
Yes.

[QUOTE=Camaro';747732]
Also, I'm leaving the MSI_Fight(Monster: Int) the way it is because I use this somewhere, I think its in Repeat Fight, I don't remember.


for N := 0 to Length(Scripts[CurrentScript].Monsters) do
begin
if (MSI_Fight(Scripts[CurrentScript].Monsters[N])) then

And now it compiles :)
It may not work exactly like you want it because of how MSI's object functions are setup. I may be wrong though. We'll see after some testing. :)

Camaro'

2010-11-05 12:42:35

From: Coh3n
Yes.


It may not work exactly like you want it because of how MSI's object functions are setup. I may be wrong though. We'll see after some testing. :)


You were right, I had to change it to Fight(Monsters :TIntArray) for it to work better. Also, how can I make Repeat Fight, once it returns false to not restart?

Coh3n

2010-11-05 15:26:25

[QUOTE=Camaro';747736]You were right, I had to change it to Fight(Monsters :TIntArray) for it to work better. Also, how can I make Repeat Fight, once it returns false to not restart?[/QUOTE]
Well, you would want it to search for the monster again if it fails. Maybe you want it to search a certain amount of tries before breaking. Here's what I suggest (you can also refer to MSI_AutoInvFull in Skills.simba).

Actually I started writing up an outline type thing and realized that we may not even need an MSI_RepeatFight. Let's think about it for a minute.

Right now, the three skills we have use the same AutoInvFull function because they perform tasks until the inventory is full. Fighting can also, but that's not always the case. If we set AutoObjects in the TScript record to MSI_Fight then it would go through the mainloop every time a monster is killed, until the number of monsters killed is > than the number specified in DeclarePlayers or the player messes up.

Of course, MSI_Fight would have to be edited so we don't get type mismatch errors again.

function MSI_Fight(): Boolean;
var
monsters: Integer;
begin
monsters := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Monsters;

if (MSI_FindObjects());
begin
// Other stuff here
end else
MSI_FindRandoms;
end;
This may require some changes to MSI_Mainloop, but I don't know that for sure.

Come to think of it, the TotalLoads, BreakLoads from TPlayerSetup may need to be moved to TScriptSetup because for fighting, it would break after killing a certain amount of monsters rather than loads. Don't worry about that right now, though. I can take care of it later if need be.

Camaro'

2010-11-05 21:43:44

From: Coh3n
Well, you would want it to search for the monster again if it fails. Maybe you want it to search a certain amount of tries before breaking. Here's what I suggest (you can also refer to MSI_AutoInvFull in Skills.simba).

Actually I started writing up an outline type thing and realized that we may not even need an MSI_RepeatFight. Let's think about it for a minute.

Right now, the three skills we have use the same AutoInvFull function because they perform tasks until the inventory is full. Fighting can also, but that's not always the case. If we set AutoObjects in the TScript record to MSI_Fight then it would go through the mainloop every time a monster is killed, until the number of monsters killed is > than the number specified in DeclarePlayers or the player messes up.

Of course, MSI_Fight would have to be edited so we don't get type mismatch errors again.

function MSI_Fight(): Boolean;
var
monsters: Integer;
begin
monsters := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Monsters;

if (MSI_FindObjects());
begin
// Other stuff here
end else
MSI_FindRandoms;
end;
This may require some changes to MSI_Mainloop, but I don't know that for sure.

Come to think of it, the TotalLoads, BreakLoads from TPlayerSetup may need to be moved to TScriptSetup because for fighting, it would break after killing a certain amount of monsters rather than loads. Don't worry about that right now, though. I can take care of it later if need be.


I understand and think we do not need a repeat fight.