home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / dust.py < prev    next >
Encoding:
Python Source  |  2000-10-27  |  9.5 KB  |  383 lines

  1. #
  2. # Polvo de tierra
  3. #----------------------------
  4. import whrandom
  5. import Bladex
  6. import math
  7. import PhantonFX
  8. import Reference
  9. import Actions
  10. import ObjStore
  11.  
  12. Bladex.AddParticleGType("Tierrax","SmokeParticle",Reference.B_PARTICLE_GTYPE_BLEND,64)
  13.  
  14. for i in range(64):
  15.     aux=(64.0-i)/64.0
  16.     r=100
  17.     g=100
  18.     b=100
  19.     a=255.0*(1.0-aux)**0.5
  20.     size=80.0+aux*900.0
  21.     Bladex.SetParticleGVal("Tierrax",i,r,g,b,a,size)
  22.  
  23.  
  24. def SetTierraColor(r,g,b):
  25.     for i in range(64):
  26.         aux=(64.0-i)/64.0
  27.         a=255.0*(1.0-aux)**0.5
  28.         size=80.0+aux*900.0
  29.         Bladex.SetParticleGVal("Tierrax",i,r,g,b,a,size)
  30.         
  31.  
  32. Bladex.AddParticleGType("FastDust","SmokeParticle",Reference.B_PARTICLE_GTYPE_BLEND,16)
  33.  
  34. for i in range(16):
  35.     aux=(16.0-i)/16.0
  36.     r=50
  37.     g=50
  38.     b=50
  39.     a=255.0*(1.0-aux)**0.5
  40.     size=40.0+aux*450.0
  41.     Bladex.SetParticleGVal("FastDust",i,r,g,b,a,size)
  42.  
  43.  
  44. def SetTierrapidaColor(r,g,b):
  45.     for i in range(16):
  46.         aux=(16.0-i)/16.0
  47.         a=255.0*(1.0-aux)**0.5
  48.         size=40.0+aux*450.0
  49.         Bladex.SetParticleGVal("FastDust",i,r,g,b,a,size)
  50.  
  51.  
  52. def RemueveTierraGen(x,y,z   ,sx,sz,pps=64,Ptypo="Tierrax",t2l=64,Death=2.0):
  53.  
  54.     tierra1=Bladex.CreateEntity("TierraRemoviendose1", "Entity Particle System D3", x +sx, y, z + sz)
  55.     tierra1.D1= -2*sx, 0, 0
  56.     tierra1.D2= -2*sx, 0, - 2*sz
  57.     tierra1.ParticleType=Ptypo
  58.     tierra1.PPS=pps
  59.     tierra1.YGravity=200.0
  60.     tierra1.Friction=0.1
  61.     tierra1.Velocity=0.0, -400.0, 0.0
  62.     tierra1.RandomVelocity=15.0
  63.     tierra1.Time2Live=t2l
  64.     if Death !=-1:
  65.         tierra1.DeathTime=Bladex.GetTime()+Death
  66.  
  67.  
  68.     tierra2=Bladex.CreateEntity("TierraRemoviendose2", "Entity Particle System D3", x + sx, y, z + sz)
  69.     tierra2.D1= -2*sx, 0, - 2*sz
  70.     tierra2.D2=     0, 0, - 2*sz
  71.     tierra2.ParticleType=Ptypo
  72.     tierra2.PPS=pps
  73.     tierra2.YGravity=200.0
  74.     tierra2.Friction=0.1
  75.     tierra2.Velocity=0.0, -400.0, 0.0
  76.     tierra2.RandomVelocity=15.0
  77.     tierra2.Time2Live=t2l
  78.     if Death !=-1:
  79.         tierra2.DeathTime=Bladex.GetTime()+Death
  80.     return tierra1,tierra2
  81.  
  82. def DropDust(x,y,z,vx,vy,vz,pps = 64,Ptypo="Tierrax",t2l=64,Death=1.0):
  83.     tierra1=Bladex.CreateEntity("Cristales", "Entity Particle System D1", x, y, z)
  84.     tierra1.ParticleType=Ptypo
  85.     tierra1.PPS=pps
  86.     tierra1.YGravity=9800.0
  87.     tierra1.Friction=0.1
  88.     tierra1.Velocity=vx,vy,vz
  89.     tierra1.RandomVelocity=50.0
  90.     tierra1.Time2Live=t2l
  91.     tierra1.DeathTime=Bladex.GetTime()+Death    
  92.     return tierra1
  93.  
  94.  
  95.  
  96. ########## Efecto de polvareda casual ##########
  97.  
  98. Bladex.AddParticleGType("Polvin","SmokeParticle",Reference.B_PARTICLE_GTYPE_BLEND,64)
  99.  
  100. intensidad = 60
  101.  
  102. def SetPolvinColor(r,g,b):
  103.     for i in range(68):
  104.         a    = 255*i/64.0
  105.         size = 512*(64-i)/64.0
  106.         if i>64: a =0;size = 0
  107.     
  108.         Bladex.SetParticleGVal("Polvin",i,r,g,b,a,size)
  109.  
  110. for i in range(68):
  111.     r=255.0
  112.     g=255.0
  113.     b=255.0
  114.     a    = 255*i/64.0
  115.     size = 512*(64-i)/64.0
  116.     if i>64: a =0;size = 0
  117.  
  118.     Bladex.SetParticleGVal("Polvin",i,r,g,b,a,size)
  119.     
  120. # Tierrilla(char.Position[0], char.Position[1], char.Position[2])
  121.  
  122. def Tierrilla(x, y, z,dx,dz):
  123.     global intensidad
  124.     
  125.     tierra1=Bladex.CreateEntity("Tierrilla", "Entity Particle System D3", x, y, z)
  126.     tierra1.D1= 3000, 0, 0
  127.     tierra1.D2= 3000, 0, 3000
  128.     tierra1.Time2Live=68
  129.     tierra1.YGravity=-500
  130.     tierra1.Velocity=dx,1000,dz
  131.     tierra1.RandomVelocity=5
  132.     tierra1.ParticleType="Polvin"
  133.     tierra1.PPS = intensidad
  134.     tierra1.DeathTime=Bladex.GetTime()+2.0
  135.  
  136. class WindFX:
  137.     Variance = 0
  138.     Sector=None
  139.     Sonido=None
  140.     x=0
  141.     y=0
  142.     z=0
  143.     wx=0
  144.     wy=0
  145.     wz=0
  146.  
  147.     def __init__(self,x,y,z):
  148.         self.Sector = Bladex.GetSector(x,y,z)
  149.         self.Sector.OnEnter = self.EntroElIluso
  150.         self.ObjId=ObjStore.GetNewId() # Para identificarlo al grabar/guardar
  151.         ObjStore.ObjectsStore[self.ObjId]=self
  152.  
  153.     def __del__(self):
  154.         del ObjStore.ObjectsStore[self.ObjId]
  155.  
  156.     def persistent_id(self):
  157.         return self.ObjId
  158.  
  159.     def __getstate__(self):
  160.         # Tiene que devolver cΣ«» poder guardar el estado de la clase
  161.         return(1,
  162.                 self.ObjId, # De GameStateAux.PersistentObject
  163.                 self.Variance,
  164.                 self.Sector,
  165.                 self.Sonido,
  166.                 self.x,
  167.                 self.y,
  168.                 self.z,
  169.                 self.wx,
  170.                 self.wy,
  171.                 self.wz
  172.                 )
  173.  
  174.  
  175.     def __setstate__(self,parm):
  176.         # Toma como parΓ«Ñtro lo que devuelve __getstate__() y debe recrear la clase
  177.         if parm[0]==1:
  178.             self.ObjId=parm[1]
  179.             ObjStore.ObjectsStore[self.ObjId]=self
  180.             self.Variance=parm[2]
  181.             self.Sector=parm[3]
  182.             self.Sonido=parm[4]
  183.             self.x=parm[5]
  184.             self.y=parm[6]
  185.             self.z=parm[7]
  186.             self.wx=parm[8]
  187.             self.wy=parm[9]
  188.             self.wz=parm[10]
  189.         else:
  190.             print "WindFX.__setstate__() -> Version mismatch"
  191.  
  192.             self.ObjId=ObjStore.GetNewId()
  193.             ObjStore.ObjectsStore[self.ObjId]=self
  194.  
  195.  
  196.     def SetSound(self,sonidox):
  197.         self.Sonido = sonidox
  198.  
  199.     def SetGenerationPoint(self,x,y,z):
  200.         self.x = x
  201.         self.y = y
  202.         self.z = z
  203.  
  204.     def SetWindVector(self,x,z):
  205.         self.wx = x
  206.         self.wz = z
  207.     
  208.     def DropWind(self):
  209.         self.Sonido.Position = self.x, self.y, self.z
  210.         self.Sonido.PlaySound(0)
  211.         Tierrilla(self.x, self.y, self.z,self.wx,self.wz)
  212.     
  213.     def EntroElIluso(self,Sector,Entity_Name):
  214.         if Entity_Name == "Player1":
  215.             if whrandom.randint(0,self.Variance) == 0:
  216.                 self.DropWind()
  217.  
  218. #------------------------------#------------------------------#------------------------------#------------------------------#
  219.  
  220. Bladex.AddParticleGType("LavaFire","FireParticle",Reference.B_PARTICLE_GTYPE_ADD,31)
  221.  
  222. for i in range(32):
  223.     if(i>16):
  224.         aux=0.0
  225.     else:
  226.         aux=(16.0-i)/16.0
  227.     r=255
  228.     g=min(100.0*(1.0-aux*aux)+35,255.0)
  229.     b=min( 50.0*(1.0-aux),255.0)
  230.     a=min(200.0*(1.0-aux),255.0)
  231.     size=130.0+math.sqrt(1.0-aux)*110.0
  232.     Bladex.SetParticleGVal("LavaFire",i,r,g,b,a,size)
  233.     
  234. D_SPEED=0.05
  235. def ChauPiedruchaTick(obj_name,time):  
  236.     global D_SPEED
  237.     
  238.     pieza = Bladex.GetEntity(obj_name)    
  239.     luz   = Bladex.GetEntity(obj_name+"Luz")
  240.  
  241.     if not pieza:
  242.         return
  243.     else:
  244.         pieza.Alpha = pieza.Alpha-D_SPEED
  245.         luz.Intensity=pieza.Alpha*10
  246.         if luz.Intensity < 1:
  247.             pieza.RemoveFromList("Timer15")
  248.             pieza.SubscribeToList("Pin")
  249.  
  250.  
  251. def ChauPiedrucha(obj_name):
  252.  
  253.     pieza=Bladex.GetEntity(obj_name)
  254.     if not pieza:
  255.         return
  256.     else:
  257.         pieza.SubscribeToList("Timer15")
  258.         pieza.TimerFunc=ChauPiedruchaTick
  259.         pieza=Bladex.GetEntity(obj_name)
  260.         fuego = Bladex.GetEntity(obj_name+"Fuego")
  261.         fuego.DeathTime=Bladex.GetTime()
  262.         
  263.  
  264. def DropPiedra(x,y,z,dx=1,dy=1,dz=1,Pname="Piedra_02"):
  265.     Piedra=Bladex.CreateEntity("Piedrita", Pname, x,y,z)
  266.     Piedra.Static = 0
  267.     
  268.     Fuego=Bladex.CreateEntity(Piedra.Name+"Fuego", "Entity Particle System D1", 0,0,0)
  269.     Fuego.ParticleType="LavaFire"
  270.     Fuego.PPS=64
  271.     Fuego.YGravity=1000
  272.     Fuego.Friction=0.1
  273.     Fuego.Velocity=0,0,0
  274.     Fuego.RandomVelocity=30.0
  275.     Fuego.Time2Live=32
  276.     Piedra.Link(Fuego)
  277.     
  278.     
  279.     Luz=Bladex.CreateEntity(Piedra.Name+"Luz","Entity Spot",0,0,0)
  280.     Luz.Color=255,100,50
  281.     Luz.Intensity=3
  282.     Luz.CastShadows=0
  283.     Luz.Precission=0.5
  284.     Luz.Visible=0
  285.     Luz.Flick=1
  286.     Piedra.Link(Luz)
  287.     
  288.     Piedra.ExclusionGroup=1
  289.     Piedra.Impulse(dx,dy,dz)
  290.  
  291.     Piedra.OnStopFunc=ChauPiedrucha
  292.     
  293.     return Piedra,Fuego,Luz
  294.  
  295. def BorraPorLasDudas2(PersonName):
  296.     wps=Bladex.GetEntity(PersonName+"WPS")
  297.     if wps:
  298.         wps.SubscribeToList("Pin")
  299.  
  300. def BorraPorLasDudas(PersonName):
  301.     Bladex.GetEntity(PersonName).CastShadows = 0
  302.     Bladex.AddScheduledFunc(Bladex.GetTime()+5, BorraPorLasDudas2,(PersonName,))
  303.  
  304. def EnPolvoPerson(PersonName,dx,dz):
  305.     # We don't want the held weapons to disappear....  be sure they are already dropped
  306.     me= Bladex.GetEntity(PersonName)
  307.     object = Bladex.GetEntity(me.InvLeft)
  308.     if me.InvLeft and object and not object.TestHit:
  309.         Actions.RemoveFromInventory (me, object,"DropLeftEvent")
  310.         object.Alpha=1.0
  311.         object.Impulse(0.0, 0.0, 0.0) 
  312.     
  313.     object = Bladex.GetEntity(me.InvRight)
  314.     if me.InvRight and object and not object.TestHit:
  315.         Actions.RemoveFromInventory (me, object,"DropRightEvent")
  316.         object.Alpha=1.0
  317.         object.Impulse(0.0, 0.0, 0.0) 
  318.     
  319.     wps=Bladex.CreateEntity(PersonName+"WPS", "Entity Particle System Dperson", 0.0, 0.0, 0.0)
  320.     wps.PersonName=PersonName
  321.     wps.ParticleType="EnPolvo"
  322.     wps.Time2Live=64
  323.     wps.RandomVelocity=0
  324.     wps.Velocity=dx,300,dz
  325.     wps.NormalVelocity=2.0
  326.     wps.YGravity=-300
  327.     wps.DeathTime=Bladex.GetTime()+1.5
  328.     
  329.     wps.PPS=300
  330.     PhantonFX.Delta = 0.1
  331.     PhantonFX.SecAgo = 10
  332.     PhantonFX.DisappearsChar(PersonName,BorraPorLasDudas)
  333.  
  334. Bladex.AddParticleGType("EnPolvo","SmokeParticle",Reference.B_PARTICLE_GTYPE_BLEND,64)
  335.  
  336. for i in range(68):
  337.     r=255.0
  338.     g=255.0
  339.     b=255.0
  340.     a    = 255*i/64.0
  341.     size = 128*(64-i)/64.0+16
  342.     
  343.  
  344.     Bladex.SetParticleGVal("EnPolvo",i,r,g,b,a,size)
  345.         
  346. """
  347. import dust
  348. import whrandom
  349.  
  350. def DropPiedrita():
  351.     r=whrandom.randint(-4000,4000)
  352.     dust.DropPiedra(5843+r, 8893, 48670,-r*15,-140000,whrandom.randint(-6000,6000))
  353.  
  354.  
  355.  
  356. dust.DropPiedra(5647, 8882, 47433,30000,-140000,0)
  357. dust.DropPiedra(5647, 8882, 47433,-30000,-140000,0)
  358. dust.DropPiedra(5647, 8882, 47433,30000,-140000,20000)
  359. dust.DropPiedra(5647, 8882, 47433,-30000,-140000,20000)
  360. dust.DropPiedra(5647, 8882, 47433,-30000,-140000,-20000)
  361. dust.DropPiedra(5647, 8882, 47433,30000,-140000,-20000)
  362.  
  363. Bladex.SetCallCheck(1)
  364.  
  365.  
  366. ------------------------------------------------------------------
  367.  
  368. import dust
  369. import Sounds
  370.  
  371. dust.intensidad = 240                           # pps
  372. dust.SetPolvinColor(255,255,255)                # snow winds
  373.  
  374. WindSound = Sounds.CreateEntitySound("..\\..\\Sounds\\M-caida-nieve1.wav", "CasualWind")
  375.  
  376. Efepolvo = dust.WindFX(-18272, 727, 30667)      # sector as params
  377. Efepolvo.SetSound(WindSound)                    # coolsound
  378. Efepolvo.SetGenerationPoint(-22836,300, 31593)  # Start
  379. Efepolvo.SetWindVector(1000,1000)               # This way is the win 
  380. Efepolvo.Variance = 0                           # Allways
  381.  
  382. ------------------------------------------------------------------
  383. """