danceMissiles.patch (3,320 bytes)
2007-09-14 11:33
Index: Lua/LuaWeaponDefs.cpp
===================================================================
--- Lua/LuaWeaponDefs.cpp (revision 4376)
+++ Lua/LuaWeaponDefs.cpp (working copy)
@@ -516,6 +516,7 @@
ADD_FLOAT("explosionSpeed", wd.explosionSpeed);
ADD_FLOAT("wobble", wd.wobble);
+ ADD_FLOAT("dance", wd.dance);
ADD_FLOAT("trajectoryHeight", wd.trajectoryHeight);
ADD_BOOL("largeBeamLaser", wd.largeBeamLaser);
Index: Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp
===================================================================
--- Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp (revision 4376)
+++ Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp (working copy)
@@ -40,6 +40,10 @@
CR_MEMBER(wobbleDir),
CR_MEMBER(wobbleTime),
CR_MEMBER(wobbleDif),
+ CR_MEMBER(danceMove),
+ CR_MEMBER(danceCenter),
+ CR_MEMBER(danceTime),
+ CR_MEMBER(isDancing),
CR_MEMBER(extraHeight),
CR_MEMBER(extraHeightDecay),
CR_MEMBER(extraHeightTime),
@@ -62,6 +66,10 @@
wobbleTime(1),
wobbleDir(0,0,0),
wobbleDif(0,0,0),
+ danceMove(0,0,0),
+ danceCenter(0,0,0),
+ danceTime(1),
+ isDancing(weaponDef?weaponDef->dance>0:false),
isWobbling(weaponDef?weaponDef->wobble>0:false),
extraHeightTime(0)
{
@@ -172,6 +180,16 @@
dir+=wobbleDir*weaponDef->wobble*(owner?(1-owner->limExperience*0.5f):1);
dir.Normalize();
}
+
+ if(isDancing) {
+ --danceTime;
+ if(danceTime<=0) {
+ danceMove = gs->randVector() * weaponDef->dance - danceCenter;
+ danceCenter += danceMove;
+ danceTime=8;
+ }
+ pos+=danceMove;
+ }
float3 orgTargPos(targPos);
float dist=targPos.distance(pos);
Index: Sim/Projectiles/WeaponProjectiles/MissileProjectile.h
===================================================================
--- Sim/Projectiles/WeaponProjectiles/MissileProjectile.h (revision 4376)
+++ Sim/Projectiles/WeaponProjectiles/MissileProjectile.h (working copy)
@@ -40,6 +40,11 @@
float3 wobbleDir;
int wobbleTime;
float3 wobbleDif;
+
+ bool isDancing;
+ int danceTime;
+ float3 danceMove;
+ float3 danceCenter; //vector that points towards the center of the dance to keep the movement "coherent"
float extraHeight;
float extraHeightDecay;
Index: Sim/Weapons/WeaponDefHandler.cpp
===================================================================
--- Sim/Weapons/WeaponDefHandler.cpp (revision 4376)
+++ Sim/Weapons/WeaponDefHandler.cpp (working copy)
@@ -353,6 +353,7 @@
wd.interceptedByShieldType = wdTable.GetInt("interceptedByShieldType", defInterceptType);
wd.wobble = wdTable.GetFloat("wobble", 0.0f) * PI / 0x7fff / 30.0f;
+ wd.dance = wdTable.GetFloat("dance", 0.0f) / GAME_SPEED;
wd.trajectoryHeight = wdTable.GetFloat("trajectoryHeight", 0.0f);
wd.noAutoTarget = (wd.manualfire || wd.interceptor || wd.isShield);
Index: Sim/Weapons/WeaponDefHandler.h
===================================================================
--- Sim/Weapons/WeaponDefHandler.h (revision 4376)
+++ Sim/Weapons/WeaponDefHandler.h (working copy)
@@ -127,6 +127,7 @@
unsigned int onlyTargetCategory;
float wobble; //how much the missile will wobble around its course
+ float dance; //how much the missile will dance
float trajectoryHeight; //how high trajectory missiles will try to fly in
struct Visuals