Page 1 of 1

Grenade explosion 'shake' effect

Posted: Mon Jun 11, 2007 1:05 pm
by DjFou
Hello guys !

I'm posting here to share, and to hope getting some infos/tweaks about a script i'm trying to do and which is already in a post @ TMT

The idea is to make a 'shake' effect when the nade explode (like earthquake)...
I've currently setup the things in the models/fx/m2fgrenadeexplosion.tik file which exec a check_nadetrig.scr to see if the nade already exploded or not, and if you're in the area, exec another script (courtesy of LeBabouin) which have to shake your screen (but don't seems to works for me :D) ...
Here is m2fgrenadeexplosion.tik :

Code: Select all

TIKI
setup
{
	scale 1.0
	path models/fx/dummy
	skelmodel dummy2.skd
}
 
init
{
	server  
	{
		classname Explosion
//		ghost
//		svflags +sendonce
		rendereffects +dontdraw
		notsolid
//		radiusdamage 200
		radiusdamage 500 //[UR]
//		radius 400
		radius 500 //[UR]
		meansofdeath grenade
		life 0.25
		dlight 1 1 1 800
		//exec global/earthquake.scr 1.2 .3 0 0 
		//exec global/quake4me.scr
		[color=red]exec global/check_nadetrig.scr[/color]
	}
}

animations
{
	idle dummy2.skc
	{
		server    
		{
			// make the explosion effect
//			entry explosioneffect grenade
			first explosioneffect grenade
			
//			last stopanimating
		}
	}
}
Here is check_nadetrig.scr :

Code: Select all

main:
 if(!self.exploded){
  self.exploded = 1 
  while (self!=NULL && self!=NIL){
   local.kaboom = self.origin
   waitframe
  }
  if(local.kaboom!=( 0.000000 0.000000 0.000000 ) && local.kaboom!=NIL)
   thread shakeItToMe local.kaboom
 }
end

shakeItToMe local.kaboom:
iprintln "Kaboom !"
for(local.player=1;local.player<=$player.size;local.player++)
      {
	if(vector_within local.kaboom $player[local.player].origin 550 && $player[local.player].health != 0)
            {
		iprintln "in the area : quake4me coming!"
		exec global/quake4me.scr
		}
	}
end
My problem is that i get an error in the quake4me.scr (cannot cast NIL on local.player.viewangles = local.viewangles bla bla bla)
Here is the quake4me.scr :

Code: Select all

//////////////////////////////////////////////////////////////////////
//earthQuakeForOnePlayer:
//////////////////////////////////////////////////////////////////////
// local.maxTilt = 3
 local.maxTilt = 0.25
 local.velocity = 0
// local.constant = -.002
// local.constant = -1.9
 local.constant = -2
 local.player = self
 
   while(local.player&&(isalive local.player)&&(local.player.electroSpotted == 1)){
    if(local.player.beamTilt!=1)
    {
     local.viewangles = local.player.viewangles
//     local.viewangles[2] = local.maxTilt
     local.viewangles[0] = local.maxTilt
     local.player.viewangles = local.viewangles
     local.player.beamTilt = 1
    }
//    if (local.viewangles[2] > local.maxTilt && local.velocity > 0)
    if (local.viewangles[0] > local.maxTilt && local.velocity > 0)
    {
     local.velocity = 0
    }
    else 
    {
//     if (local.viewangles[2] < -local.maxTilt && local.velocity < 0)
     if (local.viewangles[0] < -local.maxTilt && local.velocity < 0)
     {
      local.velocity = 0
     }
    }
    local.viewangles = local.player.viewangles
//    local.velocity += local.constant * local.viewangles[2]
    local.velocity += local.constant * local.viewangles[0]
//    local.viewangles[2] += local.velocity
    local.viewangles[0] += local.velocity
    local.player.viewangles = local.viewangles
    waitframe
 
   }
   local.viewangles = local.player.viewangles
//   local.viewangles[2] = 0
   local.viewangles[0] = 0
   local.player.viewangles = local.viewangles
   local.player.beamTilt = 0
 
end
I thought that i solve the problem, it could be useful for others, and in the other way, if you could help me, it would be very nice :P

Thanks in advance,
Dj :)

self

Posted: Mon Jun 11, 2007 6:58 pm
by tltrude
My guess would be that the quake4me.scr does not know who "self" is.

Posted: Mon Jun 11, 2007 10:17 pm
by LeBabouin

Code: Select all

shakeItToMe local.kaboom: 
iprintln "Kaboom !" 
for(local.player=1;local.player<=$player.size;local.player++) 
      { 
   if(vector_within local.kaboom $player[local.player].origin 550 && $player[local.player].health != 0) 
            { 
      iprintln "in the area : quake4me coming!" 
      local.player exec global/quake4me.scr   //<-------------------------
      } 
   } 
end 
(Thanks for courtesy Dj, but I just tweaked a bobbling script from e1l4)

Posted: Tue Jun 12, 2007 8:15 am
by DjFou
Hey!
Sorry for the long time reply, saw your post on TMT... answered a lil' late :oops:
Thanks for your help Bab :) (and others too!)

Here is the copy :
[quote=LeBabouin]Have :

Code: Select all

[COLOR=seagreen]$player[local.p][/COLOR] exec global/quake4Me.scr
[/quote]
Aw, thanks :)
I've replaced the quake4me.scr (was centering the screen... tried some tweaks but.. :() and exec it for each player in the area... not from the server.. It works nice :)
I'll now think about some 'decrescendo' shaky effect, if you're near, mid-near far etc etc...

Thanks for your help guys !
I'll post the final script here, and what not, another unuseful mod from me in the New Files ;)

Cheers ! :)

Posted: Thu Jun 14, 2007 9:52 pm
by At0miC
Hey fou! Good to see you around here. You awful pilot :wink:

Posted: Fri Jun 15, 2007 4:11 am
by LilChefDeath
very nice work!!! And i like the toilet mod :D :D its funny


KEEP UP THE GOOD WORK SOLDIER

LilChef