On a Seller NPC project
Posted: Sun Jan 27, 2013 2:39 am
Hello everyone,
I'm back trying to make script, and understand the work good scripters do. I think the first step is to make gold money piles in order to have enough money drop on the monsters. I'have already found a 3D free model for the vendor (i call him Blaze_gypsy) and integrated the script Adding NPC traders to your dungeon - buy stuff! use Alcoves from Akatana, but before beeing able to buy something, money is needed. So here is my newbie trying:
For the Gold coin, i used the gor gold coin model from Germanny in his grim_vsword_v21-128-2-1.
Then I made a pile in my blender, capture the render for the icon_atlas and integrated it in a custom atlas (sorry for , imported the pile model in GMT to edit the Gold_Coin_pile.model file.
The next step was to define the new object un a gold_coin_pile.lua imported before in my init.lua:
the script_entity name "goldScript" using check if anybody in your party is carrying a particular type of item by Billick
The effect is a fully generated pile witch create a stack (random(25)) of gold coins,....
But whatever i try, i can't destroy the gold_coin_pile in the party inventory and my spawn of the stack appears on the floor and not in the inventory. I looked the use of Grimq but my understanding of
the ChampionInventoryEx function and replace() subfunction is nearly a desaster...
I'm back trying to make script, and understand the work good scripters do. I think the first step is to make gold money piles in order to have enough money drop on the monsters. I'have already found a 3D free model for the vendor (i call him Blaze_gypsy) and integrated the script Adding NPC traders to your dungeon - buy stuff! use Alcoves from Akatana, but before beeing able to buy something, money is needed. So here is my newbie trying:
For the Gold coin, i used the gor gold coin model from Germanny in his grim_vsword_v21-128-2-1.
Then I made a pile in my blender, capture the render for the icon_atlas and integrated it in a custom atlas (sorry for , imported the pile model in GMT to edit the Gold_Coin_pile.model file.
The next step was to define the new object un a gold_coin_pile.lua imported before in my init.lua:
SpoilerShow
-- by Germanny
defineObject{
name = "gor_coin_gold",
class = "Item",
uiName = "Gold Gor Coin",
model = "mod_assets/grim_vsword/models/items/gor_coin_gold.fbx",
description = "Golden Coin of Gor",
gfxAtlas = "mod_assets/grim_vsword/textures/gui/germ_icoatlas.tga",
gfxIndex = 13,
glitterEffect = "glitter_gold",
stackable = true,
weight = 0.031, -- Modified to have a once weight
}
-- Again by Germanny
defineMaterial{
name = "gor_coin_gold",
diffuseMap = "mod_assets/grim_vsword/textures/items/gor_coin_gold_dif.tga",
specularMap = "mod_assets/grim_vsword/textures/items/gor_coin_spec.tga",
normalMap = "mod_assets/grim_vsword/textures/items/gor_coin_normal.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 70,
depthBias = 0,
}
defineObject{
name = "gold_coin_pile",
class = "Item",
uiName = "Gold Coin Pile",
model = "mod_assets/models/items/Gold_coin_pile.fbx",
description = "A small amount of gold coins",
gfxAtlas = "mod_assets/Atlas/icoatlas.tga",
gfxIndex = 31, -- number in my custom atlas
glitterEffect = "glitter_gold",
stackable = false,
weight = 0.5,
onUseItem = function(champion, item)
goldScript.amountGold(item)
end,
}
defineObject{
name = "gor_coin_gold",
class = "Item",
uiName = "Gold Gor Coin",
model = "mod_assets/grim_vsword/models/items/gor_coin_gold.fbx",
description = "Golden Coin of Gor",
gfxAtlas = "mod_assets/grim_vsword/textures/gui/germ_icoatlas.tga",
gfxIndex = 13,
glitterEffect = "glitter_gold",
stackable = true,
weight = 0.031, -- Modified to have a once weight
}
-- Again by Germanny
defineMaterial{
name = "gor_coin_gold",
diffuseMap = "mod_assets/grim_vsword/textures/items/gor_coin_gold_dif.tga",
specularMap = "mod_assets/grim_vsword/textures/items/gor_coin_spec.tga",
normalMap = "mod_assets/grim_vsword/textures/items/gor_coin_normal.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 70,
depthBias = 0,
}
defineObject{
name = "gold_coin_pile",
class = "Item",
uiName = "Gold Coin Pile",
model = "mod_assets/models/items/Gold_coin_pile.fbx",
description = "A small amount of gold coins",
gfxAtlas = "mod_assets/Atlas/icoatlas.tga",
gfxIndex = 31, -- number in my custom atlas
glitterEffect = "glitter_gold",
stackable = false,
weight = 0.5,
onUseItem = function(champion, item)
goldScript.amountGold(item)
end,
}
SpoilerShow
-- INTRODUCE FUNCTION TO CHECK IF THERE IS A SPECIFIC ITEM IN THE PARTY BACKPACK
-- Loop Check for the 4 champions of party
function checkForItemParty(item)
local i = 1
repeat
if checkForItem(party:getChampion(i), item)
then return true
end
i = i + 1
until i == 5
return false
end
-- Check in one champion backpack
function checkForItem(champion, item)
local j = 1
repeat
local itemObj = champion:getItem(j)
if itemObj ~= nil then
if itemObj.name == item
then return true
end
end
j = j+1
until j == 32
return false
end
-- RANDOM GENERATOR PILE OF GOLD COINS
-- Initialize Locals
Amount = 1
function amountGold()
Amount = math.random(25) -- for now on i tried a simple random function but later it may depends on the health of a creature
if checkForItemParty("gold_coin_pile")
then print("We have a gold pile")
spawn("gor_coin_gold", party.level, party.x, party.y, party.facing):setStackSize(Amount) -- here i generate a pile of gor gold coin
else print("We don't have gold pile")
end
end
-- Loop Check for the 4 champions of party
function checkForItemParty(item)
local i = 1
repeat
if checkForItem(party:getChampion(i), item)
then return true
end
i = i + 1
until i == 5
return false
end
-- Check in one champion backpack
function checkForItem(champion, item)
local j = 1
repeat
local itemObj = champion:getItem(j)
if itemObj ~= nil then
if itemObj.name == item
then return true
end
end
j = j+1
until j == 32
return false
end
-- RANDOM GENERATOR PILE OF GOLD COINS
-- Initialize Locals
Amount = 1
function amountGold()
Amount = math.random(25) -- for now on i tried a simple random function but later it may depends on the health of a creature
if checkForItemParty("gold_coin_pile")
then print("We have a gold pile")
spawn("gor_coin_gold", party.level, party.x, party.y, party.facing):setStackSize(Amount) -- here i generate a pile of gor gold coin
else print("We don't have gold pile")
end
end
But whatever i try, i can't destroy the gold_coin_pile in the party inventory and my spawn of the stack appears on the floor and not in the inventory. I looked the use of Grimq but my understanding of
the ChampionInventoryEx function and replace() subfunction is nearly a desaster...