Frictional Games Forum (read-only)
Problem with function activation [Script help] - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Problem with function activation [Script help] (/thread-10537.html)



Problem with function activation [Script help] - Gamemakingdude - 10-01-2011

PHP Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
    
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
    
if(ScriptDebugOn())
    {
        
GiveItemFromFile("lantern""lantern.ent");
 
        for(
int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i"tinderbox.ent");
    }
    
    
SetEntityPlayerInteractCallback("Key_1""HammerScare"true);
    
AddUseItemCallback("""Key_1""mansion_1""UsedKeyOnDoor"true);
    
AddEntityCollideCallback("Player","script_chairscare","ChairScare"false1);
    
AddEntityCollideCallback("Player","script_GruntScare","GruntScare",false,1);
    for (
int x 123x++) {
        
AddEnemyPatrolNode("servant_grunt_1""PathNodeArea_"+x0"");
        }
    
AddEntityCollideCallback("servant_grunt_1""ScriptArea_1""Reverse"false1);
}

void Reverse() {
    for (
int x 231x--) {
        
AddEnemyPatrolNode("servant_grunt_1""PathNodeArea_"+x0"");
        }
}
void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntity,false,true);
    
PlaySoundAtEntity("","unlock_door"asEntity0false);
    
RemoveItem(asItem);
}

void HammerScare(string &in entitystring &in type)
{
  
AddPropImpulse("sledge_1"30520"world");
}

void ChairScare(string &in asParentstring &in asChildint alState)
{
  
//SetEntityActive("chairscare",false);
  
AddPropImpulse("chairscare"00, -25"world");
}

void GruntScare(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_grunt_ragdoll_1",true);
    
AddPropForce("mansion_3"0050"world");
    
SetSwingDoorClosed("mansion_3",false,true);
    
PlaySoundAtEntity("","react_scare","Player",0,false);
    
AddPropImpulse("servant_grunt_ragdoll_1"0025"world");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
 
}
 
////////////////////////////
// Run when leaving map
void OnLeave()
{
 


The problem is that when i activate the gruntscare the door doesnt close, or the grunt doesnt appear. I cant see the error, can anyone else?


RE: Problem with function activation [Script help] - Tanshaydar - 10-01-2011

SetSwingDoorClosed("mansion_3",false,true);

here, you should write true instead of false if you want that door to be closed.


RE: Problem with function activation [Script help] - Gamemakingdude - 10-01-2011

(10-01-2011, 06:18 AM)Tanshaydar Wrote: SetSwingDoorClosed("mansion_3",false,true);

here, you should write true instead of false if you want that door to be closed.
It doesnt do anything. I can hear the sound but the grunt isnt appearing and the door isnt closing.
Ah wait i had the grunt going the wrong way he disappears off the map. I think i hear the door creaking but not closing.
The door isnt closing. Updated code.

PHP Code:
//Global Variables
bool GruntScareDone false;
bool chairScare false;

////////////////////////////
// Run first time starting map
void OnStart()
{
    
//Add the Lantern and 10 Tinderboxes when in Debug mode, always good to have light!
    
if(ScriptDebugOn())
    {
        
GiveItemFromFile("lantern""lantern.ent");
 
        for(
int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i"tinderbox.ent");
    }
    
SetEntityPlayerInteractCallback("Key_1""HammerScare"true);
    
AddUseItemCallback("""Key_1""mansion_1""UsedKeyOnDoor"true);
    
AddEntityCollideCallback("Player","script_chairscare","ChairScare"false1);
    
AddEntityCollideCallback("Player","script_GruntScare","GruntScare",false,1);
    for (
int x 123x++) {
        
AddEnemyPatrolNode("servant_grunt_1""PathNodeArea_"+x0"");
        }
    
AddEntityCollideCallback("servant_grunt_1""ScriptArea_1""Reverse"false1);
}

void Reverse() {
    for (
int x 231x--) {
        
AddEnemyPatrolNode("servant_grunt_1""PathNodeArea_"+x0"");
        }
}
void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntity,false,true);
    
PlaySoundAtEntity("","unlock_door"asEntity0false);
    
RemoveItem(asItem);
}

void HammerScare(string &in entitystring &in type)
{
  
AddPropImpulse("sledge_1"30520"world");
  
PlaySoundAtEntity("""fistpump","Player",0,false);
}

void ChairScare(string &in asParentstring &in asChildint alState)
{
  
//SetEntityActive("chairscare",false);
  
if(chairScare == false) {
      
AddPropImpulse("chairscare"00, -25"world");
      
chairScare true;
}
}

void GruntScare(string &in asParentstring &in asChildint alState)
{
    if(
GruntScareDone == false) {
        
SetEntityActive("servant_grunt_ragdoll_1",true);
        
PlaySoundAtEntity("","react_scare","Player",0,false);
        
AddPropImpulse("servant_grunt_ragdoll_1"1500"world");
        
SetSwingDoorClosed("mansion_3",true,true);
        
GruntScareDone true;
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
 
}
 
////////////////////////////
// Run when leaving map
void OnLeave()
{