Code: Select all
//----------------------------------------------------
// Medieval - Blacksmith
// [Config]
$kMedBlacksmithBuildingNum = 20
//----------------------------------------------------
//
// BuildingVars :
//
// 3 - Number of Axes (1) made here (ever)
// 4 - Number of Bag of nails (7) made here (ever)
// 5 - Number of pickaxes (5) made here (ever)
// 6 - Stick buy-in limit
// 7 - Steel buy-in limit
// 8 - Coal buy-in limit
// 9 - Worker wage per item
// 10 - Wage to be collected by worker
//
// 12 - Number of Ploughs (8) made here (ever)
// 13 - Number of hammer (9 made here (ever)
//
$kAxeStickRequired = 1
$kPickaxeStickRequired = 1
$kploughStickRequired = 5
$kBag of nailStickRequired = 0
$khammerStickRequired = 1
$kAxesteelRequired = 1
$kPickaxesteelRequired = 1
$kploughsteelRequired = 5
$kBag of nailsteelRequired = 1
$khammersteelRequired = 1
$kAxeCoalRequired = 1
$kPickaxeCoalRequired = 1
$kploughCoalRequired = 5
$kBag of nailCoalRequired = 1
$khammerCoalRequired = 1
$kMaxStickInStorage = 50
$kMaxSteelInStorage = 50
$kMaxCoalInStorage = 50
Function MedBlacksmithShowOwnerEmployeeDisplay( $osdX, $osdY, $wage, $minJobInvest, $currInvest )
{
$wageText = sysGetPriceText( $wage )
if ( $gBuildingNumEmployees == 1 )
{
$employeeID = sysGetEmployeeID( 0 )
$name = sysGetPlayerName( $employeeID )
osdaddat(OSDTEXT, $osdX, $osdY, 500, 20, "", "Currently employing $name for $wageText per item")
}
else if ( $wage == 0 )
{
osdaddat(OSDTEXT, $osdX, $osdY, 500, 20, "", "Not currently advertising for staff")
}
else
{
if ( $currInvest > $minJobInvest )
{
osdaddat(OSDTEXT, $osdX, $osdY, 500, 20, "", "Job vacancy for a Blacksmith ($wageText per item)")
}
else
{
$minInvText = sysGetPriceText( $minJobInvest )
osdaddat(OSDTEXT, $osdX, $osdY, 500, 20, "", "Requires minimum of $minInvText invested to take on a worker.")
}
}
}
Event( "OSDSelect", "MedSmithOSD:StickAdminApply" )
{
*setbuyprice $gBuildingNum,Stick,$gParam[1]
$gBuildingVar[6] = $gParam[2]
*setbuyprice $gBuildingNum,Steel,$gParam[3]
$gBuildingVar[7] = $gParam[4]
*setbuyprice $gBuildingNum,Coal,$gParam[5]
$gBuildingVar[8] = $gParam[6]
$ret = MedBlacksmithDisplayOwnerStickSuppliesOSD()
}
Event( "OSDSelect", "MedSmithOSD:AddStick" )
{
$hasStick = sysPlayerInventory( "Stick" )
if ( $hasStick > 0 )
{
$stickInStocks = sysAmountInStocks( "Stick" )
if ( $stickInStocks < $kMaxStickInStorage )
{
*grantitem %PLAYER% -1 Stick
*addtostocks $gBuildingNum,1,Stick
}
}
$ret = MedBlacksmithDisplayOwnerStickSuppliesOSD()
}
Event( "OSDSelect", "MedSmithOSD:AddSteel" )
{
$hasSteel = sysPlayerInventory( "Steel" )
if ( $hasSteel > 0 )
{
$steelInStocks = sysAmountInStocks( "Steel" )
if ( $steelInStocks < $kMaxSteelInStorage )
{
*grantitem %PLAYER% -1 Steel
*addtostocks $gBuildingNum,1,Steel
}
}
$ret = MedBlacksmithDisplayOwnerStickSuppliesOSD()
}
Event( "OSDSelect", "MedSmithOSD:AddCoal" )
{
$hasCoal = sysPlayerInventory( "Coal" )
if ( $hasCoal > 0 )
{
$CoalInStocks = sysAmountInStocks( "Coal" )
if ( $CoalInStocks < $kMaxCoalInStorage )
{
*grantitem %PLAYER% -1 Coal
*addtostocks $gBuildingNum,1,Coal
}
}
$ret = MedBlacksmithDisplayOwnerStickSuppliesOSD()
}
Event( "OSDSelect", "MedSmithOSD:WorkerAddStick" )
{
$hasStick = sysPlayerInventory( "Stick" )
if ( $hasStick > 0 )
{
$stickInStocks = sysAmountInStocks( "Stick" )
if ( $stickInStocks < $kMaxStickInStorage )
{
*grantitem %PLAYER% -1 Stick
*addtostocks $gBuildingNum,1,Stick
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:WorkerAddSteel" )
{
$hasSteel = sysPlayerInventory( "Steel" )
if ( $hasSteel > 0 )
{
$steelInStocks = sysAmountInStocks( "Steel" )
if ( $steelInStocks < $kMaxSteelInStorage )
{
*grantitem %PLAYER% -1 Steel
*addtostocks $gBuildingNum,1,Steel
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:WorkerAddCoal" )
{
$hasCoal = sysPlayerInventory( "Coal" )
if ( $hasCoal > 0 )
{
$CoalInStocks = sysAmountInStocks( "Coal" )
if ( $CoalInStocks < $kMaxCoalInStorage )
{
*grantitem %PLAYER% -1 Coal
*addtostocks $gBuildingNum,1,Coal
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:Main" )
{
CustomEvent( "MedBlacksmithAccessInit" )
}
Function MedBlacksmithDisplayOwnerStickSuppliesOSD( )
{
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
$stickInStocks = sysAmountInStocks( "Stick" )
$steelInStocks = sysAmountInStocks( "Steel" )
$coalInStocks = sysAmountInStocks( "Coal" )
$stickBuyPrice = sysGetBuyPrice( "Stick" )
$steelBuyPrice = sysGetBuyPrice( "Steel" )
$CoalBuyPrice = sysGetBuyPrice( "Coal" )
$hasStick = sysPlayerInventory( "Stick" )
$hasSteel = sysPlayerInventory( "Steel" )
$hasCoal = sysPlayerInventory( "Coal" )
osdaddat(OSDTEXT, 20, 10, 0, 0, "", "$stickInStocks Stick, $steelInStocks Steel, $coalInStocks Coal currently in storage")
if ( $hasStick > 0 )
{
if ( $stickInStocks < $kMaxStickInStorage )
{
osdaddat(OSDBUTTON, 20, 35, 175, 25, "AddStick", "Add Stick")
}
else
{
osdaddat(OSDFADEDBUTTON, 20, 35, 175, 25, "", "Add Stick")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 20, 35, 175, 25, "", "Add Stick")
}
if ( $hasSteel > 0 )
{
if ( $steelInStocks < $kMaxSteelInStorage )
{
osdaddat(OSDBUTTON, 213, 35, 175, 25, "AddSteel", "Add Steel")
}
else
{
osdaddat(OSDFADEDBUTTON, 213, 35, 175, 25, "", "Add Steel")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 213, 35, 175, 25, "", "Add Steel")
}
if ( $hasCoal > 0 )
{
if ( $CoalInStocks < $kMaxCoalInStorage )
{
osdaddat(OSDBUTTON, 405, 35, 175, 25, "AddCoal", "Add Coal")
}
else
{
osdaddat(OSDFADEDBUTTON, 405, 35, 175, 25, "", "Add Coal")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 405, 35, 175, 25, "", "Add Coal")
}
$lineY = 80
osdaddat(OSDTEXT, 20, $lineY, 0, 0, "", "Stick buy price :")
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "1 Stick for")
osdaddat(OSDCASHVALUE, 225, $valLineY, 100, 25, "stickbuyval", "$stickBuyPrice|0|999")
$lineY = $lineY + 25
if ( $stickBuyPrice == 0 )
{
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Not currently buying Stick)")
}
else
{
$stickBuyPriceText = sysGetPriceText( $stickBuyPrice )
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Currently buying at 1 Stick for $stickBuyPriceText)")
}
$lineY = 80
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 345, $lineY, 0, 0, "", "Max in storage :")
$stickInStorageLimit = $gBuildingVar[6]
osdaddat(OSDVALUE, 450, $valLineY, 100, 25, "stickbuylimit", "$stickInStorageLimit|5|50|5")
// --------------------- Steel
$lineY = 150
osdaddat(OSDTEXT, 20, $lineY, 0, 0, "", "Steel buy price :")
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "1 Steel for")
osdaddat(OSDCASHVALUE, 225, $valLineY, 100, 25, "Steelbuyval", "$SteelBuyPrice|0|999")
$lineY = $lineY + 25
if ( $SteelBuyPrice == 0 )
{
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Not currently buying Steel)")
}
else
{
$SteelBuyPriceText = sysGetPriceText( $SteelBuyPrice )
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Currently buying at 1 Steel for $steelBuyPriceText)")
}
$lineY = 150
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 345, $lineY, 0, 0, "", "Max in storage :")
$SteelInStorageLimit = $gBuildingVar[7]
osdaddat(OSDVALUE, 450, $valLineY, 100, 25, "Steelbuylimit", "$SteelInStorageLimit|5|50|5")
// --------------------- Coal
$lineY = 220
osdaddat(OSDTEXT, 20, $lineY, 0, 0, "", "Coal buy price :")
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "1 Coal for")
osdaddat(OSDCASHVALUE, 225, $valLineY, 100, 25, "Coalbuyval", "$CoalBuyPrice|0|999")
$lineY = $lineY + 25
if ( $CoalBuyPrice == 0 )
{
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Not currently buying Coal)")
}
else
{
$CoalBuyPriceText = sysGetPriceText( $CoalBuyPrice )
osdaddat(OSDTEXT, 150, $lineY, 0, 0, "", "(Currently buying at 1 Coal for $CoalBuyPriceText)")
}
$lineY = 220
$valLineY = $lineY - 5
osdaddat(OSDTEXT, 345, $lineY, 0, 0, "", "Max in storage :")
$CoalInStorageLimit = $gBuildingVar[8]
osdaddat(OSDVALUE, 450, $valLineY, 100, 25, "Coalbuylimit", "$CoalInStorageLimit|5|50|5")
osdaddat(OSDAPPLYBUTTON, 380, 300, 200, 25, "StickAdminApply|&stickbuyval|&stickbuylimit|&steelbuyval|&steelbuylimit|&coalbuyval|&coalbuylimit", "Apply Changes")
osdaddat(OSDBUTTON, 50, 300, 200, 25, "Main", "Main Page")
osdaddat(OSDEXITBUTTON, 50, 330, 200, 20, "", "Close")
osdactivate()
}
Event( "OSDSelect", "MedSmithOSD:StickAdmin" )
{
$ret = MedBlacksmithDisplayOwnerStickSuppliesOSD()
}
Event( "OSDSelect", "MedSmithOSD:SetPrice" )
{
$itemNum = $gParam[1]
$price = $gParam[2]
$itemName = sysGetItemName( $itemNum )
*setsellprice $gBuildingNum,$itemName,$price
$ret = MedBlacksmithOwnerSetPricesOSD()
}
Event( "OSDSelect", "MedSmithOSD:ApplySellPrice" )
{
$itemNum = $gParam[1]
$newPrice = $gParam[2]
$itemName = sysGetItemName( $itemNum )
*setsellprice $gBuildingNum,$itemName,$newPrice
$ret = MedBlacksmithOwnerSetPricesOSD()
}
Function MedBlacksmithShowItemSetPriceOSD( $itemNum )
{
$itemName = sysGetItemName( $itemNum )
$sellPrice = sysGetSellPrice( $itemNum )
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
osdaddat(OSDTEXT, 20, 10, 560, 0, "", "Note the building can only make and sell items if you have a worker")
$stickRequired = 0
$steelRequired = 0
if ( $itemNum == 1 ) // Axe
{
$stickRequired = $kAxeStickRequired
$steelRequired = $kAxeSteelRequired
$CoalRequired = $kAxeCoalRequired
}
else if ( $itemNum == 7 ) // Bag of nail
{
$stickRequired = $kBag of nailStickRequired
$steelRequired = $kBag of nailSteelRequired
$CoalRequired = $kBag of nailCoalRequired
}
else if ( $itemNum == 5 ) // Pickaxe
{
$stickRequired = $kPickaxeStickRequired
$steelRequired = $kPickaxeSteelRequired
$CoalRequired = $kPickaxeCoalRequired
}
else if ( $itemNum == 8 ) // Plough
{
$stickRequired = $kPloughStickRequired
$steelRequired = $kPloughSteelRequired
$CoalRequired = $kPloughCoalRequired
}
else if ( $itemNum == 9 ) // Hammer
{
$stickRequired = $kHammerStickRequired
$steelRequired = $kHammerSteelRequired
$CoalRequired = $kHammerCoalRequired
}
$lineY = 50
osdaddat(OSDBIGTEXT, 50, $lineY, 0, 0, "", "Set Sell Price for $itemName")
$lineY = $lineY + 30
if ( $sellPrice > 0 )
{
$priceText = sysGetPriceText( $sellPrice )
osdaddat(OSDTEXT, 50, $lineY, 500, 0, "", "Currently selling at $priceText.")
}
else
{
osdaddat(OSDTEXT, 50, $lineY, 500, 0, "", "Not currently selling")
}
$lineY = $lineY + 50
osdaddat(OSDCASHVALUE, 250, $lineY, 100, 25, "sellprice", "$sellPrice|0|10000")
$lineY = $lineY + 40
osdaddat(OSDBUTTON, 200, $lineY, 200, 25, "ApplySellPrice|$itemNum|&sellPrice", "Apply")
$lineY = $lineY + 40
if ( $gBuildingWage > 0 )
{
$wageText = sysGetPriceText( $gBuildingWage )
osdaddat(OSDTEXT, 50, $lineY, 500, 0, "", "Your employee will take $wageText of the price for their wages.")
}
else
{
osdaddat(OSDTEXT, 50, $lineY, 500, 0, "", "Don't forget your blacksmith's wages will be taken from this price.")
}
$lineY = $lineY + 16
// TODO - Give description of the amount of resource required to make
{
$stickBuyPrice = sysGetBuyPrice( "Stick" )
if ( $stickBuyPrice > 0 )
{
$stickBuyText = sysGetPriceText( $stickBuyPrice )
osdaddat(OSDTEXT, 50, 235, 500, 0, "", "Requires $stickRequired Stick (which you currently buy for $stickBuyText)")
}
else
{
osdaddat(OSDTEXT, 50, 235, 500, 0, "", "Requires $stickRequired Stick to make.")
}
$steelBuyPrice = sysGetBuyPrice( "Steel" )
if ( $steelBuyPrice > 0 )
{
$steelBuyText = sysGetPriceText( $steelBuyPrice )
osdaddat(OSDTEXT, 50, 250, 500, 0, "", "Requires $steelRequired Steel (which you currently buy for $steelBuyText)")
}
else
{
osdaddat(OSDTEXT, 50,250, 500, 0, "", "Requires $steelRequired Steel to make.")
}
$CoalBuyPrice = sysGetBuyPrice( "Coal" )
if ( $steelBuyPrice > 0 )
{
$CoalBuyText = sysGetPriceText( $CoalBuyPrice )
osdaddat(OSDTEXT,50, 265, 500, 0, "", "Requires $CoalRequired Coal (which you currently buy for $CoalBuyText)")
}
else
{
osdaddat(OSDTEXT, 50, 265, 500, 0, "", "Requires $steelRequired Steel to make.")
}
}
osdaddat(OSDBUTTON, 50, 300, 200, 25, "Main", "Main Page")
osdaddat(OSDEXITBUTTON, 50, 330, 200, 20, "", "Close")
osdactivate()
}
Event( "OSDSelect", "MedSmithOSD:ChangePrice" )
{
$itemNum = $gParam[1]
if ( $itemNum == 0 )
{
*msg %PLAYER% You cannot currently make Hammer
$ret = MedBlacksmithOwnerSetPricesOSD( )
}
else
{
$ret = MedBlacksmithShowItemSetPriceOSD( $itemNum )
}
}
Function MedBlacksmithShowSetPriceListItem( $itemNum, $lineY )
{
$itemName = sysGetItemName( $itemNum )
$sellPrice = sysGetSellPrice( $itemNum )
if ( $sellPrice > 0 )
{
$priceText = sysGetPriceText( $sellPrice )
osdaddat(OSDBUTTON, 150, $lineY, 250, 20, "ChangePrice|$itemNum", "$itemName ($priceText)")
}
else
{
osdaddat(OSDBUTTON, 150, $lineY, 250, 20, "ChangePrice|$itemNum", "$itemName (Not selling)")
}
}
Function MedBlacksmithOwnerSetPricesOSD( )
{
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
osdaddat(OSDTEXT, 20, 10, 560, 0, "", "Note the building can only make and sell items if you have a worker")
osdaddat(OSDSMALLTEXT, 150, 31, 0, 0, "", "Sell Price")
$lineY = 50
$ret = MedBlacksmithShowSetPriceListItem( 1, $lineY ) // Axe
$lineY = $lineY + 30
$ret = MedBlacksmithShowSetPriceListItem( 7, $lineY ) // Bag of nail
$lineY = $lineY + 30
$ret = MedBlacksmithShowSetPriceListItem( 5, $lineY ) // pickaxe
$lineY = $lineY + 30
$ret = MedBlacksmithShowSetPriceListItem( 8 , $lineY ) // Plough
$lineY = $lineY + 30
$ret = MedBlacksmithShowSetPriceListItem( 9 , $lineY ) // Hammer
$lineY = $lineY + 30
osdaddat(OSDBUTTON, 50, 300, 200, 25, "Main", "Main Page")
osdaddat(OSDEXITBUTTON, 50, 330, 200, 20, "", "Close")
osdactivate()
}
Event( "OSDSelect", "MedSmithOSD:SetPrices" )
{
$ret = MedBlacksmithOwnerSetPricesOSD()
}
Event( "OSDSelect", "MedSmithOSD:SetWage" )
{
*setwage $gBuildingNum $gParam[1]
$ret = MedBlacksmithOwnerWorkerAdminOSD()
}
Event( "OSDSelect", "MedSmithOSD:Sack" )
{
if ( $gBuildingNumEmployees > 0 )
{
$employeeID = sysGetEmployeeID( 0 )
$name = sysGetPlayerName( $employeeID )
*removeemployee $gBuildingNum $name
// Clear the ore that was going to go to the employee
if ( $gBuildingVar[10] > 0 )
{
*grantitem $name $gBuildingVar[10] Gold
$gBuildingVar[10] = 0
}
*msg %PLAYER% You fired your worker
}
CustomEvent( "MedBlacksmithAccessInit" )
}
Function MedBlacksmithOwnerWorkerAdminOSD()
{
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
// osdaddat(OSDIMAGE, 30, 10, 128, 128, "", "http://gameislands.net/gamecontent/civilization/menus/constructfarm1.jpg")
$wageText = sysGetPriceText( $gBuildingWage )
if ( $gBuildingNumEmployees > 0 )
{
$employeeID = sysGetEmployeeID( 0 )
$name = sysGetPlayerName( $employeeID )
osdaddat(OSDTEXT, 160,115,440,0, "", "You currently employ $name at a rate of $wageText per item")
osdaddat(OSDBUTTON, 220,140,300,25, "Sack", "Fire Worker")
}
else
{
osdaddat(OSDBIGTEXT, 20,100,560,0, "", "Set Wage (cost per item made)")
osdaddat(OSDVALUE, 215, 140, 150, 25, "wageval", "$gBuildingWage|1|500" )
osdaddat(OSDBUTTON, 200,180,150,20, "SetWage|&wageval", "Confirm")
osdaddat(OSDBUTTON, 400,180,150,20, "SetWage|0", "Not employing")
}
if ( $gBuildingWage > 0 )
{
osdaddat(OSDTEXT, 20, 250, 560, 20, "", "Current wage is $wageText per item produced.")
}
else
{
osdaddat(OSDTEXT, 20, 250, 560, 20, "", "You currently have no wage set so will not be employing anyone")
}
osdaddat(OSDBUTTON, 20, 300, 200, 25, "Main", "Main Page")
osdaddat(OSDEXITBUTTON, 20, 335, 150, 20, "", "Close")
osdactivate()
}
Event( "OSDSelect", "MedSmithOSD:Admin" )
{
$ret = MedBlacksmithOwnerWorkerAdminOSD()
}
Function MedBlacksmithOwnerOSD( )
{
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
$stickInStocks = sysAmountInStocks( "Stick" )
$steelInStocks = sysAmountInStocks( "Steel" )
$coalInStocks = sysAmountInStocks( "Coal" )
$stickBuyPrice = sysGetBuyPrice( "Stick" )
$steelBuyPrice = sysGetBuyPrice( "Steel" )
$CoalBuyPrice = sysGetBuyPrice( "Coal" )
$investText = sysGetPriceText( $gBuildingInvestment )
osdaddat(OSDTEXT, 20, 10, 560, 0, "", "Current investment : $investText")
if ( $stickBuyPrice == 0 )
{
osdaddat(OSDTEXT, 20, 35, 560, 0, "", "$stickInStocks Stick currently in storage - Not currently buying")
}
else
{
$stickBuyPriceText = sysGetPriceText( $stickBuyPrice )
osdaddat(OSDTEXT, 20, 35, 560, 0, "", "$stickInStocks Stick currently in storage - Buying at $stickBuyPriceText each (Until $gBuildingVar[6] in storage)")
}
if ( $steelBuyPrice == 0 )
{
osdaddat(OSDTEXT, 20, 50, 560, 0, "", "$steelInStocks Steel currently in storage - Not currently buying")
}
else
{
$steelBuyPriceText = sysGetPriceText( $steelBuyPrice )
osdaddat(OSDTEXT, 20, 50, 560, 0, "", "$steelInStocks Steel currently in storage - Buying at $steelBuyPriceText each (Until $gBuildingVar[7] in storage)")
}
if ( $CoalBuyPrice == 0 )
{
osdaddat(OSDTEXT, 20, 65, 560, 0, "", "$CoalInStocks Coal currently in storage - Not currently buying")
}
else
{
$CoalBuyPriceText = sysGetPriceText( $CoalBuyPrice )
osdaddat(OSDTEXT, 20, 65, 560, 0, "", "$CoalInStocks Coal currently in storage - Buying at $CoalBuyPriceText each (Until $gBuildingVar[8] in storage)")
}
osdaddat(OSDBUTTON, 200, 100, 200, 25, "StickAdmin", "Supplies Admin")
osdaddat(OSDFADEDTEXT, 20, 140, 560, 20, "", "Made here so far:")
$lineY = 165
osdaddat(OSDTEXT, 100, $lineY, 0, 20, "", "$gBuildingVar[3] Axes")
$lineY = $lineY + 20
osdaddat(OSDTEXT, 100, $lineY, 0, 20, "", "$gBuildingVar[4] Bag of nails")
$lineY = $lineY + 20
osdaddat(OSDTEXT, 100, $lineY, 0, 20, "", "$gBuildingVar[5] Pickaxes")
$lineY = 165
osdaddat(OSDTEXT, 350, $lineY, 0, 20, "", "$gBuildingVar[12] Ploughs")
$lineY = $lineY + 20
osdaddat(OSDTEXT, 350, $lineY, 0, 20, "", "$gBuildingVar[13] Hammer")
$lineY = $lineY + 20
$lineY = $lineY + 30
osdaddat(OSDBUTTON, 200, $lineY, 200, 25, "SetPrices", "Set Prices")
$ret = MedBlacksmithShowOwnerEmployeeDisplay( 50, 300, $gBuildingWage, 0, 100 )
osdaddat(OSDBUTTON, 200, 320, 200, 25, "Admin", "Worker Admin")
osdactivate()
}
Function MedBlacksmithTaskComplete( $taskNum )
{
if ( $taskNum == 1 ) // Axe
{
$itemNum = 1
$gBuildingVar[3] = $gBuildingVar[3] + 1
}
else if ( $taskNum == 2 ) // Bag of Nail
{
$itemNum = 7
$gBuildingVar[4] = $gBuildingVar[4] + 1
}
else if ( $taskNum == 3 ) // Pickaxe
{
$itemNum = 5
$gBuildingVar[5] = $gBuildingVar[5] + 1
}
else if ( $taskNum == 4 ) // Plough
{
$itemNum = 8
$gBuildingVar[12] = $gBuildingVar[12] + 1
}
else if ( $taskNum == 5 ) // Hammer
{
$itemNum = 9
$gBuildingVar[13] = $gBuildingVar[13] + 1
}
$itemName = sysGetItemName( $itemNum )
*grantitem %PLAYER% 1 $itemName
}
Event( "OSDSelect", "MedSmithOSD:Make" )
{
$price = sysGetSellPrice( $gParam[1] )
if ( $gParam[1] == 1 ) // Axe
{
$stickRequired = $kAxeStickRequired
$steelRequired = $kAxesteelRequired
$coalRequired = $kAxecoalRequired
}
else if ( $gParam[1] == 7 ) // Bag of Nail
{
$stickRequired = $kBag of Nail StickRequired
$steelRequired = $kBag of Nail steelRequired
$coalRequired = $kBag of Nail coalRequired
}
else if ( $gParam[1] == 5 ) // Pickaxe
{
$stickRequired = $kPickaxe StickRequired
$steelRequired = $kPickaxe steelRequired
$coalRequired = $kPickaxe coalRequired
}
else if ( $gParam[1] == 8 ) // Plough
{
$stickRequired = $kPloughStickRequired
$steelRequired = $kPloughsteelRequired
$coalRequired = $kPloughcoalRequired
}
else if ( $gParam[1] == 9 ) // Hammer
{
$stickRequired = $kHammerStickRequired
$steelRequired = $kHammersteelRequired
$coalRequired = $kHammercoalRequired
}
if ( $price <= $gPlayerCash )
{
if ( $gBuildingWage < $price )
{
else if ( $coalRequired > 0 )
{
$coalInStocks = sysAmountInStocks( "coal" )
if ( $stickRequired <= $stickInStocks )
else if ( $steelRequired <= $steelInStocks )
else if ( $coalRequired <= $coalInStocks )
{
$amountForInvest = $price - $gBuildingWage
$gBuildingVar[10] = $gBuildingVar[10] + $gBuildingWage
*grantcash %PLAYER% -$price
*addtoinvestment $gBuildingNum $amountForInvest
*removefromstocks $gBuildingNum,$stickRequired,Stick
*removefromstocks $gBuildingNum,$steelRequired,steel
*removefromstocks $gBuildingNum,$coalRequired,coal
if ( $gParam[1] == 1 ) // Axe
{
*dobuildingtask %PLAYER% $gBuildingAccessNum 13 Waiting for the blacksmith to make your Axe
}
else if ( $gParam[1] == 7 ) // Bag of Nail
{
*dobuildingtask %PLAYER% $gBuildingAccessNum 14 Waiting for the blacksmith to make your Bag of Nail
}
else if ( $gParam[1] == 5 ) // Pickaxe
{
*dobuildingtask %PLAYER% $gBuildingAccessNum 15 Waiting for the blacksmith to make your pickaxe
}
else ( $gParam[1] == 8 ) // Plough
{
*dobuildingtask %PLAYER% $gBuildingAccessNum 16 Waiting for the blacksmith to make your Plough
}
else if ( $gParam[1] == 9 ) // Hammer
{
*dobuildingtask %PLAYER% $gBuildingAccessNum 17 Waiting for the blacksmith to make your Hammer
}
}
}
}
}
}
}
}
//-------------------------------------------------------------
// Visitor item OSD
Function MedBlacksmithVisitorShowItemOSD( $lineY, $itemNum, $stickRequired, $steelRequired, $coalRequired )
{
$itemName = sysGetItemName( $itemNum )
$sellPrice = sysGetSellPrice( $itemNum )
$textY = $lineY + 5
osdaddat(OSDBIGTEXT, 50, $lineY, 0, 0, "", "$itemName")
if ( $sellPrice > 0 )
{
$sellPriceText = sysGetPriceText( $sellPrice )
osdaddat(OSDTEXT, 130, $textY, 0, 0, "", "for $sellPriceText")
$bCanMake = 0;
if ( $stickRequired > 0 )
{
$stickInStocks = sysAmountInStocks( "Stick" )
if ( $stickInStocks >= $stickRequired )
{
$bCanMake = 1
}
}
else
{
$steelInStocks = sysAmountInStocks( "Steel" )
if ( $steelInStocks >= $steelRequired )
{
$bCanMake = 1
}
}
else
{
$coalInStocks = sysAmountInStocks( "coal" )
if ( $coalInStocks >= $coalRequired )
{
$bCanMake = 1
}
}
if ( $bCanMake == 1 )
{
if ( $gPlayerCash >= $sellPrice )
{
osdaddat(OSDEXITBUTTON, 400, $lineY, 150, 25, "Make|$itemNum", "Make $itemName")
}
else
{
osdaddat(OSDFADEDBUTTON, 400, $lineY, 150, 25, "", "(Not enough cash)")
}
}
else
{
if ( $stickRequired > 0 )
{
osdaddat(OSDFADEDBUTTON, 400, $lineY, 150, 25, "", "(Not enough stick)")
}
else
{
osdaddat(OSDFADEDBUTTON, 400, $lineY, 150, 25, "", "(Not enough steel)")
}
else
{
osdaddat(OSDFADEDBUTTON, 400, $lineY, 150, 25, "", "(Not enough coal)")
}
}
}
else
{
osdaddat(OSDTEXT, 130, $textY, 0, 0, "", "(Not for sale)")
osdaddat(OSDFADEDBUTTON, 400, $lineY, 150, 25, "", "Purchase $itemName")
}
$textY = $lineY + 19
if ( $stickRequired > 0 )
{
osdaddat(OSDSMALLTEXT, 70, $textY, 0, 0, "", "Requires $stickRequired Stick in building")
}
else
{
osdaddat(OSDSMALLTEXT, 70, $textY, 0, 0, "", "Requires $steelRequired Steel in building")
}
else
{
osdaddat(OSDSMALLTEXT, 70, $textY, 0, 0, "", "Requires $coalRequired Coal in building")
}
}
Event( "OSDSelect", "MedSmithOSD:SellStick" )
{
$stickBuyPrice = sysGetBuyPrice( "Stick" )
if ( $stickBuyPrice > 0 )
{
$stickInStocks = sysAmountInStocks( "Stick" )
if ( $stickInStocks < $gBuildingVar[6] )
{
if ( $gBuildingInvestment >= $stickBuyPrice )
{
$hasStick = sysPlayerInventory("Stick")
if ( $hasStick >= 1 )
{
*grantitem %PLAYER% -1 Stick
*addtostocks $gBuildingNum,1,Stick
*removefrominvestment $gBuildingNum $stickBuyPrice
*grantcash %PLAYER% $stickBuyPrice
}
}
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:Sellsteel" )
{
$steelBuyPrice = sysGetBuyPrice( "steel" )
if ( $stickBuyPrice > 0 )
{
$steelInStocks = sysAmountInStocks( "steel" )
if ( $steelInStocks < $gBuildingVar[7] )
{
if ( $gBuildingInvestment >= $steelBuyPrice )
{
$hassteel = sysPlayerInventory("steel")
if ( $hassteel >= 1 )
{
*grantitem %PLAYER% -1 steel
*addtostocks $gBuildingNum,1,steel
*removefrominvestment $gBuildingNum $steelBuyPrice
*grantcash %PLAYER% $steelBuyPrice
}
}
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:Sellcoal" )
{
$coalBuyPrice = sysGetBuyPrice( "coal" )
if ( $coalBuyPrice > 0 )
{
$coalInStocks = sysAmountInStocks( "coal" )
if ( $coalInStocks < $gBuildingVar[8] )
{
if ( $gBuildingInvestment >= $coalBuyPrice )
{
$hascoal = sysPlayerInventory("coal")
if ( $hascoal >= 1 )
{
*grantitem %PLAYER% -1 coal
*addtostocks $gBuildingNum,1,coal
*removefrominvestment $gBuildingNum $coalBuyPrice
*grantcash %PLAYER% $coalBuyPrice
}
}
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:Collect" )
{
$employeeID = sysGetEmployeeID( 0 )
if ( $employeeID == $gPlayerID )
{
if ( $gBuildingVar[10] > 0 )
{
*grantcash %PLAYER% $gBuildingVar[10]
$gBuildingVar[10] = 0
}
}
$ret = MedBlacksmithVisitorOSD()
}
Event( "OSDSelect", "MedSmithOSD:JobApply" )
{
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
$hasSkill = sysPlayerSkillLevel("Blacksmith")
if ( $hasSkill < 1 )
{
osdaddat(OSDTEXT, 10, 160, 580, 20, "", "You need the 'Blacksmith' skill to be able to take a job here.")
}
else
{
$oldJobCount = $gPlayerNumJobs
*addemployee $gBuildingNum %PLAYER%
if ( $gPlayerNumJobs > $oldJobCount )
{
osdaddat(OSDTEXT, 10, 160, 580, 20, "", "Welcome to your new job.")
osdaddat(OSDTEXT, 50, 190, 500, 20, "", "You don't need to do anything to work here - though filling the building with Sticks, Steel or Coal may help keep wages regular - just come back occasionally to collect your pay")
}
else
{
osdaddat(OSDTEXT, 10, 160, 580, 20, "", "There was a problem with your application.")
osdaddat(OSDTEXT, 10, 190, 580, 20, "", "Please try again later.")
}
}
osdaddat(OSDEXITBUTTON, 50, 330, 200, 20, "", "Close")
osdactivate()
}
Event( "OSDSelect", "MedSmithOSD:QuitJob" )
{
*removeemployee $gBuildingNum %PLAYER%
*msg %PLAYER% You left your job at the Blacksmith
$ret = MedBlacksmithVisitorOSD()
}
Function MedBlacksmithVisitorOSD( )
{
$numEmployed = $gBuildingNumEmployees;
$maxEmployed = $gBuildingMaxEmployees;
$employeeID = sysGetEmployeeID( 0 )
$stickInStocks = sysAmountInStocks( "Stick" )
$steelInStocks = sysAmountInStocks( "Steel" )
$coalInStocks = sysAmountInStocks( "Coal" )
osdcreate(OSDBUILDING,"MedSmithOSD", "" )
if ( $numEmployed > 0 )
{
if ( $gBuildingInvestment > 0 )
{
$investText = sysGetPriceText( $gBuildingInvestment )
}
else
{
$investText = "nothing"
}
osdaddat(OSDTEXT, 50, 0, 0, 0, "", "The smith will make items for you for a price..")
osdaddat(OSDFADEDSMALLTEXT, 90, 15, 0, 0, "", " (Current stocks : $stickInStocks Stick, $steelInStocks Steel, $coalInStocks Coal. Investment : $investText)")
$ret = MedBlacksmithVisitorShowItemOSD( 40, 229, $kAxeStickRequired,$kAxesteelRequired,$kAxecoalRequired ) // Axe
$ret = MedBlacksmithVisitorShowItemOSD( 80, 115, $kBag of nailStickRequired,$kBag of nailsteelRequired,$kBag of nailcoalRequired ) // Bag of nail
$ret = MedBlacksmithVisitorShowItemOSD( 120, 117, $kPickaxeStickRequired,$kPickaxesteelRequired,$kPickaxecoalRequired ) // Pickaxe
$ret = MedBlacksmithVisitorShowItemOSD( 160, 224, $kPloughStickRequired,$kPloughsteelRequired,$kPloughcoalRequired ) // Plough
$ret = MedBlacksmithVisitorShowItemOSD( 200, 242, $kHammerStickRequired,$kHammersteelRequired,$kHammercoalRequired ) // Hammer
$name = sysGetPlayerName( $employeeID )
osdaddat(OSDTEXT, 20, 250, 560, 20, "", "Employs: $name (Blacksmith)")
if ( $employeeID == $gPlayerID )
{
osdaddat(OSDBUTTON, 30, 250, 100, 20, "QuitJob", "Quit Job")
if ( $gBuildingVar[10] > 0 )
{
osdaddat(OSDBUTTON, 460, 250, 100, 20, "Collect", "Collect pay")
}
else
{
osdaddat(OSDFADEDBUTTON, 460, 250, 100, 20, "", "Collect pay")
}
$wageText = sysGetPriceText( $gBuildingVar[10] )
osdaddat(OSDSMALLTEXT, 460, 275, 100, 20, "", "$wageText")
}
}
else
{
osdaddat(OSDTEXT, 20, 80, 560, 0, "", "The Blacksmith building does not function unless it has an employee")
if ( $gBuildingWage == 0 )
{
osdaddat(OSDTEXT, 20, 170, 560, 20, "", "Not currently seeking an employee")
}
else if ( $numEmployed < $maxEmployed )
{
$wageText = sysGetPriceText( $gBuildingWage )
osdaddat(OSDTEXT, 40, 170, 520, 20, "", "There is currently a job available for a Blacksmith at $wageText per item produced.")
if ( $gPlayerNumJobs < $kMaxNumJobs )
{
$isBlacksmith = sysPlayerSkillLevel("Blacksmith")
if ( $isBlacksmith > 0 )
{
if ( $gPlayerNumJobs < $kMaxNumJobs )
{
osdaddat(OSDBUTTON, 150, 200, 300, 30, "JobApply", "Apply for Job")
}
else
{
osdaddat(OSDFADEDBUTTON, 150, 200, 300, 30, "", "(You already have a job elsewhere)")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 150, 200, 300, 30, "", "(Blacksmith skill required)")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 150, 200, 300, 30, "", "(You already have a job)")
}
}
}
$hasShownMessage = 0
$stickBuyPrice = sysGetBuyPrice( "Stick" )
$steelBuyPrice = sysGetBuyPrice( "Steel" )
$coalBuyPrice = sysGetBuyPrice( "Coal" )
if ( $stickBuyPrice > 0 )
{
if ( $stickInStocks < $gBuildingVar[6] )
{
if ( $gBuildingInvestment >= $stickBuyPrice )
{
$stickBuyPriceText = sysGetPriceText( $stickBuyPrice )
if ( $steelBuyPrice > 0 )
{
$steelBuyPriceText = sysGetPriceText( $steelBuyPrice )
osdaddat(OSDTEXT, 40, 290, 520, 20, "", "This building will buy Stick at $stickBuyPriceText and Steel at $steelBuyPriceText")
}
else
{
osdaddat(OSDTEXT, 40, 290, 520, 20, "", "This building will buy Stick at $stickBuyPriceText per stick")
}
$hasShownMessage = 1
$buttonX = 310
$hasStick = sysPlayerInventory("Stick")
if ( $hasStick > 0 )
{
osdaddat(OSDBUTTON, $buttonX, 310, 130, 25, "SellStick", "Sell Stick")
}
else
{
osdaddat(OSDFADEDBUTTON, $buttonX, 310, 130, 25, "", "Sell Stick")
}
}
}
}
if ( $steelBuyPrice > 0 )
{
if ( $steelInStocks < $gBuildingVar[7] )
{
if ( $gBuildingInvestment >= $steelBuyPrice )
{
$buttonX = 380
$hasSteel = sysPlayerInventory("Steel")
if ( $hasSteel > 0 )
{
osdaddat(OSDBUTTON, $buttonX, 310, 140, 25, "SellSteel", "Sell Steel")
}
else
{
osdaddat(OSDFADEDBUTTON, $buttonX, 310, 140, 25, "", "Sell Steel")
}
}
}
}
if ( $CoalBuyPrice > 0 )
{
if ( $CoalInStocks < $gBuildingVar[8] )
{
if ( $gBuildingInvestment >= $CoalBuyPrice )
{
$buttonX = 450
$hasCoal = sysPlayerInventory("Coal")
if ( $hasCoal > 0 )
{
osdaddat(OSDBUTTON, $buttonX, 310, 140, 25, "SellCoal", "Sell Coal")
}
else
{
osdaddat(OSDFADEDBUTTON, $buttonX, 310, 140, 25, "", "Sell Coal")
}
}
}
}
if ( $employeeID == $gPlayerID )
{
if ( $hasShownMessage == 0 )
{
osdaddat(OSDTEXT, 20, 290, 560, 0, "", "$stickInStocks Stick, $steelInStocks Steel, $coalInStocks Coal currently in storage")
}
if ( $stickInStocks < $kMaxStickInStorage )
{
$hasStick = sysPlayerInventory("Stick")
if ( $hasStick > 0 )
{
osdaddat(OSDBUTTON, 40, 310, 120, 25, "WorkerAddStick", "Add Stick")
}
else
{
osdaddat(OSDFADEDBUTTON, 40, 310, 120, 25, "", "Add Stick")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 40, 310, 120, 25, "", "Add Stick")
}
if ( $steelInStocks < $kMaxSteelInStorage )
{
$hasSteel = sysPlayerInventory("Steel")
if ( $hasSteel > 0 )
{
osdaddat(OSDBUTTON, 170, 310, 120, 25, "WorkerAddSteel", "Add Steel")
}
else
{
osdaddat(OSDFADEDBUTTON, 170, 310, 120, 25, "", "Add Steel")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 170, 310, 120, 25, "", "Add Steel")
}
if ( $CoalInStocks < $kMaxCoalInStorage )
{
$hasCoal = sysPlayerInventory("Coal")
if ( $hasCoal > 0 )
{
osdaddat(OSDBUTTON, 170, 310, 120, 25, "WorkerAddCoal", "Add Coal")
}
else
{
osdaddat(OSDFADEDBUTTON, 170, 310, 120, 25, "", "Add Coal")
}
}
else
{
osdaddat(OSDFADEDBUTTON, 170, 310, 120, 25, "", "Add Coal")
}
}
else
{
if ( $hasShownMessage == 0 )
{
osdaddat(OSDTEXT, 20, 290, 560, 0, "", "$stickInStocks Stick, $steelInStocks Steel, $coalInStocks Coal currently in storage")
}
}
osdaddat(OSDEXITBUTTON, 10, 340, 150, 20, "", "Close")
osdactivate()
}
Event( "Custom", "MedBlacksmithAccessInit" )
{
if ( $gBuildingOwnerID == $gPlayerID )
{
$ret = MedBlacksmithOwnerOSD()
}
else
{
$ret = MedBlacksmithVisitorOSD()
}
}
Event( "AccessBuilding", "$kMedBlacksmithBuildingNum" )
{
CustomEvent( "MedBlacksmithAccessInit" )
}
Event( "NewBuilding", "$kMedBlacksmithBuildingNum" )
{
$gBuildingVar[6] = 10
}