Page 1 of 1

Help needed for weapon modding

Posted: Sun Mar 23, 2014 4:47 pm
by kliyo
Hello everybody
I'm trying to create a taser-like altfire for the vanilla prod, but until now i've been unsuccesfull. My aim is for the prod to keep its melee attack as the primary fire, and add an altfire that fires a dart or an electric arc (like spiderbots) at short range.
I've just started learning Uscript and this is still over my skills. I've tried copying and editing other weapons alt fire functions, but that just screwed things up. I'm not sure how to do it due to the prod being a melee weapon and the altfire need it to act as a ranged weapon. Any ideas?

PD: Sorry if my english is twisted and confusing. It's not my native language. I hope is understandable enough...

Re: Help needed for weapon modding

Posted: Sun Mar 23, 2014 11:41 pm
by ~DJ~
Hmm, well, there's an interesting tutorial that I think might help you.
Check this out.

See the PlasmaBolt example? Well, make it as a melee weapon, but when calling out the ALTFIRE function, Spawn a projectile.. or use other functions like SCOPE instead of ALTFIRE, as the tutorial suggests. Up to you though!
Also check out 'WeaponSpiderBot', maybe you can use it's code on a custom projectile of yours, or perhaps incorporate that code into your weapon.

HOPE IT HELPS. :oops:

Re: Help needed for weapon modding

Posted: Tue Mar 25, 2014 10:35 pm
by kliyo
Well...might work, if I knew how to make it work.
What I wanted to do was to add the main fire of this weapon (thanks to whomever did it) as the alt fire of the prod.

//=============================================================================
// WeaponTaser.
// lol, I actually did something here
//=============================================================================
class WeaponTaser extends WeaponProd;

var bool bLamp;
var vector EmitterOffset;

var ElectricityEmitter emitter;
var float zapTimer;
var vector lastHitLocation;
var int shockDamage;


simulated function bool ClientAltFire( float Value )
{
GotoState('Lamp');
return true;
}

function AltFire( float Value )
{
ClientAltFire(Value);

}

state Lamp
{
simulated function BeginState()
{

if (!bLamp)
{
bLamp = True;
Lightbrightness = 250;
Owner.PlaySound(Sound'Switch4ClickOn', SLOT_None, 1024);
}
else if (bLamp)
{
bLamp = False;
Lightbrightness = 0;
Owner.PlaySound(Sound'Switch4ClickOff', SLOT_None, 1024);
}
GotoState('Idle');
}}

function LampOff()
{
if (bLamp)
{
bLamp = False;
Lightbrightness = 0;
Owner.PlaySound(Sound'Switch4ClickOff', SLOT_None, 1024);
}
}

simulated function ClientDownWeapon()
{
bWasInFiring = IsInState('ClientFiring') || IsInState('ClientAltFiring') || IsInState('SimFinishFire') || IsInState('Zooming');
bClientReadyToFire = False;
GotoState('SimDownWeapon');
}

state DownWeapon
{
ignores Fire, AltFire;

function bool PutDown()
{
// alert NPCs that I'm putting away my gun
AIEndEvent('WeaponDrawn', EAITYPE_Visual);
return Super.PutDown();
}

Begin:
ScopeOff();
LaserOff();
LampOff();
if (( Level.NetMode == NM_DedicatedServer ) || ((Level.NetMode == NM_ListenServer) && Owner.IsA('DeusExPlayer') && !DeusExPlayer(Owner).PlayerIsListenClient()))
ClientDownWeapon();

TweenDown();
FinishAnim();

if ( Level.NetMode != NM_Standalone )
{
ClipCount = 0; // Auto-reload in multiplayer (when putting away)
}
bOnlyOwnerSee = false;
if (Pawn(Owner) != None)
Pawn(Owner).ChangedWeapon();
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
Super.ProcessTraceHit(Other, HitLocation, HitNormal, X, Y, Z);

zapTimer = 1;
if (emitter != None)
{
EmitterOffset.X = 0.000000;
EmitterOffset.Y = 0.000000;
EmitterOffset.Z = (Owner.CollisionHeight - 10);
emitter.SetLocation((Owner.Location) + (EmitterOffset));
emitter.SetRotation(Pawn(Owner).ViewRotation);
emitter.damageamount = ShockDamage;
emitter.TurnOn();
emitter.SetBase(Owner);
lastHitLocation = HitLocation;
}
}

// force EMP damage
function name WeaponDamageType()
{
return 'EMP';
}

function Tick(float deltaTime)
{
Super.Tick(deltaTime);

if (zapTimer > 0)
{
zapTimer -= deltaTime;

// update the rotation of the emitter
emitter.SetRotation(Pawn(Owner).ViewRotation);

// turn off the electricity after the timer has expired
if (zapTimer < 0)
{
zapTimer = 0;
emitter.TurnOff();
}
}
}

function Destroyed()
{
if (emitter != None)
{
emitter.Destroy();
emitter = None;
}

Super.Destroyed();
}

function PostBeginPlay()
{
Super.PostBeginPlay();

zapTimer = 0;
emitter = Spawn(class'ElectricityEmitter', Self);
if (emitter != None)
{
emitter.bFlicker = False;
emitter.randomAngle = 1024;
emitter.damageAmount = shockDamage;
emitter.TurnOff();
emitter.Instigator = Pawn(Owner);
}
}
defaultproperties
{
shockDamage=5
fireRate=0.25
maxRange=1280
AccurateRange=320
FireSound2=Sound'DeusExSounds.Weapons.ProdFire'
AmmoNames=Class'DeusEx.AmmoBattery'
bHasAltFire=True
recoilStrength=0.20
bCanHaveModReloadTime=True
FireOffset=(X=21.00,Y=12.00,Z=19.00),
ItemName="Spiderbot Taser"
largeIcon=Texture'DeusExUI.Icons.BeltIconProd'
largeIconWidth=47
largeIconHeight=47
Description="An early demo model for the taser used in the Chiang ARCBOT series. Owing to its repair bot roots, this hand-held device can be used as a lamp or as a means to service electronic devices."
beltDescription="SPIDERBOT"
CollisionRadius=12.75
CollisionHeight=1.75
LightType=1
LightEffect=9
LightHue=160
LightSaturation=200
LightRadius=16
}

Any ideas on how to put this main fire as the altfire of a melee weapon?

Re: Help needed for weapon modding

Posted: Wed Mar 26, 2014 6:21 pm
by Hanfling
DX Weapon code is seriously fucked up. Maybe it's easier to fire a hidden weapon instead.