Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Restore rusty valve when you die (still unsolved)
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#11
RE: Restore rusty valve when you die (still unsolved)

Here is one way you can use CreateEntityAtArea (as others have suggested).

Put a script area around where you want the valve to appear. Ill Assume for now you called it "ScriptArea_Valve". Don't put a valve there at the start.

As we want to be able to generate an infinite number of valves we are going to want a way to generate new names for them. That's where this first function comes in:
//Function for generating unique names
string generateNewName(string prefix)
{
   AddLocalVarInt("generateNewName_Count_" + prefix,1); //Add one to a count of how many times this was called
   return prefix + GetLocalVarInt("generateNewName_Count_" + prefix); //Use the count to generate a unique valve name
}

Next we want to use this code to be able to create valves. We will create another function which will create a valve at a specified area.
//Create a new valve entity at an area
void createNewValveAtArea(string &in asArea)
{
        //This will generate "Spawning_Valve_1" "Spawning_Valve_2" etc...
    string newValveName = generateNewName("Spawning_Valve_");
    
    //Create the valve
    CreateEntityAtArea(newValveName,"[FileName].ent",asArea,false);
    
    //Do any stuff with the valve here (E.g. callbacks) but use newValveName instead of "Spawning_Valve"
    //E.g. AddEntityCollideCallback(newValveName,"SomeEntity","SomeFunction",false,1);
    
    //Finally we need to keep track of what the most current valve name is (for later)
    SetLocalVarString("CurrentValvename",newValveName);
}

Now we have the code down to generate valves, we need to make a valve spawn when we start the map, as well as set up the checkpoint (your checkpoint code is probably elsewhere rather than OnStart though).
void OnStart()
{
    //Create a valve with all it's callbacks etc
    createNewValveAtArea("ScriptArea_Valve");
    //Create a checkpoint which calls "cbDeath_ValveChase"
    CheckPoint("SomeName","SomeStartArea","cbDeath_ValveChase","SomeCategory","SomeEntry");
}


Finally, all we need to do is disable the old valve and create a new one on death:
void cbDeath_ValveChase(string &in asName, int alCount)
{
    //Disable the old valve
    string oldValve = GetLocalVarString("CurrentValvename");
    SetEntityActive(oldValve,false);
    //Create a new one
    createNewValveAtArea("ScriptArea_Valve");
    
    // **The rest of your checkpoint code here**
}

There are some blanks you will have to fill in, and that code untested but provided you can activate/deactivate the entity you are using this should work.
(This post was last modified: 08-14-2012, 03:36 PM by Apjjm.)
08-14-2012, 03:33 PM
Find


Messages In This Thread
RE: Restore map when you die - by Mackiiboy - 07-31-2012, 03:59 PM
RE: Restore map when you die - by Steve - 08-04-2012, 07:07 PM
RE: Restore rusty valve when you die - by Steve - 08-05-2012, 10:03 AM
RE: Restore rusty valve when you die (still unsolved) - by Apjjm - 08-14-2012, 03:33 PM



Users browsing this thread: 1 Guest(s)