- Joined
- Mar 2, 2009
- Messages
- 576
- Reaction score
- 113
Hi,
Yesterday I thought: "maybe I can make loading characters better...".
So I looked into source and saw how rubbish is LoadCharacter function....
Then I decided to improve it.
This is the example of old-style character coding:
There are also other functions interpreted by source like:
So at First what are "setting" and "{" for??
The answer is short - nothing!
So I deleted every "setting" and "{" and the "}" of setting construction.
Also instead of "(" I decided to make source read '=' as opener and instead of ')' ';' as closer.
So the character.inc file was smaller and it looked like that:
Then I Changed some references as following:
So thanks to them script now is clearer.
The next thing is About Enabling the NPC. Why should a program load info about npc if it is not used at all( 1st consequence)?
So I made script stop reading npc info if Enabled = false.
What I found is some NPC's have items but MMI_TRADE is commented so I made the script bypass adding Shop Slots if MMI_TRADE is not included( 2nd consequence ).
The same thing with slots: if there is no slot with ID AddShopItem was defined it will bypass this part. ( 3rd consequence );
Also it is the same with Buffs and Teleport.
Then while I had no other Ideas I made every NPC as short as possible so it looks now like:
You should have noticed the cons. I will Explain that.
1st con is about Enable/Disable option. To make It work it must be at the beginning of the npc script like here:
2nd con is about the shop. To make everything work I had to move slots right after MMI_TRADE or it wouldn't work. Example:
3rd con is almost same as with shop but there must be the menu for teleport before teleports and menu for buffs before adding the buffs.
Result for now is: from 333 KB down to 136 KB character.inc file.
If you have any questions ask.
Any ideas? serve them here!
If you know: Are NPC's from character-etc and character-school.inc used?
Ideas I am thinking about:
Yesterday I thought: "maybe I can make loading characters better...".
So I looked into source and saw how rubbish is LoadCharacter function....
Then I decided to improve it.
This is the example of old-style character coding:
Code:
MaFl_Boboko
{
setting
{
AddMenu( MMI_DIALOG );
AddMenu( MMI_TRADE );
AddVendorItem( 0, IK3_SUIT, 1, 15, 27, 25 );
AddVendorItem( 0, IK3_HELMET, 1, 15, 27, 25 );
AddVendorItem( 0, IK3_GAUNTLET, 1, 15, 27, 25 );
AddVendorItem( 0, IK3_BOOTS, 1, 15, 27, 25 );
AddVendorItem( 1, IK3_SUIT, 3, 15, 27, 25 );
AddVendorItem( 1, IK3_HELMET, 3, 15, 27, 25 );
AddVendorItem( 1, IK3_GAUNTLET, 3, 15, 27, 25 );
AddVendorItem( 1, IK3_BOOTS, 3, 15, 27, 25 );
AddVendorItem( 2, IK3_SUIT, 2, 15, 27, 25 );
AddVendorItem( 2, IK3_HELMET, 2, 15, 27, 25 );
AddVendorItem( 2, IK3_GAUNTLET, 2, 15, 27, 25 );
AddVendorItem( 2, IK3_BOOTS, 2, 15, 27, 25 );
m_nStructure= SRT_SHIELD;
SetImage
(
IDS_CHARACTER_INC_000026
);
m_szDialog= "MaFl_Boboko.txt";
}
SetName
(
IDS_CHARACTER_INC_000027
);
AddVendorSlot( 0,
IDS_CHARACTER_INC_000028
);
AddVendorSlot( 1,
IDS_CHARACTER_INC_000029
);
AddVendorSlot( 2,
IDS_CHARACTER_INC_000030
);
AddVendorSlot( 3,
IDS_CHARACTER_INC_000031
);
}
- SetOutput( false );
- AddTeleport
- SetBuffSkill
- SetFigure
- SetEquip
- SetVenderType
- AddVenderItem2
- AddTeleport
- SetBuffSkill
- SetFigure
- SetEquip
- SetVenderType
- AddVenderItem2
The answer is short - nothing!
So I deleted every "setting" and "{" and the "}" of setting construction.
Also instead of "(" I decided to make source read '=' as opener and instead of ')' ';' as closer.
So the character.inc file was smaller and it looked like that:
Code:
MaMa_Ancimys
{
AddMenu = MMI_DIALOG;
SetImage =
IDS_CHARACTER_INC_000199
;
m_szDialog = "MaMa_Ancimys.txt";
SetName =
IDS_CHARACTER_INC_000200
;
}
SetImage => Image
SetName => Name
m_szDialog => Dialog
m_nStructure => Structure
AddVendorSlot => AddShopSlot
AddVendorItem => AddShopItem
AddVendorItem2 => AddShopItem2
SetVendorType => SetShopType
SetOutPut => Enable
SetBuffSkill => AddBuffSkill
SetName => Name
m_szDialog => Dialog
m_nStructure => Structure
AddVendorSlot => AddShopSlot
AddVendorItem => AddShopItem
AddVendorItem2 => AddShopItem2
SetVendorType => SetShopType
SetOutPut => Enable
SetBuffSkill => AddBuffSkill
The next thing is About Enabling the NPC. Why should a program load info about npc if it is not used at all( 1st consequence)?
So I made script stop reading npc info if Enabled = false.
What I found is some NPC's have items but MMI_TRADE is commented so I made the script bypass adding Shop Slots if MMI_TRADE is not included( 2nd consequence ).
The same thing with slots: if there is no slot with ID AddShopItem was defined it will bypass this part. ( 3rd consequence );
Also it is the same with Buffs and Teleport.
Then while I had no other Ideas I made every NPC as short as possible so it looks now like:
Code:
MaFl_TELEPORTER // 3??? ????? ???? npc
{
Enable = false;
AddMenu = MMI_DIALOG;
AddMenu = MMI_TELEPORTER;
AddTeleport = 7161, 3264; //????
AddTeleport = 8321, 3720; //??? ??
AddTeleport = 5593, 3920; //?? 1
AddTeleport = 3896, 4378; //?? 2
AddTeleport = 3221, 3416; //?? 3
AddTeleport = 5933, 5393; //????
Image = IDS_CHARACTER_INC_000832;
Dialog = "MaFl_teleporter_03nomal.txt";
Name = IDS_CHARACTER_INC_000833;
}
1st con is about Enable/Disable option. To make It work it must be at the beginning of the npc script like here:
Code:
MaFl_July06 // 2010? ?? ?????01
{
Enable = false;
2nd con is about the shop. To make everything work I had to move slots right after MMI_TRADE or it wouldn't work. Example:
Code:
MaEw_Ruoboru
{
AddMenu = MMI_DIALOG;
AddMenu = MMI_TRADE;
AddShopSlot = 0, IDS_CHARACTER_INC_000231;
AddShopItem2 =0, II_SYS_SYS_SCR_BXMKNT120SET;
AddShopItem2 =0, II_SYS_SYS_SCR_BXMBLA120SET;
AddShopItem2 =0, II_SYS_SYS_SCR_BXFKNT120SET;
AddShopItem2 =0, II_SYS_SYS_SCR_BXFBLA120SET;
AddShopSlot = 1, IDS_CHARACTER_INC_000232;
AddShopItem2 =1, II_SYS_SYS_SCR_BXMRIN120SET;
AddShopItem2 =1, II_SYS_SYS_SCR_BXMBIL120SET;
AddShopItem2 =1, II_SYS_SYS_SCR_BXFRIN120SET;
AddShopItem2 =1, II_SYS_SYS_SCR_BXFBIL120SET;
AddShopSlot = 2, IDS_CHARACTER_INC_000233;
AddShopItem2 =2, II_SYS_SYS_SCR_BXMJST120SET;
AddShopItem2 =2, II_SYS_SYS_SCR_BXMRAG120SET;
AddShopItem2 =2, II_SYS_SYS_SCR_BXFJST120SET;
AddShopItem2 =2, II_SYS_SYS_SCR_BXFRAG120SET;
AddShopSlot = 3, IDS_CHARACTER_INC_000234;
AddShopItem2 =3, II_SYS_SYS_SCR_BXMPSY120SET;
AddShopItem2 =3, II_SYS_SYS_SCR_BXMELE120SET;
AddShopItem2 =3, II_SYS_SYS_SCR_BXFPSY120SET;
AddShopItem2 =3, II_SYS_SYS_SCR_BXFELE120SET;
}
3rd con is almost same as with shop but there must be the menu for teleport before teleports and menu for buffs before adding the buffs.
Result for now is: from 333 KB down to 136 KB character.inc file.
If you have any questions ask.
Any ideas? serve them here!
If you know: Are NPC's from character-etc and character-school.inc used?
Ideas I am thinking about:
AddMenus => multi AddMenu to shorten the script and fasten loading the file
Last edited:

