I was seeing the bard's skills, and i decided to redo musicianship to simpler and get more modular for use in other skills such as peacemaking, discordance and provocation.
Instruments Package:
instruments/config/itemdesc.cfg
Code: Select all
Item 0x0EB1
{
//Main Stuff
Name standingharp
VendorSellsFor 90
VendorBuysFor 30
Weight 5
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i68
CProp FailSound i69
}
Item 0x0EB2
{
//Main Stuff
Name harp
VendorSellsFor 30
VendorBuysFor 10
Weight 2
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i70
CProp FailSound i71
}
Item 0x0EB3
{
//Main Stuff
Name lute
VendorSellsFor 40
VendorBuysFor 15
Weight 2
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i77
CProp FailSound i78
}
Item 0x0EB4
{
//Main Stuff
Name lute2
VendorSellsFor 40
VendorBuysFor 15
Weight 2
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i77
CProp FailSound i78
}
Item 0x0E9C
{
//Main Stuff
Name drum
VendorSellsFor 50
VendorBuysFor 20
Weight 3
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i57
CProp FailSound i58
}
Item 0x0E9D
{
//Main Stuff
Name tambourine
VendorSellsFor 60
VendorBuysFor 25
Weight 1
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i83
CProp FailSound i84
}
Item 0x0E9E
{
//Main Stuff
Name tambourine2
VendorSellsFor 80
VendorBuysFor 40
Weight 1
//Scripts
Script :musicianship:instrument/use
MethodScript instrument/methods
//Custom Values
CProp SuccessSound i83
CProp FailSound i84
}
Code: Select all
use uo;
CONST SUCCESS_SOUND := 0X1;
CONST FAIL_SOUND := 0X2;
/*
* MIP_FindInBackPack(mobile)
*
* Purpose
* Find an instrument inside the mobile.
*
* Parameters
* mobile: a mobile reference
*
* Return value
* Returns the reference of an instrument in the mobile
* Returns 0 if there is no intrument in the mobile
*
*/
function MIP_FindInBackPack(mobile)
return Instruments_FindInContainer( mobile.backpack );
endfunction
/*
* MIP_FindInContainer(container)
*
* Purpose
* Find an instrument inside the container.
*
* Parameters
* container: a Container reference
*
* Return value
* Returns the reference of an instrument in the container
* Returns 0 if there is no intrument in the container
*
*/
function MIP_FindInContainer(container)
foreach item in EnumerateItemsInContainer(container)
if( item.IsInstrument() )
return item;
endif
endforeach
return 0;
endfunction
/*
* MIP_FindAllInContainer(container)
*
* Purpose
* Find all the instruments inside a container.
*
* Parameters
* container: a Container reference
*
* Return value
* Returns the reference of an array of all the instruments in the container
*
*/
function MIP_FindAllInContainer(container)
var instruments := array;
foreach item in EnumerateItemsInContainer(container)
if( item.IsInstrument() )
instruments.append(item);
endif
endforeach
return instruments;
endfunction
Code: Select all
use uo;
include ":instruments:musicinstruments";
program Install()
return 1;
endprogram
exported function IsInstrument(instrument)
instrument := instrument; // Avoid compiler warning
return 1;
endfunction
exported function Play(instrument, who, type)
if( type == SUCCESS_SOUND )
PlaySoundEffect(who, GetObjProperty(instrument,"SuccessSound") );
elseif( type == FAIL_SOUND )
PlaySoundEffect(who, GetObjProperty(instrument,"FailSound") );
else
return error{"errortext":="Invalid type of play for the instrument."};
endif
return 1;
endfunction
musicianship/instrument/use.src
Code: Select all
use basic;
use uo;
use os;
include ":attributes:attributes";
include ":instruments:musicinstruments";
program use_Instrument(who, item)
if( !Accessible(who, item) )
SendSysMessage(who, "You cannot access that.");
return 0;
elseif( CInt(GetObjProperty(who, "#LastMusic")) > ReadGameClock() )
SendSysMessage(who, "You must wait a moment before playing again.");
return 0;
elseif( !ReserveItem(item) )
SendSysMessage(who, "You cannot use that");
return 0;
endif
EraseObjProperty(who, "#IsMeditating");
EraseObjProperty(who, "#HealTimer");
SetObjProperty(who, "#LastMusic", CInt(ReadGameClock() + 2));
var pts := AP_GetSkill(who, MUSICIANSHIP) + 10;
if(pts < 10)
pts := 10;
endif
if( SkillCheck(who, MUSICIANSHIP, -1, pts) > 0 )
item.Play(who, SUCCESS_SOUND);
else
item.Play(who, FAIL_SOUND);
endif
endprogram