Hyper.nl Unreal Services Forum Index Hyper.nl Unreal Services
The forum of Hyper.nl Unreal Services and the semi-offical resource for Winged Unicorn's Unreal mods
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cow melee script.

 
Post new topic   Reply to topic    Hyper.nl Unreal Services Forum Index -> Support
View previous topic :: View next topic  
Author Message
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Tue Jan 30, 2007 10:14 pm    Post subject: Cow melee script. Reply with quote

What does a cow need to melee a enemy?

i got this:


var bool bForage;
var() bool bHasBaby;
var() bool bStayClose;
var() int BiteDamage; // Basic damage done by bite.
var() float WanderRadius;
var vector StartLocation;
var BabyEvil baby;
var Pawn ScaryGuy;
var(Sounds) sound shake;
var(Sounds) sound swish;
var(Sounds) sound footstep;
var float VoicePitch;

function eAttitude AttitudeWithFear()
{
return ATTITUDE_Hate;
}

function eAttitude AttitudeToCreature(Pawn Other)
{
if ( Other.IsA('Cow') )
return ATTITUDE_Friendly;
else if ( Other.IsA('EvilCow') )
return ATTITUDE_Friendly;
else
return ATTITUDE_Ignore;
}
function PostBeginPlay()
{
VoicePitch = 0.9 + 0.2 * FRand();
if ( BabyEvil(self) != None )
VoicePitch *= 1.4;
if (bHasBaby) //add baby
{
Destination = Location;
baby = Spawn(class 'BabyEvil',,, Location + vector(Rotation) * 1.5 * CollisionRadius);
baby.mom = self;
}
Super.PostBeginPlay();
}

function Step()
{
PlaySound(Footstep, SLOT_Interact, 0.012 * Mass,, 1000);
}

function PlayWaiting()
{
local float decision;
local float animspeed;
animspeed = 0.4 + 0.4 * FRand();
decision = FRand();
if (!bool(NextAnim)) //pick first waiting animation
NextAnim = 'Breath';

if (decision < 0.3)
NextAnim = 'Breath';
else if (decision < 0.6)
{
animspeed *= 0.6;
NextAnim = 'Chew';
}
else if (decision < 0.73)
{
NextAnim = 'Root';
}
else if (decision < 0.
{
PlaySound(Roam, SLOT_Talk, 0.02 * Mass,,,VoicePitch);
NextAnim = 'Poop';
}
else if (decision < 0.9)
{
PlaySound(Shake, SLOT_Talk, 0.0083 * Mass);
NextAnim = 'Shake';
}
else
{
PlaySound(Swish, SLOT_Talk, 0.0083 * Mass);
NextAnim = 'Swish';
}
LoopAnim(NextAnim, animspeed);
}

function PlayPatrolStop()
{
PlayWaiting();
}

function PlayWaitingAmbush()
{
PlayWaiting();
}

function TweenToFighter(float tweentime)
{
TweenAnim('Breath', tweentime);
}

function TweenToRunning(float tweentime)
{
if (AnimSequence != 'Run' || !bAnimLoop)
TweenAnim('Run', tweentime);
}

function TweenToWalking(float tweentime)
{
TweenAnim('Walk', tweentime);
}

function TweenToWaiting(float tweentime)
{
TweenAnim('Breath', tweentime);
}

function TweenToPatrolStop(float tweentime)
{
TweenAnim('Breath', tweentime);
}

function PlayRunning()
{
LoopAnim('Run', -1.0/GroundSpeed,,0.3);
}

function PlayWalking()
{
LoopAnim('Walk', -1.5/GroundSpeed,,0.3);
}

function PlayThreatening()
{
local float decision;
local float animspeed;
animspeed = 0.4 + 0.6 * FRand();
decision = FRand();

if (decision < 0.3)
NextAnim = 'Breath';
else if (decision < 0.7)
{
PlaySound(Shake, SLOT_Talk, 0.0083 * Mass);
NextAnim = 'Shake';
}
else
{
PlaySound(Swish, SLOT_Talk, 0.0083 * Mass);
NextAnim = 'Swish';
}
LoopAnim(NextAnim, animspeed);
}

function PlayTurning()
{
TweenAnim('Walk', 0.3);
}

function PlayDying(name DamageType, vector HitLocation)
{
if ( FRand() < 0.6 )
PlaySound(Die, SLOT_Talk, 0.025 * Mass,,,VoicePitch);
else
PlaySound(sound'DeathC2c', SLOT_Talk, 0.025 * Mass,,,VoicePitch);

if ( (Velocity.Z > 200) && (FRand() < 0.75) )
PlayAnim('Dead3', 0.7, 0.1);
else if (FRand() < 0.5)
PlayAnim('Dead', 0.7, 0.1);
else
PlayAnim('Dead2', 0.7, 0.1);
}

function TweenToFalling()
{
TweenAnim('BigHit', 0.5);
}

function PlayInAir()
{
TweenAnim('Run',0.5);
}

function PlayLanded(float impactVel)
{
TweenAnim('Landed', 0.1);
}

function PlayTakeHit(float tweentime, vector HitLoc, int damage)
{
if ( FRand() < 0.5 )
PlaySound(HitSound1, SLOT_Interact, 0.02 * Mass,,,VoicePitch);
else
PlaySound(HitSound2, SLOT_Interact, 0.02 * Mass,,,VoicePitch);

if (Velocity.Z > 200 + 100 * FRand())
TweenAnim('BigHit', tweentime);
else if ( FRand() < 0.5 )
TweenAnim('TakeHit2', tweentime);
else
TweenAnim('TakeHit', tweentime);
}

function PlayChallenge()
{
PlayAnim('Breath', 1.0, 0.12);
}

state Waiting
{
function Landed(vector HitNormal)
{
GotoState('Flopping');
Landed(HitNormal);
}
}

state TakeHit
{
ignores seeplayer, hearnoise, bump, hitwall;

function Landed(vector HitNormal)
{
GotoState('Flopping');
Landed(HitNormal);
}
}

state FallingState
{
ignores Bump, Hitwall, HearNoise, WarnTarget;

function Landed(vector HitNormal)
{
GotoState('Flopping');
Landed(HitNormal);
}
}

state Ambushing
{
function Landed(vector HitNormal)
{
GotoState('Flopping');
Landed(HitNormal);
}
}

function PlayRangedAttack()
{
local vector projStart;

MakeNoise(1.0);
projStart = Location + CollisionHeight * vect(0,0,-1.2);
spawn(RangedProjectile ,self,'',projStart,AdjustAim(ProjectileSpeed, projStart, 900, bLeadTarget, bWarnTarget));
PlayAnim('Poop');
}

function Help(Cow Other)
{
//only used when grazing
}

state Grazing
{
function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
Vector momentum, name damageType)
{
Global.TakeDamage(Damage, instigatedBy, hitlocation, momentum, damageType);
if ( health <= 0 )
return;
if ( NextState == 'TakeHit' )
{
NextState = 'Attacking';
NextLabel = 'Begin';
GotoState('TakeHit');
}
else
EnemyAcquired();
}

function Bump(actor Other)
{
if ( (Normal(Destination - Location) Dot Normal(Other.Location - Location)) > 0.8 )
MoveTimer = -1.0;
if ( (Pawn(Other) != None) && SetEnemy(Pawn(Other)) )
EnemyAcquired();
Disable('Bump');
}

function EnemyAcquired()
{
bReadyToAttack = True;
PlayAcquisitionSound();
GotoState('Attacking');
}

function Help(Cow Other)
{
if ( (Enemy != None) && (AttitudeTo(Enemy) < ATTITUDE_Ignore) )
return;
Enemy = Other.Enemy;
if (Enemy.bIsPlayer)
AttitudeToPlayer = ATTITUDE_Hate;
else
Hated = Enemy;
Aggressiveness = 666666.0;
GotoState('Attacking');
}

function SetFall()
{
NextState = 'Grazing';
NextLabel = 'ContinueWander';
NextAnim = AnimSequence;
GotoState('FallingState');
}

function bool TestDirection(vector dir, out vector pick, bool bAlongWall)
{
local vector HitLocation, HitNormal;
local float minDist, Dist;
local actor HitActor;

dir.Z = 0;
dir = Normal(dir);
minDist = FMin(180.0, 6*CollisionRadius);
pick = Location + dir * (minDist + FRand() * 900);

HitActor = Trace(HitLocation, HitNormal, pick, Location, false);
Dist = VSize(HitLocation - Location);
if ( (Dist < minDist) && (HitNormal.Z < 0.7) )
{
if ( !bAlongWall )
return false;
pick = HitLocation - dir + (HitNormal Cross vect(0,0,1)) * 5 * CollisionRadius;
HitActor = Trace(HitLocation, HitNormal, pick , Location, false);
if (HitActor != None)
return false;
}
else
pick = HitLocation - 4 * CollisionRadius * dir;

return true;
}

function PickDestination()
{
local vector pickdir;
local bool success;
local float XY, dist;

if ( (Baby != None) && (VSize(Baby.Location - Location) > 400) )
{
Destination = Baby.Location;
return;
}

// don't wander too far
if ( bStayClose )
{
pickDir = StartLocation - Location;
dist = VSize(pickDir);
if ( dist > WanderRadius )
{
pickdir = pickDir/dist;
if ( TestDirection(pickdir, Destination, true) )
{
if (Baby != None)
Baby.FollowMom();
return;
}
}
}

//Favor XY alignment
pickdir.Z = 0;
XY = FRand();
if (XY < 0.3)
{
pickdir.X = 1;
pickdir.Y = 0;
}
else if (XY < 0.6)
{
pickdir.X = 0;
pickdir.Y = 1;
}
else
{
pickdir.X = 2 * FRand() - 1;
pickdir.Y = 2 * FRand() - 1;
pickdir = Normal(pickdir);
}

success = TestDirection(pickdir, Destination, false);
if (!success)
success = TestDirection(-1 * pickdir, Destination, true);

if (success)
{
if (Baby != None)
Baby.FollowMom();
}
else
{
Destination = Location;
GotoState('Grazing', 'Turn');
}
}

function AnimEnd()
{
PlayPatrolStop();
}

function SeePlayer(Actor SeenPlayer)
{
bForage = true;
ScaryGuy = Pawn(SeenPlayer);
if ( (Pawn(SeenPlayer).Health > 0) && SetEnemy(Pawn(SeenPlayer)) )
LastSeenPos = SeenPlayer.Location;

Disable('SeePlayer');
SetTimer(7.0, false);
}

function timer()
{
Enable('SeePlayer');
bForage = false;
}

function SetTurn()
{
local float YawErr;

if ( (Baby != None) && (FRand() < 0.35) )
Destination = Baby.Location;
else if ( (ScaryGuy != None) && (FRand() < 0.5) )
Destination = ScaryGuy.Location;
else
Destination = Location + 20 * VRand();

DesiredRotation = rotator(Destination - Location);
DesiredRotation.Yaw = DesiredRotation.Yaw & 65535;
YawErr = (DesiredRotation.Yaw - (Rotation.Yaw & 65535)) & 65535;
if ( (YawErr > 16384) && (YawErr < 49151) )
{
if ( YawErr > 32768 )
DesiredRotation.Yaw = DesiredRotation.Yaw + 16384;
else
DesiredRotation.Yaw = DesiredRotation.Yaw - 16384;
Destination = Location + 20 * vector(DesiredRotation);
}
}

function BeginState()
{
MinHitWall = -0.2;
StartLocation = Location;
Enemy = None;
SetAlertness(0.0);
bReadyToAttack = True;
bAvoidLedges = true;
Disable('AnimEnd');
NextAnim = '';
JumpZ = -1;
if (Enemy == None)
{
bForage = false;
Disable('EnemyNotVisible');
Enable('SeePlayer');
}
else
{
bForage = true;
Enable('EnemyNotVisible');
Disable('SeePlayer');
}
}

function EndState()
{
if ( Enemy.bIsPlayer )
MakeNoise(1.0);
JumpZ = Default.JumpZ;
bAvoidLedges = false;
MinHitWall = Default.MinHitWall;
}

Begin:
//log(class$" Grazing");

Wander:
if (!bForage)
Goto('Graze');
WaitForLanding();
PickDestination();
TweenToWalking(0.2);
FinishAnim();
PlayWalking();

Moving:
Enable('Bump');
MoveTo(Destination, 0.4);
Graze:
Acceleration = vect(0,0,0);
TweenAnim('Breath', 0.3);
if (FRand() < 0.5)
{
FinishAnim();
PlayAnim('Root', 0.3 + 0.4*FRand());
}
Enable('AnimEnd');
NextAnim = '';
Sleep(6 + 10 * FRand());
Disable('AnimEnd');
FinishAnim();
Goto('Wander');

ContinueWander:
FinishAnim();
PlayWalking();
Goto('Wander');

Turn:
Acceleration = vect(0,0,0);
PlayTurning();
SetTurn();
TurnTo(Destination);
Goto('Graze');
}
_________________


Last edited by mentalhunter on Wed Feb 07, 2007 8:37 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
[B@D]Thug



Joined: 07 Oct 2005
Posts: 315

PostPosted: Wed Jan 31, 2007 1:13 am    Post subject: Reply with quote

Wow, You're getting good... So fast.
_________________
Improvements along the way friends and foes.

WebSite:www.freewebs.com/agressivetoys
Back to top
View user's profile Send private message AIM Address MSN Messenger
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Wed Jan 31, 2007 7:18 pm    Post subject: Reply with quote

Lol, maybe ill have to make my point clear...
Im asking somebody who can tell me the script to let a cow melee you, i also put in the bitevariable. But the damm beast wont use his melee powers. i do got the projectile working.

And thanks for the compliment btw
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Zelk0wy[PL]



Joined: 19 Apr 2006
Posts: 110
Location: War Saw, Poland

PostPosted: Wed Jan 31, 2007 10:48 pm    Post subject: Reply with quote

Well you have won a Longest Post Contest here!!

Unfortunately there are no prizes scheduled for this... uhm... a little mistake that is. :p

And btw - next time put it in CODE section so it'll be more clear to read and you'll avoid emots
_________________
Beware the lollipop of mediocrity - lick it once and you suck forever.

Back to top
View user's profile Send private message MSN Messenger
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Thu Feb 01, 2007 4:30 pm    Post subject: Reply with quote

ok thanks for the tip
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Hyper



Joined: 24 Jan 2004
Posts: 1227
Location: Middelburg, The Netherlands

PostPosted: Thu Feb 01, 2007 9:12 pm    Post subject: Reply with quote

I have a short version:

Exec CowUp.txt

CowUp.txt
Code:

admin set cow Mass 999999999
admin set cow MaxStepHeight 100
admin set cow Health 50000
admin set cow Aggressiveness 1
admin set cow bIsWuss False
admin set cow CombatStyle 1
admin set cow JumpZ 250
admin set cow GroundSpeed 500
admin set cow SightRadius 2000
admin set cow FovAngle 120
admin set cow menuname Guard cow
admin set cow Intelligence BRAINS_MAMMAL

_________________
Alter your reality...forever.
Hyper.nl Unreal Services
unreal://hypercoop.tk
Back to top
View user's profile Send private message Visit poster's website
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Thu Feb 01, 2007 10:19 pm    Post subject: Reply with quote

Thanks Hyper, i havent thaught yet of that short readme lol.
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
[B@D]Thug



Joined: 07 Oct 2005
Posts: 315

PostPosted: Fri Feb 02, 2007 4:11 am    Post subject: Reply with quote

Execs are stupid. When you can just use a more stable way.
_________________
Improvements along the way friends and foes.

WebSite:www.freewebs.com/agressivetoys
Back to top
View user's profile Send private message AIM Address MSN Messenger
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Fri Feb 02, 2007 3:12 pm    Post subject: Reply with quote

I still dont know it lol, i need to know so i can release another mod. i know for sure there are people on this forum who know how to let a cow melee a enemy, in this case it bites the enemy.
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
mentalhunter



Joined: 15 Nov 2006
Posts: 26
Location: Meppel The Netherlands

PostPosted: Wed Feb 07, 2007 8:36 pm    Post subject: Reply with quote

Ok, i allreaddy got it, but still thanks everyone for the attention ;)
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Hyper.nl Unreal Services Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group