Page 1 of 3

Spike trap

Posted: Fri Apr 05, 2013 12:09 am
by AdrTru
This is my little mod for adding Spike traps.

http://grimrock.nexusmods.com/mods/250
SpoilerShow
Image
SpoilerShow
Image

Re: Spike trap

Posted: Fri Apr 05, 2013 12:26 am
by Komag
impressive and awesome, love it!

Re: Spike trap

Posted: Fri Apr 05, 2013 1:48 am
by msyblade
Original and well executed! The judge from the U.S. scores it a 9.3! :D

Re: Spike trap

Posted: Fri Apr 05, 2013 3:26 am
by SpiderFighter
THAT is some beautiful work!!

Re: Spike trap

Posted: Fri Apr 05, 2013 8:41 pm
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

Re: Spike trap

Posted: Fri Apr 05, 2013 10:26 pm
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!]

Re: Spike trap

Posted: Fri Apr 05, 2013 10:39 pm
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

Re: Spike trap

Posted: Fri Apr 05, 2013 10:59 pm
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

Re: Spike trap

Posted: Fri Apr 05, 2013 11:43 pm
by SpiderFighter
Damn. That code made my head hurt.

Re: Spike trap

Posted: Sat Apr 06, 2013 1:24 am
by akroma222
That is terrific!!
Maybe even "swipe_special" from the original asset pack could go well?