Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
g4m3w0rm

SpawnProjectile with angle relative to mapspot

Recommended Posts

I'm trying to fire a plasmagun from multiple mapspots with one script. The plasmaballs need to follow the angle of the mapspot.
Right now this is what I am doing.

script 4 (int tagID)
{ SpawnProjectile(tagID,"PlasmaBall",GetActorAngle(tagID)/256,20,0,0,0);
PlaySound(tagID,"weapons/plasmaf");
}
A linedef triggers the script and when there is only one mapspot firing this is no problem.
When more mapspots have to fire at the same time the angle won't be correct because these mapspots have the same TID.

Is there any way to fire these plasmaballs in the angle of the firing mapspots?

Thanks in advance,
g4m3w0rm

Share this post


Link to post

Try this example:

#define MAPSPOTS_NUMBER 4 // We have four points (mapspots) from which the plasma ball will be fired

int mapspots_tids[MAPSPOTS_NUMBER] = {5, 7, 19, 8}; // The tids of said mapspots

Script 4 (void)
{
  For(int i; i < MAPSPOTS_NUMBER; i++)
    SpawnProjectile(mapspots_tids[i], "PlasmaBall", GetActorAngle(mapspots_tids[i]) >> 8, 200, 0, 0, 0);
}
The setup expects you to have four mapspots in the map with tids: 5, 7, 8, and 19.

Share this post


Link to post

Thanks for the reply.

This is a good idea but I am actually trying to make a reusable script for different linedefs (with arguments).
A linedef with an argument would fire all mapspots with the TID in the argument.
To do this I would need more than 3 arguments in the linedef action.
Maybe I could try using successive numbers.
The only downside is that the number of mapspots is fixed like this.

This just gave me an idea.
Perhaps I can use the first argument as the first TID and the second argument to define the number of mapspots.

script 4 (int tagID, int MAPSPOTS_NUMBER)
{
    for(int i=tagID; i < tagID+MAPSPOTS_NUMBER; i++)
    {
        SpawnProjectile(i,"PlasmaBall",GetActorAngle(i) >> 8,20,0,0,0);
        PlaySound(i,"weapons/plasmaf");
    }    
}

This works! Thanks.

Share this post


Link to post

You don't need to independently play "weapons/plasmaf", the plasmaball class itself already does this.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×