changedrawmethod with "rotate" does not work, why?

Bruce

Active member
Hello guys,

I don't know why this simple script does not work...
Can someone please take a look at it?

freespecial1
....
....
@cmd Rotate 25
...
...

Code:
void Rotate(float RotateAngle)
{

    void self = getlocalvar("self");
    
    int EntityDir = getentityproperty(self, "direction");
    if(EntityDir == 0) {  // if facing left
        changedrawmethod(self, "rotate", RotateAngle);
    } else changedrawmethod(self, "rotate", -RotateAngle);
}

If I just use drawmethod rotate 25
then it works, but it always rotate 25 degrees clockwise.
I created a little script, so it can rotate 25 clockwise or counter clockwise depending on the facing direction.

I am using 4.0xx build

Thank you
 
Solution
2. If I use the script like you have, then the bosses would rotate 25 degrees counter clockwise when the bosses are facing left (How can I make the bosses rotate clockwise instead?). Somehow it is doing the opposite direction of the native command drawmethod rotate.
Just invert the rotate values to make it work on the opposite way.

Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 270
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    @cmd Tint 1 100 150 200
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    @cmd Tint...
Try resetting drawmethod first with this:

changedrawmethod(self, "reset", 1);
Thank you for your help.
It seems to work when the character is facing left. If the character is facing right, it works but it cut off the left side of the sprites.
Regardless, reset will also mess up
Code:
    drawmethod tintmode 3
    drawmethod tintcolor 255_247_0
drawmethod tintmode no longer works after drawmethod is reset.

I have
Code:
    drawmethod tintmode 3
    drawmethod tintcolor 255_247_0
at every animation, I don't know why drawmethod reset would screw it up.
 
I am also trying to use the build 4.0 function
Code:
set_drawmethod_property(self, "rotate", RotateAngle);
but it is giving an error.

Script error: openbor_set_drawmethod_property(void drawmethod, int property, <mixed> value). You must provide a valid object pointer, property id, and new value.

Script function 'set_drawmethod_property' returned an exception. See any preceding error messages above for details.
parameters: #240144520, "rotate", -25,

1mixed x = <value>;
2
3set_drawmethod_property(void <drawmethod pointer>, int <property>, x);
 
You have to turn on the enable flag when scripting drawmethod.

DC
It works with
Code:
changedrawmethod(self, "enabled", 1);

but somehow it is happening again :-(
The left side of the sprites cut off and it is messing up the
Code:
drawmethod tintmode

It may just be another issues that I am not aware of: I will take a look at my other things to see what is going on, and I will report back when I have time tomorrow.
 
Last edited:
I created a script for the tintmode and colors. Now the tintmode persists.
But for some reasons, I am able to make the boss rotate 25 degrees, then after the boss can not rotate back to 0 at frame 11, why????
Furthermore, I still can not figure out why the left side of the sprites got trimmed off after the the boss rotates 25 degrees to the left.
This doesn't make any sense :-(

Here is my code:
Code:
anim    fall
    @cmd Rotate 25
    jumpframe  1 7 -3 0   #frame, Y, X, Z  
    quakeframe    11 10 30   # {frame} {loops} {intensity}  
    landframe 11
    loop    0
    offset    792 979
    bbox 672 436 374 519
    delay    5
    frame    data/chars/Summons/Ifrit/Idle01.png
    frame    data/chars/Summons/Ifrit/Idle02.png
    frame    data/chars/Summons/Ifrit/Idle03.png
    frame    data/chars/Summons/Ifrit/Idle04.png
    frame    data/chars/Summons/Ifrit/Idle05.png
    frame    data/chars/Summons/Ifrit/Idle06.png
    frame    data/chars/Summons/Ifrit/Idle07.png
    frame    data/chars/Summons/Ifrit/Idle08.png
    frame    data/chars/Summons/Ifrit/Idle09.png
    delay    30
    frame    data/chars/Summons/Ifrit/Idle10.png
    delay    999
    offset    788 984
    @cmd Rotate -25
    frame    data/chars/Summons/Ifrit/Idle10.png

Script:
Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    int FacingDir = getentityproperty(self, "direction");
    if(FacingDir == 0){   // if facing left
        changedrawmethod(self, "rotate", RotateAngle);
    } else changedrawmethod(self, "rotate", -RotateAngle);
}
 

Attachments

  • ChronoHeroes - 0000.png
    ChronoHeroes - 0000.png
    427.1 KB · Views: 4
  • ChronoHeroes - 0001.png
    ChronoHeroes - 0001.png
    447.1 KB · Views: 5
  • ChronoHeroes - 0002.png
    ChronoHeroes - 0002.png
    492.7 KB · Views: 5
  • ChronoHeroes - 0003.png
    ChronoHeroes - 0003.png
    474.7 KB · Views: 4
  • ChronoHeroes - 0004.png
    ChronoHeroes - 0004.png
    438.8 KB · Views: 3
I created a script for the tintmode and colors. Now the tintmode persists.
But for some reasons, I am able to make the boss rotate 25 degrees, then after the boss can not rotate back to 0 at frame 11, why????
Furthermore, I still can not figure out why the left side of the sprites got trimmed off after the the boss rotates 25 degrees to the left.
This doesn't make any sense :-(

Here is my code:
Code:
anim    fall
    @cmd Rotate 25
    jumpframe  1 7 -3 0   #frame, Y, X, Z 
    quakeframe    11 10 30   # {frame} {loops} {intensity} 
    landframe 11
    loop    0
    offset    792 979
    bbox 672 436 374 519
    delay    5
    frame    data/chars/Summons/Ifrit/Idle01.png
    frame    data/chars/Summons/Ifrit/Idle02.png
    frame    data/chars/Summons/Ifrit/Idle03.png
    frame    data/chars/Summons/Ifrit/Idle04.png
    frame    data/chars/Summons/Ifrit/Idle05.png
    frame    data/chars/Summons/Ifrit/Idle06.png
    frame    data/chars/Summons/Ifrit/Idle07.png
    frame    data/chars/Summons/Ifrit/Idle08.png
    frame    data/chars/Summons/Ifrit/Idle09.png
    delay    30
    frame    data/chars/Summons/Ifrit/Idle10.png
    delay    999
    offset    788 984
    @cmd Rotate -25
    frame    data/chars/Summons/Ifrit/Idle10.png

Script:
Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    int FacingDir = getentityproperty(self, "direction");
    if(FacingDir == 0){   // if facing left
        changedrawmethod(self, "rotate", RotateAngle);
    } else changedrawmethod(self, "rotate", -RotateAngle);
}
Why are you using negative values for rotation? It works from 0 to 359 only, and if you want to change the rotation to the opposite side depending on the facing direction, you need to use the fliprotate together.

1743472088061.png
 
Why are you using negative values for rotation? It works from 0 to 359 only, and if you want to change the rotation to the opposite side depending on the facing direction, you need to use the fliprotate together.

View attachment 10418
script below is what I have tried before, but it did not rotate at all, that's why I started using negative values thinking it would rotate counter clockwise with negative values...

Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    changedrawmethod(self,"fliprotate", 1);
    changedrawmethod(self, "rotate", RotateAngle);
}

Can you please tell me what I do wrong with this script?
Thank you


I didn't see the information you provided.
I only looked at the information below the changedrawmethod and setdrawmethod

setdrawmethod(entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int
colourmap, int fillcolour, int rotate, int rotateflip, int transparencybg)
See load {name} for details
Set drawmethod for an entity or define a global drawmethod for other script functions.
entity must be a valid entity handle or an empty value.
All other parameters are optional.
flag defines whether the drawmethod is active, when set to 0, the drawmethod will not take effect.
scalex defines how the sprite will be stretch in x direction: sizex = original_sizex * scalex / 256
scaley defines how the sprite will be stretch in y direction: sizey = original_sizey * scaley / 256
flipx defines whether the sprite will be flipped left/right. 0 means don't flip and 1 means flip.
flipy defines whether the sprite will be flipped top/bottom. 0 means don't flip and 1 means flip.
shiftx defines how the sprite leans, like lightx in gfxshadow feature, in most situations you don't need this.
alpha defines which alpha blending effect will be used. 0 means no alpha effect. -1 means the entity(if given) will
use its own alpha value.
colourmap(entity only) defines which colourmap will be used. 0 means no colourmap. -1 means the entity(if given)
will use its current colourmap.
fillcolour is the colour used by the entire sprite. 0 means don't fill the sprites.
rotate is the rotate angle(clockwise), the range is from 0 to 359.
rotateflip(entity only) means whether the entity will flip its rotate direction
 
Can you please tell me what I do wrong with this script?
I tested your script and it looks fine.


Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 90
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    frame    data/chars/maxima/idle005.gif
    @cmd Rotate 270
    frame    data/chars/maxima/idle006.gif
    frame    data/chars/maxima/idle007.gif
    frame    data/chars/maxima/idle008.gif
    @cmd Rotate 0
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
 
I tested your script and it looks fine.


Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 90
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    frame    data/chars/maxima/idle005.gif
    @cmd Rotate 270
    frame    data/chars/maxima/idle006.gif
    frame    data/chars/maxima/idle007.gif
    frame    data/chars/maxima/idle008.gif
    @cmd Rotate 0
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
Can you test this with
Code:
changedrawmethod(self,"enabled", 1);
in 2 different scripts and use both of them to see if it still rotates?
I just found out I had this
Code:
changedrawmethod(self,"enabled", 1);
in both Tintmode script and Rotate script, so it would not rotate.
If I remove this
Code:
changedrawmethod(self,"enabled", 1);
off the Rotate script then it would rotate in the opposite direction (counter clockwise) with positive value.
 
in 2 different scripts and use both of them to see if it still rotates?
I don't understand, what I need to test? Are you trying to use both tint and rotate at the same time?

This was the script I already tested in my video.
Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    changedrawmethod(self,"fliprotate", 1);
    changedrawmethod(self, "rotate", RotateAngle);
}
 
I don't understand, what I need to test? Are you trying to use both tint and rotate at the same time?

This was the script I already tested in my video.
Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    changedrawmethod(self,"fliprotate", 1);
    changedrawmethod(self, "rotate", RotateAngle);
}
Yes, I put tintmode and colors script at the spawn animation, then I use the rotate script at fall animation.
I had changedrawmethod(self,"enabled", 1); in both scripts and it would not rotate.
After I removed changedrawmethod(self,"enabled", 1); from the tintmode and colors script, then it would rotate, but it rotates in the opposite direction (counter clockwise) for some reasons. I guess maybe because the boss is facing my character, that's why it is rotating counter clockwise. Is there anyway I can make the boss to rotate clockwise?

Therefore, I am wondering if it would do the same for yours if you have changedrawmethod(self,"enabled", 1); in both scripts
 
Last edited:
Therefore, I am wondering if it would do the same for yours if you have changedrawmethod(self,"enabled", 1); in both scripts
But the changedrawmethod(self,"enabled", 1) is mandatory in both rotate/tint cases.


You can also use the native drawmethod commands, but in case you need the scripted method you can mix using all commands in the same code or separately, like this.

Code:
void Rotate(int RotateAngle)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    changedrawmethod(self,"fliprotate", 1);
    changedrawmethod(self, "rotate", RotateAngle);
}

void Tint(int mode, int red, int green, int blue)
{
    void self = getlocalvar("self");
    changedrawmethod(self,"enabled", 1);
    changedrawmethod(self,"tintmode", mode);
    changedrawmethod(self,"tintcolor", rgbcolor(red, green, blue));
}

void Reset()
{
    void self = getlocalvar("self");
    changedrawmethod(self,"reset", 1);
    changedrawmethod(self,"enabled", 0);
}

Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 90
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    @cmd Tint 1 100 150 200
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    @cmd Tint 1 0 255 0
    frame    data/chars/maxima/idle005.gif
    @cmd Rotate 270
    frame    data/chars/maxima/idle006.gif
    frame    data/chars/maxima/idle007.gif
    @cmd Tint 1 254 254 254
    frame    data/chars/maxima/idle008.gif
    @cmd Rotate 0
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
    @cmd Tint 2 0 0 0
    frame    data/chars/maxima/idle009.gif
 
void Rotate(int RotateAngle) { void self = getlocalvar("self"); changedrawmethod(self,"enabled", 1); changedrawmethod(self,"fliprotate", 1); changedrawmethod(self, "rotate", RotateAngle); } void Tint(int mode, int red, int green, int blue) { void self = getlocalvar("self"); changedrawmethod(self,"enabled", 1); changedrawmethod(self,"tintmode", mode); changedrawmethod(self,"tintcolor", rgbcolor(red, green, blue)); }
Sorry for all the confusion.
I've tried the steps below last night:

1. if I use the native commands like this
Code:
drawmethod fliprotate 1
drawmethod rotate 25
then it works as expected (clockwise) when the boss is facing left.
Then I have to put the native commands drawmethod tintmode and tintcolor in every animation because I want the bosses and some enemies to be tinted the whole time.

2. If I use the script like you have, then the bosses would rotate 25 degrees counter clockwise when the bosses are facing left (How can I make the bosses rotate clockwise instead?). Somehow it is doing the opposite direction of the native command drawmethod rotate.
Since I can not use negative values, I can not figure out a way to make the bosses/enemies rotate clockwise in the fall animation with the script.

I want to be able to create a rotate script, so that
I can also use rotate script for burning_fx model in every entity fall animation for fire attacks.
like this:
Code:
anim    burn
    jumpframe 3 4 -4 0  # frame, YXZ
    landframe 9
    offset    1203 692
    bbox 1078 369 160 288
    delay    7
    move    -10
    @cmd    SpawnAndBind "BurnFX" 0 0 0 openborconstant("ANI_idle1") 25 #XYZ, AnimID, Rotate
    frame    data/chars/Dante/fall01.png
    frame    data/chars/Dante/fall02.png
    frame    data/chars/Dante/fall03.png

Thank you so much for your help.
 
Last edited:
2. If I use the script like you have, then the bosses would rotate 25 degrees counter clockwise when the bosses are facing left (How can I make the bosses rotate clockwise instead?). Somehow it is doing the opposite direction of the native command drawmethod rotate.
Just invert the rotate values to make it work on the opposite way.

Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 270
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    @cmd Tint 1 100 150 200
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    @cmd Tint 1 0 255 0
    frame    data/chars/maxima/idle005.gif
    @cmd Rotate 90
    frame    data/chars/maxima/idle006.gif
    frame    data/chars/maxima/idle007.gif
    @cmd Tint 1 254 254 254
    frame    data/chars/maxima/idle008.gif
    @cmd Rotate 0
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
    @cmd Tint 2 0 0 0
    frame    data/chars/maxima/idle009.gif

 
Solution
Just invert the rotate values to make it work on the opposite way.

Code:
anim idle
    loop    1
    delay    16
    offset    38 117
    bbox    20 0 53 119
    @cmd Rotate 270
    frame    data/chars/maxima/idle000.gif
    frame    data/chars/maxima/idle001.gif
    @cmd Tint 1 100 150 200
    frame    data/chars/maxima/idle002.gif
    @cmd Rotate 180
    frame    data/chars/maxima/idle003.gif
    frame    data/chars/maxima/idle004.gif
    @cmd Tint 1 0 255 0
    frame    data/chars/maxima/idle005.gif
    @cmd Rotate 90
    frame    data/chars/maxima/idle006.gif
    frame    data/chars/maxima/idle007.gif
    @cmd Tint 1 254 254 254
    frame    data/chars/maxima/idle008.gif
    @cmd Rotate 0
    frame    data/chars/maxima/idle009.gif
    frame    data/chars/maxima/idle009.gif
    @cmd Tint 2 0 0 0
    frame    data/chars/maxima/idle009.gif

I just tested and it worked, but
when using as a boss or enemy,
it started from Rotate 270 to 359 instead of ending with 0.

Thank you so much for your kind and patience helping me.
I can not thank you enough.
 
Back
Top Bottom