Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Script Dump
I noticed we have one for sprites, but not scripts. So I'll get us started with a couple of things I have lying around-
Improved Spin-Up/Down Mechanics Written for me by Cave, used on the Brotherhood's Confessor and Cyborg Gatling.
Attached to the weapon, this script steps the weapon RPM up/down over time to give a more 'classic' ramping effect than the simple hold-to-start delay system currently used by some Coalition gatlings. Should be used with per-shot firing sounds rather than a loop, for obvious reasons.
self.rofBase = 300; --this is the weapon's default/base RPM, should match the RateOfFire set in ini code self.rofIncreasePerShot = 50; --increase in RPM per shot fired self.rofMax = 1050; --maximum RPM self.rofTimeToReset = 3000; --this is how long the weapon takes to spin down once firing stops (automatically drops back to base after reloading) with a longer time allowing for longer pauses between fired bursts
end
function Update(self)
if self.Magazine ~= nil then if self.reloaded == false then self.reloaded = true; self.ammoCounter = self.Magazine.RoundCount; else if self.ammoCounter ~= self.Magazine.RoundCount then self.spinDownTimer:Reset(); self.RateOfFire = math.min(self.RateOfFire + (self.rofIncreasePerShot*(self.ammoCounter-self.Magazine.RoundCount)),self.rofMax); end self.ammoCounter = self.Magazine.RoundCount; if not self:IsActivated() then self.RateOfFire = math.max(self.RateOfFire - (self.rofMax-self.rofBase)*(self.spinDownTimer.ElapsedSimTimeMS/self.rofTimeToReset),self.rofBase); self.spinDownTimer:Reset(); end end else self.reloaded = false; end
end
Variable Zoom Scope By Mehman.
This script, attached to the weapon, permits smooth scaling of sharpaim level. Very useful for sniper weapons.
Code:
function Create(self) self.MaxLength = 2000; --maximum SharpLength in pixels self.LengthFactor = 1; --? self.Variation = 2; --smaller value = smoother transition when zooming end
function Update(self) local ray = SceneMan:CastObstacleRay((self.MuzzlePos*2)-self.Pos , (self.MuzzlePos-self.Pos).Normalized*self.MaxLength , Vector() , Vector() , self.ID , self.Team, 0 , 0); if (ray > 0 and self.SharpLength < self.LengthFactor*ray) then self.SharpLength = self.SharpLength+self.Variation; end if (ray <= 0 and self.SharpLength < self.LengthFactor*self.MaxLength) then self.SharpLength = self.SharpLength+self.Variation; end if (ray > 0 and self.SharpLength > self.LengthFactor*ray) then self.SharpLength = self.SharpLength-self.Variation; end end
ID-Locked Weapon Maybe from SAW?
This simple weapon-based script forces any mismatching actor to drop it. In the following example, any actor that has a presetname other than 'GDI Commando' cannot use the weapon, as they'll drop it as soon as they pick it up. This is also used to make sure that non-cyborgs can't use the Cyborg Gatling and Cyborg Commando Plasma Gun.
Code:
function Update(self) if self:IsAttached() and MovableMan:GetMOFromID(self.RootID).PresetName ~= "GDI Commando" then ToActor(MovableMan:GetMOFromID(self.RootID)):GetController():SetState(Controller.WEAPON_DROP, true); end end
Smooth Glow-Trail Various Authors
Ever hated how fast-moving objects with glow-based trails can be ugly, blobby, and/or inconsistent? Look no further! This projectile-based script causes the weapon to emit a much smoother trail - it first saw use on the 40K plasma weapons, and was later used (with tweaks) in my AEON Technologies Arsenal pack. It is also used on the Cyborg Commando Plasma Cannon, Man-Portable Railgun, Hawkeye Sniper Rifle, and others.
Simply change the particle called by CreateMOPixel and the '2' after "for i = 1, trailLength," in order to adjust both the effect you get and the actual length of the trail. If you want a more dispersing trail, you can uncomment the Effect.Vel line (remove the --) and adjust the various math.random and RangeRand variables.
Note that because this script makes a lot of glow particles it can reduce FPS on lower-end systems, so use it sparingly. Works nice for 'special' weapons, or maybe for your tracer rounds.
[code]function Update(self) local Effect local Offset = self.Vel*(20*TimerMan.DeltaTimeSecs) -- the effect will be created the next frame so move it one frame backwards towards the barrel
local trailLength = math.floor(Offset.Magnitude+0.5) for i = 1, trailLength, 2 do Effect = CreateMOPixel("CyCom Plasma Cannon Glow Trail", "Brotherhood.rte") if Effect then Effect.Pos = self.Pos - Offset * (i/trailLength) + Vector(RangeRand(-1, 1), RangeRand(-1, 1)) --Effect.Vel = Vector(math.random(1,2),0) MovableMan:AddParticle(Effect) end end end[code]
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