Jump to content

Photo

help with finding out lweapons flip and tile offsets


  • Please log in to reply
3 replies to this topic

#1 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 08 January 2017 - 12:05 AM

can someone help me find out my swords flip and tile offsets?

I have two functions for it but I link's directions are very different from the sword's 

 

here is my code

 

Spoiler

 

this is a example of the way I want the tiles to be set up

http://imgur.com/a/jxCm7



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 January 2017 - 04:21 AM

What did you base this on?
 
First, let me point out something that will save some stack space, and speed up some assembly instructions:
 
void FindOffset(int linkdir, int sworddir, int maxsworddir)
{
int offset;
int dir = (sworddir + (maxsworddir * 2)) mod maxsworddir;
 
if (dir == 0)      { offset = 0; } //Up
else if (dir == 1) { offset = 5; } //Up Left
else if (dir == 2) { offset = 1; } //Left
else if (dir == 3) { offset = 6; } //Left Down
else if (dir == 4) { offset = 0; } //Down
else if (dir == 5) { offset = 7; } //Down Right
else if (dir == 6) { offset = 1; } //Right
else if (dir == 7) { offset = 8; } //Right Up
return offset;
}

You do not need to declare a variable here, assign it, and return it. You can simply return the desired value:
void FindOffset(int linkdir, int sworddir, int maxsworddir)
{
int dir = (sworddir + (maxsworddir * 2)) mod maxsworddir;
 
if (dir == 0)      { return 0; } //Up
else if (dir == 1) { return 5; } //Up Left
else if (dir == 2) { return 1; } //Left
else if (dir == 3) { return 6; } //Left Down
else if (dir == 4) { return 0; } //Down
else if (dir == 5) { return 7; } //Down Right
else if (dir == 6) { return 1; } //Right
else if (dir == 7) { return 8; } //Right Up
else return -1; //Default if the dir input is not 0 to 7, and thus an error. 
//If you do not want a default return, remove the else statement, and change all the 'else if' statements to 'if' statements. 
}

I have no idea what you are doing here though:
int dir = (sworddir + (maxsworddir * 2)) mod maxsworddir;
This won't compile at all.  Did you mean modulus? In ZScript, Modulus is the % token.
 
 
Thus:
int dir = (sworddir + (maxsworddir * 2)) % maxsworddir;
Other than that, the intent of this calculation is unclear. I would need to see some real numbers to know if this will even compute down to values of 0 to 7, resulting from the modulus.
 
You pretty much need to document what you are doing with this, and what you mean by tile offsets, before we can assist you. Go through, and mark up each code block, with the intent of what you are doing, and post whatever script is going to call all this stuff. Our time is best spent helping, not guessing. :P
 
If you are ripping this from stdWeapons.zh, then I do not know what you are trying to accomplish. If you are reinventing the wheel, then I sincerly question why. Even I have no rationale to do that. That header does a rather brilliant job at replicating Z3 style sword slashing, and obeying the sword defence type in the process. The demo quest that comes with it should even have swords set up to demonstrate them.
 
If you are doing this just to experiment as a learning experience / thought experiment, that's another matter; and in that case, you could define whatever tile offsets you wish.  Presuming that you rewrite the FIndOffset function to work, it would produce tile offsets as follows, assuming a base tile of 25000:
 

TILE_SWORD_UP = 25000;
TILE_SWORD_LEFT = 25001;
TILE_SWORD_RIGHT = 25001; //and flip it.
TILE_SWORD_DOWN = 25000; //and flip it
TILE_SWORD_DOWNLEFT = 25005; //which seems bizarre
TILE_SWORD_DOWNRIGHT = 25007; //not sure why here either
TILE_SWORD_UPLEFT = 25005; //which is in line with DOWNLEFT, but flipped
TILE_SWORD_UPRIGHT = 25006; //This seems an error, and should be 25007, but flipped. 

I don't know why you have a four tile gap between the left/right and the angular tiles, nor why you have another gap in those. In fact, you only need two tiles for this... I would use:

TILE_SWORD_UP = 25000;
TILE_SWORD_DOWN = 25000; //but flipped on the vertical axis
TILE_SWORD_LEFT = 25000; //but rotated -90 degrees
TILE_SWORD_RIGHT = 25000; //but rotated +90 degrees
TILE_SWORD_UPLEFT = 25001;
TILE_SWORD_DOWNLEFT = 25001; //but flipped and rotated
TILE_SWORD_UPRIGHT = 25001; //but flipped
TILE_SWORD_DOWNRIGHT = 25001; //but flipped and rotated

The flip and rotate values for ZScript are:
//Flip Types for Tiles, or Sprites
const int FLIP_NONE         = 0;
const int FLIP_HORIZONTAL     = 1; //Horizontal Flip
//!This is already called in stdExtra.zh
//Fixed
const int FLIP_VERTICAL     = 2; //Vertical Flip
//!This is already called in stdExtra.zh
//Fixed
const int FLIP_HV         = 3; //Horizontal and vertical Flip
const int FLIP_VH         = 3;
const int FLIP_BOTH         = 3;

//Rotations + Flip
const int ROT_CW         = 4;
const int ROT_CW_FLIP         = 5; 
const int ROT_CCW_FLIP         = 6;
const int ROT_CCW         = 7;

Edited by ZoriaRPG, 08 January 2017 - 04:28 AM.


#3 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 08 January 2017 - 03:06 PM

@ZoriaRPG here is an updated version

 

Spoiler


#4 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 08 January 2017 - 08:18 PM

here is a even more updated version still haven't gotten it to work yet

right now the animation for the sword isn't even working and the hitboxes I have no idea what is going on there

I have updated it to use stdWeapons.zh but link I said it doesn't work

 

here is my code

Spoiler



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users