Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
Code not working for no apparent reason!
I tried working with the wiki and engine scripts but I have no freaking clue what is happening for it not to work maybe it's a bug, no errors are appearing at least.
Let me talk about the code and level editor. I made this code where when you walk in this script area, it will make the door open quickly with wind particles and stuff.
So this is the code of it
void OnStart()
{
AddEntityCollideCallback("JumpscareDoor", "AreaJumpscare", "SanityDec", true, 1);
AddEntityCollideCallback("Handle", "AreaConnect", "AttachLever", true, 1);
wakeUp();
}
void wakeUp()
{
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
PlayGuiSound("react_pant3.ogg", 1);
FadeSepiaColorTo(0, 2);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.5, 2);
SetPlayerCrouching(true); // Simulates being on the ground
AddEntityCollideCallback("Player", "AreaCollide", "EventCollide", true, 1);
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}
void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
SetPlayerLampOil(34);
GiveSanityDamage(80, false);
GivePlayerDamage(30 , "" , false, false);
SetPlayerMoveSpeedMul(0.75f);
SetPlayerRunSpeedMul(0);
//SetPlayerLookSpeedMul(0.5);
AddUseItemCallback("", "HollowNeed", "CellDoor", "UseHollowNeedOnDoor", true);
}
void UseHollowNeedOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("CellDoor", false, true);
PlaySoundAtEntity("", "unlock_door.ogg", asEntity, 0, false);
GiveSanityBoostSmall();
RemoveItem(asItem);
}
void EventCollide(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("CellGuardGrunt", true);
AddEnemyPatrolNode("CellGuardGrunt", "Node_1",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_4",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_6",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_10",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_15",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_18",0.001f, "");
}
void AttachLever(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Lever", true);
SetEntityActive(asParent, false);
PlayGuiSound("04_place_wood.ogg", 1);
SetEntityActive("Mount", false);
}
void UnlockDoor(string &in asEntity, int LeverState)
{
if(LeverState == 1)
{
SetSwingDoorLocked("Open", false, true);
SetPropStaticPhysics("Open", false);
SetEntityActive("Message", false);
GiveSanityBoostSmall();
PlaySoundAtEntity("", "unlock_door.ogg", "Open", 0, false);
SetLeverStuckState(asEntity, LeverState, false);
}
}
void SanityDec(string &in asParent, string &in asChild, int alState)
{
PlayGuiSound("react_scare1.ogg", 1);
GiveSanityDamage(15, true);
}
void int01(string &in asEntity)
{
SetMessage("Messages", "Message", 5);
}
void CollideOpeningDustDoor(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("PSDoor_1", "ps_dust_paper_blow.ps", "AreaDoor_1", false);
CreateParticleSystemAtEntity("PSDoor_2", "ps_dust_push.ps", "AreaDoor_1", false);
PlaySoundAtEntity("SoundDoor_1", "scare_wind_reverse", "AreaDoor_1", 1.0f, false);
PlaySoundAtEntity("creaking_door", "joint_door_move_special.snt", "Door_1", 1.0 / 2.5f, false);
PlaySoundAtEntity("SoundBong", "scare_tingeling.snt", "Player", 0.0f, false);
AddTimer("opendoor_1", 0.25f, "TimerOpenDoor01");
AddTimer("lightsout", 1, "TimerOpenDoor01");
AddTimer("stopeffect", 2, "TimerOpenDoor01");
StartScreenShake(0.007f,2, 0.25f,1);
FadePlayerFOVMulTo(1.5, 0.5f);
/*For CollideBeginSwirl
*/
PlaySoundAtEntity("SoundFeet1", "01_tiny1", "AreaBeginSwirl", 15.0f, false);
/*DEBUG
*/
AddDebugMessage("The door at "+asChild+" opens with dust", true);
}
void TimerOpenDoor01(string &in asTimer)
{
if(asTimer == "stopeffect"){
FadePlayerFOVMulTo(1, 1);
PlaySoundAtEntity("breath", "react_breath.snt", "Player", 1.0 / 0.75f, false);
AddTimer("lookloop", 1, "TimerRandomLook"); //Re-activate the spinning head
return;
}
if(asTimer == "lightsout"){
for(int i=1;i<=4;i++) SetLampLit("torch_static01_"+i, false, true);
for(int i=1;i<=4;i++) FadeLightTo("LightOff_"+i, 0, 0, 0, 0, 0, 1.5f);
PlaySoundAtEntity("breath2", "react_breath.snt", "Player", 1.0 / 1, false);
return;
}
PlaySoundAtEntity("Wind", "general_wind_whirl", "Player", 2, false);
PlaySoundAtEntity("scare", "react_scare.snt", "Player", 0.75f, false);
StopSound("creaking_door", 1.0f);
PlayMusic("18_amb.ogg", true, 1.0f, 0, 0, true);
CreateParticleSystemAtEntity("PSDoor_3", "ps_dust_push.ps", "AreaDoor_2", false);
CreateParticleSystemAtEntity("PSDoor_4", "ps_dust_push.ps", "AreaDoor_3", false);
SetSwingDoorClosed("Door_1", false, false);
SetSwingDoorDisableAutoClose("Door_1", true);
AddTimer("Door_1", 0.01f, "TimerSwingDoor");
GiveSanityDamage(10, true);
}
and I made every name in the level editor, comparing to this code. So I have no clue why it is not working at all, or no unknown reason. the code looks fine and nothing is missing. so I am confused, Literally!!!!!!
(This post was last modified: 02-07-2014, 05:47 PM by Radical Batz.)
|
|
02-07-2014, 05:43 PM |
|
WALP
Posting Freak
Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation:
45
|
RE: Code not working for no apparent reason!
CollideOpeningDustDoor function seems to be fine, except theres nothing calling it. Add a AddEntityCollideCallback in OnStart and it should work. The reason you are not getting any warnings is of course that you never told amnesia to run the function, so it thinks it has done everything right. Bugs only come when you tell it to do something but in an incorrect way
|
|
02-07-2014, 06:03 PM |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
RE: Code not working for no apparent reason!
But I don't have any add entity collide callback in that code o the door. Are you telling me to create one and what do I put in it?
|
|
02-07-2014, 06:07 PM |
|
WALP
Posting Freak
Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation:
45
|
RE: Code not working for no apparent reason!
AddEntityCollideCallback("Player","CollideOpeningDustDoor","[INSERT THE NAME OF THE AREA YOU WANT THE PLAYER TO COLLIDE WITH HERE!]",true,1);
put this in OnStart() and Add the name of the script area as instructed above.
|
|
02-07-2014, 06:16 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Code not working for no apparent reason!
(02-07-2014, 06:16 PM)The Mug Wrote: AddEntityCollideCallback("Player","CollideOpeningDustDoor","[INSERT THE NAME OF THE AREA YOU WANT THE PLAYER TO COLLIDE WITH HERE!]",true,1);
put this in OnStart() and Add the name of the script area as instructed above. I think you might've switched the 2nd and 3rd parameter around
AddEntityCollideCallback("Entity1", "Entity2", "FunctionCallback", true, 1);
(This post was last modified: 02-07-2014, 06:35 PM by Mudbill.)
|
|
02-07-2014, 06:34 PM |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
RE: Code not working for no apparent reason!
Still did not work
is that the code I should add? or is that just an example, that I have to fill in myself?
(This post was last modified: 02-07-2014, 06:46 PM by Radical Batz.)
|
|
02-07-2014, 06:37 PM |
|
Red
Posting Freak
Posts: 1,757
Threads: 49
Joined: Feb 2012
Reputation:
54
|
RE: Code not working for no apparent reason!
(02-07-2014, 06:37 PM)Badcat5550 Wrote: Still did not work
is that the code I should add? or is that just an example, that I have to fill in myself?
What's the ScriptArea's name, we're talking about?
|
|
02-07-2014, 07:30 PM |
|
Wapez
Senior Member
Posts: 360
Threads: 37
Joined: Mar 2012
Reputation:
19
|
RE: Code not working for no apparent reason!
It's going to be a lot easier if you don't copy the original Amnesia scripts. Create your own and you will be able to keep track of everything that you do.
All you really need is to play a particle, a sound, and swing the door open. That's all there is. Find these functions in the wiki and you're good to go. When you're comfortable with this, you can add more effects, like player reactions.
Here's a list of all the engine scripts.
http://wiki.frictionalgames.com/hpl2/amn..._functions
|
|
02-08-2014, 03:30 PM |
|
|