Solved Random aimove

Question that is answered or resolved.

dantedevil

Well-known member
Lately I have been working on improving the artificial intelligence of the enemies, so that when we have on screen several enemies of the same type, they do not have exactly the same behavior.

For this undoubtedly the best would be a random aimove, so try to find information about it and probe with this scrip, but it did not work.
Code:
anim idle2
        @script
                void self = getlocalvar("self");
        if(frame == 0){
    changeentityproperty(e, "aimove", openborconstant("AIMOVE1_WANDER"));
        }
    @end_script
    loop    1
    delay    20
    offset    82 177
    bbox    63 68 39 112
        @cmd    clearL
    frame    data/chars/gang1/tallman/idle0.png
    frame    data/chars/gang1/tallman/idle1.png
    delay    28
    frame    data/chars/gang1/tallman/idle2.png
    delay    20
    frame    data/chars/gang1/tallman/idle1.png

The log does not tell me much about it either ...
Code:
Script compile error in 'TALLMAN': e line 284, column 25

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script 'TALLMAN' data/chars/gang1/tallman/tallman.txt
Total Ram: 4294967295 Bytes
 Free Ram: 4294967295 Bytes
 Used Ram: 181211136 Bytes

Code:
 Destroyed...Done.
Unload 'RollDrum' ............Done.
Unload 'RollBarrel' ............Done.
Unload 'TALLMAN_bp' ............Done.
Unload 'cargang' ............Done.

Warning: 8 script variants are not freed, dumping...
openbor_array
openbor_loadsprite
openbor_loadsprite
openbor_loadsprite
openbor_loadsprite
openbor_loadsprite
openbor_loadsprite
openbor_loadsprite

Release game data............    Done!
Release timer................    Done!
Release input hardware.......    Done!
Release sound system.........    Done!
Release FileCaching System...    Done!

**************** Done *****************

Can't compile script 'TALLMAN' data/chars/gang1/tallman/tallman.txt
 
Last edited:
Solution
Thank you very much, my friend!
I really appreciate your help. I assure you that I always try to understand and I take my time to do things, but this time that "e" disconcerted me, I did not know what it was for.
Besides that sometimes I find it hard to understand the language. Most of the times I post, I use a translator and then I correct it by reading, since my spelling in English is not good.
I understand enough to make me understand and read, but when it comes to more advanced things such as technical explanations and scripts, even the simplest can become extremely complicated for me.
Sometimes what I need is a simple explanation like the one you gave me, they are a clear example.
That is the best way to understand and learn.
Thank...
Don't simply copy and paste codes, Dante. I've gave you this tip too many times already and, yet, you still ignores it...

What is "e" in that code? You are referring a variable that you haven't declared yet.


 
O Ilusionista said:
Don't simply copy and paste codes, Dante. I've gave you this tip too many times already and, yet, you still ignores it...

What is "e" in that code? You are referring a variable that you haven't declared yet.

I'm sorry my friend, but as I said before, I do not ignore what you say, it simply surpasses my understanding.

And about this:
What is "e" in that code? You are referring a variable that you haven't declared yet.

I do not know what you mean. I do not know how to use the variables and I have no idea how they work. I have not seen tutorials about it either.
Without a doubt this kind of things are not something that we all manage easily, it requires some advanced knowledge to be able to create that type of scripts and I do not have it.
 
You don't have letter "e" declared for enemy at all. That's why it's not working. You should read carefully from the very beginning before you find the right answer. Why not put self in changeentityproperty like this in your code since you have that self name declared?

Code:
changeentityproperty(self, "aimove", openborconstant("AIMOVE1_WANDER"));

I'm not trying to sound like a bully, but you need to try to understand how the logic in scripts works especially how utunnels did well with examples. His is explanatory with "e" being declared clearly.

Wrong in yours:

        @script
                void self = getlocalvar("self");
if(frame == 0){
changeentityproperty(e, "aimove", openborconstant("AIMOVE1_WANDER")); //Comment: Replace that e with self
}
@end_script

Like I said, no variable/value for "e" declared at all. You can copy but look carefully before you edit or run the engine. If there's something wrong, make sure to edit to see what works good.

utunnels used a for loop to declare which type of entity it will be for the entity.
 
Thank you very much, my friend!
I really appreciate your help. I assure you that I always try to understand and I take my time to do things, but this time that "e" disconcerted me, I did not know what it was for.
Besides that sometimes I find it hard to understand the language. Most of the times I post, I use a translator and then I correct it by reading, since my spelling in English is not good.
I understand enough to make me understand and read, but when it comes to more advanced things such as technical explanations and scripts, even the simplest can become extremely complicated for me.
Sometimes what I need is a simple explanation like the one you gave me, they are a clear example.
That is the best way to understand and learn.
Thank you very much dear friend!


Here my animation with the script to share with all:
Code:
anim idle
@script
    if(frame == 0){
      void self = getlocalvar("self");
      int r = rand()%30;

      if(r > 10){
   changeentityproperty(self, "aimove", openborconstant("AIMOVE1_CHASEZ"));
      } else if(r < -10){
   changeentityproperty(self, "aimove", openborconstant("AIMOVE1_WANDER"));
      }
    }
@end_script
	loop	1
	delay	20
	offset	82 177
	bbox	63 68 39 112
        @cmd    clearL
	frame	data/chars/gang1/tallman/idle0.png
	frame	data/chars/gang1/tallman/idle1.png
	delay	28
	frame	data/chars/gang1/tallman/idle2.png
	delay	20
	frame	data/chars/gang1/tallman/idle1.png
[code/]
 
Solution
Back
Top Bottom