Spike trap

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Spike trap

Post by AdrTru »

This is my little mod for adding Spike traps.

http://grimrock.nexusmods.com/mods/250
SpoilerShow
Image
SpoilerShow
Image
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Spike trap

Post by Komag »

impressive and awesome, love it!
Finished Dungeons - complete mods to play
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Spike trap

Post by msyblade »

Original and well executed! The judge from the U.S. scores it a 9.3! :D
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: Spike trap

Post by SpiderFighter »

THAT is some beautiful work!!
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Spike trap

Post by AdrTru »

Thank you for good reactions.

I wos prepared bonus.
It is generator alcoves with position track. ;)
!!! This generator must be included to some script in lua scrript for definition object, items etc.
See you code below ( its changed code from Spike trap and will be included in next version of spikeTrap mod (if it will be made:))

!!! This is old version of code !!!
SpoilerShow
table - TRamp = definition of track x=(0..100%)[time] ,y=(%)[Z axis (in SpikeTrap)]
for example:{{x=0,y=0},{x=10,y=100},{x=20,y=80},{x=30,y=80},{x=100,y=0}}
Spike sting up , little go down, stay at position and go slowly down.

variable - SpikeAnimCount = definition how many alcoves will be divided time axis
! this variable must be defined again in lua script in dungeon editor

Code: Select all

-----  Animation alcoves ----------------------------------------------------
----------------------- Functions for Ramp ------------------------------------

function GetKQ(ax,ay,bx,by)
local k,q
  k = (by-ay)*1.0/(bx-ax)*1.0
  q = 1.0*ay-(k*ax)
  return k,q
end

function GetLV(ramp,i)
return ramp[i-1].x,ramp[i-1].y,ramp[i].x,ramp[i].y
end

function GetTableFromRamp(ramp,poc)
local ax,ay,bx,by,k,q,i,j,p,x
local tab = {}
  p = 100.0 / (poc*1.0)
  i = 2
  ax,ay,bx,by = GetLV(TRamp,i)
  for j = 1, poc do
    x = (j*1.0)*(p*1.0)
    while (x > bx) and (i < #TRamp) do
      i = i+1
      ax,ay,bx,by = GetLV(TRamp,i)
    end
    if x == bx then 
      y=by
    else
      ax,ay,bx,by = GetLV(TRamp,i)
      k,q = GetKQ(ax,ay,bx,by)
      y = k*x + q
    end
    tab[j]={["x"]=x,["y"]=y/100.0}
  end 
return tab 
end


SpikeAnimCount = 20
--TRamp = {{x=0,y=0},{x=10,y=80},{x=20,y=50},{x=30,y=100},{x=50,y=100},{x=100,y=0}}
TRamp = {{x=0,y=0},{x=10,y=100},{x=20,y=80},{x=30,y=70},{x=100,y=0}}
TTRamp = GetTableFromRamp(TRamp,SpikeAnimCount)
for i = 1, #TTRamp do
  defineObject{
  	name = "spikeTrap_socket_"..i-1,
  	class = "Alcove",
  	anchorPos = vec(0, (0.5*TTRamp[i].y)-0.5, -1.5),
  	anchorRotation = vec(0, 0, 0),
  	targetPos = vec(0, 5, 0),
  	targetSize = vec(1, 1, 1),
  	placement = "wall",
  	onInsertItem = function(self, item)
  		return item.name == "SpikeTrap_spikes" and self:getItemCount() == 0
  	end,
  	editorIcon = 92,
  }
end
Last edited by AdrTru on Sat Apr 06, 2013 3:50 pm, edited 1 time in total.
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Spike trap

Post by msyblade »

So you got it animated, to see the spikes rise and slowly retract? GREAT work. Now we gotta get a playsound for it. Perhaps one of the weapon swings, [Scchhhwwiiiing!]
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Spike trap

Post by Neikun »

There might be something in the new sound effect pack recently added to the custom sound thread.

viewtopic.php?f=14&t=3575
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Spike trap

Post by AdrTru »

msyblade wrote:So you got it animated, to see the spikes rise and slowly retract? GREAT work. Now we gotta get a playsound for it. Perhaps one of the weapon swings, [Scchhhwwiiiing!]
Ok I wos upload v1.1 with this function for you :).
This script may be use generaly ( not only with Spike Trap).
For demonstrating there is added definition for track with 2 rise and then slowly retract.
(--TRamp = {{x=0,y=0},{x=10,y=80},{x=20,y=50},{x=30,y=100},{x=50,y=100},{x=100,y=0}} )
Definition of this array(graph) is little free. Must be only points sorted by x.

This script is in mod_assets\Traps\scripts\init_Traps.lua
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: Spike trap

Post by SpiderFighter »

Damn. That code made my head hurt.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Spike trap

Post by akroma222 »

That is terrific!!
Maybe even "swipe_special" from the original asset pack could go well?
Post Reply