Bruce
Active member
What I am trying to do is to be able to spawn the NPC called Mikey anytime in the level/stage whenever there is enough SM.
I want to limit 1 NPC per player to be out in the level at a time. Is there a way for me to do so?
I am using SP meter script (Tech Demo) by msmalik681 for SM meter.
link: SP meter script (Tech Demo)
After Mikey is spawned in the level, I can execute the command d u a to have Mikey perform anim freespecial1
This is the script I have:
This is the Mikey text file:
This is how I spawn Mikey:
This is all I have so far.
Whenever I spawn Mikey, sometimes I could only see Mikey for a blink of an eye.
Obviously, there is something wrong with the code.
Please notice that this is my first time ever coding about spawning a NPC Ally
Can someone please take a look at the code and see what I did wrong?
Thank you so much for your help
I want to limit 1 NPC per player to be out in the level at a time. Is there a way for me to do so?
I am using SP meter script (Tech Demo) by msmalik681 for SM meter.
link: SP meter script (Tech Demo)
After Mikey is spawned in the level, I can execute the command d u a to have Mikey perform anim freespecial1
This is the script I have:
Code:
void spawn01(void vName, float fX, float fY, float fZ)
{
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int iDirection = getentityproperty(self, "direction");
clearspawnentry(); //Clear current spawn entry.
setspawnentry("name", vName); //Acquire spawn entity by name.
if (iDirection == 0){ //Is entity facing left?
fX = -fX; //Reverse X direction to match facing.
}
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.
changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
return vSpawn; //Return spawn.
}
This is the Mikey text file:
Code:
name Mikey
type npc
subtype follow
lifespan 60
remove 0
nolife 1
hostile enemy
candamage enemy obstacle
speed 20
running 40 1 1 5 1
turndelay 0 3
bounce 1
noquake 1
#shadow 3
gfxshadow 1 3
diesound data/chars/players/Helpers/Ally/die1.wav
flash flash
bflash guard
dust dust01
toflip 1
nodieblink 1
falldie 2
palette data/chars/players/Helpers/Ally/Mikey_Stand02.gif #1
animationscript data/scripts/animatedscripts.c
ondrawscript data/scripts/shadows.c
load quake
com d u a freespecial1
anim idle
@script
void self = getlocalvar("self");
if(getentityproperty(self, "health")<=0) {
damageentity(self, self, 100, 1, 1);
}
@end_script
loop 1
offset 344 550
bbox 0 0 0 0
delay 5
frame data/chars/players/Helpers/Ally/Mikey_Stand01.gif
frame data/chars/players/Helpers/Ally/Mikey_Stand02.gif
frame data/chars/players/Helpers/Ally/Mikey_Stand01.gif
anim idle1
@script
void self = getlocalvar("self");
if(getentityproperty(self, "health")<=0) {
damageentity(self, self, 100, 1, 1);
}
@end_script
loop 1
offset 344 550
bbox 0 0 0 0
range 0 30
delay 5
frame data/chars/players/Helpers/Ally/Mikey_Stand01.gif
frame data/chars/players/Helpers/Ally/Mikey_Stand02.gif
frame data/chars/players/Helpers/Ally/Mikey_Stand01.gif
anim walk
loop 1
offset 344 550
bbox 0 0 0 0
range 30 90
delay 5
frame data/chars/players/Helpers/Ally/Mikey_Walk01.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk02.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk03.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk04.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk05.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk06.gif
frame data/chars/players/Helpers/Ally/Mikey_Walk07.gif
anim attack1
fastattack 1
loop 0
offset 344 550
bbox 0 0 0 0
range 0 29
delay 4
frame data/chars/players/Helpers/Ally/Mikey_SKill1_01.gif
frame data/chars/players/Helpers/Ally/Mikey_SKill1_02.gif
frame data/chars/players/Helpers/Ally/Mikey_SKill1_03.gif
attack1 378 359 146 163 10 0 0 0 20 15
delay 8
frame data/chars/players/Helpers/Ally/Mikey_SKill1_04.gif
attack 0 0 0 0 0 0 0 0 0 0
delay 4
frame data/chars/players/Helpers/Ally/Mikey_SKill1_05.gif
anim freespecial1
@cmd costsm 5 "ANI_freespecial99"
fastattack 1
attackone 0
hitfx data/sounds/beat3.wav
loop 0
offset 344 550
bbox 0 0 0 0
delay 5
frame data/chars/players/Helpers/Ally/special01.gif
frame data/chars/players/Helpers/Ally/special02.gif
frame data/chars/players/Helpers/Ally/special03.gif
frame data/chars/players/HelpersAlly//special04.gif
attack2 156 179 112 121 5 0 10 0 20 20
frame data/chars/players/Helpers/Ally/land01.gif
anim pain
loop 0
offset 344 550
bbox 252 219 89 181
delay 4
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 341 550
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 344 550
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 347 550
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 344 550
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 341 550
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
offset 344 550
delay 12
frame data/chars/players/Helpers/Ally/Mikey_pain01.gif
anim fall
@script
void self = getlocalvar("self");
if(frame==0){
if(getentityproperty(self,"jugglepoints") <= 0){
changeentityproperty(self, "animation", openborconstant("ANI_FALL3"));
}
}
@end_script
landframe 2
loop 0
offset 344 550
delay 2
bbox 252 219 89 181
frame data/chars/players/Helpers/Ally/Mikey_fall01.gif
delay 999
frame data/chars/players/Helpers/Ally/Mikey_fall01.gif
delay 1
frame data/chars/players/Helpers/Ally/Mikey_fall02.gif
anim rise
loop 0
offset 344 550
delay 55
frame data/chars/players/Helpers/Ally/Mikey_fall02.gif
delay 20
frame data/chars/players/Helpers/Ally/Mikey_rise01.gif
delay 14
frame data/chars/players/Helpers/Ally/Mikey_fall02.gif
delay 10
frame data/chars/players/Helpers/Ally/Mikey_rise01.gif
frame data/chars/players/Helpers/Ally/Mikey_rise02.gif
This is how I spawn Mikey:
Code:
name Ken
....
....
com d s freespecial20
....
....
anim freespecial20
@cmd costsm 10 "ANI_freespecial99"
@cmd shadow 5 20 120 6 2 255 0 0 # Red
fastattack 1
attackone 0
hitfx data/sounds/beat3.wav
loop 0
offset 303 400
bbox 0 0 0 0
delay 5
sound data/chars/players/Ken/spawn01.wav
@cmd spawn01 "Mikey" 0 0 0
delay 10
frame data/chars/players/Ken/01.gif
frame data/chars/players/Ken/02.gif
frame data/chars/players/Ken/03.gif
frame data/chars/players/Ken/04.gif
delay 10
frame data/chars/players/Ken/02.gif
frame data/chars/players/Ken/03.gif
frame data/chars/players/Ken/04.gif
delay 10
@cmd projectile 1 "dust03" 0 0 0
frame data/chars/players/Ken/land01.gif
This is all I have so far.
Whenever I spawn Mikey, sometimes I could only see Mikey for a blink of an eye.
Obviously, there is something wrong with the code.
Please notice that this is my first time ever coding about spawning a NPC Ally
Can someone please take a look at the code and see what I did wrong?
Thank you so much for your help