Advertisement
Guest User

SGL_Weaponhud

a guest
Feb 23rd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.67 KB | None | 0 0
  1. // ScriptGL WeaponHUD by GreyHound / Hunden
  2. // based on Andrews original design in hudbot
  3. // slightly modified to draw a box around the mounted weapon by some other dude
  4.  
  5. $WeaponHud::Texture["Undefined"] = "WeaponHUD.Undefined.tga";
  6. $WeaponHud::Texture["turret"] = "WeaponHUD.turret.tga";
  7. $WeaponHud::Texture["shieldpack"] = "WeaponHUD.shieldpack.tga";
  8. $WeaponHud::Texture["sensorjammerpack"] = "WeaponHUD.sensorjammerpack.tga";
  9. $WeaponHud::Texture["sensorjammer"] = "WeaponHUD.sensorjammer.tga";
  10. $WeaponHud::Texture["repairpack"] = "WeaponHUD.repairpack.tga";
  11. $WeaponHud::Texture["pulse"] = "WeaponHUD.pulse.tga";
  12. $WeaponHud::Texture["motion"] = "WeaponHUD.motion.tga";
  13. $WeaponHud::Texture["ammopack"] = "WeaponHUD.ammopack.tga";
  14. $WeaponHud::Texture["energypack"] = "WeaponHUD.energypack.tga";
  15.  
  16. $WeaponHud::Texture["sniper"] = "WeaponHUD.sniper.tga";
  17. $WeaponHud::Texture["plasma"] = "WeaponHUD.plasma.tga";
  18. $WeaponHud::Texture["mortar"] = "WeaponHUD.mortar.tga";
  19. $WeaponHud::Texture["grenade"] = "WeaponHUD.grenade.tga";
  20. $WeaponHud::Texture["blaster"] = "WeaponHUD.blaster.tga";
  21. $WeaponHud::Texture["chaingun"] = "WeaponHUD.chaingun.tga";
  22. $WeaponHud::Texture["elf"] = "WeaponHUD.elf.tga";
  23. $WeaponHud::Texture["disc"] = "WeaponHUD.disc.png";
  24. $WeaponHud::Texture["TargetLaser"] = "WeaponHUD.TargetLaser.tga";
  25.  
  26. $WeaponHud::Texture["camera"] = "WeaponHUD.camera.tga";
  27. $WeaponHud::Texture["inventory"] = "WeaponHUD.inventory.tga";  
  28. $WeaponHud::Texture["deployable"] = "WeaponHUD.deployable.tga";
  29. $WeaponHud::Texture["ammostation"] = "WeaponHUD.ammostation.tga";
  30.    
  31.  
  32.  
  33. function vhud::WeaponHud::onrender()
  34. {
  35.     if(!Control::getVisible("ScriptGL::vWeaponHud"))
  36.         return;
  37.  
  38.     if($Scriptgl::CurrentGui != "playGui")
  39.         return;
  40.  
  41.     if($pref::vWeaponHUD::hide == "true")
  42.         return;
  43.    
  44.     %pos = Control::getPosition("ScriptGL::vWeaponHud");
  45.     %x = getWord(%pos, 0);
  46.     %y = getWord(%pos, 1);
  47.    
  48.     glSetFont( "arial", 9, 0, 9 );
  49.    
  50.     %slot = -1;
  51.     if(GetItemCount("Disc Launcher"))
  52.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["disc"], GetItemCount("Disc"), "Disc Launcher");
  53.        
  54.     if(GetItemCount("Grenade Launcher"))
  55.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["grenade"], GetItemCount("Grenade Ammo"), "Grenade Launcher");
  56.        
  57.     if(GetItemCount("Chaingun"))
  58.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["chaingun"], GetItemCount("Bullet"), "Chaingun");
  59.        
  60.     if(GetItemCount("Laser Rifle"))
  61.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["sniper"], "~", "Laser Rifle");
  62.        
  63.     if(GetItemCount("Mortar"))
  64.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["mortar"], GetItemCount("Mortar Ammo"), "Mortar");
  65.        
  66.     if(GetItemCount("Blaster"))
  67.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["blaster"], "~", "Blaster");
  68.        
  69.     if(GetItemCount("ELF Gun"))
  70.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["elf"], "~", "ELF Gun");
  71.        
  72.     if(GetItemCount("Plasma Gun"))
  73.         WeaponHud::Draw(%x + %slot++*80,%y + 1*40, $WeaponHud::Texture["plasma"], GetItemCount("Plasma Bolt"), "Plasma Gun");
  74.        
  75.     //if(GetItemCount("Targeting Laser"))
  76.     //  WeaponHud::Draw(10+%slot++*80,%y, $WeaponHud::Texture["TargetLaser"], "~");
  77.    
  78.     %slot = -1;
  79.     //WeaponHud::Draw(10+%slot++*80,%y + 1*40, $WeaponHud::Texture["Undefined"], 0);
  80.    
  81.     if(GetItemCount("Turret"))
  82.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["turret"]);
  83.        
  84.     if(GetItemCount("Shield Pack"))
  85.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["shieldpack"], "", "nothing");
  86.        
  87.     if(GetItemCount("Sensor Jammer Pack"))
  88.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["sensorjammerpack"], "", "nothing");
  89.    
  90.     if(GetItemCount("Sensor Jammer"))
  91.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["sensorjammer"], "", "nothing");
  92.        
  93.     if(GetItemCount("Repair Pack"))
  94.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["repairpack"], "", "nothing");
  95.    
  96.     if(GetItemCount("Pulse Sensor"))
  97.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["pulse"], "", "nothing");
  98.        
  99.     if(GetItemCount("Motion Sensor"))
  100.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["motion"], "", "nothing");
  101.        
  102.     if(GetItemCount("Ammo Pack"))
  103.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["ammopack"], "", "nothing");
  104.    
  105.     if(GetItemCount("Energy Pack"))
  106.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["energypack"], "", "nothing");
  107.    
  108.     %slot = -1;
  109.     if(GetItemCount("Camera"))
  110.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["camera"], "", "nothing");
  111.    
  112.     if(GetItemCount("Inventory Station"))
  113.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["inventory"], "", "nothing");
  114.    
  115.     if(GetItemCount("Ammo Station"))
  116.         WeaponHud::Draw(%x + %slot++*80,%y, $WeaponHud::Texture["ammostation"], "", "nothing");
  117.  
  118. }
  119.  
  120. function WeaponHud::Draw(%x,%y, %tex, %count, %Name)
  121. {
  122.     glEnable($GL_TEXTURE_2D);
  123.     glBindTexture($GL_TEXTURE_2D, %tex);
  124.     glColor3f(1.0,1.0,1.0,1.0);
  125.  
  126.         glBegin($GL_QUADS);
  127.         glTexCoord2f(0.0,1.0);
  128.         glVertex2f(%x,%y);
  129.         glTexCoord2f(1.0,1.0);
  130.         glVertex2f(%x+60,%y);
  131.         glTexCoord2f(1.0,0.0);
  132.         glVertex2f(%x+60,%y+30);
  133.         glTexCoord2f(0.0, 0.0);
  134.         glVertex2f(%x,%y+30);
  135.     glEnd();
  136.  
  137.     glDrawString(%x + 50,%y + 20, %count);
  138.     glColor4ub(255,255,255,255);
  139.     if(GetItemdesc(GetMountedItem(0)) == %Name)
  140.     glDrawTexture("wephud_border.png", $GLEX_SCALED, %x, %y, 1, 1 );
  141. }
  142.  
  143.  
  144. function vhud::WeaponHud::create()
  145. {
  146.     if ( $vhud::WeaponHud::Loaded )
  147.         return;
  148.        
  149.     $vhud::WeaponHud::Loaded = true;
  150.    
  151.     vhud::create("ScriptGL::vWeaponHud", "0% 0%", "0% 0%", vhud::WeaponHud::onrender );
  152.     HUD::New("ScriptGL::vWeaponHud", 200, 200, 330, 75, onMouseRMB, onMouseRMB);
  153. }
  154.  
  155. vhud::WeaponHud::create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement