dantedevil
Well-known member
After know exactly how works the different types of the scripts, thanks to this info of DC.
Now I start to modify my enemies txt, because I see they have a lots of large scripts in the same animation. Some of these scripts are large Inline scripts, and I don't know how convert this in a predefined function called on a animation frame.
I have this large script, I want convert this in a scrip to call in an animation frame. The only I need is control the time in red of this line:
For now I have managed to optimize some on my own. But if I find or some other script, and I do not understand how to do it, I will share it here to help me again.
Thanks!
Now I start to modify my enemies txt, because I see they have a lots of large scripts in the same animation. Some of these scripts are large Inline scripts, and I don't know how convert this in a predefined function called on a animation frame.
Event scripts - This is the best and most optimal way by far to execute a script, and allows very easy reuse of any given function.
Predefined functions called on an animation frame - Define function methods, import them into an animation script, and then execute them with @cmd. This is the preferred method for executing actions on an animation frame when there isn't an event that can do it for you.
Inline script (@script & @end_script tags) - This is the least optimal way to add scripts. You should only ever do it for extremely simple (one or two line at most) custom logic, never for anything else. It is very sub optimal compared to running defined functions and does not allow reuse of code.
I have this large script, I want convert this in a scrip to call in an animation frame. The only I need is control the time in red of this line:
Here the scrip to convert:iTime + 8.2*200);
Code:
@script
void vSelf = getlocalvar("self"); //Caller.
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iType; //Entity type.
int iMax = openborvariant("ent_max"); //Entity count.
if(frame==1){ //Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iType = getentityproperty(vEntity, "type"); //Get target type.
//Enemy type?
if (vEntity != vSelf) //Not Self?
if (iType == openborconstant("TYPE_ENEMY")){
void iTime = openborvariant("elapsed_time") + getentityproperty(vEntity, "freezetime");
changeentityproperty(vEntity, "frozen", 1);
changeentityproperty(vEntity, "freezetime", iTime + 8.2*200);
} } }
@end_script
For now I have managed to optimize some on my own. But if I find or some other script, and I do not understand how to do it, I will share it here to help me again.
Thanks!