Author Topic: Why isn't my weapon showing up in the weapon list?  (Read 2513 times)

I admit I made some slight edits to the sword but I made sure to change the ui names and whatnot so there wouldn't be conflicting list names. Do I need more than just the UI names changed???

Link to the [broken] weapon in question: https://www.dropbox.com/s/a4tv6pax8sj9eep/Weapon_ProtoSword.zip?dl=0

yes, you need more than the UI name changed because otherwise you'd be overwriting the datablocks uiinfo.

Ah, I see. So basically any datablocks that's just "swordX" needs to be changed to "editswordX", if I'm not mistaken?
Edit: would it be possible to have forceAddonRequired in the script to take bits and pieces from the original sword instead or am I horribly wrong?
Edit: I think I fixed it. Removed like eight commented lines to shorten it a bit
Code: [Select]
//protoherosword.cs
datablock AudioProfile(protoswordDrawSound)
{
   filename    = "./protoswordDraw.wav";
   description = AudioClosest3d;
   preload = true;
};
datablock AudioProfile(protoswordHitSound)
{
   filename    = "./protoswordHit.wav";
   description = AudioClosest3d;
   preload = true;
};


//effects
datablock ParticleData(protoswordExplosionParticle)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 1.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 300;
   textureName          = "base/data/particles/chunk";
   colors[0]     = "1.0 0.7 0.9 0.9";
   colors[1]     = "1.0 0.9 0.9 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.25;
};

datablock ParticleEmitterData(protoswordExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 8;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 60;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "swordExplosionParticle";

   uiName = "Proto Hero Sword Hit";
};

datablock ExplosionData(protoswordExplosion)
{
   //explosionShape = "";
   lifeTimeMS = 500;

   soundProfile = protoswordHitSound;

   particleEmitter = protoswordExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = true;
   camShakeFreq = "80.0 80.0 80.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 3;
   lightEndRadius = 0;
   lightStartColor = "00.9 0.2 0.6";
   lightEndColor = "0 0 0";
};


//projectile
AddDamageType("Sword",   '<bitmap:add-ons/Weapon_Sword/CI_sword> %1',    '%2 <bitmap:add-ons/Weapon_Sword/CI_sword> %1',0.75,1);
datablock ProjectileData(protoswordProjectile)
{
   directDamage        = 75;
   directDamageType  = $DamageType::Sword;
   radiusDamageType  = $DamageType::Sword;
   explosion           = protoswordExplosion;
   //particleEmitter     = as;

   muzzleVelocity      = 50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 100;
   fadeDelay           = 70;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "Proto Hero Sword Slice";
};


//////////
// item //
//////////
datablock ItemData(protoswordItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./protosword.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Proto Hero Sword";
iconName = "./icon_sword";
doColorShift = true;
colorShiftColor = "0.600 0.000 0.000 1.000";

// Dynamic properties defined by the scripts
image = swordImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(protoswordImage)
{
   // Basic Item properties
   shapeFile = "./sword.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";

   correctMuzzleVector = false;

   eyeOffset = "0.7 1.2 -0.25";

   className = "WeaponImage";

   // Projectile && Ammo.
   item = protoswordItem;
   ammo = " ";
   projectile = protoswordProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = true;
   doRetraction = false;
   //raise your arm up or not
   armReady = true;

   //casing = " ";
   doColorShift = true;
   colorShiftColor = "0.600 0.000 0.000 1.000";



stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]      = "Ready";
stateSound[0]                    = protoswordDrawSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "PreFire";
stateAllowImageChange[1]         = true;

stateName[2] = "PreFire";
stateScript[2]                  = "onPreFire";
stateAllowImageChange[2]        = false;
stateTimeoutValue[2]            = 0.1;
stateTransitionOnTimeout[2]     = "Fire";

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "CheckFire";
stateTimeoutValue[3]            = 0.2;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;

stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "Fire";


stateName[5]                    = "StopFire";
stateTransitionOnTimeout[5]     = "Ready";
stateTimeoutValue[5]            = 0.2;
stateAllowImageChange[5]        = false;
stateWaitForTimeout[5] = true;
stateSequence[5]                = "StopFire";
stateScript[5]                  = "onStopFire";


};

function swordImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack);
}

function swordImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

« Last Edit: September 29, 2016, 06:21:20 AM by Space1255 »

You are going well on the changes, but there's still plenty of stuff you missed. For example, use protoswordImage in place of all remaining swordImage instances, including the functions at the bottom. More swordX instances are left alongside the aforementioned.

Make sure everything says protosword and there's nothing just sword. If you aren't going to change the projectile, it's possible to require the Sword weapon to reuse it but I'm on mobile so I can't quite show you right now.

Good luck on whatever you're making.

You are going well on the changes, but there's still plenty of stuff you missed. For example, use protoswordImage in place of all remaining swordImage instances, including the functions at the bottom. More swordX instances are left alongside the aforementioned.
Got it. I'll get on that. Thank you for your help.
Edit: will I need to change the damage type /  bitmaps / etc to Portosword or can I keep it as just sword?
« Last Edit: September 29, 2016, 12:13:18 PM by Space1255 »

You can reuse the existing damage type if you wish. Just remove the part where the damage type is added, and make sure Weapon_Sword loads before your add on does.

You can reuse the existing damage type if you wish. Just remove the part where the damage type is added, and make sure Weapon_Sword loads before your add on does.
Any way to ensure that happens?

Any way to ensure that happens?
forceloadrequiredaddon("Weapon_Sword"); in the very first line of the server.cs file.

Take a look at Guns Akimbo to see how to correctly do it with error checking and such.

Got it.
Also, if I were to make a weapon PACK, would the server.cs just be exec(bla.cs); for every weapon in it, bla.cs being the individual weapon values?
« Last Edit: September 29, 2016, 05:55:17 PM by Space1255 »

Yes, instead of asking these silly questions is always good to see if it works. Not saying these are bad questions though!
Make sure it's either referring to the folder or using something like exec("./blah.cs"); which executes from where the folder is (not the add-on folder)

the way exec works is it looks for the file in that position. "./" just indicates the same folder as the current file is in. You could optionally do "Add-Ons/addon_name/folder/file.cs" if you wanted to, though that would mean renaming your addon zip would break the paths.

Noted.
Still not working. Is there another swordX function i missed or am i just totally inept at coding?

you should check the console if it even is fully executing or if it has any errors

On it.
Code: [Select]
 CustomGameGui checking Add-On: Weapon_ProtoSword
Checking Add-On Weapon_ProtoSword
Loading Add-On: Weapon_ProtoSword
Add-Ons/Weapon_ProtoSword/server.cs Line: 1 - Syntax error.
ADD-ON "Weapon_ProtoSword" CONTAINS SYNTAX ERRORS
forget me
edit: I'm seeing a bunch of gray squares in my code [probably because i just copy and pasted the raw text] where almost all of the spaces are, should I try to replace said squares with normal spaces? [See attached]
« Last Edit: September 30, 2016, 04:18:32 PM by Space1255 »

Editing an addon while Blockland is on and trying to run the addon after the edit always returns a syntax error. Line 1 is properly commented, so either do "setmodpaths(getmodpaths());" in console, without quotation marks, to reset addons, or restart the game. If the game is closed while you're reading this, then just open the game.