Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-17-2012, 02:54 PM
pupo162 pupo162 is offline
Approved Member
 
Join Date: Feb 2010
Posts: 1,188
Default OnActorDead - Damage DS

SO ehre i am back to scripting after giving up to focus on studying.

im tryign to create a scrip who counts for point when a palne gets killed (for now).

to start:

Quote:
public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

AiAircraft aircraft = actor as AiAircraft;

//for (int i = 0; i < aircraft.Places(); i++)
//{
// if (aircraft.Player(i) != null)
// {
// // TODO: Account for more than one player in an aircraft
// player = aircraft.Player(i);
// break;
// }
//}

int value = 0;


foreach (DamagerScore ds in damages)
{

if (actor is AiPerson) break; // At moment Pilotkills are not counted

if (actor is AiGroundActor) break; // At moment Groundkills are not counted

if (actor is AiAircraft)
{
switch (aircraft.Army())
{
case 1:
if (rafa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
bluescore = bluescore + rafv[(aircraft as AiAircraft).InternalTypeName()];
//GamePlay.gpHUDLogCenter(new Player[] { player }, "You DIED!, {0} : LOST!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
GamePlay.gpHUDLogCenter("ola");
}

break;

case 2:
if (lwa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
redscore = redscore + lwv[(aircraft as AiAircraft).InternalTypeName()];
//GamePlay.gpHUDLogCenter(new Player[] { player }, "You DIED!, {0} : LOST!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
GamePlay.gpHUDLogCenter("ola");
}
break; ;
}

}
}
}

I really dony understand, how Damagerscore list works, so where i am requesting your aid.

for now, my problems are: AI is not counted as destoyed, if i crash my plane is ok, but if an AI shoots me down it dobles the score ( im guessing its becosue im not specifin initiator or reciever of the damage. I based myself on the code From "Mid-july1940_v10" mission, who looks like:

Quote:
public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

//////////////////Penalty

if (actor is AiPerson)
{
if ((actor as AiPerson).Player() != null) // Player is Human
{
GamePlay.gpLogServer(null, "{0} - KIA", new object[] { (actor as AiPerson).Player() });
PilotsInGame.AddDeathToPlayer((actor as AiPerson).Player());
}
}

//////////////////Namen Anzeigen beim zerstören von Bodeneineihten

if ((actor as AiGroundActor) != null && damages[0].initiator.Player != null)
GamePlay.gpLogServer(null, "{0} was destroyed by {1}", new object[] { (actor as AiCart).InternalTypeName().Substring(4), (damages[0].initiator.Player.Name()) });

///////////////////////////Punkte für zerstörte Einheiten
foreach (DamagerScore ds in damages)
{
int Addpoints = 0;
int value;
bool willReportDead = false;
string TargetName = "";

if (ds.initiator != null)
{
if (ds.initiator.Actor != null)
{
if (actor is AiPerson) break; // At moment Pilotkills are not counted

if (actor is AiAircraft)
{

if (PointsforAirTargets.TryGetValue((actor as AiAircraft).Type().ToString(), out value)) // Erstetzt wegen Stukaproblem
Addpoints = PointsforAirTargets[(actor as AiAircraft).Type().ToString()];

TargetName = SplitName((actor as AiAircraft).InternalTypeName());

value = 0;

if (actor.Army() == ArmyRed)
{
BlueAirKills++;

if (RAFAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
{
RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
TargetName += " (" + RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)"; // Shows Counter for Planetype
}
}

else if (actor.Army() == ArmyBlue)
{
RedAirKills++;
if (LWAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
{
LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
TargetName += " (" + LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)"; // Shows Counter for Planetype
}

}
}

if (actor is AiGroundActor)
{
if (PointsforGroundTargets.TryGetValue((actor as AiGroundActor).Type(), out value))
Addpoints = PointsforGroundTargets[(actor as AiGroundActor).Type()];

TargetName = SplitName((actor as AiGroundActor).InternalTypeName());
}



willReportDead = true;

if (ds.initiator.Actor.Army() == ArmyBlue)
{
BlueGrdKills++;
ScoreBlue += Addpoints;
if (Addpoints <=0)
{ScoreBlue += 3;}
GamePlay.gpLogServer(null, "Britisch {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
break;
}
else if (ds.initiator.Actor.Army() == ArmyRed)
{
RedGrdKills++;
ScoreRed += Addpoints;
if (Addpoints <=0)
{ScoreRed += 3;}
GamePlay.gpLogServer(null, "German {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
break;

}
}
}
}
this code, had a problem when directly copy paste, it wouldnt count Friendly kills nor, if i crashed myself.

so ... help? please?
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.