So the idea is to have a bashable resource node for players, in this case a ship wreck, which they can get placables from.
Should create the object, destroy the original.
Script goes in the onDamaged event.
Seems to run fine all the way through, can't figure out why it won't create the placable. It destroys the placable and creates the other case in the players inventory (the last else case) and creates wooden planks as it should.
[nwscript]
void main()
{
object oPC = GetLastDamager();
int hp = GetCurrentHitPoints();
int hpmax = GetMaxHitPoints();
if ((hp < (hpmax/2)) && (!GetLocalInt(OBJECT_SELF, "CREATED")))
{
int nLength = GetStringLength(GetTag(OBJECT_SELF));
string sResRef = GetStringRight(GetTag(OBJECT_SELF), nLength-8);
location sLoc = GetLocation(GetWaypointByTag("WP_creator_qst_001"));
string oResRef = GetResRef(OBJECT_SELF);
// Give the player a mesasge dependign on the item type.
if (FindSubString(sResRef, "ore") >= 0)
{
FloatingTextStringOnCreature("You manage to chip off a small nugget of metal ore!", oPC);
}
else if (FindSubString(sResRef, "wood") >= 0)
{
FloatingTextStringOnCreature("You manage to chip off a small piece of wood!", oPC);
}
else
{
// Generic message
FloatingTextStringOnCreature("Clunk!", oPC);
}
CreateItemOnObject(sResRef, oPC, 1);
// Heal the damage to the placeable by replacing it with a new one.
DelayCommand(1.0, DestroyObject(OBJECT_SELF));
SendMessageToPC(oPC, "Destroyed Object");
CreateObject(OBJECT_TYPE_PLACEABLE, oResRef, sLoc, FALSE) ;
// Will work - we use new void declared function.
//DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, oResRef, sLoc, FALSE));
SendMessageToPC(oPC, "Run Delay. and create new object");
SetLocalInt(OBJECT_SELF, "CREATED", TRUE);
SendMessageToPC(oPC, "Set Local Int");
}
}
[/nwscript]
Modifié par Calvinthesneak, 26 février 2011 - 10:14 .