Moderator: Forum Guards
//=============================================================================
// Sodacan.
//=============================================================================
class Sodacan extends DeusExPickup;
state Activated
{
function Activate()
{
// can't turn it off
}
function BeginState()
{
local DeusExPlayer player;
Super.BeginState();
The owner is the one who has this in his inventory. You must place DeusExPlayer() around it, to tell the script, that the owner must be a DeusExPlayer. Otherwise it will not find the function HealPlayer(), which is called further on in this script.
player = DeusExPlayer(Owner);
if (player != None)
player.HealPlayer(2, False);
It checks if the player exists, and if it does, it calls the function HealPlayer inside the player class. It has as variables 2 and False, the 2 is how much the player gets healed, and the False means that it wont give a medkit hiss, or recalculate the healing rate, when you activate it.
PlaySound(sound'MaleBurp');
This plays the oh so fun burping sound. No explanation needed?
UseOnce();
Whe you call this, the item gets deleted.
}
Begin:
}
defaultproperties
{
maxCopies=10
bCanHaveMultipleCopies=True
bActivatable=True
ItemName="Soda"
ItemArticle="some"
PlayerViewOffset=(X=30.000000,Z=-12.000000)
PlayerViewMesh=LodMesh'DeusExItems.Sodacan'
PickupViewMesh=LodMesh'DeusExItems.Sodacan'
ThirdPersonMesh=LodMesh'DeusExItems.Sodacan'
LandSound=Sound'DeusExSounds.Generic.MetalHit1'
Icon=Texture'DeusExUI.Icons.BeltIconSodaCan'
largeIcon=Texture'DeusExUI.Icons.LargeIconSodaCan'
largeIconWidth=24
largeIconHeight=45
Description="The can is blank except for the phrase 'PRODUCT PLACEMENT HERE.' It is unclear whether this is a name or an invitation."
beltDescription="SODA"
Mesh=LodMesh'DeusExItems.Sodacan'
CollisionRadius=3.000000
CollisionHeight=4.500000
Mass=5.000000
Buoyancy=3.000000
}
// ----------------------------------------------------------------------
// HealPlayer()
// ----------------------------------------------------------------------
function int HealPlayer(int baseHealPoints, optional Bool bUseMedicineSkill)
{
As you can see, it has 2 variables in this function. The second one is optional, so you don't have to include this variable, so you can call this function on 2 ways:
HealPlayer(2);
HealPlayer(2,False/True);
local float mult;
local int adjustedHealAmount, aha2, tempaha;
local int origHealAmount;
local float dividedHealAmount;
These are variables that will be used in this function. You cannot call these variables outside the function, since it will not recognize them as declared variables. Take a good look at the word 'local'.
If you have bUseMedicineSkill = True in the function, it will recalculate the healing amount, since, if you have a high/low medkit skill, your medkit heals more/less.
if (bUseMedicineSkill)
adjustedHealAmount = CalculateSkillHealAmount(baseHealPoints);
else
adjustedHealAmount = baseHealPoints;
origHealAmount = adjustedHealAmount;
if (adjustedHealAmount > 0)
{
And if you use a medkit --> UseMedicineSkill, it will give the sound
if (bUseMedicineSkill)
PlaySound(sound'MedicalHiss', SLOT_None,,, 256);
// Heal by 3 regions via multiplayer game
if (( Level.NetMode == NM_DedicatedServer ) || ( Level.NetMode == NM_ListenServer ))
{
// DEUS_EX AMSD If legs broken, heal them a little bit first
if (HealthLegLeft == 0)
{
aha2 = adjustedHealAmount;
if (aha2 >= 5)
aha2 = 5;
tempaha = aha2;
adjustedHealAmount = adjustedHealAmount - aha2;
HealPart(HealthLegLeft, aha2);
HealPart(HealthLegRight,tempaha);
mpMsgServerFlags = mpMsgServerFlags & (~MPSERVERFLAG_LostLegs);
}
HealPart(HealthHead, adjustedHealAmount);
if ( adjustedHealAmount > 0 )
{
aha2 = adjustedHealAmount;
HealPart(HealthTorso, aha2);
aha2 = adjustedHealAmount;
HealPart(HealthArmRight,aha2);
HealPart(HealthArmLeft, adjustedHealAmount);
}
if ( adjustedHealAmount > 0 )
{
aha2 = adjustedHealAmount;
HealPart(HealthLegRight, aha2);
HealPart(HealthLegLeft, adjustedHealAmount);
}
}
else
{
HealPart(HealthHead, adjustedHealAmount);
HealPart(HealthTorso, adjustedHealAmount);
HealPart(HealthLegRight, adjustedHealAmount);
HealPart(HealthLegLeft, adjustedHealAmount);
HealPart(HealthArmRight, adjustedHealAmount);
HealPart(HealthArmLeft, adjustedHealAmount);
}
GenerateTotalHealth();
adjustedHealAmount = origHealAmount - adjustedHealAmount;
if (origHealAmount == baseHealPoints)
{
if (adjustedHealAmount == 1)
ClientMessage(Sprintf(HealedPointLabel, adjustedHealAmount));
else
ClientMessage(Sprintf(HealedPointsLabel, adjustedHealAmount));
}
else
{
ClientMessage(Sprintf(HealedPointsLabel, adjustedHealAmount));
}
}
return adjustedHealAmount;
}
native(264) final function int PlaySound
(
sound Sound,
optional ESoundSlot Slot,
optional float Volume,
optional bool bNoOverride,
optional float Radius,
optional float Pitch
);
// ----------------------------------------------------------------------
// UseOnce()
//
// Subtract a use, then destroy if out of uses
// ----------------------------------------------------------------------
function UseOnce()
{
local DeusExPlayer player;
player = DeusExPlayer(Owner);
NumCopies--;
Reduce the number of copies you have
if (!IsA('SkilledTool'))
GotoState('DeActivated');
if (NumCopies <= 0)
{
Do you have 0 copies of the item? Or even less? Then destroy it. Also said, it will be deleted, and the item you will have in your hand, will be nothing.
if (player.inHand == Self)
player.PutInHand(None);
Destroy();
}
else
{
If you do have 1 or more copies of the item, update your belt, so you can see you used a sodacan.
UpdateBeltText();
}
}
Function A()
{
if(a != 0)
{
if(a <= 5)
{
Owned();
}
}
}
Function A()
{
if(a != 0)
{
if(a <= 5)
{
Owned();
}
}
}
~[A]lex~ wrote:I copy pasted the script straight from the file. And it doesn't show tabs in the forum
function starttime()
{
Insert Code here
}
function show time()
{
if (insert condition here)
{
insert events here
}
else
{
insert events here
}
}
~[A]lex~ wrote:Quite logical eh
~Psychotic~ wrote:~[A]lex~ wrote:Quite logical eh
Yes, but that doesn't really answer my question, lol.
AgentSmyth wrote:Oh I know this one...
They are simply things that keep the code seperate from each other i.e.
Say you want to have 2 different functions...one to...I dunno set up a timer and the other to display the time you don't want the codes running into each other, so you put these at the beggining and end of each function to declare where each function starts and ends...it also works the same with the conditionals else, if, switch.
For example
- Code: Select all
function starttime()
{
Insert Code here
}
function show time()
{
if (insert condition here)
{
insert events here
}
else
{
insert events here
}
}
Hope that helped
~[A]lex~ wrote:I use Notepad, without any thing extra
AgentSmyth wrote:my problem is i just don't know where to begin...or end...or write code...o god
-exports all the classes and looks through frantically-
Nope still nothing
AgentSmyth wrote:what do you's do for inspiration...and what would be the best and quickest way to learn scripting?
//=============================================================================
// GasGrenade.
//=============================================================================
class GasGrenade extends ThrownProjectile;
var float mpBlastRadius;
var float mpProxRadius;
var float mpGasDamage;
var float mpFuselength;
simulated function PreBeginPlay()
{
Super.PreBeginPlay();
if ( Level.NetMode != NM_Standalone )
{
blastRadius=mpBlastRadius;
proxRadius=mpProxRadius;
Damage=mpGasDamage;
fuseLength=mpFuseLength;
bIgnoresNanoDefense=True;
}
}
defaultproperties
{
mpBlastRadius=512.00
mpProxRadius=128.00
mpGasDamage=20.00
mpFuselength=1.50
fuseLength=3.00
proxRadius=128.00
AISoundLevel=0.00
bBlood=False
bDebris=False
DamageType=TearGas
spawnWeaponClass=Class'WeaponGasGrenade'
ItemName="Gas Grenade"
speed=1000.00
MaxSpeed=1000.00
Damage=10.00
MomentumTransfer=50000
ImpactSound=Sound'DeusExSounds.Weapons.GasGrenadeExplode'
LifeSpan=0.00
Mesh=LodMesh'DeusExItems.GasGrenadePickup'
CollisionRadius=4.30
CollisionHeight=1.40
Mass=5.00
Buoyancy=2.00
}
if ((damageType=='TearGas') && (Role==ROLE_Authority))
SpawnTearGas();
function SpawnTearGas()
{
local Vector loc;
local TearGas gas;
local int i;
if ( Role < ROLE_Authority )
return;
for (i=0; i<blastRadius/36; i++)
{
if (FRand() < 0.9)
{
loc = Location;
loc.X += FRand() * blastRadius - blastRadius * 0.5;
loc.Y += FRand() * blastRadius - blastRadius * 0.5;
loc.Z += 32;
gas = spawn(class'TearGas', None,, loc);
if (gas != None)
{
gas.Velocity = vect(0,0,0);
gas.Acceleration = vect(0,0,0);
gas.DrawScale = FRand() * 0.5 + 2.0;
gas.LifeSpan = FRand() * 10 + 30;
if ( Level.NetMode != NM_Standalone )
gas.bFloating = False;
else
gas.bFloating = True;
gas.Instigator = Instigator;
}
}
}
}
//=============================================================================
// TearGas.
//=============================================================================
class TearGas extends Cloud;
defaultproperties
{
DamageType=TearGas
maxDrawScale=2.00
Texture=WetTexture'Effects.Smoke.Gas_Tear_A'
}
function Timer()
{
local Actor A;
local Vector offset, dist;
local Pawn apawn;
if ( Level.NetMode != NM_Standalone )
{
// Use PawnList for multiplayer
apawn = Level.PawnList;
while ( apawn != None )
{
dist = apawn.Location - Location;
if ( VSize(dist) < cloudRadius )
{
offset = apawn.Location;
apawn.TakeDamage( Damage, Instigator, offset, vect(0,0,0), damageType );
}
apawn = apawn.nextPawn;
}
}
else
{
// check to see if anything has entered our effect radius
// don't damage our owner
foreach VisibleActors(class'Actor', A, cloudRadius)
if (A != Owner)
{
// be sure to damage the torso
offset = A.Location;
A.TakeDamage(Damage, Instigator, offset, vect(0,0,0), damageType);
}
}
}
function BeginPlay()
{
Super.BeginPlay();
// set the cloud damage timer
SetTimer(damageInterval, True);
}
(from CORE\Object.uc)
native(192) static final function float Loge ( float A );
native(193) static final function float Sqrt ( float A );
native(194) static final function float Square( float A );
native(195) static final function float FRand ();
native(244) static final function float FMin ( float A, float B );
native(245) static final function float FMax ( float A, float B );
native(246) static final function float FClamp( float V, float A, float B );
native(247) static final function float Lerp ( float Alpha, float A, float B );
native(248) static final function float Smerp ( float Alpha, float A, float B );
Andrievskaya Veronika wrote:Loge
Andrievskaya Veronika wrote:Sqrt
Andrievskaya Veronika wrote:Square
Andrievskaya Veronika wrote:FRand
Andrievskaya Veronika wrote:FClamp
wiki.beyondunreal.com wrote:If V is smaller than A, A is returned. If V is larger than B, B is returned. In any other case V is returned.
Andrievskaya Veronika wrote:Lerp
wiki.beyondunreal.com wrote:"Returns the linear interpolation between A and B."
The return value is calculated through something like this:
(B - A) * Alpha + A
Andrievskaya Veronika wrote:Smerp
wiki.beyondunreal.com wrote:Returns an Alpha-smooth nonlinear interpolation between A and B.
The return value seems to be calculated through something like this:
(-2 * (B - A) * Alpha ** 3) + (3 * (B - A) * Alpha ** 2) + A