[SOLVED]Strange script problem - ide - 10-13-2010
This is quite strange problem. I have simple interaction callback with door that activates a grunt. But for some reason the grunt is activated even when I interact with completely different door that doesn't have a callback.
basically what I did was:
I add this to the door I want to set the callback on:
Then wrote the code bellow:
Code: void doorgrunt(string &in entity){
SetEntityActive("1doorgrunt", true);
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_7", 5, "");
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_24", 0, "");
}
RE: Strange script problem - Frontcannon - 10-13-2010
(10-13-2010, 02:22 PM)ide Wrote: Code: void doorgrunt(string &in entity){
SetEntityActive("1doorgrunt", true);
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_7", 5, "");
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_24", 0, "");
}
I think you have to write the name of the door with the Callback in (string &in entity) or it'll be called everytime you interact with something
RE: Strange script problem - ide - 10-13-2010
Now I get "Expected data type" error message when trying to quick reload. Are you sure that that's really how it should be done?
Current code:
Code: void doorgrunt("mansion_11"){
SetEntityActive("1doorgrunt", true);
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_7", 5, "");
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_24", 0, "");
Edit:
Ok I tested it few times and noticed that actually interacting with door didn't cause the trigger. It was caused when I stepped through the door (also left one script area at the same time though it's not connected to the event in anyway so it shouldn't cause problems.)
RE: Strange script problem - Entih - 10-13-2010
You had it right, the function should read:
Code: void doorgrunt(string &in entity)
The game fills in the name of the entity into the variable entity when the game actually runs. I am not quite sure how it wouldn't be working though, unless you have multiple functions of the name 'doorgrunt'.
Interact callbacks should run the instant the player tries to manipulate the item.
RE: Strange script problem - Frontcannon - 10-13-2010
(10-13-2010, 02:44 PM)ide Wrote: Ok I tested it few times and noticed that actually interacting with door didn't cause the trigger. It was caused when I stepped through the door (also left one script area at the same time though it's not connected to the event in anyway so it shouldn't cause problems.)
That's interesting!
RE: Strange script problem - ide - 10-13-2010
This isn't the only "script without script" problem I get. Another is when player is supposed to hear sound and get an objective but instead he doesn't hear the sound(still gets the obj.). Though later the sound will play randomly(multiple times) even though player is no where near the actual trigger area.
RE: Strange script problem - Entih - 10-13-2010
Very odd. I can't say I've ever heard of something like that! I would need to see the script to be able to say though, it may depend on how you have the script set up.
RE: Strange script problem - ide - 10-13-2010
Code: void OnStart()
{
AddUseItemCallback("", "roomkey_1", "mansion_1", "UnlockDoor", true);
AddUseItemCallback("", "storagekey", "mansion_7", "UnlockDoor", true);
AddUseItemCallback("", "key_torture_chamber_1", "mansion_6", "UnlockDoor", true);
AddEntityCollideCallback("Player", "StepsArea_1", "sounds1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "sounds3", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "sounds2", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_6", "sounds5", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_7", "sounds6", true, 1);
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_4", "enemydisappear", true, 1);
SetEntityPlayerInteractCallback("mansion_11", "doorgrunt", true);
SetPlayerLampOil(20);
if(ScriptDebugOn())
{
GiveItemFromFile("", "lantern");
for(int i;i<10;i++)
GiveItemFromFile("","tinderbox");
}
}
void UnlockDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 1, false);
RemoveItem(asItem);
}
void sounds1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_steps_big", "ScriptArea_3", 0, false);
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
}
void sounds2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_floor_17", false, false);
SetLampLit("candlestick_floor_16", false, false);
SetMessage("Hints", "blockhint", 5);
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "notice_long", "ScriptArea_2", 0, false);
SetSwingDoorClosed("mansion_3", true, true);
SetEntityPlayerInteractCallback("mansion_4", "doorspook", true);
}
void sounds3(string &in asParent, string &in asChild, int alState)
{
AddTimer("", 0, "manhorror");
AddTimer("", 2, "gruntslash");
}
void kaappi(string &in entity){
PlaySoundAtEntity("","21_screams", "cabinet_simple_1",0,false);
GiveSanityDamage(10, true);
}
void sounds5(string &in asParent, string &in asChild, int alState){
PlaySoundAtEntity("","15_the_big_scream", "ScriptArea_2", 0, false);
AddQuest("startquest", "startquest");
}
void TurnLampOff(string &in asParent, string &in asChild, int alState){
}
void sounds6(string &in asParent, string &in asChild, int alState){
PlaySoundAtEntity("","scare_human_noices","ScriptArea_1",0,false);
}
void OfficeKeyPicked(){
CompleteQuest("startquest", "end_startquest");
}
void manhorror(string &in asTimer){
PlaySoundAtEntity("","15_man_hunted", "ScriptArea_2", 0, false);
}
void gruntslash(string &in asTimer){
PlaySoundAtEntity("","amb_idle", "ScriptArea_2", 0, false);
PlaySoundAtEntity("","attack_claw_hit", "ScriptArea_2", 0, false);
}
void enemydisappear(string & asEntity){
SetEntityActive("servant_grunt_1", false);
AddDebugMessage("enemy disapperared", false);
}
void doorspook(string &in entity){
PlaySoundAtEntity("", "scare_steps_big", "ScriptArea_9", 0, false);
}
void doorgrunt(string &in entity){
SetEntityActive("1doorgrunt", true);
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_7", 5, "");
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_24", 0, "");
}
In case you wanted to know the bugged sound is 15_the_big_scream
RE: Strange script problem - Entih - 10-13-2010
I can't quite work out what could be wrong with it even looking right at it. I'll take a closer look when I get home from class, because now I'm curious.
RE: Strange script problem - SLi78 - 10-13-2010
(10-13-2010, 04:05 PM)ide Wrote: Code: void OnStart()
{
AddUseItemCallback("", "roomkey_1", "mansion_1", "UnlockDoor", true);
AddUseItemCallback("", "storagekey", "mansion_7", "UnlockDoor", true);
AddUseItemCallback("", "key_torture_chamber_1", "mansion_6", "UnlockDoor", true);
AddEntityCollideCallback("Player", "StepsArea_1", "sounds1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "sounds3", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "sounds2", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_6", "sounds5", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_7", "sounds6", true, 1);
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_4", "enemydisappear", true, 1);
SetEntityPlayerInteractCallback("mansion_11", "doorgrunt", true);
SetPlayerLampOil(20);
if(ScriptDebugOn())
{
GiveItemFromFile("", "lantern");
for(int i;i<10;i++)
GiveItemFromFile("","tinderbox");
}
}
void UnlockDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 1, false);
RemoveItem(asItem);
}
void sounds1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_steps_big", "ScriptArea_3", 0, false);
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
}
void sounds2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_floor_17", false, false);
SetLampLit("candlestick_floor_16", false, false);
SetMessage("Hints", "blockhint", 5);
GiveSanityDamage(10, true);
PlaySoundAtEntity("", "notice_long", "ScriptArea_2", 0, false);
SetSwingDoorClosed("mansion_3", true, true);
SetEntityPlayerInteractCallback("mansion_4", "doorspook", true);
}
void sounds3(string &in asParent, string &in asChild, int alState)
{
AddTimer("", 0, "manhorror");
AddTimer("", 2, "gruntslash");
}
void kaappi(string &in entity){
PlaySoundAtEntity("","21_screams", "cabinet_simple_1",0,false);
GiveSanityDamage(10, true);
}
void sounds5(string &in asParent, string &in asChild, int alState){
PlaySoundAtEntity("","15_the_big_scream", "ScriptArea_2", 0, false);
AddQuest("startquest", "startquest");
}
void TurnLampOff(string &in asParent, string &in asChild, int alState){
}
void sounds6(string &in asParent, string &in asChild, int alState){
PlaySoundAtEntity("","scare_human_noices","ScriptArea_1",0,false);
}
void OfficeKeyPicked(){
CompleteQuest("startquest", "end_startquest");
}
void manhorror(string &in asTimer){
PlaySoundAtEntity("","15_man_hunted", "ScriptArea_2", 0, false);
}
void gruntslash(string &in asTimer){
PlaySoundAtEntity("","amb_idle", "ScriptArea_2", 0, false);
PlaySoundAtEntity("","attack_claw_hit", "ScriptArea_2", 0, false);
}
void enemydisappear(string & asEntity){
SetEntityActive("servant_grunt_1", false);
AddDebugMessage("enemy disapperared", false);
}
void doorspook(string &in entity){
PlaySoundAtEntity("", "scare_steps_big", "ScriptArea_9", 0, false);
}
void doorgrunt(string &in entity){
SetEntityActive("1doorgrunt", true);
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_7", 5, "");
AddEnemyPatrolNode("1doorgrunt", "PathNodeArea_24", 0, "");
}
In case you wanted to know the bugged sound is 15_the_big_scream
Look in your OnStart
Code: AddEntityCollideCallback("Player", "ScriptArea_6", "sounds5", true, 1);
and your function
Code: void sounds5(string &in asParent, string &in asChild, int alState){
PlaySoundAtEntity("","15_the_big_scream", "ScriptArea_2", 0, false);
AddQuest("startquest", "startquest");
}
I think you missed the area, so its playing somewhere else.
|