It is currently Sun May 19, 2013 10:45 pm




Post new topic Reply to topic  [ 3 posts ] 
My coding 
Author Message
X-51

Joined: Thu Jan 27, 2005 9:56 am
Posts: 909
Location: A planet near mars
Post My coding
I was looking though my old coding I never released or really used so thought I would post it here.

First a dart projectile that when fired, changes the targets alliance to the player so they are allied to player (would be good for MP but you'd need MPBots in game and you could change their alliances randomly and gain or lose an army of allied NPCs) you could also change this to do no damage on hit:

Quote:
//=============================================================================
// Alliance Projectile.
//==================================================================================
class MPHS_AllianceProjectile extends Dart;

auto simulated state Flying
{
simulated function ProcessTouch (Actor Other, Vector HitLocation)
{

if (bStuck)
return;

if ((Other != instigator) && (DeusExProjectile(Other) == None) &&
(Other != Owner))
{
damagee = Other;

AISendEvent('LoudNoise', EAITYPE_Audio, 2.0, blastRadius*24);
if (damagee.IsA('ScriptedPawn') && !damagee.IsA('Robot') && !damagee.IsA('CyborgDog') && !damagee.IsA('AnnaNavarre')
&& !damagee.IsA('WaltonSimons') && !damagee.IsA('MPHS_IlluminitiTroop') && !damagee.IsA('MaggieChow') && !damagee.IsA('UNATCOTroop'))
{
ScriptedPawn(damagee).SetAlliance('Player');
ScriptedPawn(damagee).ChangeAlly('Player',1.0,true);
PlaySound(ImpactSound, SLOT_None, 2.0,, 2048);
Destroy();
}
else
{
damagee.TakeDamage(damage, instigator,HitLocation,(MomentumTransfer * Normal(Velocity)), damagetype);
PlaySound(ImpactSound, SLOT_None, 2.0,, 2048);
Destroy();
}
}
}

simulated function HitWall(vector HitNormal, actor Wall)
{
if (bStickToWall)
{
Velocity = vect(0,0,0);
Acceleration = vect(0,0,0);
SetPhysics(PHYS_None);
bStuck = False;
destroy();

// MBCODE: Do this only on server side
if ( Role == ROLE_Authority )
{
if (Level.NetMode != NM_Standalone)
SetTimer(5.0,False);

if (Wall.IsA('Mover'))
{
SetBase(Wall);
Wall.TakeDamage(Damage, Pawn(Owner), Wall.Location, MomentumTransfer*Normal(Velocity), damageType);
}
}
}

if (Wall.IsA('BreakableGlass'))
bDebris = False;
AISendEvent('LoudNoise', EAITYPE_Audio, 2.0, blastRadius*24);
SpawnEffects(Location, HitNormal, Wall);

Super.HitWall(HitNormal, Wall);
}
}

defaultproperties
{
DamageType=Alliance
spawnAmmoClass=None
ItemName="Alliance Projectile"
Damage=5.000000
}



This one was done by DDL I think, its for NPCs to show their breath if you have them in a cold area of a map such as a large freezer or a snow map:

Quote:
//=============================================================================
// MPHS_ColdAreaPawns.
// If these pawns are in a cold area, they will show cold, icy breath.
//=============================================================================
class MPHS_ColdAreaPawns expands MorpheusScriptedPawns;

var particlegenerator breathgen;
var float breathtimer;
var float breathtime;

function tick(float deltatime)
{
super.tick(deltatime);

if(breathgen != none)
Updatebreathgen(deltatime);
}


function ZoneChange(ZoneInfo newZone)
{
if (!bInWorld)
return;

if(!Newzone.bWaterZone && newzone.DesiredRotation.Yaw > 0 && breathgen == none)
{
spawnBreathgen();
}
else if((newzone.bWaterZone || newzone.DesiredRotation.Yaw == 0) && breathgen != none)
{
breathgen.LifeSpan = 1 + frand();
}

super.ZoneChange(newzone);
}

function HeadZoneChange(ZoneInfo newZone)
{
if (!bInWorld)
return;

if(!Newzone.bWaterZone && newzone.DesiredRotation.Yaw > 0 && breathgen == none)
{
spawnBreathgen();
}
else if((newzone.bWaterZone || newzone.DesiredRotation.Yaw == 0) && breathgen != none)
{
breathgen.LifeSpan = 1 + frand();
}
super.HeadZoneChange(newzone);
}



function spawnbreathgen()
{
local vector loc;

if(bIsFemale)
{
loc.X += CollisionRadius * 0.25;
loc.Z += BaseEyeHeight*0.9;
}
else
{
loc.X += collisionradius * 0.5;
loc.Z += BaseEyeHeight*0.925;
}
loc = loc >> rotation;
loc += location;

//log("spawning breathgen", name);

breathgen = spawn(Class'particlegenerator',self,,loc,rotation);
if(breathgen != none)
{
breathgen.particleTexture=texture'effects.smoke.smokepuff1';
breathgen.checkTime = 0.1;
breathgen.riseRate = 3.0;
breathgen.ejectSpeed = 10.0;
breathgen.bRandomEject = true;
breathgen.particleLifeSpan = 0.75;
breathgen.SetBase(self);
}
if(AnimSequence == 'BreathLight' || AnimSequence == 'BreathLight2H' || AnimSequence == 'SitBreath')
{
//about halfway through is full inhale
breathtimer = breathtime * self.animframe;
}
else
breathtimer = frand() * breathtime;
}


function updatebreathgen(float dt)
{
local float mod;
local vector loc;

if(bIsFemale)
{
loc.X += CollisionRadius * 0.25; //the way the female meshes stand make a HUGE difference in mouthposition: it's really weird.
loc.Z += BaseEyeHeight*0.9;
}
else
{
loc.X += collisionradius * 0.5;
loc.Z += BaseEyeHeight*0.925;
}
loc = loc >> rotation;
loc += location;
breathgen.SetLocation(loc);
breathgen.setrotation(rotation);

//log("updating breathgen", name);

breathtimer += dt;

if(breathtimer > breathtime)
breathtimer = 0.0;

if(breathtimer < breathtime * 0.5 && breathgen.bSpewing)
{
breathgen.bSpewing = false;
breathgen.particleTexture = none;
}
else
{
if(breathtimer < breathtime * 0.75)
{
mod = (breathtimer - (breathtime * 0.5))/(breathtime * 0.25);
}
else
{
mod = (breathtime - breathtimer)/(breathtime * 0.25);
}
if(mod < 0)
mod = 0;
breathgen.bSpewing = true;
breathgen.particleTexture=texture'effects.smoke.smokepuff1';
breathgen.ejectSpeed = 10.0 * mod;
}
}

function beginplay()
{
if (bInWorld && !Region.zone.bWaterZone && Region.zone.DesiredRotation.Yaw > 0 && breathgen == none)
{
spawnBreathgen(); //zonechange wasn't spotting it at startup, for some reason
}

super.beginplay();
}

function destroyed()
{
if(breathgen != none)
breathgen.delayeddestroy();

super.destroyed();
}

defaultproperties
{
}

_________________
My nature videos: http://www.youtube.com/user/DynamixWarePro
My whistle/flute videos (and some other videos): http://www.youtube.com/user/DXMorpheus


Wed May 18, 2011 9:26 pm
Profile
X-51
User avatar

Joined: Wed Mar 03, 2010 1:29 am
Posts: 834
Post Re: My coding
Very cool. Thank you.

_________________
http://www.youtube.com/watch?v=e3FfPUKuGsQ&t=8m0s


Fri May 20, 2011 12:47 am
Profile
X-51

Joined: Thu Jan 27, 2005 9:56 am
Posts: 909
Location: A planet near mars
Post Re: My coding
No problem, I have more somewhere, just have to dig them up. About the NPC that shows breath, you don't have to have them in a cold place, just I wanted them for a snow map and would be more realistic.

_________________
My nature videos: http://www.youtube.com/user/DynamixWarePro
My whistle/flute videos (and some other videos): http://www.youtube.com/user/DXMorpheus


Fri May 20, 2011 9:49 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forum/DivisionCore.