02-06-2012, 04:16 AM
Hey guys.
I've got a bit of a scripting problem (or so it seems). What I want to have happen is the player picks up a key, walks into an area, and (since they have a key) the monster starts beaking down a door behind the player.
When I tested it, it didn't seem to work. Here's the whole .HPS file (it's not very big):
void OnStart()
{
SetEntityCallbackFunc("keytonextstage", "OnPickup");
AddUseItemCallback("", "keytostorageroomonedoor", "storageroomonedoor", "KeyOnDoorStorageRoomOneDoor", true);
AddEntityCollideCallback("Player", "furiousenemyspawn", "collidefuriousenemyspawn", true, 1);
}
void collidefuriousenemyspawn(string &in asParent, string &in asChild, int alState)
{
if(HasItem("keytostorageroomonedoor") == true)
{
SetEntityActive("furious_enemy", true);
ShowEnemyPlayerPosition("furious_enemy");
}
}
//void OnPickup(string &in asEntity, string &in type)
//{
// SetEntityActive("furious_enemy", true);
// ShowEnemyPlayerPosition("furious_enemy");
//}
void KeyOnDoorStorageRoomOneDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("storageroomonedoor", false, true);
PlaySoundAtEntity("", "unlock_door", "storageroomonedoor", 0, false);
RemoveItem("keytostorageroomonedoor");
}
void OnEnter()
{
}
void OnLeave()
{
}
The bolded parts are the key bits.
Is there any reason why this might not be working?
I've got a bit of a scripting problem (or so it seems). What I want to have happen is the player picks up a key, walks into an area, and (since they have a key) the monster starts beaking down a door behind the player.
When I tested it, it didn't seem to work. Here's the whole .HPS file (it's not very big):
Spoiler below!
void OnStart()
{
SetEntityCallbackFunc("keytonextstage", "OnPickup");
AddUseItemCallback("", "keytostorageroomonedoor", "storageroomonedoor", "KeyOnDoorStorageRoomOneDoor", true);
AddEntityCollideCallback("Player", "furiousenemyspawn", "collidefuriousenemyspawn", true, 1);
}
void collidefuriousenemyspawn(string &in asParent, string &in asChild, int alState)
{
if(HasItem("keytostorageroomonedoor") == true)
{
SetEntityActive("furious_enemy", true);
ShowEnemyPlayerPosition("furious_enemy");
}
}
//void OnPickup(string &in asEntity, string &in type)
//{
// SetEntityActive("furious_enemy", true);
// ShowEnemyPlayerPosition("furious_enemy");
//}
void KeyOnDoorStorageRoomOneDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("storageroomonedoor", false, true);
PlaySoundAtEntity("", "unlock_door", "storageroomonedoor", 0, false);
RemoveItem("keytostorageroomonedoor");
}
void OnEnter()
{
}
void OnLeave()
{
}
The bolded parts are the key bits.
Is there any reason why this might not be working?