I appreciate your tips and I agree with you that I climbed up a bit and I would like to apologize for that. I would be very happy if the error was only that syntax disagreement as I typed that code very quickly.
Well I'll post step by step of my system:
1) Create an item with ResRef="montelenha" and property "Activate Item" (I use here "Garbage" appearance)
2) Create an item with ResRef="pederneira" and property "Activate Item".
3) Create an object placeable to be the campfire. Set ResRef="fogueira".
4) Create an object placeable to be the sound generator of the campfire. Use invisible object appearance and set ResRef="somfogueira".
5) In the module events "onacquireitem" script do that:
5) In the module events "onactiveitem" script do that:
void MontarFogueira(object oPC)
{
location lTarget = GetLocation(oPC);
object oFogueira = CreateObject(OBJECT_TYPE_PLACEABLE, "fogueira", lTarget);
object oSom = CreateObject(OBJECT_TYPE_PLACEABLE,"somfogueira", lTarget);
SetLocalObject(oFogueira, "som_pareado", oSom);
}
void main()
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
string sItemResRef = GetResRef (oItem);
if(sItemResRef == "montelenha")
{
FloatingTextStringOnCreature ("Montando a lenha ...", oPC);
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 4.0));
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.0, MontarFogueira(oPC));
DelayCommand(4.5, SetCommandable(TRUE, oPC));
}
if(sItemResRef == "pederneira")
{
object oML = GetItemActivatedTarget();
int iFogo = GetLocalInt(oML, "fogo");
if(GetResRef(oML) == "fogueira")
{
if(iFogo == FALSE)
{
ExecuteScript("a_pederneira", GetItemActivatedTarget());
}
else
{
FloatingTextStringOnCreature("Falhou!", oPC);
AssignCommand(oPC,ClearAllActions());
}
}
}
}
6) Create a object placeable with Flame (small) appearence and set ResRef="fogofogueira".
7) Create the script a_pederneira.
void TerminarFogueira(object oFogo, object oSom)
{
SetPlaceableIllumination(oFogo, FALSE);
RecomputeStaticLighting(GetArea(OBJECT_SELF));
DestroyObject(oSom);
DestroyObject(oFogo);
DestroyObject(OBJECT_SELF);
}
void FireLoop(object oSom)
{
AssignCommand(oSom, PlaySound("al_cv_firepit1"));
DelayCommand(5.0, FireLoop(oSom));
}
void AcenderFogo()
{
object oSom = CreateObject(OBJECT_TYPE_PLACEABLE,"somfogueira",GetLocation(OBJECT_SELF));
FireLoop(oSom);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_LIGHT_ORANGE_5), OBJECT_SELF);
float fTime = 25.0;
SetLocalInt(OBJECT_SELF, "fogo", TRUE);
object oFogo = CreateObject(OBJECT_TYPE_PLACEABLE,"fogofogueira",GetLocation(OBJECT_SELF));
DelayCommand(1.0, RecomputeStaticLighting(GetArea(OBJECT_SELF)));
DelayCommand(fTime, TerminarFogueira(oFogo, oSom));
}
void main()
{
object oPC = GetItemActivator();
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 2.0));
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.5, AcenderFogo());
DelayCommand(2.5, SetCommandable(TRUE, oPC));
}
How to use:
Use the two first itens
Item 1: select any place of the map (creates the camp)
Item 2: select the placeable generated by the first item (fires the fire)