Wow, that's complicated. Alright, I'll give it a shot and tell you how it goes.
Thanks for the help.
Ugh... I can't see the image you posted... it may be a problem on my end.
So there are supposed to be two separate skull entities, and the ones on the floor are supposed to be dyn, but where are the static ones supposed to be? Are they both in the same place, or are the static skulls already in the positions in the drawing?
(This post was last modified: 05-05-2011, 10:55 PM by dragonlordsd.)
The ones on the floor are static (player is not able to move those) while the ones which are dyn (dynamic = movable) are the ones which the player move around. Ill reupload the image on this site.
The script "deactivate" the skulls which are moveable when they come close to the sticky area and "activate" the skulls which are unmovable. Thus, when the player moves one of the skulls close to the position you want that skull "clicks" into place and becomes unmovable.
You can place the dynamic skulls where you wish The static (stuck ones) set previously at the positions/places of the ritual by you. The static skulls should be set to be "deactivated" (= invisible for the player), and once activated becomes visible!
If you want to you could send me your map and I will do one of the sticky-areas for you. Perhaps that will make it clearer
ジ
(This post was last modified: 05-06-2011, 12:37 AM by Acies.)
alright, thanks, I understand now! I was confused because right now the dyn skulls are sitting on the floor, so I thought those were the ones you meant. Thanks for the help
When an item gets attached to a sticky area, it should become "static" anyway if you disable the detachable property. It may be worth considering the following approach:
Have 3 skulls - which the player can move; in this example named moveSkull_1 through moveSkull_3.
Next we create a sticky area, which will have the "attachable body name" feild set to "moveSkull_" - this means any of the skulls can be attached to this area. We also want to make the area call a function when a skull is added to the area - to do so we shall set the "attach function" feild to "cbSkullAttach" - which we shall create next.
Duplicate this sticky area until you have enough and position the new areas where you want 'em to go - make sure they are active. Feel free to play about with the other settings, though if you plan on making the skulls detachable you will also have to add a detatch callback for reasons that should become apparent.
Now it is time to do the scripting. In your hps file add the following function:
//Note: In your onStart() function, you will need to initialise
//The "skullsAttached" variable to 0 (or whatever).
void cbSkullAttach(string &in asArea, string &in asEntity) {
//Register that a skull was attached
int skulls = GetLocalVarInt("skullsAttached") +1;
SetLocalVarInt("skullsAttached", skulls);
//See if all the areas are occupied by a skull
if ( skulls >=3 )
{ <code> }
}
This will act as the callback for whenever any of the sticky areas are fired - we don't really care which are fired, or by what objects (as we know the only objects that will trigger the attaches are our skulls). We don't even really care about the order of attachment.
The beauty of this approach, is that you can have an arbitrarily high number of skulls or areas (just change the 3 to whatever). You can also have more skulls than areas and allow any of them to be used - which may be more realistic. You can also make specific skulls for specific areas by simply changing the what name of object the sticky area looks for. But what if you want to have a tonne of skulls and skull areas, or edit the puzzle lots and not really wan't to fuss about changing some numbers in a script?
Spoiler below!
As this isn't strictly necessary to your problem, i have placed it in spoiler tags. Let us assume you have named your sticky areas "skullArea_<x>" - where <x> is the number of that area, starting at 0, and ending at however many areas there are (Duplication of the area will auto-increment this number for you automatically!). If that is the case, our code can be improved:
//Returns however many entities matching a signature there are
int countEntities(string signature) {
int output=0;
for(;GetEntityExists(signature+output);output++){}
return output;
}
void cbSkullAttach(string &in asArea, string &in asEntity) {
//Register that a skull was attached
int skulls = GetLocalVarInt("skullsAttached") +1;
SetLocalVarInt("skullsAttached", skulls);
//See if all the areas are occupied by a skull
if ( skulls >= countEntities("skullArea_") )
{ <code> }
}
This allows you to add and remove areas, and skulls from the map without changing or touching the script. Provided you have enough skulls for the areas, and the naming matches what you are testing for, this will always work.
Edit: Improved the scripts a little, and added a few more notes.
Edit 2: Thanks, Acies
(This post was last modified: 05-06-2011, 03:23 AM by Apjjm.)
Apjjm's method is better, since it is "generic" (hope that is the english word for it). My method makes you apply Skull A to Area A, while Appjm's method allows you to apply Skull A to Area A, Area B and Area C.
Off-Topic: Apjjm, you really know how to script
ジ
(This post was last modified: 05-06-2011, 03:10 AM by Acies.)