Page 1 of 1

Allliance Changer..

PostPosted: Fri Jul 01, 11 10:54 am
by ~DJ~
oh how I wish Scripting Society still existed..
anyhow, people are still here.. so yeah!

I need help at this code I'm working on.. I'm trying to make a single-player modification to change NPC alliances.

So far here's my code:
[spoiler]
Code: Select all
//=============================================================================
// WeaponAC. Alliance Changer for NPCs.
//=============================================================================

class WeaponAC extends WeaponPistol;

simulated function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
   //ChangeAlly(Name newAlly, optional float allyLevel, optional bool bPermanent, optional bool bHonorPermanence)

   local int i;

   for (i=0; i<8; i++)
   {
      if( (ScriptedPawn(Other).InitialAlliances[i].AllianceName == 'Player') && (ScriptedPawn(Other).InitialAlliances[i].AllianceLevel == -1) )
      {
         DeusExPlayer(Owner).ClientMessage(ScriptedPawn(Other).Tag$""@ScriptedPawn(Other).InitialAlliances[i].AllianceLevel);
         ScriptedPawn(Other).GotoState('Wandering');
         ScriptedPawn(Other).ChangeAlly('Player', 1.0, True, False);
         ScriptedPawn(Other).bAlliancesChanged=True;
      }
      else if( (ScriptedPawn(Other).InitialAlliances[i].AllianceName == 'Player') && (ScriptedPawn(Other).InitialAlliances[i].AllianceLevel == 1) )
      {
         DeusExPlayer(Owner).ClientMessage(ScriptedPawn(Other).Tag$""@ScriptedPawn(Other).InitialAlliances[i].AllianceLevel);
         ScriptedPawn(Other).GotoState('Wandering');
         ScriptedPawn(Other).ChangeAlly('Player', -1.0, True,  False);
         ScriptedPawn(Other).bAlliancesChanged=True;
      }
   }

   Super.ProcessTraceHit(Other,HitLocation,HitNormal,X,Y,Z);
}

defaultproperties
{
     GoverningSkill=Class'DeusEx.SkillWeaponPistol'
     EnviroEffective=ENVEFF_Air
     Concealability=CONC_Visual
     HitDamage=0
     AmmoName=Class'DeusEx.Ammo10mm'
     ReloadCount=6
     PickupAmmoCount=6
     bInstantHit=True
     bPenetrating=False
     bHasMuzzleFlash=True
     bHandToHand=False
     bFallbackWeapon=True
     bEmitWeaponDrawn=False
     shakemag=0.000000
     FireSound=Sound'DeusExSounds.Weapons.PistolFire'
     CockingSound=Sound'DeusExSounds.Weapons.PistolReload'
     SelectSound=Sound'DeusExSounds.Weapons.PistolSelect'
     InventoryGroup=1337115135532
     ItemName="Alliance Changer"
     Description="A handy weapon to change someone's alliance"
     beltDescription="ALNCECHNG"
}
[/spoiler]

I wanted to make it so it reverts the current alliance for the player too, meaning that one shot would've made it an ally, the other an enemy, and so forth.

Now I'm not that expert but it seems to be not working. It does convert the enemy to an ally, but doesn't revert him back on another shot. Not that I have any idea, but something occurs in my mind.. perhaps the statement I've written doesn't sound logical.. seeing as it checks for ANY 'InitialAlliance.AllianceName' as being player, then ANY other 'InitialAlliance.AllianceLevel', could it be that it can choose from any 8 default 'InitialAlliances' and mess the statement up so it's kinda bugy..

Hopefully someone gets my engrish.. if not atleast looking at the code might've made some sense..

Thanks in advance! :oops:

PostPosted: Fri Jul 01, 11 6:49 pm
by Poor
InitialAlliances is only used to initialize the default alliances and doesn't hold information about the current alliances. It doesn't update when alliances change.

Code: Select all
var            AllianceInfoEx      AlliancesEx[16];


From what I see this array holds the real time alliance info.

But this function in ScriptedPawn provides a better way to check if the pawn is an enemy or an ally.

Code: Select all
native(2105) final function bool IsValidEnemy(Pawn TestEnemy, optional bool bCheckAlliance);

PostPosted: Fri Jul 01, 11 7:34 pm
by ~DJ~
Thank you!

However.. the part about 'AllianceInfoEx' and 'InitialAlliance'...that somewhat sounds a bit wrong to me, if it wasn't real time it shouldn't have worked.. that and the fact that the other one has 'Ex' in it's name.. doesn't that give away it's purpose.. however I'm not certain.. I'll try. :oops:

Thanks for that native function. I'll see if I can get it to any use too! :oops:

EDIT: Currently on my laptop, it seems as you might be right. Thanks, I'll try when I get on my PC!

PostPosted: Sat Jul 23, 11 4:51 pm
by Varsarus
Hello

Seeing as your discussing Alliances, is there a way to change the InitialAlliances to more than 8? or is it scripted to stay like that?

Thanks

PostPosted: Sat Jul 23, 11 11:27 pm
by Poor
I don't know why you would need more than 8 but you can make a larger array and override the function that Initializes alliances.

PostPosted: Sat Jul 23, 11 11:51 pm
by Varsarus
Poor wrote:I don't know why you would need more than 8 but you can make a larger array and override the function that Initializes alliances.


Hi

It's because I ran out of spaces on the initialalliances.

interesting what you said about the larger array though, is it possible that you can tell me what I need to do?

PostPosted: Sun Jul 24, 11 12:48 am
by Poor
You would create a new class that extends ScriptedPawn or a specific pawn you want, and override the function InitializeAlliances() to something like this.

Code: Select all
class MaxChenB extends MaxChen;

var(Alliances) InitialAllianceInfo InitialAlliancesExtra[8];

function InitializeAlliances()
{
   local int i;

   for (i=0; i<8; i++)
      if (InitialAlliances[i].AllianceName != '')
         ChangeAlly(InitialAlliances[i].AllianceName,
                    InitialAlliances[i].AllianceLevel,
                    InitialAlliances[i].bPermanent);

   for (i=0; i<8; i++)
      if (InitialAlliancesExtra[i].AllianceName != '')
         ChangeAlly(InitialAlliancesExtra[i].AllianceName,
                    InitialAlliancesExtra[i].AllianceLevel,
                    InitialAlliancesExtra[i].bPermanent);

}


Here you would use Max Chen's InitialAlliances as normal and when they are filled, you would use InitialAlliancesExtra; having 16 in total. Don't go over 16 though because ScriptedPawns can only have 16 real time alliances and you would need to override more functions to handle more.

PostPosted: Sun Jul 24, 11 1:14 am
by Varsarus
Thanks very much :D

PostPosted: Sun Jul 24, 11 1:22 pm
by Varsarus
Poor wrote:You would create a new class that extends ScriptedPawn or a specific pawn you want, and override the function InitializeAlliances() to something like this.

Code: Select all
class MaxChenB extends MaxChen;

var(Alliances) InitialAllianceInfo InitialAlliancesExtra[8];

function InitializeAlliances()
{
   local int i;

   for (i=0; i<8; i++)
      if (InitialAlliances[i].AllianceName != '')
         ChangeAlly(InitialAlliances[i].AllianceName,
                    InitialAlliances[i].AllianceLevel,
                    InitialAlliances[i].bPermanent);

   for (i=0; i<8; i++)
      if (InitialAlliancesExtra[i].AllianceName != '')
         ChangeAlly(InitialAlliancesExtra[i].AllianceName,
                    InitialAlliancesExtra[i].AllianceLevel,
                    InitialAlliancesExtra[i].bPermanent);

}


Here you would use Max Chen's InitialAlliances as normal and when they are filled, you would use InitialAlliancesExtra; having 16 in total. Don't go over 16 though because ScriptedPawns can only have 16 real time alliances and you would need to override more functions to handle more.


Hi Again

Just wondering if I ever come across the need of having more than 16 real time alliances what sort of functions would i need to override?

Thanks

PostPosted: Sun Jul 24, 11 8:20 pm
by ~ô¿ô~Nobody~
If you need more, you can just make a larger InitialAlliancesExtra array from what I see. :?

PostPosted: Sun Jul 24, 11 10:07 pm
by Poor
The array that holds current alliances is limited to 16.

Code: Select all
var            AllianceInfoEx      AlliancesEx[16];


If you wanted more than 16, you would need to create another array and update the code to use it in the functions that refer to AlliancesEx.

There are some native functions dealing with alliances so it may not properly work. Probably better to just stay below 16.

PostPosted: Sun Jul 24, 11 10:31 pm
by Varsarus
Poor wrote:The array that holds current alliances is limited to 16.

Code: Select all
var            AllianceInfoEx      AlliancesEx[16];


If you wanted more than 16, you would need to create another array and update the code to use it in the functions that refer to AlliancesEx.

There are some native functions dealing with alliances so it may not properly work. Probably better to just stay below 16.


Funnily enough I think I've seemed to have got it working without the need for that allianceinfoex...

Thanks again for your help :)