Author Topic: Scripting a boss playertype  (Read 1361 times)

Here is what is done so far.

server.cs
Code: [Select]
exec("./voices.cs");

%error = forceRequiredAddOn("Sound_Skycaptain");
if(%error == $Error::AddOn_NotFound)
{
    error("ERROR: Sound_Skycaptain - required add-on Sound_Skycaptain not found");
}

datablock PlayerData(Skycaptain : PlayerStandardArmor)
{
   runForce = 10 * 90;
   runEnergyDrain = 0;
   minRunEnergy = 0;
   maxForwardSpeed = 20;
   maxBackwardSpeed = 10;
   maxSideSpeed = 10;

   maxForwardCrouchSpeed = 7;
   maxBackwardCrouchSpeed = 7;
   maxSideCrouchSpeed = 7;

   maxdamage = 100;

   jumpForce = 12 * 120; //8.3 * 90;
   jumpEnergyDrain = 0;
   minJumpEnergy = 0;
   jumpDelay = 0;

minJetEnergy = 1;
jetEnergyDrain = 3;
canJet = 1;

uiName = "Sky Captain";
showEnergyBar = true;

   runSurfaceAngle  = 20;
   jumpSurfaceAngle = 10;
};

package skyCaptainentrance
{
function Skycaptain::onNewDataBlock(%this,%obj)
{
if(!$SCschedule && !isObject($SCschedule))
{
ServerPlay2D(SC_Entrance1);
echo(Entrance1);
$SCSchedulevar = schedule(10000, 0, SCschedule, %obj);
}
parent::onNewDataBlock(%this,%obj);
}
};
activatepackage(skycaptainentrance);

package skycaptainondisabled
{
function Skycaptain::ondisabled(%dtb, %obj, %enabled)
{
cancel($SCSchedulevar);
echo("Schdule cancled!");
parent::ondisabled(%dtb, %obj, %enabled);
}
};
activatepackage(skycaptainondisabled);

voices.cs
Code: [Select]
function skycaptainkill(%client)
{
switch(getRandom(0, 3))
{
case 0:
ServerPlay2D(SC_kill1);
echo(Killsound1);
case 1:
ServerPlay2D(SC_kill2);
echo(Killsound2);
case 2:
ServerPlay2D(SC_kill3);
echo(killsound3);
case 3:
ServerPlay2D(SC_kill4);
echo(killsound4);
}
}


function SCschedule(%obj)
{
echo("Schdule loop");
%r=(getrandom(1, 5));
if(%r==1)
{
ServerPlay2D(SC_intimidation1);
Echo(intimidation1);
}
if(%r==2)
{
ServerPlay2D(SC_intimidation2);
Echo(intimidation2);
}
if(%r==3)
{
ServerPlay2D(SC_intimidation3);
Echo(intimidation3);
}
if(%r>3)
{
Echo("No sound effect (intimidation)");
}
if(%obj.getdamagelevel()>75)
{
%lh=(getRandom(0, 6));
if(%lh==0)
{
schedule(2000, 0, ServerPlay2D, SC_lowhealth1);
echo(lowhealth1);
}
if(%lh==1)
{
schedule(2000, 0, ServerPlay2D, SC_lowhealth2);
echo(lowhealth2);
}
if(%lh==2)
{
schedule(2000, 0, ServerPlay2D, SC_lowhealth3);
echo(lowhealth3);
}
if(%lh>2)
{
echo("No sound effect (lowhealth)");
}
}
}

I need some help making a few things.

1: I need a way to break the schedule for SCschedule when the boss dies

2: I need a way to detect when the boss makes a kill (This will be scripted into whatever weapon he uses)

3: I need to make some slayer-compatible stuff such as checking the number of lives of the player, and if the round ends in a certain manner.

I would appreciate any help in coding this.
« Last Edit: March 19, 2012, 10:21:53 PM by pecon98 »

function SCschedule()
{
   cancel($SCSchedulevar); //Closes the schedule, not sure why this is done, but we do it
   if(!SC.isalive) //Check if the boss is alive (not a real variable, use your own here)
      return; //... and if it isn't, don't loop
   %r=(getrandom(1, 5));
   if(%r==1)
   {
      ServerPlay2D(SC_intimidation1);
      Echo(intimidation1);
   }
   if(%r==3)
   {
      ServerPlay2D(SC_intimidation2);
      Echo(intimidation2);
   }
   if(%r==5)
   {
      ServerPlay2D(SC_intimidation3);
      Echo(intimidation3);
   }
   $SCSchedulevar = schedule(10000, 0, SCschedule, 3); //Defines a variable so we can do stuff with the schedule
}
pretty syntax highlighting here
« Last Edit: March 14, 2012, 08:08:01 PM by Lugnut1206 »

   cancel($SCSchedulevar); //Closes the schedule, not sure why this is done, but we do it
   if(!SC.isalive) //Check if the boss is alive (not a real variable, use your own here)
      return; //... and if it isn't, don't loop
i think the cancel(); is done to prevent multiple schedules of it from accidentaly happening somehow
the if(!SC.isalive) thing i'd probably change to a variable like $currentboss = %player (the one that's the boss), then do if($currentboss.isObject())

Code: [Select]
\\Currently obsolete
i feal like you should get an error there?

and as a suggestion to it, i'd make the time between the sounds random

edit: in the voices.cs, why do you put 3 as an arguement when the function doesn't require any?
Code: [Select]
schedule(10000, 0, SCschedule, 3);

edit: in the voices.cs, why do you put 3 as an arguement when the function doesn't require any?
Code: [Select]
schedule(10000, 0, SCschedule, 3);
Opps.

EDIT: Added a check for low health to play a low-health sound.

EDIT2: I need a method for checking if the boss is dead before I can implement Lugnut's idea.
« Last Edit: March 14, 2012, 11:59:19 PM by pecon98 »

3: I need to make some slayer-compatible stuff such as checking the number of lives of the player
%client.getLives(); //check number of lives
%client.dead(); //check if dead (meaning they cannot respawn)

Could still be called Mocheeze.
« Last Edit: March 15, 2012, 06:24:32 PM by Ladios »

I could use some help finding a game function that would be called when this datablock dies. I tried tracing it but I didn't find anything I thought was helpful.

playerbossarmorr::ondisabled(%dtb, %obj, %enabled)

I found this in trace so yea...

playerbossarmorr::ondisabled(%dtb, %obj, %enabled)

I found this in trace so yea...
I must have missed it :u

I'll go use that now.

Wait, I need to make a custom armordata wont I?

Just do Skycaptain::ondisabled(%datablock,%player,%enabled)

Just do Skycaptain::ondisabled(%datablock,%player,%enabled)
Code: [Select]
package skycaptainondisabled
{
function Skycaptain::ondisabled(%dtb, %obj, %enabled)
{
cancel($SCSchedulevar);
parent::ondisabled(%dtb, %obj, %enabled);
}
};
activatepackage(skycaptainondisabled);
This works right?

I'm not updating the op with all my changes, so most of the silly errors are fixed.

Were there sounds on the other bosses that I haven't downloaded or something? :O

Were there sounds on the other bosses that I haven't downloaded or something? :O
No, this will be a first.

Updated the OP, I need help. The schedule seems to replicate itself multiple times and spirals out of control and causes massive earrape D=
« Last Edit: March 16, 2012, 01:35:15 AM by pecon98 »

Updated op, I need help with this.

silly pecon tripled his schedule definition