share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
changeset 11848 6a0d6b00dac8
parent 11494 e02f2e98bf71
child 12073 3b3894b95519
equal deleted inserted replaced
11847:38e7206a5df4 11848:6a0d6b00dac8
     1 --------------------------------
     1 --------------------------------
     2 -- HIGHLANDER / HOGS OF WAR
     2 -- HIGHLANDER / HOGS OF WAR
     3 -- version 0.4b
     3 -- version 0.4b+
     4 -- by mikade
     4 -- by mikade
     5 --------------------------------
     5 --------------------------------
     6 
     6 
     7 -----------
     7 -----------
     8 --0.1
     8 --0.1
   214 end
   214 end
   215 
   215 
   216 -- this is called when a hog dies
   216 -- this is called when a hog dies
   217 function TransferWeps(gear)
   217 function TransferWeps(gear)
   218 
   218 
   219 	if CurrentHedgehog ~= nil then
   219 	if CurrentHedgehog ~= nil and CurrentHedgehog ~= gear then
       
   220 
       
   221         local x,y,color
       
   222         local vgear
       
   223         local vgtX, vgtY, vgtdX, vgtdY, vgtAngle, vgtFrame, vgtFrameTicks, vgtState, vgtTimer, vgtTint
       
   224         local dspl = IsHogLocal(CurrentHedgehog)
       
   225         local ammolist = ''
       
   226 
       
   227         if dspl then
       
   228             x,y = GetGearPosition(CurrentHedgehog)
       
   229             color = GetClanColor(GetHogClan(CurrentHedgehog))
       
   230         end
   220 
   231 
   221         for w,c in pairs(wepArray) do
   232         for w,c in pairs(wepArray) do
   222 			val = getGearValue(gear,w)
   233 			val = getGearValue(gear,w)
   223 			if val ~= 0 and (mode == "orig" or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
   234 			if val ~= 0 and (mode == "orig" or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
   224 				setGearValue(CurrentHedgehog, w, val)
   235 				setGearValue(CurrentHedgehog, w, val)
   228 					AddAmmo(CurrentHedgehog, w, val+1)
   239 					AddAmmo(CurrentHedgehog, w, val+1)
   229 				-- assign ammo as per normal
   240 				-- assign ammo as per normal
   230 				else
   241 				else
   231 					AddAmmo(CurrentHedgehog, w, val)
   242 					AddAmmo(CurrentHedgehog, w, val)
   232 				end
   243 				end
       
   244                 if dspl then
       
   245                     if ammolist == '' then
       
   246                         ammolist = GetAmmoName(w)
       
   247                     else
       
   248                         ammolist = ammolist .. ' • ' .. GetAmmoName(w)
       
   249                     end
       
   250                     x = x + 2
       
   251                     y = y + 32
       
   252                     vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
       
   253                     if vgear ~= nil then
       
   254                         vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
       
   255                         vgtFrame = w
       
   256                         SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
       
   257                     end
       
   258                 end
   233 
   259 
   234 			end
   260 			end
   235 		end
   261 		end
   236 
   262 
       
   263         PlaySound(sndShotgunReload);
       
   264         if dspl and ammolist ~= '' then
       
   265             AddCaption(ammolist, color, capgrpAmmoinfo)
       
   266         end
   237 	end
   267 	end
   238 
   268 
   239 end
   269 end
   240 
   270 
   241 function onGameInit()
   271 function onGameInit()