various cross-user script bits?

Forum Archive - from http://theuniversal.net
Locked
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

various cross-user script bits?

Post by zaroba »

Couple different things I'm wonder if possible.

Sell to building script - storage capacity effected by different building.
Player A owns Building 1 and Building 2
Player B wants to sell something to Building 1
Can the script somehow see if the owner of Building 1 also owns Building 2?


To go along with this.
Production Script - Automated storage in external building
When the production script for Building 1 runs, can it see if the owner of Building 1 also owns a Building 2 and then remove items from Building 1 and add them to Building 2?

Ideally building proximity would also play a roll in all this, either same town or tile distance. Don't need somebody having main buildings in one city and all the support buildings halfway across the map.


Something that I'm hoping to do for zoric is that players can build separate storage buildings which will be used by buildings they own to basically increasestorage capacity for both demanded and produced items. Along with having many other cross-building effects, like increasing qty produced or decreasing time to produce or resources needed. Even needing to own a certain building before a different building can produce items. Like needing to build a Hen House before a farm can produce Eggs.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

mm, well, theoretically you could do that with existing stuff by running a *eventallbuildings custom event, checking each building to see if its owned by the player and in the right place, then storing the results in the original building's or player's vars - but that'd be really unpleasant and the script would take a long time to run once you got a lot of buildings on the world. I really wouldn't recommend it :].

For 0.66.4 i've added a (rather verbosively named) sys function : sysPlayerGetNearestOwnedBuildingOfType( [PlayerID], [BuildingType], [WorldX], [WorldY] ) which may be a bit more practical.
That will return a buildingID if the player owns a particular building type within 1km of the world coord. (0 otherwise).

I've also added sysGetPlayerOwnedBuilding( [PlayerID], [Index] ) which (combined with the new while loops) could be used to get the building IDs for all the buildings owned by the player.
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

p.s. I've updated the current full list of sys functions at :
http://theuniversal.net/worldmanual/dok ... _functions and am working through documenting some more of 'em.

Here's a wee example of the latter :

Code: Select all

Function	SendOwnedBuildingsList( $playerID )
{
	$playerName = sysGetPlayerName( $playerID )

    $loop = 1
	while( $loop < 10 )
	{
	   $buildingID = sysPlayerGetOwnedBuilding( $playerID, $loop )
		// No more buildings
       if ( $buildingID == 0 )
	   {
		   return
	   }
	 
	   $buildingName = sysGetBuildingName( $buildingID )
	   *msg $playerName Building $loop : ID = $buildingID ( $buildingName )
	   $loop += 1
	}
}

Event( "Custom", "TestFunc" )
{
	SendOwnedBuildingsList( $gPlayerID )
}
Locked