• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Ilu' simple scripts

O Ilusionista

Captain 80K
Hi everyone.

During the development of my projects, I just stop creating simple codes several tasks. Even I do not have the same level of programmers as BB and DC, I think it does not hurt to share, they can be useful :) And you will see that I am a random fan :)


All those codes should be saved in a file and called in ANIMATIONSCRIPT.
Some of those codes are based in codes from other coders, remember to credit then also, ok?


1. anichangeattack​


Useful when you need to change from one animation to another, where an attack will be performed.

Based on anichangee function (I forgot the author).
Note: there are some cases where anichange should be used, thanks to the flags. Read more about it here

C-like:
void anichangeattack(void Ani){
    // Douglas Baldan / O Ilusionista
    // version 1.0 - 23/07/13 --- [url=http://www.brazilmugenteam.com]www.brazilmugenteam.com[/url]
    // Animation changer into attacks
    void self = getlocalvar("self");
    performattack(self, openborconstant(Ani)); //Change the animation
}



Usage:
@cmd anichangeattack "ANI_FOLLOW5"

This will make the entity go to FOLLOW5 animation.

2. randomJump​


Useful to make the entity to do a jump into random directions. One of the nice ways to use it is to put this in your itens when they are spawned from obstacles

C-like:
void randomJump (int vx, int vy) 
{
    // Douglas Baldan / O Ilusionista
    // version 1.0 - 23/07/13 --- [url=http://www.brazilmugenteam.com]www.brazilmugenteam.com[/url]
    // makes the entity execute a jump into a random direction
    void vSelf = getlocalvar("self"); // Gets the caller
    int Xr = rand()%vx+0.5;    // Random X vel, between the chosen velocity
    int Yr = 2+rand()%vy;    // Random Y vel + 2, to ensure a vertical jump, between the chosen velocity
    if (Yr <0){    // If the Y is negative,
        Yr = Yr*-1;    // Make it positive
        }
    changeentityproperty(vSelf, "velocity", Xr, 0, Yr); // Change entity velocity
       }

Usage:

@cmd randomJump 3 4

3 - X velocity

4 - Y velocity


3. randomJumpZ​


The same case as above, but including the Z axis too.


C-like:
void randomJumpZ (int vx, int vy, int vz)
{
    // Douglas Baldan / O Ilusionista
    // version 1.0 - 23/07/13 --- [url=http://www.brazilmugenteam.com]www.brazilmugenteam.com[/url]
    // makes the entity execute a jump into a random direction
    void vSelf = getlocalvar("self"); // Gets the caller
    int Xr = rand()%vx;    // Random X vel, between the chosen velocity
    int Yr = 3+rand()%vy;    // Random Y vel + 1, to ensure a vertical jump, between the chosen velocity
    int Zr = rand()%vz;    // Random Z vel, between the chosen velocity
    if (Yr <0){            // If the Y is negative,
        Yr = Yr*-1;            // Make it positive
      }
      changeentityproperty(vSelf, "velocity", Xr, Zr, Yr); // Change entity velocity
}



Usage:

@cmd randomJumpZ 3 4 2

3 - X velocity

4 - Y velocity

2 - Z velocity



4. changeName​


Useful for changing the entity name.

NOTE: There is a limitation in this code - it won't work on the first frame of spawn/respawn animation.

You need to put it on the second frame.



C-like:
void changeName (void iName)
// Change entity name
// 24.09.2013 - Douglas Baldan - O Ilusionista --- [url=http://www.brazilmugenteam.com]www.brazilmugenteam.com[/url]
{
        void    vSelf   = getlocalvar("self");
        changeentityproperty(vSelf, "name", iName);
}

Usage:

@cmd changeName "New_Name"

5. unbind

If you use a binded entity to another entity and need to unbind it, this code is useful for that.

C-like:
void unbind ()
// unbind entity
// 24.09.2013 - Douglas Baldan - O Ilusionista --- [url=http://www.brazilmugenteam.com]www.brazilmugenteam.com[/url]
{
void    vSelf   = getlocalvar("self");
bindentity(vSelf, NULL());
}



Usage:

@cmd unbind


6. spawnRandom​


Spawns another entity (which needs to be loaded first) at random X and Y positions, giving a very cool looking.
This code uses the Spawn01 function by Damon Caskey and you need that function to make it works.

See the exemple below - the little flames were generated by this code

C-like:
void spawnRandom(void vName,int vx, int vy )
// Spawn entity at random places
// 24.09.2013 - Douglas Baldan - O Ilusionista
// Based in Damon Caskey "spawn01" function, and you need that function to make it works.
// vx = maximum X position range
// vy = maximum Y position range
{
int Xr = rand()%vx;    // Random X pos
int Yr = rand()%vy;    // Random Y pos
spawn01(vName,vx+Xr,vy+Yr,0);
}

Usage:

@cmd spawnRandom "name" 50 100

Keep in mind that the given value will work from its negative value to the positive value. IOW, 50 pixels means "from -50 to 50 pixels"


7. spawnRandomZ​


The same case of above, but works for X, Y and Z axis.
This code was based on a modified version of Damon Caskey's Spawn01 function, that doesn't cares for direction, called spawn000. You need that spawn000 function to make this work.


spawn000

C-like:
void spawn000(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner) without direction
    //Damon Vaughn Caskey
    //07/06/2007 -- Modified by Douglas Baldan/O Ilusionista
    //
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
      //fY: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.

    clearspawnentry(); //Clear current spawn entry.
    setspawnentry("name", vName); //Acquire spawn entity by name.

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    vSpawn = spawn(); //Spawn in entity.
    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    return vSpawn; //Return spawn.
}


spawnRandomZ

C-like:
void spawnRandomZ(void vName,int vx, int vy, int vz )
// Spawn entity at random places
// 24.09.2013 - Douglas Baldan - O Ilusionista
// Based in Damon Caskey "spawn01" function, and you need that function to make it works.
// vx = maximum X position range
// vy = maximum Y position range
// vz = maximum Z position range
{
int Xr = rand()%vx;    // Random X pos
int Yr = rand()%vy;    // Random Y pos
int Zr = rand()%vz;    // Random Z pos

spawn000(vName,Xr,Yr,Zr);
}

Usage:

@cmd spawnRandom "name" 50 100 120


8. refill​


Refill the MP bar with the desired value.


C-like:
void refill(int iValue)
//Refill the MP bar with the desired value.
//Douglas Baldan - O Ilusionista
{
    void self = getlocalvar("self");
    changeentityproperty(self, "mp", iValue);
}


Usage:

@cmd refill 50

Refill 50 points of MP


9. mpcost​


Spend some MP


C-like:
void mpcost( int MCost)

{// Spend some MP
    void self = getlocalvar("self");
    void MPower = getentityproperty(self,"mp"); //get mp
    changeentityproperty(self, "mp", MPower-MCost);//consume mp
}

Usage:

@cmd mpcost 50

Drains 50 points of MP

--------------------------------------

I have many other codes to share, I will edit this post once I have time.
See ya,

O Ilusionista.
 
Last edited:
Thanks O', I'm not clued up when it comes to scripts..in actual fact I don't know how to even start using a pre provided 1.
But when I do figure it out one day, these scripts you provided here would be most helpful.
 
Thanks for share, sure they will be usefull.

And i add other script that results indispensable to me:

Code:
void aniframe(void Ani, int Frame){	
	// Animation changer
    void self = getlocalvar("self"); // Get self

    changeentityproperty(self, "animation", openborconstant(Ani));
	// Change to desired animation
	changeentityproperty(self, "animpos", Frame);
	// Change to desired frame
}

It changes to other anim, but you can choose the frame you want to switch to.
Frames are indexed, so starts from 0. Frame 1 = 0.

This other version changes to attack anim anim:

Code:
void aniframe(void Ani, int Frame){	
	// Animation changer
    void self = getlocalvar("self"); // Get self

    changeentityproperty(self, "animation", openborconstant(Ani));
	// Change to desired animation
	changeentityproperty(self, "animpos", Frame);
	// Change to desired frame
}

How to use:
Call it on frame, like this
@cmd aniframe "ANI_IDLE" 0
 
Oi Ilusionista! Queria fazer um pile drive estilo Haggar (Final Fight 2 pro SNES), que também atinge outros inimigos que estão por perto. Como posso fazer isso? Qual a maneira mais prática?
 
*Sergio, welcome. But in this forum, you need to post in english only.
(Sergio, bem-vindo. Mas neste fórum, vc tem que postar em inglês apenas)

You need to open a new topic to ask this.
 
O Ilusionista said:
*Sergio, welcome. But in this forum, you need to post in english only.
(Sergio, bem-vindo. Mas neste fórum, vc tem que postar em inglês apenas)

You need to open a new topic to ask this.

He already DID ask, here.

Sergio, I am losing my patience. You are making non English posts, posting off topic questions in active threads, and asking the same question in multiple places. I already warned you once about the latter. Do not do it again or you will be muted.

DC
 
Damon, I don't know him too much, he poped at my channel asking for help, I helped him and suggested him to join here.
But, sure, he needs to follow the rules.

(Sergio, por favor, siga as regras do fórum).
 
Ok Damon. I will open a new topic. Don´t loose your patience. I didn´t mean to disrespect your forum. I just want to know from other programmers some tips.
But now that i know i cant do the same question to many people, i won´t do it again. Sorry! No rudeness needed!
 
Maybe it's because of the persistence, but don't get me wrong, you might be a nice guy. He's not being rude, you're just making actions that make people think that you're impatient.

Sometimes it's best to just wait for the answer, since most of the people here have other lives other than OpenBOR and couldn't attend to your problem sooner.  ;)

Just saying.

... And It's better to make another topic on OpenBOR help on the Help & Resources section. It's much more cleaner and clearer that way.
 
No problem CRxTRDude! I just want to learn more from this awesome platform, and make cool games faithful to some well know games.
Thanks for the advice anyway!
 
mpcostAnim
Spend some MP within a desired value. If MP is less than the cost, changes to a desired animation.

Copy this function to your animationscript file:
Code:
void mpcostAnim(int MCost, void Ani)
{// Spend some MP with the desired value. If MP is less than the cost, changes to a desired animation.
// Douglas Baldan / O Ilusionista - 12.01.2018
void self = getlocalvar("self"); // get self
void MPower = getentityproperty(self,"mp"); //get mp
	if (MPower>MCost){ // if MP is greater than the cost
	changeentityproperty(self, "mp", MPower-MCost);//consume mp
	} else {
	performattack(self, openborconstant(Ani));	// change to the desired animation
	}
}

Usage
@cmd mpcostAnim 10 "ANI_RUNATTACK"

Watch out for the case change - the function is called "mpcostAnim", not "mpcostanim".
Script is case sensitive.
 
Back
Top Bottom