Page 1 of 1

Questions

Posted: Tue Jul 31, 2007 3:33 pm
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?

Posted: Fri Aug 03, 2007 4:53 pm
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.

Posted: Fri Aug 03, 2007 5:18 pm
by LtForce
thanks

Posted: Sat Aug 04, 2007 7:34 pm
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

Posted: Sat Aug 04, 2007 8:17 pm
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.

Posted: Sun Aug 05, 2007 9:09 pm
by darksmaster923
use the active hud element cmd thing