Welcome Guest ( Login | Register )


All times are UTC - 5 hours



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu May 28, 2009 1:39 pm   Post subject: Deil's Myrmidon

Joined: May 28, 2009
Posts: 1
This weapon is a seeking disc launcher automatically looking for further targets and hitting them several times. In case of no target, it attacks its source object.
Create a new file called deilsmyrmidon.cs and paste the following code into it.
//--------------------------------------
// Deil's Myrmidon
//--------------------------------------

datablock SeekerProjectileData(DMProjectile)
{
   projectileShapeName = "disc.dts";
   scale               = "0.5 0.5 0.5";
   hasDamageRadius     = true;
   indirectDamage      = 0.4;
   damageRadius        = 10;
   radiusDamageType    = $DamageType::DM;
   kickBackStrength    = 2500;

   explosion           = "DiscExplosion";
   underwaterExplosion = "UnderwaterDiscExplosion";
   splash              = DiscSplash;

   velInheritFactor    = 1.0;    // to compensate for slow starting velocity, this value
                                 // is cranked up to full so the missile doesn't start
                                 // out behind the player when the player is moving
                                 // very quickly - bramage
   baseEmitter         = DiscSplash;

   lifetimeMS          = 12000;
   muzzleVelocity      = 10.0;
   maxVelocity         = 500.0;
   turningSpeed        = 500.0;
   acceleration        = 100.0;

   proximityRadius     = 3;

   terrainAvoidanceSpeed         = 1800;
   terrainScanAhead              = 50;
   terrainHeightFail             = 19;
   terrainAvoidanceRadius        = 100; 

   flareDistance = 200;
   flareAngle    = 30;

   sound = discProjectileSound;

   hasLight    = true;
   lightRadius = 6.0;
   lightColor  = "0.175 0.175 0.5";

   explodeOnWaterImpact = false;
};
//--------------------------------------------------------------------------
// Ammo
//--------------------------------------

datablock ItemData(DMAmmo)
{
   className = Ammo;
   catagory = "Ammo";
   shapeFile = "ammo_disc.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
   pickUpName = "some DM discs";
};

//--------------------------------------------------------------------------
// Weapon
//--------------------------------------

datablock ShapeBaseImageData(DMImage)
{
   className = WeaponImage;
   shapeFile = "weapon_disc.dts";
   item = DM;
   ammo = DMAmmo;
   emap = true;
   
   projectileSpread = 1.0 / 1000.0;
   
   projectile = DMProjectile;
   projectileType = SeekerProjectile;
   isSeeker     = true;
   seekRadius   = 200;
   maxSeekAngle = 14;
   seekTime     = 0.5;
   minSeekHeat  = 0.0;
   
   minTargetingDistance             = 15;
   
   stateName[0]                     = "Activate";
   stateTransitionOnTimeout[0]      = "ActivateReady";
   stateTimeoutValue[0]             = 0.5;
   stateSequence[0]                 = "Activate";
   stateSound[0]                    = DiscSwitchSound;

   stateName[1]                     = "ActivateReady";
   stateTransitionOnLoaded[1]       = "Ready";
   stateTransitionOnNoAmmo[1]       = "NoAmmo";

   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateSequence[2]                 = "DiscSpin";
   stateSound[2]                    = DiscLoopSound;
   stateTransitionOnTriggerDown[2]  = "CheckWet";

   stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.4;
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateSound[3]                    = DiscFireSound;

   stateName[4]                     = "Reload";
   stateTransitionOnNoAmmo[4]       = "NoAmmo";
   stateTransitionOnTimeout[4]      = "Ready";
   stateTimeoutValue[4]             = 6.5;
   stateAllowImageChange[4]         = false;
   stateSequence[4]                 = "Reload";
   stateSound[4]                    = DiscReloadSound;

   stateName[5]                     = "NoAmmo";
   stateTransitionOnAmmo[5]         = "Reload";
   stateSequence[5]                 = "NoAmmo";
   stateTransitionOnTriggerDown[5]  = "DryFire";

   stateName[6]                     = "DryFire";
   stateSound[6]                    = DiscDryFireSound;
   stateTimeoutValue[6]             = 1.0;
   stateTransitionOnTimeout[6]      = "ActivateReady";
   
   stateName[7]                     = "CheckTarget";
   stateTransitionOnNoTarget[7]     = "Fire";
   stateTransitionOnTarget[7]       = "Fire";
   
   stateName[8]                     = "CheckWet";
   stateTransitionOnWet[8]          = "WetFire";
   stateTransitionOnNotWet[8]       = "CheckTarget";
   
   stateName[9]                     = "WetFire";
   stateTransitionOnNoAmmo[9]       = "NoAmmo";
   stateTransitionOnTimeout[9]      = "Reload";
   stateSound[9]                    = DiscFireSound;
   stateRecoil[3]                   = LightRecoil;
   stateTimeoutValue[9]             = 0.4;
   stateSequence[3]                 = "Fire";
   stateScript[9]                   = "onWetFire";
   stateAllowImageChange[9]         = false;

};
datablock ItemData(DM)
{
   className = Weapon;
   catagory = "Spawn Items";
   shapeFile = "weapon_disc.dts";
   image = DMImage;
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
   pickUpName = "a deil's myrmidon";
   emap = true;
};

function DMImage::onFire(%data,%obj,%slot)
{
   %p = Parent::onFire(%data, %obj, %slot);
   MissileSet.add(%p);
   %target = %obj.getLockedTarget();
   if(%target)
      %p.setObjectTarget(%target);
   else if(%obj.isLocked())
      %p.setPositionTarget(%obj.getLockedPosition());
   else
      %p.setObjectTarget(%obj);
}

function DMImage::onWetFire(%data, %obj, %slot)
{
   %p = Parent::onFire(%data, %obj, %slot);
   MissileSet.add(%p);
   %p.setNoTarget();
}

function DMProjectile::onExplode(%data, %proj, %pos, %mod)
{
  %target = FindClosestPlayer(%proj,%pos);
  %targVec = %target.getPosition();
  if(%target)
  {
    %projDir = VectorNormalize(VectorSub(%targVec, %pos));
    %p = new SeekerProjectile()
    {
       dataBlock        = "DMProjectile";
       initialDirection = %projDir;
       initialPosition  = %pos;
       sourceObject     = %proj.sourceObject;
       sourceSlot       = %proj.sourceSlot;
       vehicleObject    = 0;
    };
    MissionCleanup.add(%p);
    %p.setObjectTarget(%target );
  }
  Parent::onExplode(%data, %proj, %pos, %mod);
}

function FindClosestPlayer(%proj,%pos)
{
  InitContainerRadiusSearch(%pos, 200, $TypeMasks::PlayerObjectType);
  %objSrch = containerSearchNext();
  if(isObject(%objSrch))
  {
    %objNextSrch = containerSearchNext();
    while(isObject(%objNextSrch))
    {
      if(VectorDist(%pos, %objNextSrch.getPosition()) < VectorDist(%pos, %objSrch.getPosition()) && %objNextSrch.team != %proj.sourceObject.team && !%objNextSrch.isCloaked())
        %objSrch = %objNextSrch;
      %objNextSrch = containerSearchNext();
    }
  }
  if(%proj.sourceObject.getState() !$= "Dead" )
    if(!%objSrch || %objSrch.team == %proj.sourceObject.team || %objSrch.isCloaked() || %objSrch.getState() $= "Dead")
    %objSrch = %proj.sourceObject;
  return %objSrch;
}


Paste this into controlDefaults.cs
function useDM( %val )
{
   if ( %val )
      use( DM );
}

And add this line
passengerKeys.copyBind( moveMap, useDM );


Paste the following into OptionsDlg.cs around line 1390
$RemapName[$RemapCount] = "Deil's Myrmidon";
$RemapCmd[$RemapCount] = "useDM";
$RemapCount++;


Paste this code into hud.cs around line 240
case "DM":
   reticleHud.setBitmap("gui/ret_disc");
   reticleFrameHud.setVisible(true);


Paste the following code snippets into inventory.cs
Into function ShapeBase::hasAmmo( %this, %weapon)
case DM:
   return( %this.getInventory( DMAmmo ) > 0 );

Into function ShapeBase::clearInventory(%this)
%this.setInventory(DM,0);
%this.setInventory(DMAmmo,0);

And this into serverCmdGiveAll(%client)
%player.setInventory(DM,1);
%player.setInventory(DMAmmo,999);


Paste this into file inventoryHud.cs
$InvWeapon[10] = "Deil's Myrmidon"; 

$NameToInv["Deil's Myrmidon"] = "DM";


Paste this into file player.cs into the several datablocks for lights, mediums and heavies
max[DM] = 1;
max[DMAmmo] = 15;


Edit ammopack.cs as followed
$AmmoItem[7] = DMAmmo;

$numAmmoItems = 8;

max[DMAmmo] = 20;


Add a new damage type in file damagetypes.cs
$DamageType::DM = 37;

And add the following code for all datablocks
shieldDamageScale[$DamageType::DM]       = 1.0;
damageScale[$DamageType::DM]             = 1.0;


Add death messages in file deathmessages.cs
$DeathMessageSelfKill[$DamageType::DM, 0] = '\c0The Devil has turned against %1.';
$DeathMessageSelfKill[$DamageType::DM, 1] = '\c0The Deil has canceled his pact with %1.';
$DeathMessageSelfKill[$DamageType::DM, 2] = '\c0%1 has made a bad pact.';
$DeathMessageSelfKill[$DamageType::DM, 3] = '\c0%1 has had to run away from %3 own disc.';
$DeathMessageSelfKill[$DamageType::DM, 4] = '\c0The Deil has shown his unpredictability to %1.';

$DeathMessageTeamKill[$DamageType::DM, 0] = '\c0%4 TEAMKILLED %1 with a deil\'s myrmidon!';

$DeathMessage[$DamageType::DM, 0] = '\c0Deil kills %1 for %4.';
$DeathMessage[$DamageType::DM, 1] = '\c0%4 has made a pact with the Devil against %1.';
$DeathMessage[$DamageType::DM, 2] = '\c0%4\'s DM disc dices %1.';
$DeathMessage[$DamageType::DM, 3] = '\c0%4 sends %1 to hell.';
$DeathMessage[$DamageType::DM, 4] = '\c0%4 victimizes %1 for the Devil.';


Add the weapon in file weapon.cs
$WeaponsHudData[11, bitmapName] = "gui/hud_disc";
$WeaponsHudData[11, itemDataName] = "DM";
$WeaponsHudData[11, ammoDataName] = "DMAmmo";

$WeaponsHudCount = 12;

$AmmoIncrement[DMAmmo] = 10;

exec("scripts/weapons/deilsmyrmidon.cs");


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

All times are UTC - 5 hours


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:  
cron