Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- datablock audioDescription( audioSlightQuietClosest3D : audioClosest3D )
- {
- volume = 0.8;
- };
- datablock audioProfile( quake3_hitsound )
- {
- filename = "./hitsound.wav";
- description = audioSlightQuietClosest3D;
- preload = true;
- };
- package quake3_package
- {
- function armor::onNewDataBlock( %this, %obj )
- {
- parent::onNewDataBlock( %this, %obj );
- if ( isObject( %cl = %obj.getControllingClient() ) )
- {
- %cl.sendQ3Update();
- }
- }
- function gameConnection::setControlObject( %this, %obj )
- {
- parent::setControlObject( %this, %obj );
- %this.sendQ3Update();
- }
- function player::setHealth( %this, %value, %cl )
- {
- if ( %this.getDataBlock().getName() $= "playerQuake3Armor" )
- {
- %this.health = mClamp( mFloatLength( %value, 0 ), -20, 200 );
- if ( %this.health > 100 && !isEventPending( %this.decayQ3HealthTick ) )
- {
- %this.decayQ3HealthTick = %this.schedule( 1000, "decayQ3HealthTick" );
- }
- else if ( %this.health <= 0 )
- {
- %this.kill();
- }
- else if ( isObject( %cl = %this.getControllingClient() ) )
- {
- %cl.sendQ3Update();
- }
- }
- else
- {
- parent::setHealth( %this, %value, %cl );
- }
- }
- function player::kill( %this, %cl )
- {
- if ( %this.getDataBlock().getName() $= "playerQuake3Armor" )
- {
- %this.health = 0;
- %this.armor = 0;
- %this.damage( %this, %this.getHackPosition(), 1, $DamageType::Suicide );
- }
- else
- {
- parent::kill( %this, %cl );
- }
- }
- };
- activatePackage( "quake3_package" );
- function playerQuake3Armor::onAdd( %this, %obj )
- {
- %obj.health = 100;
- %obj.armor = 0;
- if ( isObject( %cl = %obj.getControllingClient() ) )
- {
- %cl.sendQ3Update();
- }
- }
- function playerQuake3Armor::onNewDataBlock( %this, %obj )
- {
- if ( !strLen( %obj.health ) )
- {
- %obj.health = 100;
- }
- if ( !strLen( %obj.armor ) )
- {
- %obj.armor = 0;
- }
- parent::onNewDataBlock( %this, %obj );
- }
- function playerQuake3Armor::damage( %this, %obj, %src, %pos, %dmg, %type )
- {
- %dmg = mCeil( %dmg );
- if ( %dmg <= 0 )
- {
- return;
- }
- if ( isObject( %cl = %obj.getControllingClient() ) )
- {
- %cl.play2D( quake3_hitsound );
- }
- if ( %obj.armor )
- {
- %part = mCeil( %dmg * ( 2 / 3 ) );
- if ( %obj.armor >= %part )
- {
- %dmg -= %part;
- %obj.armor -= %part;
- }
- else
- {
- %dmg -= $armor;
- %obj.armor = 0;
- }
- }
- %obj.health -= %dmg;
- if ( %obj.health <= 0 )
- {
- %obj.spawnTime = 0;
- // if ( %obj.health <= -20 )
- // {
- // kill with gib;
- // }
- // else
- // {
- parent::damage( %this, %obj, %src, %pos, %this.maxDamage, %type );
- // }
- }
- else
- {
- %obj.playPain();
- }
- }
- function gameConnection::sendQ3Update( %this )
- {
- %obj = %this.getControlObject();
- if ( isObject( %obj ) && ( %obj.getType() & $TypeMasks::PlayerObjectType ) && %obj.getDataBlock().isQ3A )
- {
- commandToClient( %this, 'Q3A_Health', %obj.health );
- commandToClient( %this, 'Q3A_Armor', %obj.armor );
- }
- else
- {
- commandToClient( %this, 'Q3A_Health', 0 );
- commandToClient( %this, 'Q3A_Armor', 0 );
- }
- }
- function player::decayQ3HealthTick( %this )
- {
- cancel( %this.decayQ3HealthTick );
- if ( %this.health > 100 )
- {
- %this.health -= 100;
- if ( %this.health < 100 )
- {
- %this.health = 100;
- }
- }
- else
- {
- return;
- }
- if ( isObject( %cl = %this.getControllingClient() ) )
- {
- %cl.sendQ3Update();
- }
- %this.decayQ3HealthTick = %this.schedule( 1000, "decayQ3HealthTick" );
- }
- // function q3a_deal_damage( %damage )
- // {
- // %damage = mCeil( %damage );
- // if ( $armor )
- // {
- // %part = mCeil( %damage * ( 2 / 3 ) );
- // if ( $armor >= %part )
- // {
- // %damage -= %part;
- // $armor -= %part;
- // }
- // else
- // {
- // %damage -= $armor;
- // $armor = 0;
- // }
- // }
- // $health -= %damage;
- // if ( $health <= 0 )
- // {
- // íf ( $health <= -20 )
- // {
- // kill with gib;
- // }
- // else
- // {
- // kill;
- // }
- // }
- // }
Add Comment
Please, Sign In to add comment