View topic - Explode (piece) that can be given a direction/speed



All times are UTC + 1 hour


Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 07 Dec 2011, 21:23 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Usually Explode (piece) makes the piece fly of in some lame random direction.
From
void CUnitScript::Explode(int piece, int flags)
0.5f-gs->randFloat()) * 6.0f, 1.2f + gs->randFloat() * 5.0f, (0.5f - gs->randFloat()) * 6.0f

But the speed of the unit is also factored in and thus if you change unitspeed via MoveCtrl, you can basically direct what speed/direction the pieces fly:

Image

Image

Code:
function headExplodeTest ()   
   local speed = 100
   local x,y,z=Spring.GetUnitPosition (unitID) --needed so unit does not bounce all over the place
   while (true) do
      for a = 1, 360, 10 do
         xs = math.sin (math.rad(a)) * speed
         zs = math.cos (math.rad(a)) * speed
         Spring.MoveCtrl.Enable (unitID)
         Spring.MoveCtrl.SetPhysics  (unitID, x,y,z,
         xs, 0, zs,
         0, 0, 0)      
         Explode (head, SFX.FALL)
         --Spring.MoveCtrl.Disable (unitID) --doesnt seem to work
         Sleep (100)
      end
   end
end

Problem is, changing unit speed makes it go into that direction because physics. So atm I only got it to work with unmobile units, but eg for death animations it should be ok with mobile units. (dead units dont move unless journeywar)
Also works with SHATTER btw, the shards fly off in the same direction.


Top
 Offline Profile  
 
PostPosted: 07 Dec 2011, 21:27 
Spring Developer

Joined: 08 Oct 2006, 15:58
1)
Code:
class CPieceProjectile: public CProjectile

2) http://springrts.com/wiki/Lua_SyncedCtrl#Projectiles
3) ???
4) profit!


Top
 Offline Profile  
 
PostPosted: 07 Dec 2011, 21:31 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
oh.
But to get a projectileID I need to enable WatchProjectile/Weapon (or whats it called) and I thought that was expensive?
Also what is the projectile/weapon DefID for exploded unit pieces?


Top
 Offline Profile  
 
PostPosted: 07 Dec 2011, 21:36 
Spring Developer

Joined: 08 Oct 2006, 15:58
Quote:
But to get a projectileID I need to enable WatchProjectile/Weapon (or whats it called) and I thought that was expensive?


To get piece projectile ID's you don't, because a certain developer has not yet added a watch-filter for them.

Quote:
Also what is the projectile/weapon DefID for exploded unit pieces?


nil


Top
 Offline Profile  
 
PostPosted: 07 Dec 2011, 22:04 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
proOwnerID seems to be unitID and GetProjectileName is the piece name. (was afraid that it would be nil or something silly)
cool cool except now it is almost too easy.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.