Page 303 of 400
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 5:52 pm
by 7Soul
Does 'setBombPower()' not work? Like, I can do it and I do a print() on the bombPower and it has changed, but the bomb still does the same damage...
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 7:14 pm
by Zo Kath Ra
7Soul wrote: ↑Tue Apr 16, 2019 5:52 pm
Does 'setBombPower()' not work? Like, I can do it and I do a print() on the bombPower and it has changed, but the bomb still does the same damage...
Works for me:
Shock bomb lying on the ground.
Floor trigger calls a script sets the bomb's power to another value.
Damage done to a forest ogre is about the same as the bomb power, sometimes a bit higher, sometimes a bit lower.
edit:
What happens when you stack bombs of the same type, but with different attack powers?
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 7:57 pm
by minmay
Stacks are actually a single object. When you add an item to a stack, it's destroyed and the only thing that changes about the stack is the stack size. So you can't have a stack of bombs with different attack powers.
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 8:30 pm
by 7Soul
What I have is the onAttack function in the bomb, and in it I got this code:
Code: Select all
print("bomb")
local bomb = self.go.bombitem
print("before: " .. bomb:getBombPower())
bomb:setBombPower(1)
print("after: " .. bomb:getBombPower())
The output in game is:
But the enemies still take around 55 damage
I do the same thing with other throwing weapons and it works
Also tried the floor trigger calling a simple script too
Code: Select all
function fire()
fire_bomb_2.bombitem:setBombPower(1)
end
And it still does the same damage as before
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 10:55 pm
by minmay
Are you sure you are using the same bomb that you set the bomb power of? Remember, splitting a stack, including by using a ThrowAttackComponent/RangedAttackComponent, makes a new item with almost none of the attributes of the original stack. If you set the bombPower of a stack of 2 bombs to 1, but then split the stack by using the ThrowAttackComponent, the thrown bomb will have the original 55 power.
Re: Ask a simple question, get a simple answer
Posted: Tue Apr 16, 2019 11:48 pm
by 7Soul
minmay wrote: ↑Tue Apr 16, 2019 10:55 pm
Are you sure you are using the same bomb that you set the bomb power of? Remember, splitting a stack, including by using a ThrowAttackComponent/RangedAttackComponent, makes a new item with almost none of the attributes of the original stack. If you set the bombPower of a stack of 2 bombs to 1, but then split the stack by using the ThrowAttackComponent, the thrown bomb will have the original 55 power.
It seems like the game treats bombs and other thrown weapons differently
This is in the onAttack hook:
Code: Select all
if self.go.bombitem then
print("bomb")
local bomb = self.go.bombitem
print("before: " .. bomb:getBombPower())
bomb:setBombPower(999)
print("after: " .. bomb:getBombPower())
else
print("knife")
print("before: " .. self:getAttackPower())
self:setAttackPower(999)
print("after: " .. self:getAttackPower())
end
With a stack over 1, both print the values as expected, but only the knife does ~999 damage.
With a stack of 1, now the bomb damage works...
Re: Ask a simple question, get a simple answer
Posted: Wed Apr 17, 2019 10:02 am
by Marskilla
Isaac wrote: ↑Sat Apr 13, 2019 5:00 pm
(...)
The iterator functions are map.allEntities() and map.entitiesAt(x,y).
(...)
One can also [repeatedly] use the global function findEntity() with string concatenation, to find matching entities one by one.
I couldn't have dreamed of a better explaination, thanks !
_________
Here's a tricky one :
For a puzzle, player has to put 3 items in a chest. If the item is not one of the exepected item, the item is destroyed and then the player is punished (fireburst).
If all the 3 items are in the chest party will be teleported.
I did this and it works, but here the thing : once the party is teleported the screen flickers randomly. Even with an exported dungeon. I tried many things and realised my code was not the problem.
I guess the problem occurs when one teleport a party when the camera look down at a chest. If I call my code by pushing a button evrything is ok.
I tried to find a method to close a chest but didn't find one in the scripting reference.
I tried to move the party back with a setPosition but then screen flickers.
Can I close the chest by script or can I
move (not teleport) the party ?
Re: Ask a simple question, get a simple answer
Posted: Wed Apr 17, 2019 1:56 pm
by Marskilla
Marskilla wrote: ↑Wed Apr 17, 2019 10:02 am
(...)once the party is teleported the screen flickers randomly. (...) I guess the problem occurs when one teleport a party when the camera look down at a chest. (...)
Ok, found something : I call the destroy() method on the chest and recreate it after the party has been teleported. It doesn't answer the question "how do we close a chest" nor "how do we physically move the party" and it is not elegant but my problem is solved : no more flickering.

Re: Ask a simple question, get a simple answer
Posted: Wed Apr 17, 2019 11:16 pm
by Isaac
Marskilla wrote: ↑Wed Apr 17, 2019 10:02 am
Can I close the chest by script or can I
move (not teleport) the party ?
Code: Select all
party.party:knockback(party.facing+2%3)
This does both.
I could not replicate the screen flashing, and I did have the party teleport from an open chest; with no issues.
Re: Ask a simple question, get a simple answer
Posted: Thu Apr 18, 2019 9:47 am
by Marskilla
Isaac wrote: ↑Wed Apr 17, 2019 11:16 pm
(...)
I could not replicate the screen flashing, and I did have the party teleport from an open chest; with no issues.
(...)

Are you on mac, or windows ?
I'm stuck with XP 32 bits... Nvidia Driver 331, GPU GT1200, OpenGL Version 3.3.0, Grimrock 2.2.4
When I saw the problem was within the preview window of the editor, the full screen of the editor and with an exported dungeon I thought the problem was for everyone.
Anyway thanks for the knockbak method ! Much more clean than a destroy()
I searched
http://www.grimrock.net/modding/scripti ... yComponent but my poor english made me looked for a "move" method or something like that. I thought knockback was to produce a wall effect.
I also searched at
http://www.grimrock.net/modding/scripti ... tComponent ...
Sorry
With all your answers, my dungeon ows you !