Player shoot directions

kdo

Member
Is there a way to player shoot projectiles in all directions? I need  shoot up,down, right and left....If im correct, i saw something like this in contra lock'n loaded..... is it just possible with scrip? thanks
 
I just started messing around with adding in created scripts, so apologies if I'm wrong, but Bloodbane has a script in the downloads section (simple + useful scripts) with this function :

- shooter {projectilename} {x} {y} {z} {Vx} {Vy} {Vz}
Shoot projectile from certain distance and with certain speed
projectilename = name of shot projectile
x = x distance relative to char
y = y distance relative to char
z = z distance relative to char
Vx = x velocity
Vy = y velocity
Vz = z velocity


maybe that is what you are after.
 
Thank handsnfeetface ....i'll see if its work for me....btw.... im doing a topdown game and i need to give the player the ability to shoot projectiles when pick up a weapon in up, down right and left direction , i know how to do this with attack, cancels and freespecials, but this way its hasnt a weapon behavior like bullet counts and reload with a item... thanks again
 
Actually, the shooter function posted above only controls where projectile will be fired to. It's not linked with direction keys so for topdown view game, you need more than just that function
 
I don't know how you control facing direction for your topdown game. If you can define animations for walking north, northeast, east and so on without script then shooter function is sufficient. But if you can't, you need script for the former, something like this function:

Code:
void keyint(void Ani, int Frame, void Key, int Hflag)
{// Change current animation if proper key is pressed or released
// Animation is changed to attack mode

    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int iPIndex = getentityproperty(self,"playerindex"); //Get player index
    void iRKey;

      if (Key=="U"){ //Up Required?
        iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
      } else if (Key=="D"){ //Down Required?
        iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
      } else if (Key=="L"){ //Left Required?
        iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
      } else if (Key=="R"){ //Right Required?
        iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
      } else if (Key=="F"){ //Forward Required?
        if (Dir == 0){ // Facing Left?
          iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
        } else { // Facing Right
          iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
        }
      } else if (Key=="B"){ //Backward Required?
        if (Dir == 1){ // Facing Right?
          iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
        } else { // Facing Left
          iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
        }
      } else if (Key=="J"){ //Jump Required?
        iRKey = playerkeys(iPIndex, 0, "jump"); // "Jump"
      } else if (Key=="A"){ //Attack Required?
        iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
      } else if (Key=="S"){ //Special Required?
        iRKey = playerkeys(iPIndex, 0, "special"); // "Special"
      }

      if (Hflag==1){ //Not holding the button case?
        iRKey = !iRKey; //Take the opposite condition
      }

      if (iRKey){
        if (Ani=="ANI_IDLE"){ // Going idle?
          setidle(self, openborconstant("ANI_IDLE")); //Be idle!
        } else {
          performattack(self, openborconstant(Ani)); //Change the animation
        }
        updateframe(self, Frame); //Change frame
      }
}

this function changes animation if defined key is held (or released depends on setting)
 
Cool..... what i heve to do to mke it works? :-[
My topdown  sytem is based on Nicks topdown ....  but i implemented some things like backwalk and backwalk attack... buts its still using  anim up and anim down and cancel freespecial to make some attack...but  once i put the cancel i cant use nothing else like cutsknife or throwfreme ... im geting creazy hear....any way...thanks  Bloodbane... i need to understand how to make your function work...and know if it works in this topdown system.
 
usage
Code:
@cmd keyint {animation} {frame} {key} {Hflag}

You would add it to your IDLE anim.  Instead of UP/DOWN animations you create FOLLOW anims.  Check if key is held down for walking animations, then for the UP/DOWN idle anims you would check when key is released.  You will also need to add velocity script in the custom walking anims.

There's also a script by MatMan from his mixmasters mod, I used in it my Doom mod so you can shoot/attack while moving.  It might be useful for your game.  I've posted it at the bottom, It also requires aniscp.c from mixmasters mod. Which was too large to post.


There's also a way with his scripts to create an auto fire attack, also useful for making machine guns etc.


AUTO FIRE / AUTO ATTACK

Code:
void changeanibykeytoattackforself(void Ani, int Frame, void Key, int Hflag, int Limit)
{// Change current animation if proper key is pressed or released provided HP is more than limit
// V0.07
// Matman
    void self = getlocalvar("self");
    if ( checkent(self) == 1 ) {
      changeanibykeytoattack(self, Ani, Frame, Key, Hflag, Limit);
    }
}


For example if your shooting animation is ATTACK, you can make a copy of it as ATTACK2 and add this command to each animation.  Now when you hold down the ATTACK key it will cycle both animations.  You can add a delay in the last frame

IN ATTACK1 ANIM
Code:
@cmd	changeanibykeytoattackforself "ANI_Attack2" 0 "A" 0 0

IN ATTACK2 ANIM
Code:
@cmd	changeanibykeytoattackforself "ANI_Attack1" 0 "A" 0 0


EXAMPLE

Code:
anim	attack1
	offset	56 112
	loop  0
	delay	12
	bbox	32 12 45 108
	frame	data/chars/doomguy/pistol/e3.png
	bbox	52 12 45 108
	offset	76 112
	sound	data/sfx/dspistol.wav
	@cmd	projectile 1 "Bullet" 72 1 88
	frame	data/chars/doomguy/pistol/f3.png
	bbox	32 12 45 108
	offset	56 112
	frame	data/chars/doomguy/pistol/e3.png
	@cmd	changeanibykeytoattackforself "ANI_Attack2" 0 "A" 0 0
	frame	data/chars/doomguy/pistol/e3.png
		
anim	attack2
	offset	56 112
	loop	0
	delay	12
	bbox	32 12 45 108
	frame	data/chars/doomguy/pistol/e3.png
	bbox	52 12 45 108
	sound	data/sfx/dspistol.wav
	offset	76 112
	@cmd	projectile 1 "Bullet" 72 1 88
	frame	data/chars/doomguy/pistol/f3.png
	bbox	32 12 45 108
	offset	56 112
	frame	data/chars/doomguy/pistol/e3.png
	@cmd	changeanibykeytoattackforself "ANI_Attack1" 0 "A" 0 0
	frame	data/chars/doomguy/pistol/e3.png



MOVE WHILE ATTACKING

declare in player model
Code:
keyscript	 	data/scripts/ky.c

ky.c - (Can be renamed if you want) 
Code:
// Script for moving while attacking.
#import "data/scripts/aniScp.c"

void main(){
  // get variables ready
  int player = getlocalvar("player");
  
  void self = getplayerproperty(player, "ent");
  int anim = getentityproperty(self, "animationid");
  /*
  if ( anim == openborconstant("ANI_IDLE")
     || anim == openborconstant("ANI_WALK")
     || anim == openborconstant("ANI_RUN")
     || anim == openborconstant("ANI_Faint") )
          {
            if ( checkkeycombo(self, "A", 0) ) {
              performattack(self, openborconstant("ANI_Attack1"), 1);
            }
          }
  */

  //I'm sure there is a better way of doing this but....
  if ( anim == openborconstant("ANI_Attack1" )
      || anim == openborconstant("ANI_Attack2")
      || anim == openborconstant("ANI_Attack3") ) {

    if ( checkkeycombo(self, "UF", 0) ) {
      tossself(0, -1, 0, -0.5);
    } else
    if ( checkkeycombo(self, "UB", 0) ) {
      tossself(0, 1, 0, -0.5);
    } else
    if ( checkkeycombo(self, "DF", 0) ) {
      tossself(0, -1, 0, 0.5);
    } else
    if ( checkkeycombo(self, "DB", 0) ) {
      tossself(0, 1, 0, 0.5);
    } else
    if ( checkkeycombo(self, "F", 0) ) {
      tossself(0, -1, 0, 0);
    } else
    if ( checkkeycombo(self, "B", 0) ) {
      tossself(0, 1, 0, 0);
    } else
    if ( checkkeycombo(self, "U", 0) ) {
      tossself(0, 0, 0, -0.5);
    } else
    if ( checkkeycombo(self, "D", 0) ) {
      tossself(0, 0, 0, 0.5);
    }
  }

}

You'll also need to edit the velocity values and the animation names to suit your mod.

Hope this helps.
 
BTW you can edit the range value in BACKWALK to affect how close to enemies you need to be before backwalk kicks in.  The same applies for IDLE animations.

Code:
range {min} {max}

With the auto attack and attack while moving script it should handle the walking backwards and shooting.  Otherwise the best method is actually how Bloodbane did his Contra mod, thou it 's a lot harder to setup.
 
Thank you so much BeasTie by all your help and atention with me ....i'll try to use all this ...is some there some mod that use something like this?
Would be nice to see it working....btw...i'll try just like you teached... thanks again!!!

Ahhh! just to say...im doing a Metal Gear Solid V Phantom Pain bor mod ... with a semi open world, it is top down and the player has 3 tipes of gun an 1 punch... just the punch works, abaout the guns, player has the and walk with it in hands by...no shoot....iet...sooner i'll upload some images and video..just need to solve some problems like shoot... ;)
 
Sorry the info is a bit condensed, I just didn't have time to explain in more detail. 

Bloodbane's Contra mod would be the best to study and it's also complete.  Thou the method is a bit more involved, it's basically the same as what I mentioned with custom walks. 

He uses the keyint script plus a series of custom animations so he can have shooting while walking for multiple directions.  The concept is fairly simple, it just takes a bit of setup.  I've done it once before but I needed Bloodbane to explain what was going on in his mod for me.  I'll try to dig out his PM's where he explained the system.

Feel free to send me your mod if you like, I can probably understand it better by taking a look.

Is the game planning to be something like this type of view?
True%20Lies%20(G).png

True Lies SNES - https://en.wikipedia.org/wiki/True_Lies_(video_game)

Or perfect topdown like this?
Alien%20Breed_2.png

Alien Breed (PC/DOS) - http://www.abandonia.com/en/games/425/Alien+Breed.html (this game is abandonware so you can download it)
 
I've always wanted that RPG style where you move directions like you said in True Lies style. Did you check out with slash128's Demon Sluga mod? There's that type where you can move around in almost specific directions in one of the modes. You can use any follow animation if you want specific diagonal directions with scripts. That way, it will play like True Lies or Zelda.
 
Otherwise the best method is actually how Bloodbane did his Contra mod, thou it 's a lot harder to setup.

It's harder to setup cause I have to switch between multiple animations. BTW Contra uses seperate animations for these: walk, walk shoot, walk aim up, walk shoot up, stand, aim up and so on
In Aliens Clash, script setting was simple cause both Rode and Brue doesn't switch animation when shooting
 
  Thank @maxman. @Bloodbane and @BeasTie by all atention and answers... i need to take a look in all mods thet were mentioned...i have pakexplod somes...but the scripts are too hard for me...i have no talent to codes just for graphics....btw i'll try to do like you said.
Beastie im using  rame to idle animation  3 frames to walk up 3 to walk down 3 to walk right and 3 to walk left.... 1 to death and repeating aal this to fall,rise,pain....
 
Back
Top Bottom