## XIII
Class WeaponOno

source: C:\XIII\XIII\Classes\WeaponOno.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--XIII.WeaponOno

Direct Known Subclasses:BazookWeaponOno, CrossBowWeaponOno, GunWeaponOno, M16WeaponOno, M60WeaponOno, MagnumWeaponOno, RifleWeaponOno, TKnifeWeaponOno

class WeaponOno
extends Engine.Info

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`Material` | `MyOno`
`float` | `fadeTime` HOW LONG WILL A TEXT BE VISIBLE (it wades down smoothly using a sine function...
`float` | `lastBurstTime` Makes the Ratata restart when you've released fire for a short time and continues shooting
`OnoType` | `myOnoType`
`int` | `onoPosXRandMin,` rand position relative Canvas.ClipX*0.5
`onoPosX,` | `onoPosY` position where the ono text is rendered (randomized)
`int` | `onoPosYRandMin,` rand position relative Canvas.ClipY*0.5
`Texture` | `onoTexture2ToRender` some weapons like the RA TA TA needs two textures
`Texture` | `onoTextureToRender` Makes the Ratata restart when you've released fire for a short time and continues shooting
`bool` | `renderOno` enables /disables the actual rendering of the ono....
`int` | `scaleFactor` based on scaleRandDeltaMin, scaleRandDeltaMax; 1,0 by default
`scaleRandDeltaMin,` | `scaleRandDeltaMax` ]0, 10] 1.0 is default and results in no scaling.
`float` | `weaponFiredTimer` Primary == 0 secondary == 1 noammo == 2 reload == 3 not used yet....
`int` | `weaponFired[4]` Primary == 0 secondary == 1 noammo == 2 reload == 3 not used yet....
`Texture` | `weaponNoAmmoOnoTexture` Out of ammo "Click"
`Texture` | `weaponOnoAltTexture` Secondary fire on primary weapon
`Texture` | `weaponOnoTexture` Primary texture for primaty weapon.. Also the first texture in the compound RAtatata
`Texture` | `weaponOnoTexture2` the TA in the compund RATATATA effect
`Texture` | `weaponReloadOnoTexture` not used yet
`Texture` | `weaponSilencerOnoTexture` Only used for the beretta right now

Function Summary
`simulated` | `FirePrimaryWeapon()`
    //_____________________________________________________________________________
    // called from XIIIWeapon when a shot is fired
`simulated` | `FirePrimaryWeaponAlt()`
    //_____________________________________________________________________________
    // called from XIIIWeapon when a shot is fired
`simulated` | `ReloadPrimaryWeapon()`
    //_____________________________________________________________________________
`simulated` | `renderFixed(Canvas Canvas)`
    //_____________________________________________________________________________
`simulated` | `renderRatata(Canvas Canvas)`
    //_____________________________________________________________________________
`simulated` | `updateFixed()`
    //_____________________________________________________________________________
`simulated` | `updateRatata()`
    //_____________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004
    00005	class WeaponOno extends Info;
    00006
    00007	//#exec OBJ LOAD FILE=XIIIXboxPacket.utx
    00008
    00009	var material MyOno;
    00010
    00011	enum OnoType
    00012	{
    00013	    ONOTYPE_DISABLED,
    00014	    ONOTYPE_FIXED,
    00015	    ONOTYPE_FADECENTERED,
    00016	    ONOTYPE_FADECENTER,
    00017	    ONOTYPE_EXPAND,
    00018	    ONOTYPE_RATATA,
    00019	    ONOTYPE_RATARATA
    00020	};
    00021
    00022	var OnoType myOnoType;
    00023	var int     weaponFired[4];      // Primary == 0 secondary == 1 noammo == 2         reload == 3 not used yet....
    00024	var float   weaponFiredTimer;
    00025
    00026	// VARS THAT CAN BE TWEAKED
    00027	// These default settings should be overridded if required
    00028	// in PostBeginPlay() for respective weapon
    00029	var float   fadeTime;                 // HOW LONG WILL A TEXT BE VISIBLE (it wades down smoothly using a sine function...
    00030	var int     onoPosXRandMin,           // rand position relative Canvas.ClipX*0.5
    00031	            onoPosXRandMax;
    00032	var int     onoPosYRandMin,           // rand position relative Canvas.ClipY*0.5
    00033	            onoPosYRandMax;
    00034	var float   scaleRandDeltaMin, scaleRandDeltaMax;  // ]0, 10]      1.0 is default and results in no scaling.
    00035	                                                   // for ratatata effects scaleRandDeltaMin is the "left" size and scaleRandDeltaMax the right...  Set to 1.0 for no variation.
    00036	// VARS THAT CAN BE TWEAKED
    00037	var int     onoPosX, onoPosY;         // position where the ono text is rendered (randomized)
    00038	var int     scaleFactor;              // based on scaleRandDeltaMin, scaleRandDeltaMax;   1,0 by default
    00039	var bool    renderOno;                // enables /disables the actual rendering of the ono....
    00040	var texture weaponOnoTexture;         // Primary texture for primaty weapon.. Also the first texture in the compound RAtatata
    00041	var texture weaponOnoTexture2;        // the TA in the compund RATATATA effect
    00042	var texture weaponNoAmmoOnoTexture;   // Out of ammo "Click"
    00043	var texture weaponReloadOnoTexture;   // not used yet
    00044	var texture weaponSilencerOnoTexture; // Only used for the beretta right now
    00045	var texture weaponOnoAltTexture;      // Secondary fire on primary weapon
    00046	var float   lastBurstTime;            // Makes the Ratata restart when you've released fire for a short time and continues shooting
    00047	var texture onoTextureToRender;
    00048	var texture onoTexture2ToRender;      // some weapons like the RA TA TA needs two textures
    00049
    00050	CONST DBOno=false;
    00051	//_____________________________________________________________________________
    00052	simulated event RenderOverlays( canvas Canvas )
    00053	{
    00054	//    Canvas.SetPos(0,0);
    00055	//    Canvas.font = class'xiiibasehud'.default.smallfont;
    00056	//    Canvas.DrawText("WeaponOnoOverLays for class "$owner.class);
    00057
    00058	  switch (myOnoType)
    00059	  {
    00060	    case ONOTYPE_DISABLED:
    00061	      return;
    00062	    break;
    00063
    00064	    case ONOTYPE_EXPAND:
    00065	    case ONOTYPE_FIXED:
    00066	      updateFixed();
    00067	      renderFixed(Canvas);
    00068	    break;
    00069
    00070	    case ONOTYPE_RATATA:
    00071	    case ONOTYPE_RATARATA:
    00072	      updateRatata();
    00073	      renderRatata(Canvas);
    00074	    break;
    00075
    00076	  }
    00077	}
    00078
    00079	//_____________________________________________________________________________
    00080	simulated function updateFixed()
    00081	{
    00082	  if ( weaponFiredTimer < Level.TimeSeconds )
    00083	    renderOno = false;
    00084
    00085	  if (weaponFired[0] != 0)
    00086	  {
    00087	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00088	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00089	    onoTextureToRender  = weaponOnoTexture;//
    00090	    scaleFactor         = RandRange(scaleRandDeltaMin,scaleRandDeltaMax);
    00091	    if ( onoTextureToRender != none )
    00092	      renderOno         = true;
    00093	    else
    00094	      renderOno         = false;
    00095	  }
    00096	  else if (weaponFired[2] != 0)
    00097	  {
    00098	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00099	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00100	    onoTextureToRender  = weaponNoAmmoOnoTexture;
    00101	    scaleFactor         = RandRange(scaleRandDeltaMin,scaleRandDeltaMax);
    00102	    renderOno           = true;
    00103	  }
    00104	  else if (weaponFired[1] != 0)
    00105	  {
    00106	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00107	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00108	    scaleFactor         = RandRange(scaleRandDeltaMin,scaleRandDeltaMax);
    00109	    onoTextureToRender  = weaponOnoAltTexture;
    00110	    renderOno           = true;
    00111	  }
    00112	  else if (weaponFired[3] != 0)
    00113	  {
    00114	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00115	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00116	    onoTextureToRender = weaponReloadOnoTexture;
    00117	    renderOno          = true;
    00118	  }
    00119
    00120	  if (onoTextureToRender == none)
    00121	    renderOno          = false;
    00122
    00123	  weaponFired[0] = 0;
    00124	  weaponFired[1] = 0;
    00125	  weaponFired[2] = 0;
    00126	  weaponFired[3] = 0;
    00127
    00128	  //log("updatefixed");
    00129
    00130	}
    00131
    00132	//_____________________________________________________________________________
    00133	simulated function renderFixed(canvas Canvas)
    00134	{
    00135	    local byte alpha;
    00136	    local float fAlpha;
    00137
    00138	    if ( !renderOno )
    00139	        return;
    00140	    // if (weaponFired[2])
    00141	    // weaponFiredTimer = Level.TimeSeconds + FlashLength;
    00142	    // RandRange(,)
    00143	    if ( DBOno )Log("ONO"@self@"RenderFixed");
    00144
    00145	    Canvas.Style = ERenderStyle.STY_Alpha;
    00146
    00147	    fAlpha = (weaponFiredTimer - Level.TimeSeconds)/fadeTime;
    00148	    alpha  = sin(fAlpha*3.14159265*0.5)*255.0;
    00149	    Canvas.SetDrawColor(255,255,255,alpha);
    00150
    00151	    Canvas.SetPos(Canvas.ClipX*0.5 + onoPosX, Canvas.ClipY*0.5 + onoPosY);
    00152	    if (myOnoType == ONOTYPE_EXPAND)
    00153	    {
    00154	      Canvas.SetDrawColor(255,255,255,255);
    00155	      Canvas.DrawTile(onoTextureToRender, scaleFactor*120.0*(1.0-fAlpha)+40.0, scaleFactor*120.0*(1.0-fAlpha)+40.0, 0,0, onoTextureToRender.USize, onoTextureToRender.VSize);
    00156	    }
    00157	    else
    00158	    {
    00159	//      if (Weapon(owner).HasSilencer())
    00160	//        Canvas.DrawTile(weaponSilencerOnoTexture, scaleFactor*40.0*(fAlpha)+140.0, scaleFactor*40.0*(fAlpha)+40.0, 0,0, weaponSilencerOnoTexture.USize, weaponSilencerOnoTexture.VSize);
    00161	//      else
    00162	        Canvas.DrawTile(      onoTextureToRender, scaleFactor*40.0*(fAlpha)+40.0, scaleFactor*40.0*(fAlpha)+40.0, 0,0, onoTextureToRender.USize, onoTextureToRender.VSize);
    00163	    }
    00164	//    Canvas.font = class'xiiibasehud'.default.smallfont;
    00165	//    Canvas.DrawText("FIXE0D WeaponOnoOverLays for class "$owner.class);
    00166	    //log("renderfixed");
    00167	}
    00168
    00169	//_____________________________________________________________________________
    00170	simulated function updateRatata()
    00171	{
    00172	  if ( DBOno )Log("ONO"@self@"updateRatata");
    00173
    00174	  if (weaponFiredTimer < Level.TimeSeconds)
    00175	  {
    00176	    renderOno      = false;
    00177	    weaponFired[0] = 0;
    00178	    weaponFired[1] = 0;
    00179	    weaponFired[2] = 0;
    00180	    return;
    00181	  }
    00182
    00183
    00184	  if (weaponFired[0] != 0)
    00185	  {
    00186	    if (weaponFired[0] > 12)
    00187	      weaponFired[0] = 11;
    00188
    00189	    onoTextureToRender  = weaponOnoTexture;
    00190	    onoTexture2ToRender = weaponOnoTexture2;
    00191	    renderOno           = false;
    00192	  }
    00193	  else if (weaponFired[1] != 0)
    00194	  {
    00195	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00196	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00197	    onoTextureToRender  = weaponOnoAltTexture;
    00198	    onoTexture2ToRender = none;//weaponOnoTexture2;
    00199	    renderOno          = true;
    00200	    weaponFired[0] = 0;
    00201	    weaponFired[1] = 0;
    00202	    weaponFired[2] = 0;
    00203	  }
    00204	  else if (weaponFired[2] != 0)
    00205	  {
    00206	    onoPosX             = RandRange(onoPosXRandMin,onoPosXRandMax);
    00207	    onoPosY             = RandRange(onoPosYRandMin,onoPosYRandMax);
    00208	    onoTextureToRender  = weaponNoAmmoOnoTexture;
    00209	    onoTexture2ToRender = none;//weaponOnoTexture2;
    00210	    renderOno           = true;
    00211	    weaponFired[0] = 0;
    00212	    weaponFired[1] = 0;
    00213	    weaponFired[2] = 0;
    00214	  }
    00215
    00216	}
    00217
    00218	//_____________________________________________________________________________
    00219	simulated function renderRatata(canvas Canvas)
    00220	{
    00221	  local byte  alpha;
    00222	  local float fAlpha;
    00223	  local int   q, x,y;
    00224	  local float localscale;
    00225
    00226	  if (!renderOno)
    00227	    return;
    00228
    00229	  if ( DBOno )Log("ONO"@self@"renderRatata");
    00230
    00231	  if (weaponFired[0] != 0)
    00232	  {
    00233	    fAlpha = (weaponFiredTimer - Level.TimeSeconds)/fadeTime;
    00234	    alpha  = sin(fAlpha*3.14159265*0.5)*255.0;
    00235	    Canvas.Style = ERenderStyle.STY_Alpha;
    00236	    Canvas.SetDrawColor(255,255,255,alpha);
    00237
    00238	    x = Canvas.ClipX*0.5 - weaponFired[0] * 30.0 * 0.5;
    00239	    for (q=0; q<weaponFired[0]; q++)
    00240	    {
    00241	      localscale = (scaleRandDeltaMax-scaleRandDeltaMin)* q/11.0/*weaponFired[0]*/+scaleRandDeltaMin;
    00242
    00243	      y = sin(x*0.03 + Level.TimeSeconds*4.0)*15.0 + Canvas.ClipY*0.5+50.0;
    00244	      Canvas.SetPos(x, y);
    00245
if (myOnoType == ONOTYPE_RATATA) 00246 { 00247 00248 if (q==0) 00249 Canvas.DrawTile(onoTextureToRender, localscale*32, localscale*32, 0,0, onoTextureToRender.USize, onoTextureToRender.VSize); 00250 else 00251 Canvas.DrawTile(onoTexture2ToRender, localscale*32, localscale*32, 0,0, onoTexture2ToRender.USize, onoTexture2ToRender.VSize); 00252 } 00253 else if (myOnoType == ONOTYPE_RATARATA) 00254 { 00255 if ( (q%2) == 0 ) 00256 Canvas.DrawTile(onoTextureToRender, localscale*32, localscale*32, 0,0, onoTextureToRender.USize, onoTextureToRender.VSize); 00257 else 00258 Canvas.DrawTile(onoTexture2ToRender, localscale*32, localscale*32, 0,0, onoTexture2ToRender.USize, onoTexture2ToRender.VSize); 00259 } 00260 00261 x += 40.0*localscale; 00262 } 00263 } 00264 else 00265 renderFixed(Canvas); 00266 00267 } 00268 00269 //_____________________________________________________________________________ 00270 // called from XIIIWeapon when a shot is fired 00271 simulated function FirePrimaryWeapon() 00272 { 00273 if ( DBOno )Log("ONO"@self@"FirePrimaryWeapon"); 00274 00275 if (Weapon(owner).HasAmmo()) 00276 { 00277 if (Level.TimeSeconds - lastBurstTime > 0.2) 00278 weaponFired[0] = 0; 00279 00280 weaponFired[0]++; 00281 weaponFiredTimer = Level.TimeSeconds + fadeTime; 00282 lastBurstTime = Level.TimeSeconds; 00283 weaponFired[1] = 0; 00284 weaponFired[2] = 0; 00285 } 00286 else 00287 { 00288 weaponFired[0] = 0; 00289 weaponFired[1] = 0; 00290 weaponFired[2]++; 00291 weaponFiredTimer = Level.TimeSeconds + fadeTime; 00292 } 00293 } 00294 00295 //_____________________________________________________________________________ 00296 // called from XIIIWeapon when a shot is fired 00297 simulated function FirePrimaryWeaponAlt() 00298 { 00299 if ( DBOno )Log("ONO"@self@"FirePrimaryWeaponAlt"); 00300 00301 if (Weapon(owner).HasAltAmmo()) 00302 { 00303 weaponFired[0] = 0; 00304 weaponFired[2] = 0; 00305 weaponFired[3] = 0; 00306 weaponFired[1]++; 00307 weaponFiredTimer = Level.TimeSeconds + fadeTime; 00308 } 00309 else 00310 { 00311 weaponFired[0] = 0; 00312 weaponFired[1] = 0; 00313 weaponFired[3] = 0; 00314 weaponFired[2]++; 00315 weaponFiredTimer = Level.TimeSeconds + fadeTime; 00316 } 00317 } 00318 00319 //_____________________________________________________________________________ 00320 simulated function ReloadPrimaryWeapon() 00321 { 00322 /* not finished... 00323 weaponFired[3]++; 00324 weaponFiredTimer = Level.TimeSeconds + fadeTime; 00325 weaponFired[0] = 0; 00326 weaponFired[1] = 0; 00327 weaponFired[2] = 0; 00328 */ 00329 } 00330 00331 // These default settings should be overridded if required 00332 // in subclasses for respective weapon 00333 00334 00335 defaultproperties 00336 { 00337 myOnoType=ONOTYPE_FIXED 00338 fadeTime=0.600000 00339 onoPosXRandMin=20 00340 onoPosXRandMax=140 00341 onoPosYRandMin=-20 00342 onoPosYRandMax=40 00343 scaleRandDeltaMin=0.500000 00344 scaleRandDeltaMax=1.500000 00345 scaleFactor=1 00346 }

End Source Code