Menus overhaul #14
							
								
								
									
										87
									
								
								sources/Zeds/Mean/MeanBleedInventory.uc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								sources/Zeds/Mean/MeanBleedInventory.uc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,87 @@ | |||||||
|  | class MeanBleedInventory extends Inventory; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | const dmtype_bleed=class'NiceDamTypeStalkerBleed'; | ||||||
|  | var private int maxBleedCount; | ||||||
|  | var private float fBleedPeriod; | ||||||
|  | 
 | ||||||
|  | var private float fNextBleedTime; | ||||||
|  | 
 | ||||||
|  | var float bleedLevel; | ||||||
|  | var MeanZombieCrawler stalker; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function Tick(float DeltaTime) | ||||||
|  | { | ||||||
|  |     fNextBleedTime = Level.TimeSeconds; | ||||||
|  |     // start the timer
 | ||||||
|  |     SetTimer(0.1, true); | ||||||
|  |     // disable me, coz im too fast and resource hungry
 | ||||||
|  |     Disable('Tick'); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | event Timer() | ||||||
|  | { | ||||||
|  |     local pawn locpawn; | ||||||
|  |     local bool amAlive; | ||||||
|  |     local float bleedDamage; | ||||||
|  | 
 | ||||||
|  |     locpawn = Pawn(Owner); | ||||||
|  |     amAlive = locpawn != none && locpawn.Health > 0; | ||||||
|  | 
 | ||||||
|  |     // if pawn owner is dead or bleed count is done - destroy
 | ||||||
|  |     if (!amAlive || maxBleedCount < 0) | ||||||
|  |         Destroy(); | ||||||
|  | 
 | ||||||
|  |     if (fNextBleedTime < Level.TimeSeconds) | ||||||
|  |     { | ||||||
|  |         maxBleedCount--; | ||||||
|  |         fNextBleedTime += fBleedPeriod; | ||||||
|  | 
 | ||||||
|  |         bleedDamage = calcBleedDamage(bleedLevel, rand(7)); | ||||||
|  |         if (bleedDamage < 1.0) | ||||||
|  |         { | ||||||
|  |             maxBleedCount = 0; | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (stalker != none) | ||||||
|  |             locpawn.TakeDamage(bleedDamage, stalker, locpawn.Location,  | ||||||
|  |                    vect(0, 0, 0), dmtype_bleed); | ||||||
|  |         else | ||||||
|  |             locpawn.TakeDamage(bleedDamage, locpawn, locpawn.Location,  | ||||||
|  |                    vect(0, 0, 0), dmtype_bleed); | ||||||
|  | 
 | ||||||
|  |         if (locpawn.isA('KFPawn')) | ||||||
|  |         { | ||||||
|  |             KFPawn(locpawn).HealthToGive -= 2 * bleedLevel; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // Returns bleed damage, corresponding to given bleed level and damage scale.
 | ||||||
|  | // Rand(7) should be used as a scale.
 | ||||||
|  | // Separate function created to allow for lowest/highest damage value computing.
 | ||||||
|  | final private function int calcBleedDamage(float level, int scale) | ||||||
|  | { | ||||||
|  |     return level * (3 + scale); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // cleanup
 | ||||||
|  | function Destroyed() | ||||||
|  | { | ||||||
|  |     if (stalker != none) | ||||||
|  |         stalker = none; | ||||||
|  | 
 | ||||||
|  |     super.Destroyed(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | defaultproperties | ||||||
|  | { | ||||||
|  |     maxBleedCount=7 | ||||||
|  |     fBleedPeriod=1.500000 | ||||||
|  | } | ||||||
| @ -190,20 +190,44 @@ function bool MeleeDamageTarget(int hitdamage, vector pushdir) | |||||||
| 
 | 
 | ||||||
|     if (result && targetPawn != none) |     if (result && targetPawn != none) | ||||||
|     { |     { | ||||||
|        if (targetPawn.ShieldStrength > 100) |         if (targetPawn.ShieldStrength > 100) | ||||||
|            return result; |             return result; | ||||||
|        else if (targetPawn.ShieldStrength < 0) |         else if (targetPawn.ShieldStrength < 0) | ||||||
|            effectStrenght = 1.0; |             effectStrenght = 1.0; | ||||||
|        else |         else | ||||||
|            effectStrenght = (100 - targetPawn.ShieldStrength) * 0.01; |             effectStrenght = (100 - targetPawn.ShieldStrength) * 0.01; | ||||||
| 
 | 
 | ||||||
|        class'MeanReplicationInfo'.static |         MakeBleed(targetPawn, effectStrenght); | ||||||
|                .findSZri(targetPawn.PlayerReplicationInfo) |  | ||||||
|                .setBleeding(Self, effectStrenght); |  | ||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | final private function MakeBleed(NiceHumanPawn poorpawn, float effectStrenght) | ||||||
|  | { | ||||||
|  |     local Inventory I; | ||||||
|  |     local bool bFoundPoison; | ||||||
|  | 
 | ||||||
|  |     if (poorpawn.Inventory != none) | ||||||
|  |     { | ||||||
|  |         for (I = poorpawn.Inventory; I != none; I = I.Inventory) | ||||||
|  |         { | ||||||
|  |             if (MeanBleedInventory(I) != none) | ||||||
|  |             { | ||||||
|  |                bFoundPoison = true; | ||||||
|  |                MeanBleedInventory(I).stalker = self; | ||||||
|  |                MeanBleedInventory(I).bleedLevel = effectStrenght; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     if (!bFoundPoison) | ||||||
|  |     { | ||||||
|  |        I = Controller.Spawn(class<Inventory>(DynamicLoadObject(string(class'MeanBleedInventory'), class'Class'))); | ||||||
|  |        MeanBleedInventory(I).stalker = self; | ||||||
|  |        MeanBleedInventory(I).bleedLevel = effectStrenght; | ||||||
|  |        I.GiveTo(poorpawn); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function RemoveHead() | function RemoveHead() | ||||||
| { | { | ||||||
|     Super(NiceMonster).RemoveHead(); |     Super(NiceMonster).RemoveHead(); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user