Questions
Questions
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!
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:
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.
Then the pawns simply save their state by modifying the attributes they added. In Nirhis they do this every second.
When the game is loaded the pawn reads the attributes.
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.
I hope this makes sense to you.
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");
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");
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");
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.
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA