Pawn is damaged by falling ?

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Vertex
Posts: 108
Joined: Fri May 22, 2015 1:01 am
Location: Colombia
Contact:

Pawn is damaged by falling ?

Post by Vertex »

As I can make a Pawn takes damage from a height to fall. If you are jumping from a height that does not suffer damage, but it is very high breaking legs and harm.
Any suggestions?
http://www.iris3dgames.com Reality Factory Spanish :wink:
Veleran
Posts: 895
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Pawn is damaged by falling ?

Post by Veleran »

This will take you some time to script it but you will make it.
in low the level commands i saw this
in Special Pawn Script Variables, if this returns to true as you fall

Code: Select all

self.IsFalling 
A read-only variable that is true if the Pawn is currently falling.

next you might want to try this from the distance section of commands

Code: Select all

DISTANCE
float GetCollideDistance(string BoneName, float OffsetX, float OffsetY, float OffsetZ); 
Tests for collision between the bone's current position and the position with the offset applied and returns the distance between current position and impact point.

And if it returns a value -of -say 128 ,you must find a way through percent,int parameters to modify the health attribute amount by -50% and if it was 256 units reduce it by -100% .

I am trying to help but have not studied scripting much,and can not tell you enough about this fall damage.
i did not have time right now to check and compare existing scripts to study how you can do this,but maybe you could do it and look in any template scripts you have from demos ,to take some ideas.
User avatar
Vertex
Posts: 108
Joined: Fri May 22, 2015 1:01 am
Location: Colombia
Contact:

Re: Pawn is damaged by falling ?

Post by Vertex »

Thank you very much :)

I have another concern : As I can assign a Hud to an attribute of a Pawn , as I am working with Player Script do not know how to relate the content of the greeting attribute have assigned to the Pawn by AddAttribute ( ... ) , to be updated in one HUD.

Image
http://www.iris3dgames.com Reality Factory Spanish :wink:
Veleran
Posts: 895
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Pawn is damaged by falling ?

Post by Veleran »

May we take a look at your scripts ?.Is that attribute something only the Pawn has and not the Player?If yes you have to script it to activate a predefined hud and the rest,and modify the attribute through the script.
I thought you use a generic scripted player,whatever happens to the pawn you control modifies the player attributes and hud.
some commands,

Code: Select all

 ActivateHudElement(string AttributeName, bool Flag); 
Activate/Deactivate the HUD for the attribute AttributeName. 

ShowHudPicture(int HUDpicture#, bool IsVisible);
ShowHudPicture(int HUDpicture#, bool IsVisible, string EntityName, int ScreenX, int ScreenY, float DisplayTime);
ShowHudPicture(int HUDpicture#, bool IsVisible, string EntityName, int ScreenX, int ScreenY, float DisplayTime, int WinX, int WinY); 
Draws a BMP, JPG, TGA, PNG or an animated GIF file on the screen at location ScreenX, ScreenY.

HUDpicture# identifies the image pre-defined in the HUD.ini file 
IsVisible if true, the picture will be displayed, if false the picture is no longer displayed 
EntityName defines the entity the image is attached to. If EntityName is empty ("") then no attachement is made. Special EntityNames are "Player" and "Camera". 
ScreenX, ScreenY define the location on the screen where to draw the image if EntityName is empty (""). If EntityName is "Player" or "Camera" or the name of a Pawn, Attribute or StaticEntityProxy entity, then the picture is attached to that entity and ScreenX and ScreenY are interpreted as offsets relative to the origin of the entity. 
DisplayTime is the time to display the picture. If DisplayTime is 0, then the picture is displayed for 1 frame. If DisplayTime is larger than 0, the picture is displayed for DisplayTime seconds. After this time the IsVisible flag is automatically set to false. 
WinX, WinY can be used to define the viewport on the picture and display only part of the picture. 

NOTE: HudPictures are always displayed on top of the HUD or FilllScreenAreas but under ShowText-strings. If you put multiple pictures on top of eachother, then the HUDpicture# you assign to the pictures defines also the sequence in which pictures will overlap. The lowest defined HUDpicture# is displayed on the bottom. Each picture with a higher HUDpicture# will be displayed on top of the lower one. HUDpicture# is limited to 100 minus the number of other HUDs you define.
User avatar
Vertex
Posts: 108
Joined: Fri May 22, 2015 1:01 am
Location: Colombia
Contact:

Re: Pawn is damaged by falling ?

Post by Vertex »

Code: Select all


Jugador
{
	// -------------------------------------------------
	// Nombre Fichero 	: Jugador.s.
	// Nombre Projecto 	: Pawn.
	// Sitio Web		: http://www.iris3dgames.com
	// Scripter			: Yue Rexie
	// Fecha			: 07 - Jul - 2015
	// -------------------------------------------------
	// Notas			: Fichero encargado de crear
	//				 	  el personaje jugador scripteado. 
	//					  
	// -------------------------------------------------
	
	// Variables Globales.
	CONSOLA[true]												// Estado Consola.						
	FUERZASALTO[40]												// Fuerza de Salto.
	SALTO[false]												// Verificador de Salto.
	
	COLY[60]
	COLX[15]
	COLZ[50]
	
	// Animaciones.
	ANIMPLAY[Animacion]											// Animacion Actual.
	ANIMDESCANSO[Descanso]										// Animacion Descanso.
	ANIMSALTO[InicioSalto]										// Animacion Salto. 
	ANIMCORRER[Correr]
	ANIM[0]
	ANIMCAMBIO[0]
	
	// Orden Inicial.
	InicioJugador[()
	{
		Config.Consola(self.EntityName,CONSOLA);				// Acivar / Desactivar Consola.
		Jugador.StepHeight(10);
		Jugador.BoxHeight(COLY);
		Jugador.BoxWidth(COLX);
		
		Config.Atributos.Vida(); // Init Attribute Health
		
		Jugador.LowLevel("ConfigJugador");						// Orden de Bajo nivel.
	}]
	
	// Ordenes de bajo nivel.
	ConfigJugador[()
	{
		Config.Atributos.InitVida(); // Set value 100 attribute Health
		Jugador.yaw_speed = 1000;								// Velocidad de Giro.
		
		
		Jugador.think = "UpdateJugador";						// Nueva orden.
		
	}]
	
	// Update Jugador.
	UpdateJugador[()
	{
		//Jugador.debug(GetCollideDistance("Estomago", 0, -30, 0));
	    
		Config.Atributos.VidaAfectada(); // Damage Attribute Health.
		
		Jugador.ControlJugador();								// Controlando el Jugador.								
	}]
	
	// Control Jugador.
	ControlJugador[()
	{
		ANIM = 0;	
		
		// Moviendo Jugador.
		//Jugador.SetBoundingBox(ANIMDESCANSO, 15);
		Jugador.MovimientoJugador(Config.Input.Key.W,0,Config.Input.Key.S);			
		Jugador.MovimientoJugador(Config.Input.Key.S,180,Config.Input.Key.W);		
		Jugador.Saltar();
		Jugador.Animaciones();
	}]
	
	// Moviendo Jugador.
	MovimientoJugador[(Key,Giro,Key2)
	{
		
		
			if((Jugador.IsKeyDown(Key)) and (Jugador.IsKeyDown(Key2)=false))
			{	
				
				
				ANIMPLAY = StringCopy(ANIMCORRER);
				ANIM = 1;
				Jugador.walkmove(Jugador.current_yaw, 200);
				
				Jugador.ideal_yaw = Camara.current_yaw-ConvertDegrees(Giro);
				if(Jugador.IsKeyDown(Config.Input.Mouse.B3)=false)
				{
					Jugador.ChangeYaw();
				}
		
			}
			
			
			
		
			
			
		
		
	}]
	
	Saltar[()
	{
		
		if((Jugador.IsKeyDown(Config.Input.Key.SP)) and (SALTO = false))
		{
			SALTO=true;
			ANIMPLAY = StringCopy(ANIMSALTO);
			ANIM = 2;
			
			
				
			
				
			
			
		}
		else
		{
			
			
			
			if((Jugador.IsKeyDown(Config.Input.Key.SP)=false) and (SALTO = true))
			{
				
				//if(SALTO = true)
				//{
					Jugador.ForceUp(FUERZASALTO);
				//}
				
				SALTO=false;
			}
		}
		
		

		
		// Cayendo.
		if(Jugador.IsFalling)
		{
			ANIMPLAY = StringCopy(ANIMSALTO);
			ANIM = 2;	
			
		}


	}]
	
	// Animaciones.
	Animaciones[()
	{
		
		
		if( ANIM < 1 )
		{
			ANIMPLAY = StringCopy(ANIMDESCANSO);
		}
		
		
		if (Integer(ANIMCAMBIO) != Integer(ANIM) )
		{
			AnimateBlend(ANIMPLAY,0.2);
			
		}
		
		ANIMCAMBIO = Integer(ANIM);
		if(Jugador.animate_at_end)
		{
			
			AnimateHold(ANIMPLAY);
           
		}
		
		
		
			
	}]
	
	
}

Code: Select all

Camara
{
	// -------------------------------------------------
	// Nombre Fichero 	: Camara.s.
	// Nombre Projecto 	: Pawn.
	// Sitio Web		: http://www.iris3dgames.com
	// Scripter			: Yue Rexie
	// Fecha			: 07 - Jul - 2015
	// -------------------------------------------------
	// Notas			: Fichero encargado de crear
	//				 	  la camara libre. 
	//					  
	// -------------------------------------------------

	// Variables Globales.
	CONSOLA[true]										// Estado Consola.
	
	// Orden Inicial.
	InicioCamara[()
	{
		Config.Consola(self.EntityName,true);			// Activando Consola.
	
		Camara.LowLevel("ConfigCamara");				// Orden de Bajo nivel.
	}]
	
	// Ordenes de bajo nivel.
	ConfigCamara[()
	{
		
		
		Camara.AttachCamera();							// Se engancha la Camara.
		Camara.PawnRender(false);
		Camara.think = "UpdateCamara";					// Nueva orden.
		
	}]
	
	UpdateCamara[()
	{
		
		
		Camara.PositionToPawn(Jugador.EntityName,0,0,0,true,false);// Camara sigue al jugador.
		Camara.MatchPlayerAngles();						// Camara igra al rededor del Jugador.
		
	}]
	
}



Code: Select all

Config
{
	// -------------------------------------------------
	// Nombre Fichero 	: Config.s.
	// Nombre Projecto 	: Pawn.
	// Sitio Web		: http://www.iris3dgames.com
	// Scripter			: Yue Rexie
	// Fecha			: 09 - Jul - 2015
	// -------------------------------------------------
	// Notas			: Fichero encargado de crear
	//				 	  Objetos  varios.. 
	//					  
	// -------------------------------------------------	
	
    Input
	{
		Key
		{
			W[15]
			S[27]
			SP[46]
		}
		
		Mouse
		{
			B3[73]
			
		}
		
	}

	// Activando Consola.
	Consola[(Objeto,Encender);
	{
		
		Mensaje = "Init Objeto "# Objeto # " Ok!";
		
			switch (Objeto)
			{
				case "Jugador"
				{
						
						Jugador.Console(Encender);
						Jugador.debug(Mensaje);

				}
				case "Camara"
				{
						Camara.Console(Encender);
						Camara.debug(Mensaje);	
					
				}
				case "Config"
				{
						Config.Console(Encender);
						Config.debug(Mensaje);	
					
				}				
				
			}

	}]
	
	
	Atributos
	{
		VIDA[VIDA]
		MAXVIDA[100]
		
		
		Vida[()
		{
			
			Jugador.AddAttribute(VIDA);
			
		}]
		
		InitVida[()
		{
			Jugador.SetAttribute(VIDA,MAXVIDA);
		}]
		
		VidaAfectada[()
		{
			// Sufre daño por caida.
			if(Jugador.IsFalling)
			{
				Jugador.debug("CAYENDO");
			}
			else
			{
				
				Jugador.debug("NO");
			}
			
		}]
		
	}

	
    //------------------------------------------------
	//------------------------------------------------
	
	// Variables Globales.
	CONSOLA[true]										// Estado Consola.
	
	// Orden Inicial.
	InicioConfig[()
	{
		
		Config.Consola(self.EntityName,CONSOLA);		// Acivar / Desactivar Consola.
		
		Config.LowLevel("ConfigConfig");
	}]

	ConfigConfig[()
	{
		
		Config.PlayerRender(true);
		Config.think = "UpdateConfig";
	}]

	UpdateConfig[()
	{
		
		Config.PlayerToPosition(0,0,0);
		
		
		
	}]
}
The downside is that not as creating a Hud for a Pawn , the default Huds the default player Hud.ini believe in , and automatically linked to the attribute with the player.ini file where attributes are created with the same name hud , however for pawn I not understand how.
http://www.iris3dgames.com Reality Factory Spanish :wink:
User avatar
Vertex
Posts: 108
Joined: Fri May 22, 2015 1:01 am
Location: Colombia
Contact:

Re: Pawn is damaged by falling ?

Post by Vertex »

Ok, no problem.
If not the best way , two attributes with the same name, one created in the file to the player player.ini default one created in the script for the pawn , and when the attribute changes pawn revalued player of the default attribute .

Code: Select all

; Player.ini
; Health

[VIDA]
initial = 0
low = 0
high = 100

Code: Select all

; Hud.ini
[VIDA]
type = verticle
frame = hud\a_Vidai.bmp
framealpha = hud\a_Vida.bmp
indicator = hud\Vidai.bmp
indicatoralpha = hud\a_Vidai.bmp
framex = -128
framey = -256
indicatoroffsetx = 0
indicatoroffsety = 0
indicatorheight = 256
;flipindicator = true
;active = modify
modifydirection = both
;displaytime = 3

[~VIDA]
type = numeric
framex = -80
framey = -140
indicatoroffsetx = 0
indicatoroffsety = 0
font = 13
width = 3
;active = modify
modifydirection = both
;displaytime = 3

Code: Select all

// Update Jugador.
	UpdateJugador[()
	{
		//Jugador.debug(GetCollideDistance("Estomago", 0, -30, 0));
	    
		Config.Atributos.UpdateHudVida(); // Update Hud Player default.
		
		
		Config.Atributos.VidaAfectada(); // Damage Attribute Health.
		
		Jugador.ControlJugador();								// Controlando el Jugador.								
	}]

Code: Select all

Config
{
	// -------------------------------------------------
	// Nombre Fichero 	: Config.s.
	// Nombre Projecto 	: Pawn.
	// Sitio Web		: http://www.iris3dgames.com
	// Scripter			: Yue Rexie
	// Fecha			: 09 - Jul - 2015
	// -------------------------------------------------
	// Notas			: Fichero encargado de crear
	//				 	  Objetos  varios.. 
	//					  
	// -------------------------------------------------	
	
    Input
	{
		Key
		{
			W[15]
			S[27]
			SP[46]
		}
		
		Mouse
		{
			B3[73]
			
		}
		
	}

	// Activando Consola.
	Consola[(Objeto,Encender);
	{
		
		Mensaje = "Init Objeto "# Objeto # " Ok!";
		
			switch (Objeto)
			{
				case "Jugador"
				{
						
						Jugador.Console(Encender);
						Jugador.debug(Mensaje);

				}
				case "Camara"
				{
						Camara.Console(Encender);
						Camara.debug(Mensaje);	
					
				}
				case "Config"
				{
						Config.Console(Encender);
						Config.debug(Mensaje);	
					
				}				
				
			}

	}]
	
	
	Atributos
	{
		VIDA[VIDA]
		MAXVIDA[100]
		
		
		Vida[()
		{
			
			Jugador.AddAttribute(VIDA);
			
		}]
		
		InitVida[()
		{
			Jugador.SetAttribute(VIDA,MAXVIDA);
		}]
		
		[b]UpdateHudVida[()
		{
			
			Jugador.SetAttribute(VIDA,Jugador.GetAttribute(VIDA,"Jugador"),"Player");
			
		}][/b]
		
		
		VidaAfectada[()
		{
			// Sufre daño por caida.
			if(Jugador.IsFalling)
			{
				Jugador.debug("CAYENDO");
			}
			else
			{
				
				Jugador.debug("NO");
			}
			
		}]
		
	}

	
    //------------------------------------------------
	//------------------------------------------------
	
	// Variables Globales.
	CONSOLA[true]										// Estado Consola.
	
	// Orden Inicial.
	InicioConfig[()
	{
		
		Config.Consola(self.EntityName,CONSOLA);		// Acivar / Desactivar Consola.
		
		Config.LowLevel("ConfigConfig");
	}]

	ConfigConfig[()
	{
		
		Config.PlayerRender(true);
		Config.think = "UpdateConfig";
	}]

	UpdateConfig[()
	{
		
		Config.PlayerToPosition(0,0,0);
		
		
		
	}]
}
Image
http://www.iris3dgames.com Reality Factory Spanish :wink:
User avatar
Vertex
Posts: 108
Joined: Fri May 22, 2015 1:01 am
Location: Colombia
Contact:

Re: Pawn is damaged by falling ?

Post by Vertex »

Code: Select all

CaidaAfectaSalud[()
		{
			
			
			
			
			ALTURA = Jugador.GetCollideDistance("Estomago",0,-128,0);
			
			if(Jugador.IsFalling)
			{
				if(ALTURA= -1)
				{
					DAMAGE = true;
				}
				
				
			}
			else
			{
				
				if(DAMAGE=true)
				{
					Jugador.SetAttribute(VIDA,Jugador.GetAttribute(VIDA,"Jugador")-40,"Jugador");
					DAMAGE=false;
				}
					
			}	
			
		}]
And my character falling to suffer harm, but want to improve it according to the height from which to fall , suffer more or less damage.

For example if you jump from a second floor , the damage is greater than that if you do from a first.

Any suggestions?
http://www.iris3dgames.com Reality Factory Spanish :wink:
Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Pawn is damaged by falling ?

Post by Allanon »

Start a timer the first time Jugador.IsFalling is true then when Jugador.IsFalling is false stop the timer and then base your damage on how long the actor was falling.
Post Reply