Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm setting up a script, and am trying to help a friend with theirs by adding in to where while the player is holding down "key" they are blocking, when they are pressing and holding down the left mouse button, they will prepare a bash,

it works like this, "bashStart" triggers a bash preparation animation, similar to power attacks where you hold down the attack button. "ReleaseBash" is when the actual bashing happens.

However, I just can't seem to get it to work. The game reads "key" and "key2" but I don't think the game reads "WM_LBUTTONDOWN". Here is what I got so far.

while (TRUE)
    {

        CActor *player = Game::GetPlayer();
        TESIdleForm *blockAnim = (TESIdleForm *)dyn_cast(Game::GetFormById(ID_TESIdleForms::BlockStart), "TESForm", "TESIdleForm");
        TESIdleForm *stopBlockAnim = (TESIdleForm *)dyn_cast(Game::GetFormById(ID_TESIdleForms::StopBlocking), "TESForm", "TESIdleForm");
        TESIdleForm *bashAnim = (TESIdleForm *)dyn_cast(Game::GetFormById(ID_TESIdleForms::bashStart), "TESForm", "TESIdleForm");
        TESIdleForm *releasebashAnim = (TESIdleForm *)dyn_cast(Game::GetFormById(ID_TESIdleForms::ReleaseBash), "TESForm", "TESIdleForm");

        if (GetKeyPressed(key)) 
        {
            Actor::PlayIdle(player, blockAnim);
            wasBlocking=true;
        }

        if (GetAsyncKeyState(WM_LBUTTONDOWN) && wasBlocking)
        {
            Actor::PlayIdle(player, bashAnim);
            wasBlocking=true;
        }

        if (!GetAsyncKeyState(WM_LBUTTONDOWN) && wasBlocking)
        {
            Actor::PlayIdle(player, releasebashAnim);
        }

        if(!GetKeyPressed(key) && wasBlocking)
        {
            Actor::PlayIdle(player, stopBlockAnim);
            wasBlocking=false;
        }

        Wait(0); // In order to switch between script threads Wait() must be called anyway

    }
}
share|improve this question
    
"I'm setting up a script, and am trying to help a friend with theirs by adding in to where while the player is holding down "key" they are blocking, when they are pressing and holding down the left mouse button, they will prepare a bash, it works like this, "bashStart" triggers a bash preparation animation, similar to power attacks where you hold down the attack button. "ReleaseBash" is when the actual bashing happens." I don't understand this. Could you revisit the paragraph? –  sm4 Jun 14 '13 at 9:25
    
There are keys that a friend of mine set, which was "key" and "key2", these are supposed to be configurable, and "key" activates blocking within the game, which the game in question is skyrim by the way. I wanted to add bashing, remember, there are two animations that happen with bashing in this game, bashStart, and ReleaseBash, "bashStart" begins the bashing preparation, similar to how in some games you hold down the attack button to perform a power attack. "ReleaseBash" performs the actual bashing animation. I am running out of space so let me make another comment. –  Jeremy Jun 14 '13 at 9:33
    
What I'm trying to get is to get the player to bash by releasing the left mouse button. You are familiar with how power attacks work in some games right? This is difficult to explain as it is so please bear with my example. In some games there is the standard click to attack, and some other games have the click and hold power, and you can release it at anytime in between to perform a standard attack. I want that, but for bashing in this game. Bashing like, with a shield, sword, etc, being familiar with skyrim would also help in answering this question. –  Jeremy Jun 14 '13 at 9:37
1  
It seems you can only start a power attack if you are already blocking, is this the desired behaviour? –  gareththegeek Jun 14 '13 at 10:37
    
no, there is no power attack here, that was just an example of something similar that I'm trying to go for. Bashing is the desired behaviour. What I want is a click and hold, remember there are two animations, where the bashing is prepared(you're holding down the bashing button), and then when you release the bashing button, it performs the actual bashing. youtube.com/watch?v=5akL95pWnbE See this video for example, do you see the guy hitting the person with their shield? If you pay careful attention, it's not one animation, but two, it goes back, then hits. –  Jeremy Jun 14 '13 at 11:07
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.