| Blockland Forums > Modification Help |
| Scripting a boss playertype |
| (1/4) > >> |
| pecon98:
Here is what is done so far. server.cs --- Code: ---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); --- End code --- voices.cs --- Code: ---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)"); } } } --- End code --- 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. |
| Lugnut:
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 |
| phflack:
--- Quote from: Lugnut1206 on March 14, 2012, 08:46:13 PM --- 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 --- End quote --- 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()) --- Quote from: pecon98 on March 14, 2012, 08:16:16 PM --- --- Code: ---\\Currently obsolete --- End code --- --- End quote --- 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: ---schedule(10000, 0, SCschedule, 3); --- End code --- |
| pecon98:
--- Quote from: phflack on March 14, 2012, 09:10:27 PM ---edit: in the voices.cs, why do you put 3 as an arguement when the function doesn't require any? --- Code: ---schedule(10000, 0, SCschedule, 3); --- End code --- --- End quote --- 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. |
| Greek2me:
--- Quote from: pecon98 on March 14, 2012, 08:16:16 PM ---3: I need to make some slayer-compatible stuff such as checking the number of lives of the player --- End quote --- %client.getLives(); //check number of lives %client.dead(); //check if dead (meaning they cannot respawn) |
| Navigation |
| Message Index |
| Next page |