Questions

Discuss any other topics here
Post Reply
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Questions

Post by LtForce »

I've just noticed that RF's saving sys doesn't save NPC's dying, only player position. Has anyone done a script or something that saves deaths of NPCs? Wans't that accomplished in Nirhis? And if so can I use that script?
Last edited by LtForce on Sat Aug 04, 2007 7:34 pm, edited 1 time in total.
Lithuanians for Georgia!
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

To my knowledge saving in RF only stores the attributes and the info about player (position, yaw and pitch). So you have to make the pawns save info about themselves to the player's attributes. For example the position, yaw and whether they are dead or not.

In Nirhis, each pawn creates unique names for the attributes they are going to use. This is done in the beginning with these lines:

Code: Select all

savehealth = Concat(self.EntityName,"_health");
savestate = Concat(self.EntityName,"_state");
savex = Concat(self.EntityName,"_x");
savey = Concat(self.EntityName,"_y");
savez = Concat(self.EntityName,"_z");
saveyaw	= Concat(self.EntityName,"_yaw");
The pawn takes its entityname, adds some letters to it and saves it as a variable so it's easier to use. So for example a pawn called enemy1 would use attributes enemy1_health, enemy1_state, enemy1_x, etc.

Then the pawns add attributes with those names to the player's attributes.

Code: Select all

AddAttribute(StringCopy(savehealth),-1000,1000,"Player");
AddAttribute(StringCopy(savestate),-1000,1000,"Player");
AddAttribute(StringCopy(savex),-100000,100000,"Player");
AddAttribute(StringCopy(savey),-100000,100000,"Player");
AddAttribute(StringCopy(savez),-100000,100000,"Player");
AddAttribute(StringCopy(saveyaw),-100000,100000,"Player");
Then the pawns simply save their state by modifying the attributes they added. In Nirhis they do this every second.

Code: Select all

SetAttribute(StringCopy(savehealth),GetAttribute(HEALTHATTRIBUTE),"Player");
SetAttribute(StringCopy(savestate),STATE,"Player");
SetAttribute(StringCopy(savex),self.current_X,"Player");
SetAttribute(StringCopy(savey),self.current_Y,"Player");
SetAttribute(StringCopy(savez),self.current_Z,"Player");
SetAttribute(StringCopy(saveyaw),self.current_yaw/0.0174532925199433,"Player");
When the game is loaded the pawn reads the attributes.

Code: Select all

SetAttribute(HEALTHATTRIBUTE,GetAttribute(StringCopy(savehealth),"Player"));
SetPosition(self.EntityName,GetAttribute(StringCopy(savex),"Player"),GetAttribute(StringCopy(savey),"Player"),GetAttribute(StringCopy(savez),"Player"));
self.ideal_yaw = GetAttribute(StringCopy(saveyaw),"Player")*0.0174532925199433;

I also used an attribute to save the order in which the pawn is. I gave the savestate attribute different integer values based on the order in which the pawn is. For example idle order could be 1, alert 2, attack 3, dead 4 etc... Then when the games is loaded the pawn check the value of that attribute and jump into that order.

Code: Select all

if(state = 1)
{
	AnimateHold(IDLE);
	self.think = "idle";
	return 0;
}
	if(state = 2)
{
	SetFOV(ALERTFOV);
	self.yaw_speed = YAWSPEED;
	self.think = "alert";
	return 0;
}

I hope this makes sense to you.
Pain is only psychological.
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Post by LtForce »

thanks
Lithuanians for Georgia!
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Post by LtForce »

Ok, now I have another question: I made a HUD element that shouws how many bullets are left in the magazine, but I want to make it like this: when one magazine ends that bullet counter also disappears, but it reappears when player reloads, but I can't
Lithuanians for Georgia!
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post by scott »

have an if statment maybe (i have never scripted :P)
if bullets in current mag = 0 then hide bullet count
else bullet count show.
bullet count is the amont of bullets and the bullet number image.
*GD*
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

use the active hud element cmd thing
Herp derp.
Post Reply