Thegr8test
Member
I'm not sure how to call this function in the players script when I try @cmd shooterm the game crashes, if I drop the m then the mod loads and runs fine but the projectile isn't mapped to the players map.
void shoot(void Shot, float dx, float dy, float dz)
{ // Shooting projectile
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void vShot;
if (Direction == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
vShot = projectile(Shot, x+dx, z+dz, y+dy, Direction, 0, 0, 0);
return vShot;
}
void shooter(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting projectile with speed control
void vShot = shoot(Shot, dx, dy, dz);
changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
changeentityproperty(vShot, "speed", Vx);
return vShot;
}
void shooter2(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz)
{//Spawns projectile next to caller and move it with speed
//vName: Model name of entity to be spawned in
//fX: X location adjustment
//fY: Y location adjustment
//fZ: 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);
}
void shooterM(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting special projectile with speed control and matches its map with own's map
void self = getlocalvar("self");
int map = getentityproperty(self,"map");
void Spawn;
Spawn = shooter(Shot, dx, dy, Vx, Vy);
changeentityproperty(Spawn, "map", map);
}
@cmd shooterM "plasma" 30 65 1 0 0 0
void shooterM(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting special projectile with speed control and matches its map with own's map
void self = getlocalvar("self");
int map = getentityproperty(self,"map");
void Spawn;
Spawn = shooter(Shot, dx, dy, dz, Vx, Vy, Vz);
changeentityproperty(Spawn, "map", map);
}
#include "data/scripts/conditional.c"
void hpcost( int HCost)
{// Spend some life
void self = getlocalvar("self");
void Life = getentityproperty(self,"health"); //get health
if (Life > HCost){ //Does the entity have enough health?
changeentityproperty(self, "health", Life-HCost);//consume health
}
}
void paleta(int Pal)
{//
void self = getlocalvar("self"); //Get calling entity.
int oPal = getentityproperty(self, "mapdefault");
if (Pal > 0){
changeentityproperty(self, "colourmap", Pal);
}
else{
changeentityproperty(self, "colourmap", oPal);
}
}
void regen (int regH)
{// Spend some life
void self = getlocalvar("self");// get caller
void Life = getentityproperty(self,"health"); //get health
changeentityproperty(self, "health", Life+regH);//add health
}
void checkPal(void Ani, int Remap)
{// Attack interruption if there's player
// Only occurs if remap matches
void self = getlocalvar("self");
int Map = getentityproperty(self, "map");
void target = findtarget(self); //Find player
if(target!=NULL() && Map!=Remap){
performattack(self, openborconstant(Ani)); //Attack!
}
}
void spawnAni(void vName, float fX, float fY, float fZ, void Ani, float Vx, float Vy, float Vz)
{
//spawnB (Generic spawner) + Specific animation + velocities
//Damon Vaughn Caskey + Douglas Baldan
//07/06/2007
//
//Spawns entity next to caller.
//
//vName: Model name of entity to be spawned in.
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.
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.
performattack(vSpawn, openborconstant(Ani));
changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);
return vSpawn; //Return spawn.
}
void spawn000(void vName, float fX, float fY, float fZ)
{
//spawn01 (Generic spawner) without direction
//Damon Vaughn Caskey
//07/06/2007
//
//Spawns entity next to caller.
//
//vName: Model name of entity to be spawned in.
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.
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.
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.
return vSpawn; //Return spawn.
}
void teleportentityrandomlyonscreen(int screenwidth)
{
//MatMan v0.02
//Screenwidth needs to be put in manually as openborcvarial hresolution doesn't work
void self = getlocalvar("self");
int ichancex = 0;
int ichancey = 0;
ichancex = rand()%screenwidth;
if (ichancex < 0) { ichancex = -ichancex ;}
ichancex = ichancex + openborvariant("xpos");
ichancey = rand()%screenwidth;
if (ichancey < 0) { ichancey = -ichancey ;}
ichancey = ichancey + openborvariant("ypos");// + openborvariant("PLAYER_MIN_Z");
changeentityproperty(self, "position", ichancex, getentityproperty(self, "z"), getentityproperty(self, "a"));
//TODO: Need to set it that it randomly place's the entity along the z plane.
//changeentityproperty(self, "position", ichancex, ichancey, getentityproperty(self, "a"));
//changeentityproperty(self, "position", fx, fz, fy);
//openborvariant("PLAYER_MIN_Z");
//openborvariant("PLAYER_MAX_Z");
return self;
}
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;
iRz = rand()%(Width/2) + Width/2 ;
changeentityproperty(self, "position", iRx + XPos, iRz + openborvariant("PLAYER_MIN_Z")); //Randomly teleport
}
void fixRandom()
{// Randomly teleports onScreenB
void self = getlocalvar("self"); //Get calling entity
int XPosB = openborvariant("XPos"); //Get ScreenB edge's position
int ScreenB = openborvariant("hResolution"); // Get ScreenB WidthB
int WidthB = openborvariant("PLAYER_MAX_Z") - openborvariant("PLAYER_MIN_Z"); // Get WidthB
int iRxB = rand()%(ScreenB/2) + ScreenB/2 ;
int iRzB;
iRzB = rand()%(WidthB/2) + WidthB/2 ;
changeentityproperty(self, "position", iRxB + XPosB, iRzB + openborvariant("PLAYER_MIN_Z")); //Randomly teleport
}
void antiwallCollide(int Dist, void Ani)
{// Checks if there is wall at defined distance (Dist)
// If there is wall, change animation to Ani
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)
{
changeentityproperty(self, "animation", openborconstant(Ani));
}
}
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)
{
// 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;
//iRz = rand()%(Width/2) + Width/2 ;
//changeentityproperty(self, "position", iRx + XPos, iRz + openborvariant("PLAYER_MIN_Z")); //Randomly teleport
randomteleonscreen();
}
}
void randomJump (int vx, int vy)
{
// Douglas Baldan / O Ilusionista
// version 1.0 - 23/07/13
// makes the entity execute a jump into a random direction
void vSelf = getlocalvar("self"); // Gets the caller
int Xr = rand()%vx; // Random X vel, between the chosen velocity
int Yr = 2+rand()%vy; // Random Y vel + 1, to ensure a vertical jump, between the chosen velocity
if (Yr <0){ // If the Y is negative,
Yr = Yr*-1; // Make it positive
}
changeentityproperty(vSelf, "velocity", Xr, 0, Yr); // Change entity velocity
}
//void randomPitch (void iSample, int basePitch, int rangePitch)
//{
//int iPitch = basePitch+(rand()%rangePitch);
//if (iPitch <0){iPitch = iPitch *-1}
//int iSound = loadsample(iSample);
//playsample(iSound, 0, openborvariant("effectvol"), openborvariant("effectvol"), iPitch, 0)
//}
void aniLimit(void Ani, int Frame, int Limit)
{// Change current animation if MP falls below limit
void self = getlocalvar("self");
void MP = getentityproperty(self,"mp");
if (MP < Limit){
changeentityproperty(self, "animation", openborconstant(Ani),2);
updateframe(self, Frame);
}
}
void mpcost(int Cost)
{// Spend some MP
void self = getlocalvar("self");
int MP = getentityproperty(self,"mp");
changeentityproperty(self, "mp", MP-Cost); //Spend!
}
@cmd shooterM "plasma" 30 65 1 0 0 0
name EBBomb
type none
candamage player
lifespan 4
nolife 1
palette none
subject_to_wall 0
subject_to_hole 1
no_adjust_base 0
subject_to_gravity 1
subject_to_obstacle 0
subject_to_platform 0
anim idle
loop 1 2 6
delay 5
followanim 1
followcond 1
landframe 8
offset 12 12
attack 2 2 22 22 10 1
frame data/chars/bloboss/Bshot1.png
frame data/chars/bloboss/Bshot4.png
frame data/chars/bloboss/Bshot3.png
frame data/chars/bloboss/Bshot2.png #
frame data/chars/bloboss/Bshot1.png
frame data/chars/bloboss/Bshot4.png
frame data/chars/bloboss/Bshot3.png
frame data/chars/bloboss/Bshot2.png #
attack 0
frame data/chars/misc/empty.gif
anim follow1
delay 6
offset 12 12
frame data/chars/misc/empty.gif
void toss(void Bomb, float dx, float dy, float dz)
{ // Tossing bomb
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void vShot;
if (Direction == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
vShot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
return vShot;
}
void tosserM(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Tossing bombs with speed control and matches its map with own's map
void self = getlocalvar("self");
int map = getentityproperty(self,"map");
void Spawn;
Spawn = toss(Shot, dx, dy, dz);
changeentityproperty(Spawn, "velocity", Vx, Vz, Vy);
changeentityproperty(Spawn, "speed", Vx);
changeentityproperty(Spawn, "map", map);
}