Code: Select all
[color=orange]21st September, 2006 - Maarc[/color]
Added commentary to some of the party classes headers
Updated AddMember() and RemoveMember() to return a bool as to it's success
Updated Leader() change code so that the leader is always first on the list
Added isNPC property to the Party class to help us with how our code will go
CChar now has an InParty() method, which is currently unused - will be used for fast lookups of party presence later. This is NOT to be saved, as it disappears on server shutdown.
Exposed the new party classes to the JS Engine
var partyObject = CreateParty( leader ); // Returns NULL if the party failed to be made
Party Class
Methods
bool Remove( memberToRemove );
bool Add( memberToAdd ); // If it's a PC, then it will send an INVITE ONLY It is up to the PC to accept/decline
obj GetMember( index ); // Returns a character object for the member at that index
Properties
leader // Character object that is the leader, can return null - EDITABLE
memberCount // Returns the number of characters in the group - READONLY
isNPC // Returns true if it's an NPC party, false if not - EDITABLE
Character Class
Properties
party // Returns a party object that is the party associated, or null - READONLY (use party management for this!)
partyLootable // Boolean that dictates whether the character is lootable by the party - EDITABLE - Note that if you are not in a party, this does nothing!
This is the exposure of the code so far. It exposes party creation (though not destruction) to the script engine. I would not advise holding on to a party hook for too long, because anything that would increase/decrease the members in future will deal with autodestruction (a party of 1 will result in destruction). So use it as needed, just don't expect it to last across events.
But also note that this means NPC parties can exist! You *CANNOT* mix PCs and NPCs in a party, that would be a bad thing ... but you can create an NPC only. So for those who want custom AI and other things with spawners, now's your chance ... spawn that orc leader with underlings, chunk them in a party, and write some custom AI to help it all out
I do hope to improve the underlying parts, and start shunting some automated things in there, but again, this is a start more than anything. Ideas and feedback are always welcome, and vetting by Grimson and Giwo would be great, as it's been a while, and I'd suspect that you guys now have a much better set of eyes than I do
Very rough and ready script:
Code: Select all
function onUse( pUser, iUsed )
{
var socket = pUser.socket;
socket.SysMessage( "OK, party test's a going!" );
var myParty = CreateParty( pUser );
if( myParty != null )
{
socket.SysMessage( "We created a party with us as leader" );
}
else
{
socket.SysMessage( "Party creation failed, look it up!" );
}
return false;
}