FAIL (the browser should render some flash content, not this).
Geschrieben von: Laruna   

IMPORTANT This Tutorial is not yet finished. It will be in the next days. It is public to give some programmers the chance to take a first look at it.

This little tutorial shall show how some items can work well together an create some kind of roleplay economy. We have a set of 7 items here.

Overview

  1. an axe which produces wood
  2. a dasher which loots "troll herb/weed" from several herbs
  3. a knife which crafts a troll pipe out of 5 wood pieces
  4. the troll herbs/weed
  5. perfect "Crystalsong Forest Wood"
  6. The Trollpipe
  7. A Eventkiller, a ooc item which resets some events we will set up

Lets start with the scripting and designing items. A mandatory point to remember is that we first need to create the items that want to produce later. This means that we have to work through the list backwards. We ignore the "Eventkiller" for now.

IMPORTANT The items like "perfect wood" and "troll herbs" should only by original created by one player per Realm Faction (one Horde player, one Alliance player). Otherwise we get incompatibility issues. Cause every item is determined by an idividual ID. These individual ID is used by some items to make sure players have this items in there bags.

the perfect wood

Simply create an item, name it, add text, choose a wood like icon and save it.

the troll herbs

Create another item , name it, add text, choose a herb like item and save it.

the troll pipe

This is the first of three item which are a little more complicated. The main credit for this item goes to Pilus. The item consists severell pieces.

We need some information which we do not get from within the game. To get these you go to
"WoW folder/WTF/youraccount/realm/char/savedvariables/ghi.lua"
In there you search for the name of an item we created. In the case of the troll pipe we nee the troll herbs. Nearby you will see a line which contains something like "CHARNAME_12345678". Copy this piece we will need this. And remember this technique.

Now lets go and create the pipe item ...

  1. Requirement (LUA STATEMENT) (we need the troll herb information):
    GHI_CountItem("YOURCHARNAME_12345678") > 0
  2. new script (forfilled):
       level = 60; -- a value which defines the intensity of the effect
    if level >= 10 then -- insert fog
    GHI_EffectFrameEffect0:SetAlpha(0.6);
    GHI_EffectFrameEffect0Texture:SetVertexColor(0.5, 0.5, 0.5);
    GHI_EffectFrameEffect0:Show();
    end
    if level >= 20 then
    local r = random(1,#(GHI_ColorList));
    local color = GHI_EffectColors[GHI_ColorList[r]];
    GHI_EffectFrameEffect1Texture:SetVertexColor(color.r, color.g, color.b);
    UIFrameFlash(GHI_EffectFrameEffect1, 3.0,3.0, 300, nil, 0.0, 0);
    end
    if level >= 30 then
    local r = random(1,#(GHI_ColorList));
    local color = GHI_EffectColors[GHI_ColorList[r]];
    GHI_EffectFrameEffect2Texture:SetVertexColor(color.r, color.g, color.b);
    UIFrameFlash(GHI_EffectFrameEffect2, 6.0,4.0, 300, nil, 0.0, 0);
    end
    if level >= 40 then
    local r = random(1,#(GHI_ColorList));
    local color = GHI_EffectColors[GHI_ColorList[r]];
    GHI_EffectFrameEffect3Texture:SetVertexColor(color.r, color.g, color.b);
    UIFrameFlash(GHI_EffectFrameEffect3, 11.0,4.0,300, nil, 0.0, 0);
    end
  3. new buff (forfilled): create a buff wich describes that you smoked and kind of stoned right now
  4. random emotes (forfilled): create some emotes
  5. new script (forfilled):
    GHI_EffectFrameEffect0:Hide();
  6. new consume item (forfilled): pick the troll herbs we created earlier (amount 1)
  7. new emote (forfilled): to show that the effect is diminishing
  8. new message (not forfilled): enter a text that describes that you tried to smoke withouth the herbs
  9. new buff (not forfilled): Create a debuff with 5 minute duration that player is cleaning his pipe

The axe & The Dasher

The axe and later on the dasher are the two items which are the hole fundament of the economic chaine. Before we will start creating these items, I will explain why these items are so fundamental.

economic reason

I thought about how to get a group of items which will on one hand interact with each other and on the other hand help players to interact with each other. To realize this we need a basic economic principle ... demand and supply. Therefore we have two items (knife and pipe) in our chain which require goods to work. This is the opportunity to create a demand for goods. These goods have to be marginally and not free for everyone to create a demand for them.

The marginally goods are the herbs and the wood. These goods are not copyable by others (a technical aspect of ghi items) but players can gather these goods. Therefore some players get the axe, some players the dasher and some players the knife to craft a pipe out of five pieces of wood.

With this in mind we know that the players are in need to trade the goods with each other. One player alone only has one piece of the puzzle. All together can create and use an interesting item for roleplaying.

technical reason

The second reason why the axe and the dasher are so fundamental is that these two items can create goods almost automatically. The script within the items creates two event listeners.

  1. first event is the opening event of the "loot window"
  2. second event is the "item push" event which takes place when the player "loots" an item.

I will try to describe the script in a simple and short way.

  1. creating a list of items which will help us to determine that the player is doing a desired action.
    • ... killing a monster
    • ... gathering a specific herbs
    • ... gathering a specific ore
    • ... crafting something
  2. setting up the event listeners
  3. tell the script what it shall do when something happens
    1. EVENT: loot window open
    2. compare the loot window with the "looting" list, if the "loot window" contains something we have in our list we go on
    3. EVENT: pushing the item from the "loot window" to the bag
    4. setting some switches to "true" and tell the item to use itself

Now lets take a look hot to create the items.

  1. new requirement (LUA STATEMENT) :
    A switch which is set to "true" by the script (see  2.) when player does something we want (mostly looting something)
    myx == "true"
  2. new script and set it to "is not forfilled":
    -- this is a comment, as every thing is atfer "--"
    local txlooting =  {"Gesplittertes Holz"}; 
    -- within the braces we have a wood wich players
    -- can loot from "Grove Walker"s in Crystalsong Forest.
    if GAX1 == nil then
       GAX1 = CreateFrame("Frame", "DIXa",UIParent);
       GAX2 = CreateFrame("Frame", "DIXb",UIParent);
       -- creating frames to which we will asign the event listeners
       -- assignment following now
       GAX1:SetScript("OnEvent", function() GAX1_OnEvent() end);
       GAX2:SetScript("OnEvent", function() GAX2_OnEvent() end);
       GAX1:RegisterEvent("LOOT_OPENED");
       GAX2:RegisterEvent("ITEM_PUSH");
       -- done
       DEFAULT_CHAT_FRAME:AddMessage("registriert GHI");
       -- inform player that the item is active
       function GAX1_OnEvent()
          if event == "LOOT_OPENED" then 
             -- look up the item info and assign it to vars
             lI, lN, lQ, lR, lL = GetLootSlotInfo(1);
             function fl() -- compare "txlooting" with the loot window
                for k,v in ipairs(txlooting) do
                   if lN == v then
                      return true;
                   end
                end
             end
             function GAX2_OnEvent()
                if event == "ITEM_PUSH" and fl() == true then 
                   lN = nil;
                   myx ="true"; 
                   cix = {};
                       table.insert(cix,1,"true");
                       table.insert(cix,2,random(10));
                   if cix[1] == "true" then
                      cix_a = "true";
                      myx = "true";
                   else
                      cix_a = "false";
                   end
                   -- item searching for itself 
                   local bag,slot = GHI_FindItem("ITEM_ID");
                   -- item uses itself
                   GHI_UseItem(bag,slot); 
                end
             end
          end
       end   
    
  3. new requirement (LUA STATEMENT):
    If the switches are set to true and a random generated number is higher or equal 70 this requirement is set to true.
     myx == "true" and cix_a == "true" and random(100) >= 70
  4. new "produce item" function (is forfilled): set amount to 2, choose the wood we created earlier.
  5. new script (run always):
    myx =  false;
 
FAIL (the browser should render some flash content, not this).