help with insta-death square script and other Qs

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Useful scripts repository

Post by Komag »

You would make the script very close to the example:

function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 50)
hudPrint("A noxious gas fills the chamber!")
end

Then just create your pressure plate and connect the pressure plate to the script with activate - poisontrap

it works to do the damage, but there is poison cloud effect or lingering poison, so I'm not exactly sure how to do that part yet
-----------------
The original thread for the insta-kill script was here:
viewtopic.php?f=14&t=3248
Finished Dungeons - complete mods to play
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Lua scripts

Post by sevenbirds »

Hello everyone. I'm moving my questions to this thread instead of flooding the excellent scripting example one if that is all right.

So I'm trying to create a tile that damage any player or monster that steps on it, then continuously deals damage over a period of time. Here is what I currently have.

Code: Select all

function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 5)
	end
This is connected to a timer called poisontimer set with the interval of 2,defaulted to stopped and calls the poisontrap function when activated. stepping on a pressure plate activates this timer, with the idea being that it will do 5 damage every 2 seconds.

I then have a counter named poisoncounter that starts at 15. poisontimer is connected and decrements poisoncounter every time it activates. This is reset when the same pressure plate is activated. My idea is that it will cause a lingering poison that does 5 damage every 2 seconds for 30 seconds, and start all over again if you step on the pressure plate. However, right now all it does is hurt you once. the lingering damage never happens. Does anyone have any idea where I went wrong?

EDIT: I solved the problem. Always make sure to restart the preview, don't just pause. the changes were not taking effect until I stopped the playtest an redid it. this works like a charm now. However, it still doesn't damage enemies as far as I can tell. Is there a way to get this to affect both enemies and the party?
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Lua scripts

Post by petri »

Why not just spawn a poison cloud there?
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Lua scripts

Post by sevenbirds »

petri wrote:Why not just spawn a poison cloud there?
It's times like this that make learning fun. Here I was trying to reinvent the wheel and that's all it took. Thank you so much!
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Lua scripts

Post by Xzalander »

Hah Seven, still its always good to try and look at the complicated methods also, as it opens up avenues. Perhaps you want a slightly stronger poison cloud or one that lasts longer, one that doesn't infect and only causes poison damage and so forth.
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Lua scripts

Post by Montis »

sevenbirds wrote:

Code: Select all

function poisontrap()
damageTile(party.level, party.x, party.y, party.facing, 1, "poison", 5)
	end
[...]
However, it still doesn't damage enemies as far as I can tell. Is there a way to get this to affect both enemies and the party?
When you use the code above it will always damage the tile that the player is on (and thus the party), no matter who's stepping on the pressure plate.

Edit:
If you want to damage monsters, you have to specify the square that needs to get damaged (probably the one with the pressure plate). See code by Xzalander below.
Last edited by Montis on Thu Sep 20, 2012 1:28 pm, edited 3 times in total.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: help with insta-death square script and other Qs

Post by Komag »

I split off this section of the discussion into a new thread, to try to maintain the script repository thread as mostly just a place for finished scripts :)
Finished Dungeons - complete mods to play
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: help with insta-death square script and other Qs

Post by Montis »

Komag wrote:I split off this section of the discussion into a new thread, to try to maintain the script repository thread as mostly just a place for finished scripts :)
Thanks a lot!
I actually took some time to make an index in the first post of that thread. :)
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Lua scripts

Post by Xzalander »

Montis I think he means he wants the poison trap to hurt monsters as well.

In which case you simply specify the tile location instead of using party.x etc

So for example

Code: Select all

function poisontrap()
damageTile(1, 14, 14, 0, 1, "poison", 5)
   end
That would cause the poison effect to happen on Floor 1, Grid Reference 14x 14y. 0 is the direction (north).
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Lua scripts

Post by Montis »

Xzalander wrote:Montis I think he means he wants the poison trap to hurt monsters as well.
Uh yes, I just said that he will always damage the party with the code that he used. I edited the post above to make it a bit more clear what I meant.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
Post Reply