Author Topic: Can someone help me script this? PC "falls unconcious" and then loads a new area.  (Read 341 times)

Legacy_simo7mate

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0


                How I first tried to tackle this is applying knock down effect then teleporting PC to a waypoint named go11 

However, upon testing in game, all it did was knock him down and the converstation ended. Will it work if I add a delay command or something. If so, how? 
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0


               Not sure but you may want to "knock em down", fade to black, clear the action que, then port em, then fade from black. It may be the knock down is tying up the action que, and thereby voiding the port, which a player can do by running and such at times. So fade em out and clear their que, the fade to black will keep them from seeing their char getting back up.
               
               

               
            

Legacy_simo7mate

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0


               This is the script I tried

void main()
{

object oPC = GetPCSpeaker();

object oTarget;
oTarget = oPC;

effect eEffect;
eEffect = EffectKnockdown();

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 10.0f);

FadeToBlack(oPC);

AssignCommand(oPC, ClearAllActions());

location lTarget;
oTarget = GetWaypointByTag("go11");

lTarget = GetLocation(oTarget);

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

AssignCommand(oPC, ActionJumpToLocation(lTarget));

}

Didn't work. It knocked him down, fade to black and stayed like that.
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0


               Instead of applying an effect, have him play the fall forward dead front animation.
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0


               I don't see a fadeFromBlack... ....


Have a look at this page: Fade to Black

EDIT:  For that matter I am not sure that performing some other action in the queue after knockdown will end the knockdown effect.  IE the teleport may cancel the effect, you may need to apply the knockdown again after teleportation.
               
               

               


                     Modifié par Calvinthesneak, 27 juin 2011 - 12:18 .
                     
                  


            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0


               Also, when ClearAllActions() happens the final action in the queue which is ActionJumpToLocation will be removed from the queue.  So, the jump should never happen.

The result should be:
1) Fade to Black
2) Queue up the actions:  ClearAllActions, ClearAllActions, ActionJumpToLocation
3) Do first action: ClearAllActions, which removes the last 2 actions from the queue

Now the PCs action queue is empty so nothing more happens.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0


               ClearAllActions is instant and it wont queue up. Clearing actions is anyway rather pointless in this case, because being knocked down does pretty much the same thing. Also you are clearing actions twice, which is double the pointlessness. (Is that a word?)

Clear actions only affects actions queued at the precise moment it is called, and it does not go through the queue. This means even if you delay an action, it won't be removed, because it is not yet in the queue.

--> They wont affect ActionJump in this script because it will be queued after actions are cleared.

Im not sure if ActionJump works if you are knocked down, try using JumpToLocation instead.
               
               

               


                     Modifié par Xardex, 28 juin 2011 - 09:39 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0


               

Xardex wrote...

.......... double the pointlessness. (Is that a word?)
........


It came out your mouth didn't it, that makes it a word.
               
               

               
            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0


               The knockdown is in effect for 10 seconds. The jump, not being delayed, is attempted immediately. Since the player is knocked down he isn't going to be able to jump anywhere (or do anything else at all for that mattter except be knocked down) so the jump command simply fails due to his knocked down condition at the time.

Try something like this instead:
[nwscript]void main()
{ object oPC       = GetPCSpeaker();
  object oWaypoint = GetWaypointByTag( "go11" );
  if( !GetIsPC( oPC ) || !GetIsObjectValid( oWaypoint )) return;
 
  // PC and waypoint are both found, so assign him a new set of actions that:
  // 1) knock him down for 10 seconds (probably too long for this)
  // 2) fade his screen to black
  // 3) wait at black screen until knockdown effect wears off so he can jump again
  // 4) jump him to the waypoint
  // 5) fade his screen back in
  // 6) unlock his action queue so he can operate his mouse and keyboard again.
  //
  // Finally, lock his action queue so the actions just given to him cannot be interrupted
  // using a mouse click or keypress like ESC before they all complete.
  //
  AssignCommand( oPC, ClearAllActions() );
  AssignCommand( oPC, ActionDoCommand( ApplyEffectToObject( DURATION_TYPE_TEMPORARY, EffectKnockdown(), oPC, 10.0f )));
  AssignCommand( oPC, ActionDoCommand( FadeToBlack( oPC )));
  AssignCommand( oPC, ActionWait( 11.0 ));
  AssignCommand( oPC, ActionJumpToObject( oWaypoint ));
  AssignCommand( oPC, ActionDoCommand( FadeFromBlack( oPC )));
  AssignCommand( oPC, ActionDoCommand( SetCommandable( TRUE, oPC )));
 
  // lock action queue
  AssignCommand( oPC, SetCommandable( FALSE, oPC ));
}[/nwscript]
Note: If the PC is immune to knockdown effect, he won't be knocked down. You may want to consider using ActionPlayAnimation using ANIMATION_LOOPING_DEAD_BACK or DEAD_FRONT instead to put him on the ground.
               
               

               
            

Legacy_Vivienne L

  • Full Member
  • ***
  • Posts: 130
  • Karma: +0/-0


               I've done something similar in my module via cutscene using gestalt cutscene script:
#include "in_g_cutscene"
void main()

code for cutscene...blah blah......very long attack sequence...
GestaltActionAnimate (27.0, oPC, ANIMATION_LOOPING_DEAD_FRONT, 11.0, 1.0);
// Fade to black   (camera starts fading out as PC falls)
   GestaltCameraFade       (26.0, oPC,   FADE_CROSS,FADE_SPEED_MEDIUM,6.0);
// End cutscene  (camera is still faded out when PC is transported to the waypoint in another area:)
   GestaltStopCutscene     (31.0, oPC, "WP_INN_PC");
The above is not the complete script which seemed too long to post, just the relevant parts of the script made more than a year ago...

in the on enter script for the inn which i copied from somewhere:  partial code:
{
   FadeFromBlack (GetFirstPC());
}
// fade in
       DelayCommand (2.5f, fade_in());

This works perfectly but the only problem is that every time the PC enters the inn there is an unnecessary fade in.  I also placed a trigger around the waypoint and had this in the on enter script:
 void main() // This is the full script; it also empties the inventory and brings down hitpoints.  I copied and altered this from somewhere too and was just thinking that maybe i should add the fade in here as well instead because this script only runs once:
{
   object oPC = GetEnteringObject();

   if (!GetIsPC(oPC)) return;

   int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));

   if (DoOnce==TRUE) return;

   SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);

   effect eEffect;
   object me = GetFirstPC();
   int n = GetCurrentHitPoints (me) - 1;

   if (n > 0){
       eEffect = EffectDamage (n, DAMAGE_TYPE_PIERCING, DAMAGE_POWER_PLUS_TWENTY);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, me);

SetTime (55, 0, 0, 0);

DelayCommand (1.0f, AssignCommand (me, ActionPlayAnimation (ANIMATION_LOOPING_DEAD_BACK, 1.0f, 180000.0f)));

   object oItem = GetFirstItemInInventory(oPC);

    while (GetIsObjectValid(oItem))
    {
         DestroyObject(oItem);
         oItem = GetNextItemInInventory(oPC);
    }
    int nSlot;
    for (nSlot = 0; nSlot < INVENTORY_SLOT_BOLTS; nSlot++)
    {
         oItem = GetItemInSlot(nSlot, oPC);
         DestroyObject(oItem);
    }



object oPJs = CreateItemOnObject("tornrags", oPC);


DelayCommand(0.5, AssignCommand(oPC, ActionEquipItem(oPJs, INVENTORY_SLOT_CHEST)));
   }
}

the "tornrags" is a custom item but you could substitute whatever you want
I hope this helps!