It is currently Mon May 20, 2013 8:01 am




Post new topic Reply to topic  [ 43 posts ]  Go to page Previous  1, 2, 3  Next
FGR's Coding & Other Needs (Currently no issues) 
Author Message
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Okay, so I decided to incorporate at least one new gun into the mod, it being a submachine gun with a scope. So I thought "hey, I liked the iron sights in Deus Ex Unreal Revolution, maybe I should incorporate them so it'd differ somehow from the normal assault gun!". After getting the required permissions from Ceski, I started to use my amazing copy & paste powers to see if it'd work. To my surprise, it compiled without a hitch but when I use the scope in-game, it brings up the same scope as in the sniper rifle.

So here's what I've got.

Added to the .UC file of my custom player character:

Quote:
function Possess()
{

local DeusExRootWindow root;

Super.Possess();

root = DeusExRootWindow(rootWindow);

root.hud.Destroy();
root.hud = DeusexHUD(root.NewChild(Class'myGameHUD'));

root.hud.UpdateSettings(Self);
root.hud.SetWindowAlignments(HALIGN_Full,VALIGN_Full, 0, 0);

// replace scope with iron sights

root.scopeView.Destroy();
root.scopeView = DeusExScopeView(root.NewChild(Class'ceskiHUDIronSights',False));
root.scopeView.SetWindowAlignments(HALIGN_Full, VALIGN_Full);
root.scopeView.Lower();


}


So to my understanding, this piece of code would override ALL the scope code in DX with the code from 'ceskiHUDIronSights'. Now, I only want this to affect only one gun (named WeaponSMG5) but at this point it might be a bit irrelevant because the iron sights themselves don't come up properly!

ceskiHUDIronSights reads:

Quote:
//=============================================================================
// ceskiHUDIronSights.
//=============================================================================
//
//fake iron sights for WeaponSMG5
//slightly modified by FGR with permission from Ceski
//
class ceskiHUDIronSights extends DeusExScopeView;

var float gunlagX, gunlagY;
var float lastEye, curEye;
var vector lastLoc, curLoc;
var rotator lastRot, curRot;
var vector lastVel, curVel;
var float lastJump;

function PlaySwish(int swishNum)
{
local Sound swishSound;

if (swishNum == 1)
swishSound = Sound'RifleSelect';
else
swishSound = Sound'RifleSelect';

Player.PlaySound(swishSound, SLOT_None);
}

function ActivateView(int newFOV, bool bNewBinocs, bool bInstant)
{
desiredFOV = Player.DefaultFOV - newFOV;

if (Player != None)
{
curEye = Player.EyeHeight;
lastEye = Player.EyeHeight;
curLoc = Player.Location;
lastLoc = Player.Location;
curRot = Player.ViewRotation;
lastRot = Player.ViewRotation;
curVel = Player.Velocity;
lastVel = Player.Velocity;
lastJump = 0;

PlaySwish(1);
Player.bob = 0.008;
Player.desiredFOV = desiredFOV;

bViewVisible = True;
Show();
}
}

function ShowView()
{
if (bViewVisible)
{
curEye = Player.EyeHeight;
lastEye = Player.EyeHeight;
curLoc = Player.Location;
lastLoc = Player.Location;
curRot = Player.ViewRotation;
lastRot = Player.ViewRotation;
curVel = Player.Velocity;
lastVel = Player.Velocity;
lastJump = 0;

PlaySwish(1);
Player.bob = 0.008;
Player.SetFOVAngle(desiredFOV);

Show();
}
}

function DeactivateView()
{
if (Player != None)
{
PlaySwish(2);
Player.bob = Player.Default.bob;
Player.DesiredFOV = Player.Default.DefaultFOV;

bViewVisible = False;
Hide();
}
}

function HideView()
{
if (bViewVisible)
{
Hide();

PlaySwish(2);
Player.bob = Player.Default.bob;
Player.SetFOVAngle(Player.Default.DefaultFOV);
}
}

event DrawWindow(GC gc)
{
local float sightX, sightY, sightWidth, sightHeight;
local int toffset;
local float gunTest;
local float tempLag1,tempLag2;
local rotator tempRot1,tempRot2;
local float diffEye;
local vector diffLoc;
local rotator diffRot;
local vector diffVel;
local float centerDist;

Super(window).DrawWindow(gc);

if (GetRootWindow().parentPawn != None)
{
if (Player.IsInState('Dying'))
return;
}

//--------------------------------------------
//gun lag stuff
//--------------------------------------------
//update variables
curEye = Player.EyeHeight;
curLoc = Player.Location;
curRot = Player.ViewRotation;
curVel = Player.Velocity;

//update differences
diffEye = curEye - lastEye;
if (Abs(diffEye) > 8.0 || Abs(diffEye) < 0.01)
diffEye = 0;

diffLoc = curLoc - lastLoc;

tempRot1 = curRot;
tempRot2 = lastRot;
if (tempRot1.Pitch >= 32768)
tempRot1.Pitch = tempRot1.Pitch - 65536;
if (tempRot2.Pitch >= 32768)
tempRot2.Pitch = tempRot2.Pitch - 65536;
diffRot = tempRot1 - tempRot2;
if (diffRot.Yaw >= 32768)
diffRot.Yaw = diffRot.Yaw - 65536;
else if (diffRot.Yaw <= -32768)
diffRot.Yaw = diffRot.Yaw + 65536;

diffVel = curVel - lastVel;
if (Abs(diffVel.X) < 0.1)
diffVel.X = 0;
if (Abs(diffVel.Y) < 0.1)
diffVel.Y = 0;
if (Abs(diffVel.Z) < 0.1)
diffVel.Z = 0;

//return to center lag
if (abs(gunlagX) > 0)
gunlagX = gunlagX * 0.5;
if (abs(gunlagX) < 0.1)
gunlagX = 0;
if (abs(gunlagY) > 0)
gunlagY = gunlagY * 0.5;
if (abs(gunlagY) < 0.1)
gunlagY = 0;

//jump lag
if ((lastJump == 1) && (Player.Physics == PHYS_Falling))
{
gunlagY += 16;
lastJump = 0;
}
if ((lastVel.Z == 0) && (curVel.Z > 0) && (Player.Physics == PHYS_Falling))
{
gunlagY += 6;
lastJump = 1;
}

//land lag
if ((lastJump <= -Player.JumpZ) && (Player.Physics == PHYS_Walking))
{
gunlagY += 16;
lastJump = 0;
}
if ((lastVel.Z <= -Player.JumpZ) && (Player.Physics == PHYS_Walking))
{
gunlagY += 6;
lastJump = lastVel.Z;
}

//look lag
if (diffRot != rot(0,0,0))
{
tempLag1 = -FClamp(diffRot.Yaw,-3000,3000)/3000*32;
tempLag2 = FClamp(diffRot.Pitch,-3000,3000)/3000*32;
if (abs(tempLag1) > 1)
gunlagX += tempLag1;
if (abs(tempLag2) > 1)
gunlagY += tempLag2;
}

//crouch lag
if (diffEye != 0)
gunlagY += FClamp(diffEye,-10,10)/10*8;

//movement lag
if (diffVel != vect(0,0,0))
{
//forward and back
gunTest = normal(vector(lastRot)) dot (diffLoc*vect(1,1,0));
if (gunTest > 0.01)
gunlagY += FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
if (gunTest < -0.01)
gunlagY -= FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;

//left and right
gunTest = normal(vector(lastRot+rot(0,-16384,0))) dot (diffLoc*vect(1,1,0));
if (gunTest > 0.01)
gunlagX += FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
if (gunTest < -0.01)
gunlagX -= FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
}

//update variables
lastEye = Player.EyeHeight;
lastLoc = Player.Location;
lastRot = Player.ViewRotation;
lastVel = Player.Velocity;

//move in sync with Player bob
if (abs(Player.WalkBob.X) > 0)
gunlagX += Player.WalkBob.X*4;
if (abs(Player.WalkBob.Z) > 0)
gunlagY += Player.WalkBob.Z*4;

//make sure we stay in reticle
gunlagX = FClamp(gunlagX,-32,32);
gunlagY = FClamp(gunlagY,-32,32);


//--------------------------------------------
//draw ironsights
//--------------------------------------------
sightWidth = 256;
sightHeight = 256;
sightX = (width-sightWidth)*0.5;
sightY = (height-sightHeight)*0.5;

//timing for shooting animation
toffset = 26.0 * (Player.Level.TimeSeconds % 0.2);

//some day...
//if (WeaponPistolY(Player.inHand) != None)
//{
//}


if (WeaponSMG5(Player.inHand) != None)
{
//draw that annoying vignetting crap that every single game has these days
gc.SetStyle(DSTY_Modulated);
gc.DrawPattern(0, 0, width, 128, 4, 128, Texture'HUDGradient1');
gc.DrawPattern(0, height-128, width, 128, 4, 128, Texture'HUDGradient2');
gc.DrawPattern(0, 0, 64, height, 64, 4, Texture'HUDGradient3');
gc.DrawPattern(width-64, 0, 64, height, 64, 4, Texture'HUDGradient4');

//if we're shooting, cycle through muzzleflashes and both ironsight sizes
if (WeaponSMG5(Player.inHand).bFiring && WeaponSMG5(Player.inHand).IsAnimating() && (WeaponSMG5(Player.inHand).AnimSequence == 'Shoot'))
{
if (toffset == 0)
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-24, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
gc.SetStyle(DSTY_Translucent);
gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-24, 256, 256, 0, 0, Texture'HUDMuzzleFlash1');
}
else if (toffset == 1)
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-16, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
gc.SetStyle(DSTY_Translucent);
gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-16, 256, 256, 0, 0, Texture'HUDMuzzleFlash2');
}
else if (toffset == 3)
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-24, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
gc.SetStyle(DSTY_Translucent);
gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-24, 256, 256, 0, 0, Texture'HUDMuzzleFlash3');
}
else if (toffset == 4)
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-16, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
gc.SetStyle(DSTY_Translucent);
gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-16, 256, 256, 0, 0, Texture'HUDMuzzleFlash4');
}
else
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-8, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1a');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-8, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2a');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-8, sightWidth, sightY, 0, 0, Texture'HUDIronSights3a');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4a');
}
}
else
{
//if we're crouching, use the large ironsights
if (Player.bForceDuck || Player.bIsCrouching)
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-22, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-22, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-22, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
}
//use the basic ironsights
else
{
gc.SetStyle(DSTY_Modulated);
gc.DrawTexture(sightX+gunlagX, sightY+gunlagY, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1a');
gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2a');
gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY, sightWidth, sightY, 0, 0, Texture'HUDIronSights3a');
gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4a');
}
}
}
}



The original code had 'WeaponFR27' instead of 'WeaponSMG5'. WeaponSMG5.uc itself includes both bCanHaveScope=True as well as bHasScope=True.

Now, the original code from DXUR hasn't been changed any further than those replacements, and of course the iron sights work properly in DXUR. I searched through all of the DXUR .UC files to see if anything else would refer to the IronSights, but the only other code fileswith "Iron" in it concerned ammo. Even the .UC file for the general HUD modifications in DXUR doesn't refer to the iron sights at all.

Anyone got an idea?

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Sun Apr 01, 2012 11:44 am
Profile WWW
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Alright, now I managed to get the iron sights to work properly when you run the game from its own EXE (and INI files).

However, it turned out just as I feared, so that now all the other guns with scopes have the iron sights as well (or at least lack the textures). Anyone know how to make them only work with WeaponSMG5?

Oh, and even on the maximum skill level the rifle-with-iron-sights still has shaky hands whereas the sniper rifle is completely stable.

Any idea, guys?

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Tue Apr 03, 2012 8:07 pm
Profile WWW
Traditional Evil Scientist
Traditional Evil Scientist

Joined: Mon Oct 17, 2005 10:03 am
Posts: 3639
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
The main problem for me here is the formatting of the posted code makes it near-impossible to read.

Is the original like that, or does the original actually have tab-indenting (or any indenting at all)?

Also, if you're only getting it to run via particular ini/exe files, it suggests that your playerclass isn't being used (you can check the log file to see who's getting possessed). You can simply add your playerclass actor to maps to make the game use that when testing the map, incidentally.

Regarding the sights applying to everything, this is most likely because nowhere in your code (that I can see) does it make any attempt to check which weapon is being currently zoomed, thus it will naturally assume the code as presented applies to all guns (since at the moment, it does). It's difficult to work out where best to add a check, because..well: formatting. (my eyes!)

Also, it does't appear to factor weaponskill into the mix, so viewbobbing (which looks to be quite hacky anyway) will be skill-independent. Again this is probably an easy fix if only the code were more readable. Also, I'm not actually sure the viewbobbing of the sight in any way affects your actual shooting, it appears to just wobble the drawing of the sights from side to side, not the actual aimpoint of your weapon.


Wed Apr 04, 2012 8:26 am
Profile
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Hmm yeah, didn't factor in that copypasting would destroy the formatting. I think I'll use my old friend, PasteBin, from now on.

So here's the IronSight class: http://pastebin.com/4mDT5H1r
And here's the part from the mod's custom player class: http://pastebin.com/z7RP559T

I think it's odd, I've added the custom player class (under DeusExPlayer->Human->JCDentonMale or so) onto every level but I guess just testing the level from UED uses DeusEx.ini instead of the mod's own ini file. But at any rate, I'm glad it works with the actual way how you're going to be able to run the mod in the future but I sure hope it's not going to hinder (m)any other things.

I also tried adding some shoddy code to make that Possess() part only take WeaponSMG5 into account but despite (or because of) my copypasting glory, I never got the packages to compile. ceski actually warned me that a lot of the code was just to make the jokes in DXUR work so it might be really shoddy at places.

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Wed Apr 04, 2012 8:51 am
Profile WWW
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Any ideas, fellas? :]

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Wed Apr 11, 2012 6:38 am
Profile WWW
Traditional Evil Scientist
Traditional Evil Scientist

Joined: Mon Oct 17, 2005 10:03 am
Posts: 3639
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Sorry, whenever I have free time I'm not near my big ol' pile o' code, which I was simply going to C&P from. Long story short, it's entirely possible to do this, and I'll post the code when I get a moment.


Wed Apr 11, 2012 9:37 pm
Profile
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
No probs, right now I'm not really able to work on the mod until May 4th anyhow :|

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Thu Apr 12, 2012 11:46 am
Profile WWW
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
Alright, I'm back in action!

In addition to the aforementioned problem, here's another one! (SPOILER WARNING if it matters) I want to create a weapons 'automat' shop. So in practice, you talk to the seller who opens one of those slots after you've paid for the item. Apparently I should have just stuck with default DX seller conversations (which I'll do from now on to save time... oh so much time) since now it tends to work properly for just most of the time. As in, the player is only able to successfully buy items 8/10 times even if they have the necessary amount of credits (even though the Check Personas have ">= Greater Than or Equal To" as their condition). Any ideas where the problem could lie?

Also, when you buy the first set of LAMs the correct mover opens properly but you seem to be unable to actually pick up the LAM item itself unless you buy the other set. So I wonder if it's something related to the conversation itself or the close proximity of the mover brushes.

Cheers!

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Sat May 05, 2012 3:16 pm
Profile WWW
X-51
User avatar

Joined: Wed Mar 03, 2010 1:29 am
Posts: 834
Post Re: FGR's Coding Needs (Open request: April 1st 2012)
FastGamerr wrote:
Alright, I'm back in action!

In addition to the aforementioned problem, here's another one
how did you create that image of the whole conversation?

Quote:
Also, when you buy the first set of LAMs the correct mover opens properly but you seem to be unable to actually pick up the LAM item itself unless you buy the other set. So I wonder if it's something related to the conversation itself or the close proximity of the mover brushes.
Sounds like bsp problem. You might try moving them apart, or re-creating it in a more "stable" manner.

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


Sat May 05, 2012 4:38 pm
Profile
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding & Other Needs (Open request: April 1st 2012
Just edited that image in PSP7 since 'Export Conversation' didn't include all the details :|

Yeah, fixed the LAM issue (for now) by moving the other LAM slot to the lower row. Thanks!

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Sat May 05, 2012 5:41 pm
Profile WWW
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding & Other Needs (Open requests from April 201
Any clues, dudes?

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Fri May 18, 2012 5:00 pm
Profile WWW
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding & Other Needs (Open requests from April 201
Here's a third issue! ;>_>

I'm planning a situation where a certain character's (a human ScriptedPawn) injury will affect the conversation you'll have with the character. In practice, if the pawn is in 100% full health, you'll trigger a certain conversation whereas if the pawn has been injured, a different conversation will follow.

Once again my UnrealScript shenanigans proved to no avail (and sadly 'Check Persona' in the conversations only concern the player!) so now I'm wondering what should I do instead to make it work. At least at this point the whole thing actually compiles properly even if it actually doesn't work as it should.

Here's the current version of the MissionScript's Timer section

Then again, it currently only concerns the 100% health situation. Also assuming that the health values are based on percentages (so 1 = 100%) so that the code would remain the same even if I decided to change the pawn's health values in UED afterwards.

Any help? On any of the issues? <_<

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Tue Jun 19, 2012 9:54 am
Profile WWW
Traditional Evil Scientist
Traditional Evil Scientist

Joined: Mon Oct 17, 2005 10:03 am
Posts: 3639
Post Re: FGR's Coding & Other Needs (Open requests from April 201
health is actually numeric, so 1 health would be 1 hit point, which generally would mean the pawn was dead already (since health integrates health values from head, torso etc).

If you want to go for 0-1 values use pawn.health/pawn.default.health.

bCheckHealth never gets set to true, either, so that'd be a stumbling block.


Thu Jun 21, 2012 3:01 pm
Profile
UNATCO
User avatar

Joined: Sat Jul 10, 2010 10:06 am
Posts: 141
Location: Finland
Post Re: FGR's Coding & Other Needs (Open requests from April 201
Alrighty, so I added a "bCheckHealth = True;" before "foreach AllActors(class'PawnInQuestion', PawnInQuestion)" and changed "if (bCheckHealth && (PawnInQuestion.Health <= 1))" to "if (bCheckHealth && (PawnInQuestion.Health <= 3500))" (all the different body part health integers + Health together) and it indeed finally succeeds in triggering 'M66PawnInQuestionConversation'. However, it triggers it at all times, even if the pawn has e.g. 15% health left (in all body parts).

It's like the code somehow skips the whole "PawnInQuestion.CheckHealth" part because if I remove '<' from it, the code refuses to compile at all.

I also started thinking that nothing in the script actually defines the purpose of bCheckHealth, so I wonder if I have to add in stuff like this somewhere.

Quote:
function bool bCheckHealth(Pawn PawnInQuestion)
{
if(PawnInQuestion.Health = 3500)
{
return true;
}
else
{
return false;
}
}


(that particular function didn't compile, btw)

_________________
If you want to give me some pizza money:
Image
DX Nihilum
T O D O A TC T O D A Y


Thu Jun 21, 2012 4:29 pm
Profile WWW
Traditional Evil Scientist
Traditional Evil Scientist

Joined: Mon Oct 17, 2005 10:03 am
Posts: 3639
Post Re: FGR's Coding & Other Needs (Open requests from April 201
Ok, well. if() statements with a single = won't work, since X = Y sets X to equal Y, whereas X == Y checks whether X already equals Y.

So.

Something like this might work:

Code:
function timer()
{
   local scriptedpawn P;
   local float h;

   super.timer();


   if(!flags.getbool(healthRelevantConvo_played) && flags.getbool('CheckHealth'))
   {
      foreach allactors(Class'scriptedpawn', p, 'pawntag')
      {
         h = p.health/p.default.health;
         if(h >= 0.5)
         {         
            flags.setbool('PawnOK',true);
            break;
         }
         else if(h >= 0.2)
         {
            flags.setbool('pawnOk',false);
            flags.setbool('pawnInjured', true;)
            break;
         }
         else
         {
            flags.setbool('pawnOk',false);
            flags.setbool('pawnInjured',false);
            flags.setbool('pawnFucked', true);
            break;
         }
      }
   }   
}


So set the checkhealth flag to start checking, and then call the convo that uses it "healthRelevantConvo".

Obviously tweak the numbers as appropriate. :)


Sun Jun 24, 2012 2:21 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 43 posts ]  Go to page Previous  1, 2, 3  Next


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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:  
cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forum/DivisionCore.