void spawnToss(void name, float dx, float dy, float dz, float Vx, float Vy, float Vz, void ani, int atk, int setMap)
{//Spawn and Toss entity with defined conditions (DEFAULT TOSS SCRIPT USED FOR ALL SPAWNED ENTITIES, LIKE ITENS)
void self = getlocalvar("self");
void type = getentityproperty(self, "type");
void hostile = getentityproperty(self, "hostile");
void candamage = getentityproperty(self, "candamage");
void vSpawn = spawn01(name, dx, dy, dz);
int direction = getentityproperty(self, "direction");
int map = getentityproperty(self, "map");
if(direction == 0){
Vx = -Vx;//Change direction to match facing
}
tossentity(vSpawn, Vy, Vx, Vz); //Toss entity with defined speed
if(ani != NULL()){ //Spawn with a specific animation??
changeentityproperty(vSpawn, "animation", openborconstant(ani));
}
if(atk != NULL()){ //This entity is used for attacks??
void vAniID = getentityproperty(self, "animationID");
int disable = getentityproperty(self, "energycost", "disable", openborconstant(vAniID));
changeentityproperty(vSpawn, "parent", self);
changeentityproperty(vSpawn, "owner", self);
changeentityproperty(vSpawn, "hostile", hostile);
changeentityproperty(vSpawn, "candamage", candamage);
setglobalvar("projectile"+self, vSpawn);
setentityvar(vSpawn, "disable", disable);
if(type == openborconstant("TYPE_ENEMY")){ //Is entity a enemy type?
changeentityproperty(vSpawn, "type", openborconstant("TYPE_SHOT"));
}
}
if(setMap != NULL()){
changeentityproperty(vSpawn, "map", map);
}
}
name statue
health 80
nolife 1
nomove 1
type enemy
speed 0
nomove 1 1
noquake 1
gfxshadow 1 1
death 1
setlayer 99
nodieblink 3
animationscript data/scripts/lescript.c
alternatepal data/chars/obstacles/statue/alt1.gif
load coin
anim spawn
delay 2
offset 83 176
bbox 38 64 66 112
platform -38 182 84 84 150 150 20 110
frame data/chars/obstacles/statue/statue_vibration2.png
anim idle
offset 83 176
bbox 38 64 66 112
platform -38 182 84 84 150 150 20 110
frame data/chars/obstacles/statue/statue_vibration2.png
anim pain
delay 4
offset 83 176
bbox 38 64 66 112
platform -38 182 84 84 150 150 20 110
frame data/chars/obstacles/statue/statue_vibration1.png
@cmd spawnToss "coin" 0 35 0 1 1 0
frame data/chars/obstacles/statue/statue_vibration2.png
frame data/chars/obstacles/statue/statue_vibration3.png
anim death
loop 1 3 4
delay 16
offset 147 176
platform 38 182 84 84 150 150 20 110
flash carglass
frame data/chars/obstacles/statue/statue_death1.png
frame data/chars/obstacles/statue/statue_death2.png
frame data/chars/obstacles/statue/statue_death3.png
frame data/chars/obstacles/statue/statue_death3.png
kimono said:How I can make this statue throw coins at different places each time it being hit?
Bloodbane there is a way to prevent it, you can adapt this function, which chooses a random position between the screensize and MIN and MAX z positions:while in #2, coins might fly outside limits.
void randomteleonscreen()
{// Randomly teleports onscreen
void self = getlocalvar("self"); //Get calling entity
int XPos = openborvariant("xpos"); //Get screen edge's position
int Screen = openborvariant("hResolution"); // Get screen width
int Width = openborvariant("PLAYER_MAX_Z") - openborvariant("PLAYER_MIN_Z"); // Get width
int iRx = rand()%(Screen/2) + Screen/2 ;
int iRz;
if (Width>0){
iRz = rand()%(Width/2) + Width/2 ;
}
changeentityproperty(self, "position", iRx + XPos, iRz + openborvariant("PLAYER_MIN_Z")); //Randomly teleport
}
void antiwallRandom(int Dist)
{// Checks if there is wall at defined distance (Dist)
// If there is wall, change to random position to avoid landing on walls
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
float H;
if (Direction == 0){ //Is entity facing left?
Dist = -Dist; //Reverse Dist to match facing
}
H = checkwall(x+Dist,z);
if(H > y)
{
randomteleonscreen();
}
}
Yes, the code doesn't take your entity position into account. It will get the screen resolution (width) and the MINZ/MAXZ of your stage.I will try your solution O Ilusionista, but as afar as I can see, the coins will be spawned at a random position, but not dropped from the entity, am I correct?
x= 0 - 320 and z= 170 -240:
anim pain
@script
if(frame==1){
int iDx = rand()%25;
int iDz = rand()%10;
shooter2("coin", -30, 70, 0, iDx*0.1, 2, iDz*0.1);
}
@end_script
delay 4
offset 83 176
bbox 38 64 66 112
platform -38 182 84 84 150 150 20 110
frame data/chars/obstacles/statue/statue_vibration1.png
frame data/chars/obstacles/statue/statue_vibration2.png
frame data/chars/obstacles/statue/statue_vibration3.png
void shooter2(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz)
{//Spawns projectile next to caller
//vName: Model name of entity to be spawned in
//fX: X location adjustment
//fZ: Y location adjustment
//fY: Z location adjustment
//Vx: X speed
//Vy: Y speed
//Vz: Z speed
void self = getlocalvar("self"); //Get calling entity
int Direction = getentityproperty(self, "direction");
void vSpawn; //Spawn object.
vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in projectile
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
changeentityproperty(vSpawn, "velocity", Vx, Vz, Vy);
return vSpawn;
}
I've got the same problem with the smartbomb: some coins are thrown above the zmin value of the stage and that makes believe that the coins stay in the air.