MsHannerBananer
Member
Posts: 218
Threads: 34
Joined: Sep 2013
Reputation:
10
|
[Solved, sort of] Grunt Not Disappearing
I have a script set up where the player sees a grunt, or as she describes it, "creature" from down a hall. The thing is scripted to appear, cross through a doorway, and then hits a script box that deactivates it. I felt it was better than making the grunt a hallucination, because you can here the poofing sound and see the dust. I wanted to make it a clean magic trick and have the grunt just plain ol' disappear.
Script is below. My names match and everything, but I feel like I'm missing something. I recently put in some hammer+chipper script, so I don't know if something's messing with it or what. I just need a second, third, and fourth set of eyes to make sure I haven't done anything wrong.
NOTE: The script WORKED ONCE. The FIRST time I tested and before I put in any hammer+chipper stuff, the script actually worked.
int Swings = 0;
void OnStart() { AddEntityCollideCallback("Player", "seeShadow", "See_Grunt",true, 1); AddEntityCollideCallback("silent_grunt", "silent_grunt_gone", "Disable_Grunt",true, 1); AddEntityCollideCallback("Player", "MapChange", "ChangeMap", false, 1); AddUseItemCallback("", "stone_hammer_chipper", "breakstone_1", "Break_Rock", true); }
void OnEnter() {
}
void OnLeave() {
}
//GRUNT//
void See_Grunt(string &in asParent, string &in asChild, int alState) { SetPlayerActive(false); StartPlayerLookAt("silent_grunt", 2.0f, 4.0f, "See_Grunt_Walk"); }
void See_Grunt_Walk() { SetEntityActive("silent_grunt", true); AddTimer("endwalkTimer", 8.0f, "End_Walk_Timer"); SetEnemyDisableTriggers("silent_grunt", true); AddEnemyPatrolNode("silent_grunt", "silent_path_3", 0.1f, ""); AddEnemyPatrolNode("silent_grunt", "silent_path_5", 0.1f, ""); AddEnemyPatrolNode("silent_grunt", "silent_path_7", 0.1f, ""); AddEnemyPatrolNode("silent_grunt", "silent_path_8", 0.1f, ""); }
void Disable_Grunt(string &in asParent, string &in asChild, int alState) { SetEntityActive("silent_grunt", false); }
void End_Walk_Timer(string &in asTimer) { SetPlayerActive(true); StopPlayerLookAt(); }
//CHANGE MAP//
void ChangeMap(string &in asParent, string &in asChild, int alState) { ChangeMap("014_wateroffice.map", "PlayerStartArea_1", "", ""); }
//HAMMER CHIPPER//
void Break_Rock(string &in asItem, string &in asEntity) { Swings = 1; SetEntityActive("move_hammer", true); SetEntityActive("rock_chipper", true); StartPlayerLookAt("move_hammer", 2, 2, ""); AddTimer("hammermove", 0.1, "MoveHammerTimer"); AddTimer("hammersound", 0.27, "MoveHammerTimer"); AddTimer("hammerreset", 0.4, "MoveHammerTimer"); AddTimer("hammerrepeat", 0.6, "MoveHammerTimer"); }
void MoveHammerTimer(string &in asTimer) { if(asTimer == "hammermove") SetMoveObjectState("move_hammer", 0.4); else if(asTimer == "hammersound") { StopPlayerLookAt(); PlaySoundAtEntity("", "impact_rock_high", "breakstone_1", 0, false); PlaySoundAtEntity("", "15_hammer", "Player", 0, false); } else if(asTimer =="hammerreset") SetMoveObjectState("move_hammer", 0); if(Swings < 3 && asTimer =="hammerrepeat") { AddTimer("hammermove", 0.01, "MoveHammerTimer"); AddTimer("hammersound", 0.17, "MoveHammerTimer"); AddTimer("hammerreset", 0.3, "MoveHammerTimer"); AddTimer("hammerrepeat", 0.5, "MoveHammerTimer"); Swings = Swings + 1; } else if(Swings == 3 && asTimer =="hammerrepeat") { AddTimer("hammermove", 0.2, "MoveHammerTimer"); AddTimer("hammersound", 0.37, "MoveHammerTimer"); AddTimer("hammerreset", 0.5, "MoveHammerTimer"); AddTimer("hammerrepeat", 0.8, "MoveHammerTimer"); AddTimer("Break", 0.42, "MoveHammerTimer"); Swings = Swings + 1; } else if(Swings == 4 && asTimer =="Break") { Break_Rocks_Complete(); SetEntityActive("move_hammer", false); SetEntityActive("rock_chipper", false); } }
void Break_Rocks_Complete() { SetEntityActive("breakstone_1", false); SetEntityActive("breakstone_2", false); SetEntityActive("med_rock_1", true); SetEntityActive("med_rock_2", true); SetEntityActive("med_rock_3", true); SetEntityActive("large_rock_1", true); SetEntityActive("large_rock_2", true); SetEntityActive("large_rock_3", true); SetEntityActive("small_rock_1", true); SetEntityActive("small_rock_2", true); SetEntityActive("small_rock_3", true); SetEntityActive("small_rock_4", true); SetEntityActive("small_rock_5", true); SetEntityActive("small_rock_6", true); SetEntityActive("small_rock_7", true); SetEntityActive("small_rock_8", true); SetEntityActive("small_rock_9", true); SetEntityActive("small_rock_10", true); CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "breakrock_dust", false); PlaySoundAtEntity("", "25_break_rock", "Player", 0, false); }
|
|
06-19-2014, 02:44 AM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Grunt Not Disappearing
I see no reason for it to not work. If the grunt successfully follows the path, then the script is running fine. The only thing that can maybe be the issue, is the area the grunt collides with. Perhaps it's too small or something wrong with it? Did you modify it?
All I can think of is that the "disable grunt" callback isn't called.
|
|
06-19-2014, 02:51 AM |
|
MsHannerBananer
Member
Posts: 218
Threads: 34
Joined: Sep 2013
Reputation:
10
|
RE: Grunt Not Disappearing
(06-19-2014, 02:51 AM)Mudbill Wrote: I see no reason for it to not work. If the grunt successfully follows the path, then the script is running fine. The only thing that can maybe be the issue, is the area the grunt collides with. Perhaps it's too small or something wrong with it? Did you modify it?
All I can think of is that the "disable grunt" callback isn't called.
For some reason you managed to remind me to exhaust my options completely before I post my problems, which... is something I don't seem capable of doing when it comes to scripting with Amnesia. *Epic Facepalm*
I just set up a timer that disabled the enemy after a certain amount of seconds, and although the first time I put was a little too long, it worked.
For some reason my callback isn't calling for the enemy to be disabled, despite multiple attempts to copy and paste names from the level editor to the .hps file to prevent mismatched names. I've deleted the collide completely, and I'm going to time it so the grunt is disabled via timer.
Normally, I solve mysterious problems like these myself by exhausting my resources completely and going around those problems with other scripts, even though it might be unorthodox and taxing. This is one of the few occasions I didn't at first, but everything worked out in the end.
I feel a little embarrassed with myself that I posted this without even thinking about using other methods.
Now my only problem is finding out why the collide area didn't work...
|
|
06-19-2014, 03:15 AM |
|
Romulator
Not Tech Support ;-)
Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation:
195
|
RE: [Solved, sort of] Grunt Not Disappearing
The only thing I can think of is if the grunt is in sight. If the player can see the grunt, they won't just vanish at the end of the pathnode allocated. But you seem to compensate with the SetEntityActive script anyway.
I think in the Model Editor, there is an option in the grunt's settings to disable them at the end of their allocated pathnode path, something like AutoRemoveAtEnd. If that's true, then I don't see why it shouldn't vanish unless it is in the Player's vision.
Have you tried setting the grunt collision event alState (in the CollideCallback) to 0? So when it enters or leaves the script_area, it can disable it otherwise?
Till then, the timer is probably a good use to compensate.
Probably not much help, but just within my experiences.
Discord: Romulator#0001
|
|
06-19-2014, 07:23 AM |
|
Acies
Posting Freak
Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation:
73
|
RE: [Solved, sort of] Grunt Not Disappearing
Some random guesses:
Does the collision area have a negative scale/size? Has it automatically added a "_1" at the end? Could you have done a 'save and exit' once the grunt was removed once? That might have disabled areas, but the grunt spawns nevertheless due to 'a callback function added in the leveleditor'.
ジ
|
|
06-19-2014, 02:21 PM |
|
|