Main Search
Delta Corp Forum Index
 
 
FAQ Members Groups Profile Private Messages

Important Notice: We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024. If you wish to migrate to our paid hosting service, please contact [email protected].
While Hitting (Hard Challange)

 
Post new topic   Reply to topic    Delta Corp Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
NintendoZACHERY
Newbie


Joined: 07 Feb 2008
Posts: 8

PostPosted: Sat May 24, 2008 1:48 am    Post subject: While Hitting (Hard Challange) Reply with quote

Hello, I have a idea for A Brick Script Where:

1. You Tuch it (Keep Tuching)
2.While hitting the brick You loose 2 health
3. If not hitting the brick you stop lossing health.

By my understanding this is Very difficult. I asked ICE128 he didn't know how, and i even asked Telamon, He didn't know.

as you can see this is a hard challange.
Back to top
View user's profile Send private message
SirGelatina
Site Admin


Joined: 01 Mar 2008
Posts: 116
Location: Behind you

PostPosted: Sat May 24, 2008 2:47 am    Post subject: Reply with quote

Not sure if it will work

Code:
local damagepercycle = 2
local delaybetweendmg = 1 -- In Seconds

function returnInverse(num)
   if num == 2 or num == 4 or num == 6 then
      return num - 1
   else
      return num + 1
   end
end

function checkIfTouching(part)
   local one = {}
   local one[1] = part.Position.y + ( part.Size.y / 2 )
   local one[2] = part.Position.y - ( part.Size.y / 2 )
   local one[3] = part.Position.x + ( part.Size.x / 2 )
   local one[4] = part.Position.x - ( part.Size.x / 2 )
   local one[5] = part.Position.z + ( part.Size.z / 2 )
   local one[6] = part.Position.z - ( part.Size.z / 2 )

   local two = {}
   local obj = script.Parent
   local two[1] = obj.Position.y + ( obj.Size.y / 2 )
   local two[2] = obj.Position.y - ( obj.Size.y / 2 )
   local two[3] = obj.Position.x + ( obj.Size.x / 2 )
   local two[4] = obj.Position.x - ( obj.Size.x / 2 )
   local two[5] = obj.Position.z + ( obj.Size.z / 2 )
   local two[6] = obj.Position.z - ( obj.Size.z / 2 )

   for x=1, #one do
      if one[x] - two[returnInverse(x)] > -1 then
         return false
      end
   end
   return true
end

function onTouched(Toucher)
   local humanoid = Toucher.Parent:findFirstChild("Humanoid")
   if humanoid ~= nil then
      repeat
         humanoid.Health = humanoid.Health - damagepercycle
         wait(delaybetweendmg)
      until checkIfTouching(Toucher) == false
   end
end

script.Parent.Touched:connect(onTouched)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
NintendoZACHERY
Newbie


Joined: 07 Feb 2008
Posts: 8

PostPosted: Wed May 28, 2008 7:17 pm    Post subject: Reply with quote

Daaaaang but it didnt work sorry =P
Back to top
View user's profile Send private message
SirGelatina
Site Admin


Joined: 01 Mar 2008
Posts: 116
Location: Behind you

PostPosted: Wed May 28, 2008 7:29 pm    Post subject: Reply with quote

It works only for non-collidable bricks. �t checks if any of your bodyparts or another brick is IN the script's Parent. For collidable bricks, it would be needed another script.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
SirGelatina
Site Admin


Joined: 01 Mar 2008
Posts: 116
Location: Behind you

PostPosted: Wed May 28, 2008 8:25 pm    Post subject: Reply with quote

I made some mistakes on the script. Try this:

Code:
local damagepercycle = 2
local delaybetweendmg = 1 -- In Seconds

function returnInverse(num)
   if num == 2 or num == 4 or num == 6 then
      return num - 1
   else
      return num + 1
   end
end

function checkIfTouching(part)
   local one = {}
   one[1] = part.Position.y + ( part.Size.y / 2 )
   one[2] = part.Position.y - ( part.Size.y / 2 )
   one[3] = part.Position.x + ( part.Size.x / 2 )
   one[4] = part.Position.x - ( part.Size.x / 2 )
   one[5] = part.Position.z + ( part.Size.z / 2 )
   one[6] = part.Position.z - ( part.Size.z / 2 )

   local two = {}
   local obj = script.Parent
   two[1] = obj.Position.y + ( obj.Size.y / 2 )
   two[2] = obj.Position.y - ( obj.Size.y / 2 )
   two[3] = obj.Position.x + ( obj.Size.x / 2 )
   two[4] = obj.Position.x - ( obj.Size.x / 2 )
   two[5] = obj.Position.z + ( obj.Size.z / 2 )
   two[6] = obj.Position.z - ( obj.Size.z / 2 )

   local countIn = 0
   for x=1, #one do
      if x == 1 or x == 3 or x == 5 then
         if one[x] > two[returnInverse(x)] then
            countIn = countIn +1
         end
      else
         if one[x] < two[returnInverse(x)] then
            countIn = countIn +1
         end
      end
   end
print (countIn)
   if countIn == 6 then
   return true
   end
   return false
end

function onTouched(Toucher)
   local humanoid = Toucher.Parent:findFirstChild("Humanoid")
   if humanoid ~= nil then
      repeat
         humanoid.Health = humanoid.Health - damagepercycle
         wait(delaybetweendmg)
      until checkIfTouching(Toucher) == false
   end
end

script.Parent.Touched:connect(onTouched)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
NintendoZACHERY
Newbie


Joined: 07 Feb 2008
Posts: 8

PostPosted: Wed May 28, 2008 8:54 pm    Post subject: Reply with quote

Yay It Works, Thanks. But uh. Also. Could You Make It Slightly Simplifyed To Where Theres a Section in the script you can make it do other things? and also, it works. but not All the time.
Back to top
View user's profile Send private message
SirGelatina
Site Admin


Joined: 01 Mar 2008
Posts: 116
Location: Behind you

PostPosted: Wed May 28, 2008 9:08 pm    Post subject: Reply with quote

But there IS a section to do that! It's:

function onTouched(Toucher)
local humanoid = Toucher.Parent:findFirstChild("Humanoid")
if humanoid ~= nil then
repeat
humanoid.Health = humanoid.Health - damagepercycle
wait(delaybetweendmg)

until checkIfTouching(Toucher) == false
end
end
Back to top
View user's profile Send private message Send e-mail MSN Messenger
NintendoZACHERY
Newbie


Joined: 07 Feb 2008
Posts: 8

PostPosted: Wed May 28, 2008 11:10 pm    Post subject: Reply with quote

well ok
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Delta Corp Forum Index -> Script Requests All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Back to Top              
Jenova Template © digital-delusion.com
Powered by phpBB © 2001, 2002 phpBB Group



For Support - http://forums.BizHat.com

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!