| Blockland Forums > Modification Help |
| Explosion: Continuous shockwave |
| << < (2/4) > >> |
| Red_Guy:
im not real sure what effect your going for here with %waves always set to 1. but try this and see if it makes more sense. note its UNTESTED --- Code: ---function DoomNukeRocketProjectile::onExplode(%this,%obj) { parent::onExplode(%this, %obj); schedule(400, 0, "DoomNukeRocketProjectile::LaunchWave", %this, %obj, 1); } function DoomNukeRocketProjectile::LaunchWave(%this,%obj, %waves) { %projectile = NukeWaveProjectile; %position = %obj.getPosition(); for (%numbar=0; %numbar<%waves; %numbar++) { if ($times > 8) { $times = 0; return; } %x = (getRandom(-7,7) - 0.5) * 3.141592653; %y = (getRandom(-7,7) - 0.5) * 3.141592653; %z = (getRandom(-7,7) - 0.5) * 3.141592653; %velocity = %x SPC %y SPC %z; %p = new projectile() { dataBlock = %projectile; initialVelocity = %velocity; initialPosition = %position; sourceObject = %obj; sourceSlot = %obj.client.player.lastFragslot; client = %obj.client; }; $times++; %this.schedule(400, "LaunchWave", %p, %waves); MissionCleanup.add(%p); } } --- End code --- |
| phflack:
i think you messed up the code boxes, and not sure how to do projectiles, although i can look over basic things, and isn't the schedule function supposed to be: schedule(delay, 0, function name, arguments);? |
| takato14:
--- Quote from: phflack on January 04, 2011, 04:50:19 PM ---i think you messed up the code boxes, and not sure how to do projectiles, although i can look over basic things, and isn't the schedule function supposed to be: schedule(delay, 0, function name, arguments);? --- End quote --- If that's the case, then the example I used for the schedule(); (bushi's homing vector) is wrong. :/ |
| takato14:
--- Quote from: Red_Guy on January 04, 2011, 04:46:52 PM --- --- Code: ---[code]im not real sure what effect your going for here with %waves always set to 1. but try this and see if it makes more sense. note its UNTESTED --- End code --- function DoomNukeRocketProjectile::onExplode(%this,%obj) { parent::onExplode(%this, %obj); schedule(400, 0, "DoomNukeRocketProjectile::LaunchWave", %this, %obj, 1); } function DoomNukeRocketProjectile::LaunchWave(%this,%obj, %waves) { %projectile = NukeWaveProjectile; %position = %obj.getPosition(); for (%numbar=0; %numbar<%waves; %numbar++) { if ($times > 8) { $times = 0; return; } %x = (getRandom(-7,7) - 0.5) * 3.141592653; %y = (getRandom(-7,7) - 0.5) * 3.141592653; %z = (getRandom(-7,7) - 0.5) * 3.141592653; %velocity = %x SPC %y SPC %z; %p = new projectile() { dataBlock = %projectile; initialVelocity = %velocity; initialPosition = %position; sourceObject = %obj; sourceSlot = %obj.client.player.lastFragslot; client = %obj.client; }; $times++; %this.schedule(400, "LaunchWave", %p, %waves); MissionCleanup.add(%p); } } [/code] --- End quote --- %waves is always set to one, because I only want to spawn one projectile at a time. The launchWave function is meant to be run a certain number of times, then stop running. By increasing $times by one each time it is run, this can be done. However, I need to reset it once it reaches 8 or whatever I end up setting it to. EDIT: Tested your function, it doesnt work :/ |
| Red_Guy:
--- Quote from: phflack on January 04, 2011, 04:50:19 PM ---i think you messed up the code boxes, and not sure how to do projectiles, although i can look over basic things, and isn't the schedule function supposed to be: schedule(delay, 0, function name, arguments);? --- End quote --- schedule works 2 ways: 1) schedule(delay, 0, function, args) 2) object.schedule(delay, function, args) - this calls function' on object takato14 - put some echo() statements in your code to see whats going on. Once you get past trivial scripts, the "compile and pray" method doesnt work anymore. |
| Navigation |
| Message Index |
| Next page |
| Previous page |