Aller au contenu

Photo

Crafting - Mining boulders and crystals. How?


  • Veuillez vous connecter pour répondre
14 réponses à ce sujet

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

How to make a placeable object be mineable?

Thanks.



#2
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

Set the placeable to useable in its properties then attach a script in OnUsed that runs the mining event or you can just drop some ore in its inventory. Arbor Falls has a really advanced system for this sort of thing. You can download the mod from the Vault.

 

Since you seem new to building you should check out the The Aurora Toolset Manual and The Lexicon. The Toolset Manual is indispensable for making modules and covers just about everything you'll need to know. They also published a Design Manual that goes into more detail specifically about constructing modules. The Lexicon is the bible for scripting.

 

This thread also has numerous tutorials and guides you can check out.

 

Also, please reduce the size of your text. We're not blind  :P


  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Thanks, Pstemarie.

What's the OnUsed mining event script?



#4
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

Thanks, Pstemarie.

 

What's the OnUsed mining event script?

 

That would be a script you make yourself that defines what happens when the rock is "mined." 

 

The easiest method is to set the placeable rock to "usable" and "has inventory" (under placeable properties), then place the ore item in its inventory. When the PC clicks on the rock, they can take the ore.

 

A little more complex, but more realistic method would be to set the placeable rock to usable as above. Then, in its OnDamaged event, create a script that drops the custom ore item when the object is destroyed. PCs would then have to "attack" the rock and destroy it to get the ore. This also has the added bonus of cleaning up your areas by destroying placeables that aren't needed anymore.

 

There are many other ways to do this depending upon your ability to code and familiarity with the toolset. Keep in mind though that, traditionally, most players don't like overly complex systems for such mundane tasks unless there is a decent payout at the end.


  • WhiteTiger aime ceci

#5
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

"Also, please reduce the size of your text. We're not blind   :P", lol. This was good.

I used Verdana font type and 18 size. But I will take into consideration when writing larger texts.



#6
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I usually do not place items in inventory on the rocks, perhaps a script to give the item to the "GetLastUsedBy();".

However, I would like your help to create the OnUsed script, the character animation and load time that the player will take when mine the rock.



#7
Shadooow

Shadooow
  • Members
  • 4 471 messages

I usually do not place items in inventory on the rocks, perhaps a script to give the item to the "GetLastUsedBy();".

However, I would like your help to create the OnUsed script, the character animation and load time that the player will take when mine the rock.

Download ATS crafting, CNR crafting or other crafting system from vault and if you do not want to use whole crafting system, then just rip the scripts for mining.


  • WhiteTiger aime ceci

#8
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I'll check this on vault. Thanks, Shadooow.



#9
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

So I decided to make the OnUsed script, as Pstemarie said.

 

/////////////////////////////////////////////////////////////////////////

void main()
{
object oPC = GetLastUsedBy();
object oSelf = OBJECT_SELF;
if (!GetIsPC(oPC)) return;
string sPlacable = GetTag (OBJECT_SELF);
AssignCommand (oPC, ClearAllActions());
 
if (sPlacable == "MyBoulderTAG")
{
DelayCommand (1.0, AssignCommand(oPC,PlayAnimation); //Here we need "PickUpItem" Animation
DelayCommand (2.0, FloatingTextStringOnCreature ("Mining item...", oPC));
CreateItemOnObject("MyItemMineredRESREF", GetLastUsedBy(), 1); //This function isn't working with DelayCommand (3.0)
DelayCommand (4.0, ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(),oSelf)));
return;
}
 
}
/////////////////////////////////////////////////////////////////////////
 
PS: It's incomplete.


#10
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
Try this script.
 

//oMiner     = the creature doing the mining
//sMinedLoot = the resref of the mined item to create on the creature
//nStack     = the stack size of the loot item that will be mined, defaults to 1
void CreateMinedLoot(object oMiner, string sMinedLoot, int nStack = 1)
{
    CreateItemOnObject(sMinedLoot, oMiner, nStack);
}
 
void main()
{
    object oPC = GetLastUsedBy();
    string sLoot = GetLocalString(OBJECT_SELF, "MinedLootRESREF"); //specify the RESREF of the loot on the placeable to be mined
                                                                   //allows for finer control
 
    //only do this for PCs
    if (!GetIsPC(oPC))
        return;
 
    //only do for mineable objects
    //* replaced the tag check with a variable check (this way you don't need to change the tag)
    if (GetLocalInt(OBJECT_SELF, "IsMineable") == 1)
    {
        AssignCommand(oPC, ClearAllActions()); //moved this here so it only occurs if the PC is truly mining
        DelayCommand(1.0, AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0)));
        DelayCommand(2.0, FloatingTextStringOnCreature ("Mining item...", oPC));
        DelayCommand(3.0, CreateMinedLoot(oPC, sLoot));
        DestroyObject(OBJECT_SELF, 7.0);
    }
}

  • WhiteTiger aime ceci

#11
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

The animation was amazing and the script works fine. I just made a change into the time of receiving the item that has been increased from 3 seconds.

 

I have a note: You can click on the object and escape from mining - do not lose the item.

 

Maybe it's because the character is not stuck, he is free to walk out while the mining process is happening.

 

----------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------Edited--------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------

 

1. At line DelayCommand(3.0, CreateMinedLoot(oPC,sLoot)); we need eraser oPC, sLoot because the declaration does not parameters. If we delete it, we should also delete the command line string sLoot = GetLocalString(OBJECT_SELF, "MinedLootRESREF"); having this, only: DelayCommand(6.0, CreateMinedLoot());

 

OBS: I have increased 3 secs to better minning performance.

 

2. It's a great idea use DelayCommand to start the CreateMinedLoot void, perhaps we can do some changes to simplify this void:

 

      void CreateMinedLoot()
{
    object oPC = GetLastUsedBy();
    CreateItemOnObject("ItemResRef", oPC, 1);
}
 
3. I don't understand why if (GetLocalInt(OBJECT_SELF, "IsMineable") == 1) {...}, I have changed this to:
 
    string sPlacable = GetTag(OBJECT_SELF);
    if (sPlacable == "MyPlaceableMinerableTAG")
{...}

 

Everything worked fine, so (OnUsed Script):

      void CreateMinedLoot()
{
    CreateItemOnObject("ItemReceivedTAG", GetLastUsedBy(), 1);
}

void main()
{
    object oPC = GetLastUsedBy();
    if (!GetIsPC(oPC)) return;
    string sPlacable = GetTag(OBJECT_SELF);

    if (sPlacable == "PlaceableTAG")
    {
        AssignCommand(oPC, ClearAllActions());
        DelayCommand(1.0, AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0)));
        DelayCommand(2.0, FloatingTextStringOnCreature ("Minning...", oPC));
        DelayCommand(6.0, CreateMinedLoot());
        DestroyObject(OBJECT_SELF, 7.0);
    }
}

Modifié par WhiteTiger, 05 mars 2014 - 04:36 .


#12
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

I liked the idea and so decided to include this in my module. The thought process behind the variables is...

 

1. I created several ore items that can be "mined" from placeable "ore deposits" scattered around the area. These include:

  • Iron
  • Silver
  • Copper
  • Raw Gems

2. The RESREF of the item mined from the ore deposit is stored as a string variable on the placeable after it is placed in the area.

 

3. The integer variable "IsMineable" just tells the script if the ore deposit can be mined. This variable is added to the placeable after it is placed in the area. 

 

I prefer to use variables for tagging objects that used in subsystems because it eliminates the need to create custom templates. Instead you can use standard BioWare templates and just add the variables once they are placed in the area. Its just a matter of personal preference on my part. As for the being able to get of the mining activity, try this...

 

AssignCommand(oPC, ClearAllActions());
SetCommandable(TRUE, oPC);
DelayCommand(1.0, AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0)));
DelayCommand(2.0, FloatingTextStringOnCreature ("Mining item...", oPC));
DelayCommand(5.0, CreateMinedLoot());
DestroyObject(OBJECT_SELF, 7.0);
DelayCommand(7.0, SetCommandable(FALSE, oPC));

  • WhiteTiger aime ceci

#13
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Let's take two things into consideration.

 

1. The line SetCommandable(TRUE, oPC); needs happen after the animation, if not, the same does not occur.

 

2. Use TRUE to allow and FALSE to stuck.

 

I have organized the code and now you can use the same script OnUsed for all objects:

    void CreateMinedLoot()
{
    string sPlacable = GetTag(OBJECT_SELF);
    object oPC = GetLastUsedBy();

        if (sPlacable == "TagOfFirstPlaceable")
    {
    CreateItemOnObject("ResrefOfFirstItem", oPC, 1);
    SetCommandable(TRUE, oPC);
    return;
    }
        if (sPlacable == "TagOfSecondPlaceable")
    {
    CreateItemOnObject("ResrefOfSecondItem", oPC, 1);
    SetCommandable(TRUE, oPC);
    return;
    }
}

void main()
{
    object oPC = GetLastUsedBy();
    if (!GetIsPC(oPC)) return;
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, PlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0));
        DelayCommand(0.1, SetCommandable(FALSE, oPC));
        DelayCommand(1.0, FloatingTextStringOnCreature ("Mining...", oPC));
        DelayCommand(6.9, CreateMinedLoot());
        DestroyObject(OBJECT_SELF, 7.0);
        return;
}

All thanks to Pstemarie.



#14
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

Good job! You might want to use this method. With SetCommandable, TRUE will "stick" the PC so he can't do anything else and FALSE will "unstick" him. I pulled the setup from the Lexicon

 

Add this function above your void main () :

void doMine()
{
    // Note that OBJECT_SELF is now the assigned object
    ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0);
    ActionDoCommand(SetCommandable(TRUE));
    SetCommandable(FALSE);
}

Then replace your void main () with this code:

void main ()
{
        AssignCommand(oPC, ClearAllActions());
        AssignCommand(oPC, doMine());
        DelayCommand(1.0, FloatingTextStringOnCreature ("Mining item...", oPC));
        DelayCommand(4.0, CreateMinedLoot());
        DestroyObject(OBJECT_SELF, 7.0);
}

You also don't need that last return statement. The whole script looks like this:

void CreateMinedLoot()
{
    string sTag = GetTag(OBJECT_SELF);
    if (sTag == "TagofFirstPlaceable") CreateItemOnObject("ResrefOfFirstItem", oPC, 1);
    else if (sTag == "TagofSecondPlaceable") CreateItemOnObject("ResrefOfSecondItem", oPC, 1);
}
 
void doMine()
{
    // Note that OBJECT_SELF is now the assigned object
    ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 6.0);
    ActionDoCommand(SetCommandable(TRUE));
    SetCommandable(FALSE);
}
 
void main()
{
    object oPC = GetLastUsedBy();
    if (!GetIsPC(oPC)) return;
    
    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, doMine());
    DelayCommand(1.0, FloatingTextStringOnCreature ("Mining item...", oPC));
    DelayCommand(4.0, CreateMinedLoot());
    DestroyObject(OBJECT_SELF, 7.0);
}

  • WhiteTiger aime ceci

#15
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I already implemented this system to my project and it's working very well. Thanks.

 

About commandable function, I have used:

 

TRUE = UnStuck

FALSE = Stuck

 

But any problem is only reverse.