Why doesn't this ScriptedPawn fire a projectile?

Discussions about UT99
Post Reply
User avatar
OjitroC
Godlike
Posts: 3641
Joined: Sat Sep 12, 2015 8:46 pm

Why doesn't this ScriptedPawn fire a projectile?

Post by OjitroC »

This is the Skraag from MUPawns
Skraag.jpg
It should have both a ranged attack and a melee attack but ... it doesn't. All the relevant default properties are set correctly as far as I can tell - this is the code
Spoiler
var() byte BladeDamage;
var(Sounds) sound Spin;
var(Sounds) sound Firing;
var(Sounds) sound Syllable1;
var(Sounds) sound Syllable2;
var(Sounds) sound Syllable3;
var(Sounds) sound Syllable4;

function eAttitude AttitudeToCreature(Pawn Other)
{
if ( Other.IsA('ScriptedPawn') )
{
if ( Other.IsA('Abaddon') )
return ATTITUDE_Friendly;
else if ( Other.IsA('Skraag') )
return ATTITUDE_Friendly;
else
return ATTITUDE_Ignore;
}
else
return ATTITUDE_Hate;
}

function PreSetMovement()
{
bCanJump = true;
bCanWalk = true;
bCanSwim = false;
bCanFly = true;
bCanDuck = true;
MinHitWall = -0.6;
if (Intelligence > BRAINS_Reptile)
bCanOpenDoors = true;
if (Intelligence == BRAINS_Human)
bCanDoSpecial = true;
}

function TryToDuck(vector duckDir, bool bReversed)
{
local vector HitLocation, HitNormal, Extent;
local actor HitActor;

//log("duck");
duckDir.Z = 0;
if ( (Skill == 0) && (FRand() < 0.5) )
DuckDir *= -1;

Extent.X = CollisionRadius;
Extent.Y = CollisionRadius;
Extent.Z = CollisionHeight;
HitActor = Trace(HitLocation, HitNormal, Location + 100 * duckDir, Location, false, Extent);
if (HitActor != None)
{
duckDir *= -1;
HitActor = Trace(HitLocation, HitNormal, Location + 100 * duckDir, Location, false, Extent);
}
if (HitActor != None)
return;

//log("good duck");
Destination = Location + 150 * duckDir;
Velocity = 400 * duckDir;
AirSpeed *= 2.5;
GotoState('TacticalMove', 'DoMove');
}

function SetMovementPhysics()
{
SetPhysics(PHYS_Flying);
}

singular function Falling()
{
SetPhysics(PHYS_Flying);
}

function PlayWaiting()
{
PlayAnim('Breath', 0.5,0.05);
}

function PlayPatrolStop()
{
PlayWaiting();
}

function PlayWaitingAmbush()
{
PlayWaiting();
}

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

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

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

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

function PlayRunning()
{
if ( AnimSequence == 'Firing' )
LoopAnim('Breath', -1.0/AirSpeed, 0.5, 0.4);
else
LoopAnim('Breath', -1.0/AirSpeed,, 0.4);
}

function PlayThreatening()
{
local float decision;

decision = FRand();

if ( decision < 0.7 )
PlayAnim('Breath', 0.4, 0.4);
else if ( decision < 0.8 )
PlayAnim('SpinAttack', 0.4, 0.25);
else
{
PlayThreateningSound();
TweenAnim('Fighter', 0.3);
}
}

function PlayTurning()
{
LoopAnim('Breath');
}

function PlayDying(name DamageType, vector HitLocation)
{
PlaySound(Die, SLOT_Talk, 4 * TransientSoundVolume);
PlayAnim('Dead1', 0.7, 0.1);
}

function PlayTakeHit(float tweentime, vector HitLoc, int damage)
{
if ( FRand() < 0.6 )
TweenAnim('LeftHit', tweentime);
else
TweenAnim('RightHit', 1.5 * tweentime);
}

function TweenToFalling()
{
TweenAnim('Still', 0.2);
}

function PlayInAir()
{
LoopAnim('Breath');
}

function PlayLanded(float impactVel)
{
PlayAnim('Still');
}

function PlayVictoryDance()
{
PlayAnim('Firing', 0.6, 0.1);
PlaySound(Syllable4, SLOT_Interact);
}

function PlayMeleeAttack()
{
local vector adjust;
adjust = vect(0,0,0);
adjust.Z = Target.CollisionHeight;
Acceleration = AccelRate * Normal(Target.Location - Location + adjust);
PlaySound(Spin, SLOT_Interact);
PlayAnim('SpinAttack');
}

function PlayRangedAttack()
{
local vector adjust;
adjust = vect(0,0,0);
adjust.Z = Target.CollisionHeight + 20;
Acceleration = AccelRate * Normal(Target.Location - Location + adjust);
PlayAnim('Firing');
PlaySound(Firing, SLOT_Interact);
}

function SpawnShots()
{
local rotator FireRotation;
local vector X,Y,Z, projStart;

GetAxes(Rotation,X,Y,Z);
MakeNoise(1.0);
projStart = Location + 0.2 * CollisionRadius * X + 0.2 * CollisionRadius * Y + 0.25 * CollisionHeight * Z;
FireRotation = AdjustAim(ProjectileSpeed, projStart, 400, bLeadTarget, bWarnTarget);
spawn(RangedProjectile,self,'',projStart, FireRotation);

projStart = projStart - 0.5 * CollisionRadius * Y;
FireRotation.Yaw += 400;
spawn(RangedProjectile,self,'',projStart, FireRotation);

projStart = projStart - 0.3 * CollisionRadius * X;
FireRotation.Yaw += 400;
spawn(RangedProjectile,self,'',projStart, FireRotation);

projStart = projStart + 0.5 * CollisionRadius * Y;
FireRotation.Yaw += 400;
spawn(RangedProjectile,self,'',projStart, FireRotation);
}

function SpinDamageTarget()
{
(MeleeDamageTarget(BladeDamage, (BladeDamage * 1300 * Normal(Target.Location - Location))));
PlaySound(Spin, SLOT_Interact);
}

function PlayMovingAttack()
{
if ( AnimSequence == 'Breath' )
PlayAnim('Firing', 1.0, 0.2);
else
PlayAnim('Firing');
}

State TacticalMove
{
ignores SeePlayer, HearNoise;

function EndState()
{
AirSpeed = Default.AirSpeed;
Super.EndState();
}
}
Can anybody indicate why the Skraag doesn't fire or cause melee damage?

I would say that MUPawns is rather buggy - for example, the code for this Pawn calls an animation Float that it doesn't have.
User avatar
EvilGrins
Godlike
Posts: 9739
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by EvilGrins »

Well, it's set up to fire a tentacle attack and it's also setup for ranged attacks... but other than directly testing it, I don't see why it isn't doing what you say it's not doing.
Attachments
Clip0005.png
Clip0005.png (10.26 KiB) Viewed 380 times
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
User avatar
papercoffee
Godlike
Posts: 10451
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by papercoffee »

Maybe there isn't any projectile which can be fired...
User avatar
EvilGrins
Godlike
Posts: 9739
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by EvilGrins »

papercoffee wrote: Fri Apr 15, 2022 12:33 amMaybe there isn't any projectile which can be fired...
Don't think that's it, I just think they have an unusually limited range.

Its attacks only do a 34 in damage, and when I tested it I noted they didn't shoot so I got really close to them and they swarmed me... all twisting at odd angles around me and that seemed pointless until I noticed I was losing health.

They use swarm attacks and once you can't move as they're all around you, they stab you to death at close range.
Attachments
Shot0138.png
Shot0138.png (2.07 KiB) Viewed 378 times
Shot0137.png
Shot0137.png (263.44 KiB) Viewed 378 times
Shot0132.png
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
User avatar
SilverSound
Adept
Posts: 344
Joined: Fri Nov 06, 2015 10:12 am
Personal rank: Curious
Location: St. Cloud, Florida

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by SilverSound »

I don't see any code telling it to attack at all. I only see code that defines spawning a projectile. It needs to actually be told to shoot in order for it to shoot.

The only state I see is "State tactical move" so it basically only should move around in a level.

My guess on why it does swarmy melee attacks could be related to the base pawn class having melee states.
"Woah what?! I wish I was recording that...."
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by Barbie »

The first line with class definition is missing. Maybe the parent class calls the (user defined) function "SpawnShots()", where the projectiles are fired.
----------
<EDIT>
Found it:

Code: Select all

class Skraag extends ScriptedPawn;
So function SpawnShots() is never called - no projectiles are fired.
----------
<EDIT2>
Are you using this for mapping? Then a simple fix would be possible.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
OjitroC
Godlike
Posts: 3641
Joined: Sat Sep 12, 2015 8:46 pm

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by OjitroC »

EvilGrins wrote: Fri Apr 15, 2022 12:37 am Its attacks only do a 34 in damage, and when I tested it I noted they didn't shoot so I got really close to them and they swarmed me... all twisting at odd angles around me and that seemed pointless until I noticed I was losing health.
When summoned individually, the Skraag will carry out a melee attack (the SpinAttack animation) but it does not appear to do any damage - at least I haven't suffered any damage from it that I have noticed.
SilverSound wrote: Fri Apr 15, 2022 2:37 am I don't see any code telling it to attack at all. I only see code that defines spawning a projectile. It needs to actually be told to shoot in order for it to shoot.
I wondered about that.
Barbie wrote: Fri Apr 15, 2022 8:03 am The first line with class definition is missing. Maybe the parent class calls the (user defined) function "SpawnShots()", where the projectiles are fired.
Apologies - I should have stated that I left that part out of the code I quoted.
Barbie wrote: Fri Apr 15, 2022 8:03 am So function SpawnShots() is never called - no projectiles are fired ...

Are you using this for mapping? Then a simple fix would be possible.
I want to use this in MonsterSpawn rather than placing it in a map (directly or via a factory). Ideally I would like to subclass it and alter a few of the default properties (health, speed of movement, projectile, etc) to make it a bit more challenging.

So the question is ... can I call the function SpawnShots() in a subclass so it does fire projectiles? And if so, what code should I use?
User avatar
sektor2111
Godlike
Posts: 6412
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by sektor2111 »

Look at Brutes or Skaarj, try copy some combat codes from there but... see if are not involved certain animations because these have to be changed - if pawn has firing animations...
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by Barbie »

OjitroC wrote: Fri Apr 15, 2022 9:32 am Ideally I would like to subclass it and alter a few of the default properties (health, speed of movement, projectile, etc) to make it a bit more challenging.

So the question is ... can I call the function SpawnShots() in a subclass so it does fire projectiles?
That was my first thought, too. BUT function FireProjectile() is defined as FINAL in class'ScriptedPawn', and so it cannot be overwritten in child class. Other ScriptedPawns use special function in animation sequences to call function FireProjectile(), here for example class'Brute':

Code: Select all

#exec MESH NOTIFY MESH=Brute1 SEQ=WalkFire TIME=0.18 FUNCTION=SpawnRightShot

function SpawnRightShot() {
	FireProjectile( vect(1.2,-0.7,0.4), 750);
}
Same can happen with class'Skraag':

Code: Select all

#exec MESH SEQUENCE MESH=Skraag SEQ=Firing STARTFRAME=30 NUMFRAMES=15 RATE=15
In that line the addition "FUNCTION=SpawnShots" is missing.

Also because of a lot of missing states I'd take only the mesh and sounds and recode it completely.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
OjitroC
Godlike
Posts: 3641
Joined: Sat Sep 12, 2015 8:46 pm

Re: Why doesn't this ScriptedPawn fire a projectile?

Post by OjitroC »

Barbie wrote: Sat Apr 16, 2022 8:26 am That was my first thought, too. BUT function FireProjectile() is defined as FINAL in class'ScriptedPawn', and so it cannot be overwritten in child class. Other ScriptedPawns use special function in animation sequences to call function FireProjectile() ... Also because of a lot of missing states I'd take only the mesh and sounds and recode it completely.
Thanks for the clarification and explanation - that gives me a better understanding of the situation. I might see what I can do with reusing the mesh with new code.
Post Reply