This script is for the new animated lance rack in 1.69. On using the rack, one lance is removed from it, and a lance of the same colour appears in the players' hand.
I couldn't find an existing script, so I made one.
The demo module and erf include the placeable, script and lance templates, so it's plug-and-play.
By default, once the rack is empty, it provides an infinite supply of blue lances. There's a switch in the script to turn this off, so the rack does nothing once empty.
I've been using this with Suspender's Jousting System, which requires a supply of lances (quite reasonably, you can't continue with a broken lance).
UNSUPPORTED
The author no longer supports this work. Please feel free to use, amend or republish as you see fit.
Posted by BelowTheBelt at 2009-07-20 22:53:21 Voted 10.00 on 07/20/09
Love this script!
Made a slight tweak to the script to make the rack respawn with a full set of lances once the 4 have been removed.
It maintains the sequence of lance colors aligned to the lances created in inventory.
You need to have the rack added to your custom palette and use that tag in the script.
This bypasses the function to set the bInfinite variable, which prevents the the lance rack from giving more than 4 lances...but if you want a respawning lance rack, you probably want to be able to distribute more than four lances anyway... I'm sure someone could script it to do both.
// Animated lance rack
// OnUsed script for an animated lance rack.
// If you want it to be empty after all the lances have been taken,
// set bInfinite to FALSE. By default, it keeps handing out blue
// lances forever.
// It expects lance item templates with the following resrefs:
// lance_yellow
// lance_red
// lance_blue
// lance_black
void main()
{
object oPC = GetLastUsedBy();
object oLever = OBJECT_SELF;
int nStatus = GetLocalInt(oLever, "Status") + 1;
string sLance = "blue";
int bInfinite = TRUE;
object oItem;
location lLoc = GetLocation (oLever);
SetLocalInt(oLever, "Status", nStatus);
if (nStatus == 1)
{
sLance = "yellow";
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE, 1.0, 1.0);
}
if (nStatus == 2)
{
sLance = "red";
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE, 1.0, 1.0);
}
if (nStatus == 3)
{
sLance = "blue";
PlayAnimation(ANIMATION_PLACEABLE_OPEN, 1.0, 1.0);
}
if (nStatus == 4)
{
sLance = "black";
DestroyObject (oLever);
CreateObject (OBJECT_TYPE_PLACEABLE, "plc_lance001", lLoc);
}
if (nStatus > 4)
{
if (!bInfinite)
{
return;
}
}
oItem = CreateItemOnObject("lance_" + sLance, oPC);
AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTHAND));
}
Posted by frudillao at 2008-11-17 16:13:04 Voted 10.00 on 11/17/08
Great work as usual! hehe :) _________________________
You must be Logged In to post comments in this section.