Forums Index >> Modding >> scripting for scoring?
Page : <1> :
Do you have e-mail where I could send it or some other help, I think I'm able to help you if you mean that test server where I was? Edit: Yay it works, this is a great gametype becouse it's scrum where heavytanks and mediums don't lose everytime. %) I'll send it to you if you give your e-mail I don't think you want I post it here for everyone.
Last edited: Saturday, January 14, 2006 at 10:37:54 PM
Umm... To be honest I don't see why you CAN'T post it here... Might help someone else too
Cheers for the help
Some thing may go wrong when posting it to forums but let's try. This is tank2.cs
Exec("./tank.cs");
//-----------------------------------------------------------------------------
Function TankData::create(%block)
{
Switch$(%block)
{
Case "LightTank":
%obj = new Tank() {
DataBlock = %block;
};
Return(%obj);
Case "MediumTank":
%obj = new Tank() {
DataBlock = %block;
};
Return(%obj);
Case "HeavyTank":
%obj = new Tank() {
DataBlock = %block;
};
Return(%obj);
}
Return(-1);
}
Function TankData::onAdd(%this,%obj)
{
}
Function TankData::onTargetDestroyed(%db,%this,%killer)
{
// need to deal with both ai bots and players as killer's and killee's
%isPlayerKilled = isObject(%this.client);
%isPlayerKiller = isObject(%killer.client);
If (%isPlayerKiller)
{
%killer.incScore(1,1);
%killer.client.kills++;
If (%killer.client.kills % 10 == 0)
SpawnTarget(TargetSaucer);
}
If (%isPlayerKilled)
CommandToClient(%client,'CenterPrint',"Your brain has been separated from your tank, press SPACE.", 0, 1 );
Else if (%this.dataBlock.getName() !$= "TargetSaucer")
SpawnTarget(%this.dataBlock);
If (LocalClientConnection.kills == 5)
Schedule(1500,0,"exitTargetPractice");
}
Function TankData::onDestroyed(%db,%this,%killer)
{
If ($Game::SinglePlayer)
{
%db.onSPDestroyed(%this,%killer);
Return;
}
If ($Game::TargetRange)
{
%db.onTargetDestroyed(%this,%killer);
Return;
}
// need to deal with both ai bots and players as killer's and killee's
%client = %this.client;
%client.deaths++;
// echo("killed tank: " @ %this @ ", client: " @ %client);
// echo("killer tank: " @ %killer @ ", client: " @ %killerClient);
If (isObject(%killer))
{
MessageAll('MsgClientKilled','%1 has been eliminated by %2!',%client.name,%killer.client.name);
If ($Game::MissionType $= "Scrum")
{
// this is a score...
If ($Game::TeamGame)
{
If (%killer.client.team.getId() != %client.team.getId())
%killer.incScore(1,1);
}
Else
%killer.incScore(1,1);
}
%killer.client.kills++;
}
Else
{
MessageAll('MsgClientKilled','%1 has been eliminated!',%client.name);
}
If ($Game::MissionType $= "Scrum")
{
If ($Game::TeamGame)
{
If (isObject(%killer) && %killer.client.team.getId() == %client.team.getId())
// team killer, lose point
%this.incScore(-1,-1);
Else
%this.incScore(-1,0);
}
Else
%this.incScore(-1,-1);
}
If (!isObject(%client.ai))
{
If ($Game::aiControlMode)
{
%client.player = 0;
%client.schedule(4000,"spawnPlayer");
}
Else
CommandToClient(%client,'CenterPrint',"Your brain has been separated from your tank, press SPACE.", 0, 1 );
}
Else
SpawnBotPlayer(%client);
}
Function Tank::onRemove(%this)
{
}
// Based on old GameConnection incScore function -- moved here for ai
Function Tank::incScore(%this,%delta,%deltaTeam)
{
%client = %this.client;
// handle floor on score
If (-%delta>%client.score)
{
%client.cumScore -= %client.score;
%client.score = 0;
}
Else
{
%client.score += %delta;
%client.cumScore += %delta;
}
If (isObject(%client.team))
{
If (-%deltaTeam>%client.team.score)
{
%client.team.cumScore -= %client.team.score;
%client.team.score = 0;
}
Else
{
%client.team.score += %deltaTeam;
%client.team.cumScore += %deltaTeam;
}
}
MessageAll('MsgClientScoreChanged', "", %client.score, %client.cumScore, %client);
If (isObject(%client.team))
MessageAll('MsgTeamScoreChanged', "", %client.team.score, %client.team.cumScore, %client.team.getId());
}
Function PowerUpData::onEnter(%db,%this,%tank)
{
//echo(%tank.client.name @ " enters powerup " @ %this.getId() @ " of type " @ %db.type);
If (%db.type $= "weapon")
{
%choice = getRandom($NumPupTypes-1);
%tank.setProjectile($pupTypes[%choice]);
If (getRandom(10)<=2 && !$Game::SinglePlayer)
%this.schedule(5000,"setDatablock","Heal");
// schedule say $pupSnds[%choice]
If (isObject(%tank.client))
%tank.client.schedule(1000,"play2D",$pupSnds[%choice]);
}
Else if (%db.type $= "health")
{
%tank.hurtMe(-100);
%this.schedule(5000,"setDatablock","TestPowerup");
// schedule say Heal
If (isObject(%tank.client))
%tank.client.schedule(1000,"play2D","ActivateHeal");
}
Else if (%db.type $= "ammo")
{
%this.playUserThread(1,1,true);
%tank.setProjectile(%tank.getDataBlock().defaultProjectile);
// schedule say Reload
If (isObject(%tank.client))
%tank.client.schedule(1000,"play2D","ActivateReload");
}
Else if (%db.type $= "goal")
{
If ($Game::MissionType $= "Scrum")
{
If (%tank.getFlag() != -1)
{
ServerPlay3D(PupOffSound,%this.getTransform());
%flag = %tank.getFlag();
%flag.clearMount();
%flag.setTransform(VectorAdd(pickSpawnPoint(""),"0 0 10"));
%flag.setGoal(pickGoal());
If ($Game::TeamGame)
BottomPrintAll(%tank.client.nameBase SPC "scored a goal for the" SPC %tank.client.team.shortName SPC "team!",4,2);
Else
BottomPrintAll(%tank.client.nameBase SPC "scored a goal!",4,2);
%tank.incScore(1,1);
}
}
}
Yup, you have to change some of the Functions to functions and maybe Elses to elses and if it still doesn't work you just have to change every first letters into lower case I think...It would be so easy to just send it to e-mail.
Last edited: Sunday, January 15, 2006 at 4:43:14 AM
Page : <1> :
Im trying to make a sortof battlescrum type mod. How can you make it that you get points by killing people in a scrum game?
I've been trying to run it using tank2.cs