Help with shooterM function

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.
 
Well there are couple reasons game crashed from setting function wrong to have not loaded the function before

So have you declared animationscript before? if you have, does it have shooterM function?
 
yeah it says can't compile script


Code:
void shooterM(void Shot, float dx, float dy, float Vx, float Vy)
{ // 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);
}
 
when I try @cmd shooterm the game crashes

Ah I see, function name must be typed in exact way. You typed it 'shooterm' but the function name is 'shooterM' therefore engine can't find the function and thus crashed
So you should type @cmd shooterM
 
Here's an example from Aliens Clash:

name    Blob1
health  10
nomove  1
type enemy
cantgrab 1
nodrop  2
death  1
nopain  1
nolife  1
offscreenkill 3000
diesound data/sounds/squish1.wav
animationscript  data/scripts/lescript.c
takedamagescript data/scripts/blink.c
palette data/chars/blob/BLime.png
alternatepal    data/chars/blob/Bblink.png
alternatepal    data/chars/blob/BGreen.png
alternatepal    data/chars/blob/BCyan.png
alternatepal    data/chars/blob/BBlue.png

...

anim death
delay 30
offset  45 91
        @cmd    shooterM "Bub" -13 20 -1 2
        @cmd    shooterM "Bub" -13 40 -0.5 4
        @cmd    shooterM "Bub" 13 20 1 2
        @cmd    shooterM "Bub" 13 40 0.5 4
frame data/chars/misc/empty.gif
        @cmd    suicide
frame data/chars/misc/empty.gif

and this is Bub's text:

name    Bub
type    none
lifespan  3
subject_to_wall 0
subject_to_hole 1
no_adjust_base 0
subject_to_obstacle 0
subject_to_platform 0
palette data/chars/blob/BLime.png
alternatepal    data/chars/blob/BBlink.png
alternatepal    data/chars/blob/BGreen.png
alternatepal    data/chars/blob/BCyan.png
alternatepal    data/chars/blob/BBlue.png


anim idle
delay 800
offset 16 32
landframe 1
frame  data/chars/blob/bub.png
delay 10
frame data/chars/misc/empty.gif

This works perfectly
As you can see both Blob1 and Bub use same set of alternate palettes
 
for some reason this still doesn't work for but as far as I can tell it should

I call it in the character text like this

Code:
@cmd	shooterM "plasma" 30 65 0 0

and this the palette set for both the player and projectile

Code:
palette data/chars/Ironman/j2.png
alternatepal data/chars/Ironman/alt.png
alternatepal data/chars/Ironman/alt2.png
alternatepal data/chars/Ironman/alt3.png
 
What exactly you mean by 'doesn't work'?

Also, I assume each palette has different color set for the plasma beam right?
I've tried it yesterday and it worked well, though Ironman previously used shoot function which works similar to throwframe. OTOH shooterM function quoted above is used in 2D mod, that's why it doesn't have parameters for z axis
 
I've just examined your alternate palettes and it turns out the cause of this problem is not because of script, but instead of the palettes themselves
alt1.png and alt2.png don't contain different colors for the plasma beam, that's why when they are using alternate palette, they look exactly the same
alt3.png OTOH does contain different colors for the beam though

So my suggestion is to update your alternate palettes and set different color for the plasma
 
I've just checked it and my thought is correct, there's a problem with the function called by shooterM function

Read grabscript.c and you can find 2 shoot functions which have significant difference. Here, I quoted a part of it to show them:
Code:
...
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");

   if (Direction == 0){ //Is entity facing left?                  
      dx = -dx; //Reverse X direction to match facing
   }

   projectile(Shot, x+dx, z+dz, y+dy, Direction, 0, 0, 0);
}

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");

   if (Direction == 0){ //Is entity facing left?                  
      dx = -dx; //Reverse X direction to match facing
   }

   projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
}




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 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;
}
...

Because of having 2 functions with same name, OpenBoR engine only take one i.e the first one. The first shoot function doesn't allow modifying shot's properties including map/palette. That's why Ironman's plasma still use default palette
To solve this, simply delete the first one

And while I'm on it, I noticed incompability problem. I'll quote this part:
Code:
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);
}

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 Vx, float Vy)
{ // 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);
}

shooterM calls shooter function which unfortunately call it with wrong way (parameter difference)
I don't know where did you get that shooterM function but as I posted before, it's used specially for 2D mods, that's why it doesn't have parameters for z axis
Anyways, it should be like this:
Code:
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);
}

And modify shooter function into this:
Code:
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;
}

Last, fix how ironman calls this function into this:
@cmd shooterM "plasma" 30 65 1 0 0 0
 
Back
Top Bottom