I've been browsing the forum for a long while, but never posted anything (cause i didn't have anything useful to say)...
This is my first try to create a package, is made for 097, and is a tailoring skill package that use the crafting system, new gumps and so.
It works at most, has still something to be fixed but i'd like to have your opinion about it.
You'll find that portions of code have been taken from carpentry package (i needed some "help" to create gumps and see how these gumps are made - functions and so on - ).
It uses both the crafting package and the item/clothing package to work.
This is the tailoring.src
Code: Select all
/*
New 097 Tailoring system
Made to be more similar to new crafting skill
2007, Jarsil for [Enyaw] Shard
v 0.1 alpha
*/
use cfgfile;
use util;
include ":attributes:attributeConstants";
include ":attributes:attributes";
include ":attributes:skillCheck";
include ":crafting:crafting";
include ":crafting:craftingRepair";
include ":crafting:toolWear";
const SCISSORS_SOUND := 0x0249;
var item_config := ReadConfigFile(":*:itemdesc");
var craft_config := ReadConfigFile(":tailoring:tailoring");
program use_sewingkit(who, tool)
if ( !ReserveItem(tool) )
SendSysMessage(who, "That is already in use.");
return 0;
elseif( (!tool.movable) || !ReserveItem(tool) )
SendSysMessage(who, "You cannot use that");
return 0;
elseif( !(tool in EnumerateItemsInContainer(who.backpack)) )
SendSysMessage(who, "That item is not in your backpack.");
return 0;
endif
EraseObjProperty(who, "#IsMeditating");
EraseObjProperty(who, "#HealTimer");
var rinfo := sendCraftGump(who, TAILORING);
// OK was pressed, close it on out
if(rinfo == 0)
return 0;
endif
var the_objtype := rinfo[1];
var amt := rinfo[2];
var repairit := rinfo[3];
if(repairit)
repair_this(who, craft_skill);
return 0;
endif
TailoringItems(who, tool, the_objtype, amt);
endprogram
function TailoringItems(who, tool, objtype, amt)
var itemchk := MaterialSelection(who, craft_skill, lower(craft_config[objtype].type));
if( !itemchk )
return 0;
endif
var item1 := itemchk[1];
var item1objtype := itemchk[2];
var ptmod := itemchk[3];
var x := who.x, y := who.y, item2 := 0;
var material2obj := craft_config[objtype].material2obj;
if( TypeOf(material2obj) == "String" )
var holder := material2obj;
// Let's now select the secondary material. Chk is not passed, as currently
// ingots do not hold a cprop to know which type they was originally like boards
// or cut leather.
itemchk := MaterialSelection(who, craft_skill, lower(holder));
if( !itemchk )
return 0;
endif
item2 := itemchk[1];
ptmod := ptmod + CInt(itemchk[3]);
endif
var theitem, chk := 0;
var itemname := craft_config[objtype].name;
var material := Cint(craft_config[objtype].material);
var material2 := Cint(craft_config[objtype].material2);
var reqd := Cint(craft_config[objtype].skill);
var skillid2 := craft_config[objtype].skillID;
var skill2 := Cint(craft_config[objtype].skill2);
var diff := Cint(craft_config[objtype].difficulty);
var pts := Cint(craft_config[objtype].points);
pts := CInt(pts + ptmod);
var counter := 0;
while(counter < amt)
if((who.x != x) || (who.y != y))
SendSysMessage(who, "You stop tailoring.");
break;
endif
if( !tool )
break;
endif
sleep(2);
if( GetAmount(item1) >= material )
if( item2 != 0 && GetAmount(item2) < material2 )
SendSysMessage(who, "You do not have enough materials.");
return 0;
endif
if( CraftCheckSkill(who, craft_skill, diff, pts) > 0 )
if( skillid2 )
if( (skill2 <= AP_GetSkill(who, skillid2)) )
theitem := CreateCraftItem(who, craft_skill, item1, item1objtype, objtype, material, itemname, reqd);
else
chk := -2;
endif
else
theitem := CreateCraftItem(who, craft_skill, item1, item1objtype, objtype, material, itemname, reqd);
if( theitem && theitem != 0 && !theitem.errortext )
if( item2 != 0 )
if( !SubtractAmount(item2, material2) )
DestroyItem(theitem);
chk := -1;
endif
else
CheckToolWear (who, tool, craft_skill);
chk := 1;
endif
else
chk := 0;
endif
endif
endif
endif
if( chk == 0 )
SubtractAmount(item1, (material / 2));
if( material2 )
if( !SubtractAmount(item2, CInt(material2 / 2)) )
SendSysMessage(who, "You do not have enough materials.");
return 0;
endif
endif
SendSysMessage(who, "You failed to create the item, and some of your materials are lost.");
counter := counter + 1;
continue;
endif
if( chk == -1 )
SendSysMessage(who, "You do not have enough materials.");
return 0;
endif
if( chk == -2 )
SendSysMessage(who, "You do not have the required skill.");
return 0;
endif
theitem.movable := 1;
counter := counter + 1;
endwhile
return 1;
endfunction
Studded Leather now will request the presence of metal ingots in your inventory, otherwise you'll not be able to create studded material.
Config files are made on the basis of carpentry.cfg and CarpMenu.cfg (respectively tailoring.cfg and TailMenu.cfg)
Just and example of tailoring.cfg (in ./config):
Code: Select all
tailoring 0x1efd
{
Name fancy shirt
Skill 25.0
Difficulty 10.0
Points 10.0
Material 8
Type cloth
Exceptional 1
Mark 1
Retain 1
}
Code: Select all
Craftitem Index
{
//Index Menus
Title <center>Tailoring Selection Menu</center>
Skill tailoring
SkillID tailoring
Group Other
Group Cloth
Group Leather
Group Leather Armor
Group Studded Armor
Group Shoes
}