Ask a simple question, get a simple answer
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: Ask a simple question, get a simple answer
Hi all.
I am using md_npc monsters in my mod which is cool. Is there a way to stop the damage the party does to them? EG: If the party attacks or cast spells at the monster the damage stuff happens and I don't want that.
Is the a hook or something I can add to the Monster Code. I mean if the monster is attacked nothing happens no blood etc....
I still want the Interact, Set Route, Ongive etc.. to work just not the damage to the monsters. Thanks in advance.
I am using md_npc monsters in my mod which is cool. Is there a way to stop the damage the party does to them? EG: If the party attacks or cast spells at the monster the damage stuff happens and I don't want that.
Is the a hook or something I can add to the Monster Code. I mean if the monster is attacked nothing happens no blood etc....
I still want the Interact, Set Route, Ongive etc.. to work just not the damage to the monsters. Thanks in advance.
Re: Ask a simple question, get a simple answer
monster_id.monster:setMonsterFlag("Invulnerable",true)Mysterious wrote:Hi all.
I am using md_npc monsters in my mod which is cool. Is there a way to stop the damage the party does to them? EG: If the party attacks or cast spells at the monster the damage stuff happens and I don't want that.
Is the a hook or something I can add to the Monster Code. I mean if the monster is attacked nothing happens no blood etc....
I still want the Interact, Set Route, Ongive etc.. to work just not the damage to the monsters. Thanks in advance.
Attacks may still happen, but show zero damage.
Re: Ask a simple question, get a simple answer
Ok, yeah I guess it does make sense that goTo() could be for any object. I guess I never tried anything else. It does have serious limitations though. Of course it will only go after objects on the same level. But even then, if the object is too far or the path too complicated to get to it, the game will ignore the request and not "goTo" anything. It's limitations is one of the main reasons I had to write my own path finding AI.THOM wrote: I know I can do this inside the monster-definition. But what I want to do is to have a monster that behaves like a normal monster and at a certain moment it starts to go to a certain point of the map. So I think I have to add this behaviour during the game to the brain. Or something like that.
BTW the goTo command also understands names of objects, not only items. It works in my dungeon already like this.
So here is the easiest way to make a monster do a goTo() on certain condition. Let's say if a floor trigger is activated, he will do the goTo. Here is code that would have to be found in a script called "script_entity_1" on a normal mob: herder_1
Code: Select all
function customThinkFN(brain)
if floor_trigger_1.floortrigger:isActivated() then
brain:goTo("dungeon_door_1")
end
end
function initMonster()
herder_1.brain:addConnector("onThink", "script_entity_1", "customThinkFN")
end
Re: Ask a simple question, get a simple answer
thanx! works perfect!
-
- Posts: 16
- Joined: Wed Jan 11, 2017 9:46 pm
Re: Ask a simple question, get a simple answer
Hello,
First I want to say thanks for the ui question, I was looking for the graphics component on the class list and not objects and classes category.
Second, I have a question regarding something I already asked about the traits because it has come up again.
Because I have a usableItem and not an Item, I cannot use item functions such as hasTrait or even have access to itemHooks such as onEquipItem.
I was thinking of creating an itemClone and then use this itemClone for the usableItem that i will have on my scene, thus giving me access to the hook functions.
Is this the best way to proceed in regards to usableItems?
First I want to say thanks for the ui question, I was looking for the graphics component on the class list and not objects and classes category.
Second, I have a question regarding something I already asked about the traits because it has come up again.
Because I have a usableItem and not an Item, I cannot use item functions such as hasTrait or even have access to itemHooks such as onEquipItem.
I was thinking of creating an itemClone and then use this itemClone for the usableItem that i will have on my scene, thus giving me access to the hook functions.
Is this the best way to proceed in regards to usableItems?
Code: Select all
cloneObject{
name = "Potion_Energy_IC",
baseObject = "potion_energy",
components = {
{
class = "Item",
uiName = "Potion of energy",
onEquipItem = function(item, champion, slot)
print("yo")
hooks.script.item_OnEquipItem(item, champion, {"magic"})
end,
onUnequipItem = function(item, champion, slot)
print("yo")
hooks.script.item_OnEquipItem(item, champion, {"magic"})
end
}
},
}
cloneObject{
name = "Potion_Energy",
baseObject = "Potion_Energy_IC",
components = {
{
class = "UsableItem",
uiName = "Potion of energy",
onUseItem = function(item, champion)
hooks.script.item_OnUsePotion(item, champion, {"magic"})
end,
}
},
}
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
UsableItem and Item are defined together for usable items.
Example from the asset pack:
You can use all defined hooks for these components and they will interact fine.
Components usually have no interactions between each other can be used together.
Example from the asset pack:
Code: Select all
defineObject{
name = "potion_energy",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/flask.fbx",
},
{
class = "Item",
uiName = "Energy Potion",
gfxIndex = 145,
weight = 0.3,
stackable = true,
traits = { "potion" },
},
{
class = "UsableItem",
--emptyItem = "flask",
sound = "consume_potion",
onUseItem = function(self, champion)
champion:regainEnergy(75)
champion:playHealingIndicator()
end,
},
},
}
Components usually have no interactions between each other can be used together.
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Question - Can someone please explain to me the point of the 'cloneObject' add-on when you can just define an object from a base one?
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 16
- Joined: Wed Jan 11, 2017 9:46 pm
Re: Ask a simple question, get a simple answer
Thank you, did not realise the components worked like that. Does make a lot of sense and it is helpfull.
However, i still have one problem.
I cannot do something as simple as a getWeigtht although the item has weight.
Any work around?
However, i still have one problem.
Code: Select all
cloneObject{
name = "Potion_Energy",
baseObject = "potion_energy",
components = {
{
class = "UsableItem",
onUseItem = function(item, champion)
print(item:getWeight())
end,
},
{
class = "Item",
onEquipItem = function(item, champion, slot)
print(item:getWeight())
end,
}
},
}
Any work around?
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
This has to do with references.
I suggest you start using 'self' instead of 'item', would make understanding easier.
The first variable indexes the component that calls the hook.
The UsableItem function's 'item' variable is the equivalent of objectID.usableitem
The Item function's 'item' variable is the equivalent of objectID.item
Since UsableItem doesn't have a getWeight() function, which is why it crashes.
To check the weight of the item through the UsableItem components functions, you'll have to use this:
self.go is called from a components function, and references to the game object holding the component that called self.go
self.go.item:getWeight() from a component = objectID.item:getWeight()
I suggest you start using 'self' instead of 'item', would make understanding easier.
The first variable indexes the component that calls the hook.
The UsableItem function's 'item' variable is the equivalent of objectID.usableitem
The Item function's 'item' variable is the equivalent of objectID.item
Since UsableItem doesn't have a getWeight() function, which is why it crashes.
To check the weight of the item through the UsableItem components functions, you'll have to use this:
Code: Select all
onUseItem = function(self, champion)
print(self.go.item:getWeight())
end
self.go is called from a components function, and references to the game object holding the component that called self.go
self.go.item:getWeight() from a component = objectID.item:getWeight()
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 16
- Joined: Wed Jan 11, 2017 9:46 pm
Re: Ask a simple question, get a simple answer
thank you,
A question, is it possible to get the traits? There is an add and a has function, but is there any work around to find the traits?
A question, is it possible to get the traits? There is an add and a has function, but is there any work around to find the traits?