Musicianship Skill v2

Made a small change or new addition to the Distro that makes a difference? You can post the changes here in .patch or .diff file format, for others to use or even added to the official Distro SVN!

Moderators: POL Developer, Distro Developer

Locked
User avatar
ELSoft
Journeyman Poster
Posts: 61
Joined: Sun Jun 18, 2006 7:45 pm

Musicianship Skill v2

Post by ELSoft »

Hi
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

}

instruments/include/musicinstrument.inc

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
instruments/instrument/method.src

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 Skill

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
Attachments
elsoft_musicianship_24082009.diff
(12.05 KiB) Downloaded 330 times
User avatar
Damien White
Journeyman Poster
Posts: 68
Joined: Tue Aug 18, 2009 6:34 pm
Location: Canada

Re: Musicianship Skill v2

Post by Damien White »

Dude, the following is not setup in the instructions above...

musicianship/instrument/use.src

include ":instruments:musicinstruments";

I think we need to change that to...

include ":instruments:includes:musicinstruments";

please correct me if I am wrong.


Thanks in advance.
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Musicianship Skill v2

Post by Tomi »

09-25 Shinigami
Fixed : eCompile - FileCheck for multiple include of same File
e.g.: inside scripts\textcmd\test\textcmd.src:
Include "../../../pkg/std/housing/include/test";
Include ":housing:test";
Include ":housing:include/test";
will be handled as same file now
User avatar
ELSoft
Journeyman Poster
Posts: 61
Joined: Sun Jun 18, 2006 7:45 pm

Re: Musicianship Skill v2

Post by ELSoft »

With this and the timedScript, it would be very easy to make Discordance. The same for Provocation and Peacemaking, but both depends of the pet's AI. I don't very well about the status pets AI but i think that it is incomplete =S .
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Musicianship Skill v2

Post by Tomi »

Updated to 098 Distro
Locked