Grim 2 rope item
Posted: Fri Jan 15, 2016 1:33 am
I created a rope in LOG1. I got the model from The Tomb of Tiggy Tamal mod and used my own code. I placed the code in the dungeon and used the onUseItem() hook to call it. I found that I had to right-click the rope when in the champion's container (or backpack as I like to call it). It would not work from the champion's hand. I then defined the rope as a wand and created a spell to call the code when cast. This worked fine but only from the hand. I found that also calling the code with the onUseItem() hook, would allow the rope to be used from the champion's hand or backpack like the rope in LOG2. Success!
Now, the rope in LOG2 is great, but I am trying to add a climb-up feature to it. I added a 'secondaryAction' command to the definition so when right-click-hold is used on the rope it will run the code to climb up. I tried to add a 'UsableItem' component and used the 'onUseItem' hook to call my code. Well, to my suprise, when I tried it out, the champion ATE THE ROPE! So, I switched to the 'onAttack' hook of the 'ItemAction' component and it worked. But it only works from the champion's hand. I noticed the Grim 2 rope works from both places. Would love to know how you guys did it. Can't figure that one out.
Now, to use the climb-up feature, I have to check for an open pit on the level above and the 'map:entitiesAt()' function does not use a level parameter. I could not use something like 'party.map:entitiesAt()' because, of course, the party is on the level below which will not show the pit above. To resolve this problem I placed a blocker somewhere on each level and named them, lmL1 (level-marker-Level-1), lmL2, lmL3, etc. I was then able to refer to the correct marker entity with...
local lmID = "lmL" .. party.level -1 --set up correct ID
lma = findEntity(lmID) --lma = nil if level marker not found
Thus, something like...
function chkAbove(lm,x,y) --lma, party.x and party.y are passed
for e in lm.map:entitiesAt(x,y) do
if e.name ~= string.gsub(e.name,"pit","") then --if pit found
if e.pit:isOpen() then return true end --and it is open return 'true'
end
end
end
now works to find an open pit above the party. (To clarify, I also check for blockages above where the party will be landing.)
It seems like a lot of extra work to be able to use the new 'eneitiesAt()' function and more inportant, if I move levels up or down in the editor, it will screw up all my blocker markers. So any level order changes will result in my having to go in and change the blocker id's.
Am I going about all this the hard way? Is there a better way of checking for entities on other levels?
I know this is a lengthy post and I apologize for that but I didn't know how else to explain the problem.
Now, the rope in LOG2 is great, but I am trying to add a climb-up feature to it. I added a 'secondaryAction' command to the definition so when right-click-hold is used on the rope it will run the code to climb up. I tried to add a 'UsableItem' component and used the 'onUseItem' hook to call my code. Well, to my suprise, when I tried it out, the champion ATE THE ROPE! So, I switched to the 'onAttack' hook of the 'ItemAction' component and it worked. But it only works from the champion's hand. I noticed the Grim 2 rope works from both places. Would love to know how you guys did it. Can't figure that one out.
Now, to use the climb-up feature, I have to check for an open pit on the level above and the 'map:entitiesAt()' function does not use a level parameter. I could not use something like 'party.map:entitiesAt()' because, of course, the party is on the level below which will not show the pit above. To resolve this problem I placed a blocker somewhere on each level and named them, lmL1 (level-marker-Level-1), lmL2, lmL3, etc. I was then able to refer to the correct marker entity with...
local lmID = "lmL" .. party.level -1 --set up correct ID
lma = findEntity(lmID) --lma = nil if level marker not found
Thus, something like...
function chkAbove(lm,x,y) --lma, party.x and party.y are passed
for e in lm.map:entitiesAt(x,y) do
if e.name ~= string.gsub(e.name,"pit","") then --if pit found
if e.pit:isOpen() then return true end --and it is open return 'true'
end
end
end
now works to find an open pit above the party. (To clarify, I also check for blockages above where the party will be landing.)
It seems like a lot of extra work to be able to use the new 'eneitiesAt()' function and more inportant, if I move levels up or down in the editor, it will screw up all my blocker markers. So any level order changes will result in my having to go in and change the blocker id's.
Am I going about all this the hard way? Is there a better way of checking for entities on other levels?
I know this is a lengthy post and I apologize for that but I didn't know how else to explain the problem.