May I kindly ask for a simple code modification?

kimduck

New member
void main(){
void self = getlocalvar("self");
void vAniID = getentityproperty(self,"애니메이션ID")
int MP = getentityproperty(자기 자신, "mp");

if(vAniID != openborconstant("ANI_SPECIAL")){
changeentityproperty(self, "mp", MP + 1);
}
}
I’ve asked this question before, and I got a helpful answer from Bloodbane. Thank you so much!


It works well when I attack directly, but now I want it to work with projectiles like fireballs too.


So instead of applying the effect to myself, I want to apply it to a specific entity by name.
For example, I want to increase the MP of an entity named "baba".


Could you please show me how to modify the code so that MP +1 is applied to the entity named "baba" instead of to self?


I would really appreciate it.


P.S.: I’ve asked ChatGPT several times before, but I’ve never received a clear or accurate answer. 😭
 
Last edited:
Solution
I've modified the script for this baba:
C:
void main(){
    void Given = cari("baba");
    int MP;

    if(Given != 0){
      MP = getentityproperty(Given,"mp");
      changeentityproperty(Given, "mp", MP + 1);
    }
}

void cari(void Name)
{// Find entity with same Name then return that entity
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iName;                                         //Entity name.
    int  iMax      = openborvariant("count_entities");  //Entity count.
    void Result;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity =...
@kimduck its against the forum rules to post content in any other language than english. You can use a translator and we will do our best to understand (I am not a native english speaker either):

I asked this question before and got a helpful answer from Bloodbane. Thank you so much!

It works fine when you attack directly, but now I want to apply it when you use a projectile like a fireball.

So instead of applying it to myself, I want to apply it to a target with a specific entity name.
For example, I want to increase the MP of an entity named "baba".

Could you please modify the code so that the MP +1 applies to the entity named "baba" instead of self?

I would really appreciate it if you could let me know.

ps: I've asked this question on ChatGPT many times, but I've never gotten a clear and precise answer. 😭

First, forget about ChatGPT for this. It wasn't trained with OpenBOR script language and it will screw your code.
second, if I understood right, you want to spawn a fireball and make it to refill the player called "baba" MP upon hit, right?

Well, ou either need to set "parent" on the code you are using to spawn that entity - and redirect the "self" to "parent" or make a loop for all available entities and search for your valid target (which would be an overkill in myu opinion).

How you are calling this fireball?
 
@kimduck its against the forum rules to post content in any other language than english. You can use a translator and we will do our best to understand (I am not a native english speaker either):



First, forget about ChatGPT for this. It wasn't trained with OpenBOR script language and it will screw your code.
second, if I understood right, you want to spawn a fireball and make it to refill the player called "baba" MP upon hit, right?

Well, ou either need to set "parent" on the code you are using to spawn that entity - and redirect the "self" to "parent" or make a loop for all available entities and search for your valid target (which would be an overkill in myu opinion).

How you are calling this fireball?
Yes, I want to shoot a projectile, and when that projectile hits, I want the entity named "baba" to gain +1 MP.
I'm calling it like this:
@cmd projectile 1 "darkfire2" 50 0 0
 
I've modified the script for this baba:
C:
void main(){
    void Given = cari("baba");
    int MP;

    if(Given != 0){
      MP = getentityproperty(Given,"mp");
      changeentityproperty(Given, "mp", MP + 1);
    }
}

void cari(void Name)
{// Find entity with same Name then return that entity
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iName;                                         //Entity name.
    int  iMax      = openborvariant("count_entities");  //Entity count.
    void Result;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iName   = getentityproperty(vEntity, "defaultname"); //Get target name

      if(iName == Name){
        Result = vEntity;
        break;
      } else {
        Result = 0;
      }
    }
    return Result;
}

This one will find entity whose name is exactly baba and if it finds out, it will add 1 MP to that baba.

HTH
 
Solution
I've modified the script for this baba:
C:
void main(){
    void Given = cari("baba");
    int MP;

    if(Given != 0){
      MP = getentityproperty(Given,"mp");
      changeentityproperty(Given, "mp", MP + 1);
    }
}

void cari(void Name)
{// Find entity with same Name then return that entity
    void vEntity;                                       //Target entity placeholder.
    int  iEntity;                                       //Entity enumeration holder.
    int  iName;                                         //Entity name.
    int  iMax      = openborvariant("count_entities");  //Entity count.
    void Result;

    //Enumerate and loop through entity collection.
    for(iEntity=0; iEntity<iMax; iEntity++){
      vEntity = getentity(iEntity);                 //Get target entity from current loop.
      iName   = getentityproperty(vEntity, "defaultname"); //Get target name

      if(iName == Name){
        Result = vEntity;
        break;
      } else {
        Result = 0;
      }
    }
    return Result;
}

This one will find entity whose name is exactly baba and if it finds out, it will add 1 MP to that baba.

HTH
Wow~~ I can't believe this is possible... You're truly amazing. Thank you. I'm astonished. I deeply respect you
 
Back
Top Bottom