Author Topic: i need a particular script  (Read 338 times)

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« on: September 06, 2014, 04:38:41 pm »


               

Hey i need someone to make a script for me.


 


 


i am making a crafting system for a persistent world module. the system works like this: the player gathers ingredients from around the module areas. The player then talks to the alchemist npc to start a convo. In the convo the player select a category of items then select a sub category then select the item they want to make. The script then checks the players inventory for the ingredients for that particular item and also if they have in their inventory the gold required. if they dont have all of it then the alchemist tells them they dont have everything and the convo ends. If they have it, the alchemist asks them for confirmation to make the item. If the player selects no the convo ends and if they select yes the ingredients and gold is removed from the players inventory and the item being crafted is added to the players inventory and the alchemist says: you have successfully made "item" and the player clicks to End Dialog. Also another feature i want some recipes to have 90% chance to turn out one item and 10% chance to turn out another item, with the alchemist stating the item they made as before. 


 


I made the conversation and i just need someone to make the script for me. My knowledge of script making is limited to changing integers and tags to tweak scripts and to put them where but not more than that.


 


I have made about 50 items to be crafted from a lot more variety of ingredients



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
i need a particular script
« Reply #1 on: September 06, 2014, 06:31:49 pm »


               

That's not one script, that's like 50 scripts, though it's mostly copy/pasting different ingredient/item tags/resrefs.  Is module resource count an issue for you at all?  It might be possible to set up a more complicated system overall that used far less scripts.



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« Reply #2 on: September 07, 2014, 06:49:13 am »


               

its a small module so i think resource count wont be a problem. 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
i need a particular script
« Reply #3 on: September 07, 2014, 09:09:43 am »


               

I think this should work for you as a template.



// Take the exact amount of ingredients
void TakeExactItems(object oPC, string sTag, int nItems);

// Get the exact amount of ingredients
int GetItemCount(object oPC, string sTag);

void main()
{
    // Set up our variables
    object oPC = GetPCSpeaker();
    string sReagent1 = "reagent1", sReagent2 = "reagent2", sReagent3 = "reagent3", sBlueprint1 = "item1", sBlueprint2 = "item2";
    int nReagent1 = 1, nReagent2 = 2, nReagent3 = 4, nGold = 50;

    // Check for gold
    if (GetGold(oPC) < nGold)
    {
        FloatingTextStringOnCreature("Not enough gold", oPC, FALSE);
        return;
    }

    // Check all ingredients
    if (GetItemCount(oPC, sReagent1) < nReagent1)
    {
        FloatingTextStringOnCreature("Not enough of reagent 1", oPC, FALSE);
        return;
    }

    if (GetItemCount(oPC, sReagent2) < nReagent2)
    {
        FloatingTextStringOnCreature("Not enough of reagent 2", oPC, FALSE);
        return;
    }

    if (GetItemCount(oPC, sReagent3) < nReagent3)
    {
        FloatingTextStringOnCreature("Not enough of reagent 3", oPC, FALSE);
        return;
    }

    // Take the gold
    TakeGoldFromCreature(nGold, oPC, TRUE);

    // Take the ingredients
    TakeExactItems(oPC, sReagent1, nReagent1);
    TakeExactItems(oPC, sReagent2, nReagent2);
    TakeExactItems(oPC, sReagent3, nReagent3);

    // 90% chance for blueprint 1, 10% for blueprint2
    if (Random(10))
    {
        CreateItemOnObject(sBlueprint1, oPC);
    }
    else
    {
        CreateItemOnObject(sBlueprint2, oPC);
    }
}

// Take the exact amount of ingredients
void TakeExactItems(object oPC, string sTag, int nItems)
{
    int nTaken, nStackSize;
    object oItem = GetFirstItemInInventory(oPC);
    while (GetIsObjectValid(oItem) && nTaken < nItems)
    {
        if (GetTag(oItem) == sTag)
        {
            nStackSize = GetItemStackSize(oItem);
            if (nStackSize > nItems - nTaken)
            {
                SetItemStackSize(oItem, nStackSize - nItems + nTaken);
                return;
            }
            else
            {
                DestroyObject(oItem);
                nTaken += nStackSize;
            }
        }

        oItem = GetNextItemInInventory(oPC);
    }
}

// Get the exact amount of ingredients
int GetItemCount(object oPC, string sTag)
{
    int nCount;
    object oItem = GetFirstItemInInventory(oPC);
    while (GetIsObjectValid(oItem))
    {
        if (GetTag(oItem) == sTag)
        {
            nCount += GetItemStackSize(oItem);
        }

        oItem = GetNextItemInInventory(oPC);
    }

    return nCount;
}

Can include the secondary functions in a library if you want.



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« Reply #4 on: September 07, 2014, 10:05:42 am »


               

i tested it and it works. Thank you so much!



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« Reply #5 on: September 11, 2014, 06:07:26 pm »


               

hey how do i modify it so that blueprint1 and blueprint2 has a 50/50 chance instead of 90/10 chance?



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« Reply #6 on: September 11, 2014, 06:23:00 pm »


               

oh, i just checked the lexicon. correct me if im wrong but you change the Random(10) to Random(2) if you want 50/50 am i right? 



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
i need a particular script
« Reply #7 on: September 11, 2014, 06:50:14 pm »


               

and if i want 35%/65% i change the (Random(10)) to (Random(20)) < 7 right? 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
i need a particular script
« Reply #8 on: September 12, 2014, 12:03:26 am »


               


oh, i just checked the lexicon. correct me if im wrong but you change the Random(10) to Random(2) if you want 50/50 am i right? 




 


That would work, yes.


 




and if i want 35%/65% i change the (Random(10)) to (Random(20)) < 7 right? 




 


(Random(20) < 7)


 


but otherwise yes.