mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
- [FIX] Fixed Definitions.d.ts had misselled void and onSpeechInput was missing SpeachID - [UPD] Updated lots of js scripts to use socket with system message where needed instead of pUser, - [FIX] Fixed House Christmas Tree Items with a base ornament and Removed unused house_item line on the tree addon. - [UPD] Updated Dictonary with missing golem construct messages and updated the js script to match.
135 lines
3.9 KiB
JavaScript
135 lines
3.9 KiB
JavaScript
/// <reference path="../definitions.d.ts" />
|
|
// @ts-check
|
|
// Tool used by Tinkerers to craft Iron Golems
|
|
const maxControlSlots = GetServerSetting( "MaxControlSlots" );
|
|
|
|
// maxFollowers only comes into play if maxControlSlots is set to 0 in UOX.INI
|
|
const maxFollowers = GetServerSetting( "MaxFollowers" );
|
|
const golemControlSlots = 4;
|
|
|
|
/** @type { ( user: Character, iUsing: Item ) => boolean } */
|
|
function onUseChecked( pUser, iUsed )
|
|
{
|
|
var socket = pUser.socket;
|
|
if( ValidateObject( iUsed ))
|
|
return;
|
|
|
|
// Check to see if it's locked down
|
|
if( iUsed.movable == 2 || iUsed.movable == 3 )
|
|
{
|
|
socket.SysMessage( GetDictionaryEntry( 774, socket.language )); // That is locked down and you cannot use it
|
|
return false;
|
|
}
|
|
|
|
var itemOwner = GetPackOwner( iUsed, 0 );
|
|
if( itemOwner == null || itemOwner.serial != pUser.serial )
|
|
{
|
|
socket.SysMessage( GetDictionaryEntry( 1763, socket.language )); // That item must be in your backpack before it can be used.
|
|
return false;
|
|
}
|
|
|
|
if( pUser.skills.tinkering < 60 )
|
|
{
|
|
socket.SysMessage( GetDictionaryEntry( 2772, socket.language )); // You must be a Journeyman or higher Tinker to construct a golem.
|
|
return false;
|
|
}
|
|
|
|
// Check to see if player actually has space for ANY more pets/followers
|
|
if( maxControlSlots > 0 )
|
|
{
|
|
if( pUser.controlSlotsUsed + golemControlSlots > maxControlSlots )
|
|
{
|
|
socket.SysMessage( GetDictionaryEntry( 2390, socket.language )); // That would exceed your maximum number of pet control slots.
|
|
return;
|
|
}
|
|
}
|
|
else if( pUser.followerCount >= maxFollowers )
|
|
{
|
|
// Only checked if maxControlSlots is set to 0
|
|
var tempMsg = GetDictionaryEntry( 2346, socket.language ); // You can maximum have %i pets/followers active at the same time.
|
|
socket.SysMessage( tempMsg.replace( /%i/gi, maxFollowers ));
|
|
return;
|
|
}
|
|
|
|
// Check if player has enough resources to construct the golem
|
|
// 1 power crystal, 50 iron ingots, 50 bronze ingots and 5 gears
|
|
if( pUser.ResourceCount( 0x1f1c ) < 1 )
|
|
{
|
|
socket.SysMessage(GetDictionaryEntry( 2870, socket.language )); // You need a power crystal to construct a golem.
|
|
}
|
|
else if( pUser.ResourceCount( 0x1bf2 ) < 50 )
|
|
{
|
|
socket.SysMessage(GetDictionaryEntry( 2871, socket.language )); // You need more iron ingots to construct a golem.
|
|
}
|
|
else if( pUser.ResourceCount( 0x1bf2, 0x06d6 ) < 50 )
|
|
{
|
|
socket.SysMessage(GetDictionaryEntry( 2872, socket.language )); // You need more bronze ingots to construct a golem.
|
|
}
|
|
else if( pUser.ResourceCount( ) < 5 )
|
|
{
|
|
socket.SysMessage(GetDictionaryEntry( 2873, socket.language )); // You need more gears to construct a golem.
|
|
}
|
|
else
|
|
{
|
|
// Construct the golem!
|
|
var golemNPC = SpawnNPC( "crafted_golem", pUser.x, pUser.y, pUser.z, pUser.worldnumber, pUser.instanceID );
|
|
if( ValidateObject( nSpawned ))
|
|
{
|
|
// Delete the clockwork assembly
|
|
iUsed.Delete();
|
|
|
|
// Set player as owner of the golem
|
|
golemNPC.owner = pUser;
|
|
|
|
// Start following the player
|
|
golemNPC.Follow( pUser );
|
|
|
|
// Add golem as an active follower of the player
|
|
pUser.AddFollower( golemNPC );
|
|
|
|
// Play a sound effect
|
|
golemNPC.SoundEffect( 0x241, true );
|
|
|
|
// Apply power-modifications based on player's Tinkering skill
|
|
ApplyGolemPower( golemNPC, pUser );
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function ApplyGolemPower( golemNPC, pUser )
|
|
{
|
|
// Calculate power-scale value
|
|
var powerScale;
|
|
var tinkerSkill = pUser.skills.tinkering;
|
|
if( tinkerSkill >= 1000 )
|
|
{
|
|
powerScale = 1.0;
|
|
}
|
|
else if( tinkerSkill >= 900 )
|
|
{
|
|
powerScale = 0.9;
|
|
}
|
|
else if( tinkerSkill >= 800 )
|
|
{
|
|
powerScale = 0.8;
|
|
}
|
|
else if( tinkerSkill >= 700 )
|
|
{
|
|
powerScale = 0.7;
|
|
}
|
|
else
|
|
{
|
|
powerScale = 0.6;
|
|
}
|
|
|
|
// Scale golem NPC's attributes and skills
|
|
golemNPC.strength *= powerScale;
|
|
golemNPC.dexterity *= powerScale;
|
|
golemNPC.intelligence *= powerScale;
|
|
golemNPC.skills.magicresistance *= powerScale;
|
|
golemNPC.skills.tactics *= powerScale;
|
|
golemNPC.skills.wrestling *= powerScale;
|
|
}
|