SOLVED: spawn enemy with weapon

msmalik681

OpenBOR Developer
Staff member
is there any way to spawn a enemy with a weapon at the moment I am using a script to change weapon after spawn but i cant find any default way to do this built into the engine.
 
I think I remember seeing a weapon spawn parameter. I'll dig into it.

Edit : Yes there is indeed a weapon command (like coords, at, map, etc) that you can use in a level file.

You can also use "weapon" with setspawnentry.
 
I advice you to spawn an enemy in this way:
anim SPAWN
frame empty
weaponframe 0 X


Not use script because is bugged for now...
openBOR is fully BUGGED and I hope in a new version soon...
 
nsw25 said:
Check my urban lockdown game. Imnot at a computer till tonight but i have this in my game and works fine

thanks but this method wont work for me as i do not have any real weapons the reason i made a weapon version is to make a alternative fighting style for the same enemy and not have to re-code the base animations.

@white dragon

I already have a working script I will keep with my current method thanks everyone for your suggestions.
 
sure no problem here is the animation script:

void wcheck()
{
void self = getlocalvar("self");
char name = getentityproperty(self,"name");
if (name == "A")
  {
changeentityproperty(self, "weapon", 1);
  }
else if (name == "B")
  {
changeentityproperty(self, "weapon", 2);
  }
else if (name == "C")
  {
changeentityproperty(self, "weapon", 3);
  }
else if (name == "D")
  {
changeentityproperty(self, "weapon", 4);
  }
}


spawn the enemy like this:

spawn  hanzoatk
health 50
alias B
map 1
coords  450 280
at      0

then add this line at the start of enemy idle animation:

anim idle
loop      1
delay      25
offset    19 117
bbox      2 12 40 108
@cmd wcheck
        frame      data/chars/enemies/ninja/sshanzo/idle01.png

this works for me as enemies do not display names on screen but i would have liked the script to work on spawn but that will screw up the weapon this way it retains all animations from parent and you just have to add new attack animations and behavior if needed.  HTH
 
This is weird so everytime idle loops engine will change weapon to existing one.
I would modify this and put in spawn animation :
Code:
						@script
                void self = getlocalvar("self");
          int HP = getentityproperty(self,"health");
		if ( HP == 20 ){
   changeentityproperty(self, "weapon", 1);
		}
		if ( HP == 30 ){
   changeentityproperty(self, "weapon", 2);
		}
		if ( HP == 40 ){
   changeentityproperty(self, "weapon", 3);
		}
}
	@end_script

 
Back
Top Bottom