| Blockland Forums > Modification Help |
| Support_AmmoReserve - Ammo System |
| << < (4/5) > >> |
| The Titanium:
I believe it actually works now. --- Code: ---package AmmoReserve { function ItemData::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f) { if(%obj.weaponReserveLoaded >= 1 && (%col.getType() & $TypeMasks::PlayerObjectType)) { echo("ONCOLLISION"); %col.pickup(%obj); } else Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f); } function ItemData::onPickup(%this,%obj,%user,%amt) { echo("hi"); %data = %obj.dataBlock; %dropReserve = %obj.weaponReserveLoaded; %p = %dropReserve / 100; %addslot0 = %user.maxReserve[0] * %p; %addslot1 = %user.maxReserve[1] * %p; %addslot2 = %user.maxReserve[2] * %p; %addslot3 = %user.maxReserve[3] * %p; %addslot4 = %user.maxReserve[4] * %p; if(%dropReserve >= 1) { //if(%user.tool[0].getID() !$= "" && %user.toolReserve[%user.tool[0]] !$= "") //if(%user.getID[%user.tool[0]] !$= "" && %user.toolReserve[%user.tool[0]] !$= "") if(%user.toolReserve[0] !$= "") %user.toolReserve[0] += %addslot0; if(%user.toolReserve[1] !$= "") %user.toolReserve[1] += %addslot1; if(%user.toolReserve[2] !$= "") %user.toolReserve[2] += %addslot2; if(%user.toolReserve[3] !$= "") %user.toolReserve[3] += %addslot3; if(%user.toolReserve[4] !$= "") %user.toolReserve[4] += %addslot4; echo("err"); %user.playAudio(0,ErrorSound); %obj.delete(); schedule(10,0,ResetReserve,%user); schedule(10,0,DisplayAmmo,%user); return; } else Parent::OnPickup(%this,%obj,%user,%amt); } function ItemData::onAdd(%this,%obj) { if($weaponReserveLoaded !$= "") { %obj.weaponReserveLoaded = $weaponReserveLoaded; $weaponReserveLoaded = ""; echo("lol"); } Parent::onAdd(%this,%obj); } function WeaponImage::onMount(%this, %obj, %slot) { if(%obj.currTool == -1 || %obj.toolReserve[%obj.currTool] $= "") { %obj.maxReserve[%obj.currTool] = %this.item.maxReserve; %obj.dropReserve[%obj.currTool] = %this.item.dropReserve; %obj.toolReserve[%obj.currTool] = %this.item.spawnReserve; echo("onmount"); } Parent::onMount(%this, %obj, %slot); } function servercmdDropTool(%client,%slot) { if(!isObject(%client.player)) return Parent::servercmdDropTool(%client,%slot); //if(!isObject(%client.player.tool[%slot]) || %client.player.tool[%slot].maxReserve <= 0) // return Parent::servercmdDropTool(%client,%slot); //$weaponAmmoLoaded = %client.player.dropReserve[%client.player.currTool]; //if(%client.player.tool[%slot].dropReserve >= 0) //if(%client.player.maxReserve[%client.player.currTool] == 800) //$WeaponReserveLoaded = 1; if(%client.player.dropReserve[%client.player.currTool] !$= "") $WeaponReserveLoaded = %client.player.dropReserve[%client.player.currTool]; %client.player.maxReserve[%client.player.currTool] = ""; %client.player.dropReserve[%client.player.currTool] = ""; %client.player.toolReserve[%client.player.currTool] = ""; return Parent::servercmdDropTool(%client,%slot); } function ResetReserve(%this) { if(%this.toolReserve[0] > %this.maxReserve[0]) %this.toolReserve[0] = %this.MaxReserve[0]; if(%this.toolReserve[1] > %this.maxReserve[1]) %this.toolReserve[1] = %this.MaxReserve[1]; if(%this.toolReserve[2] > %this.maxReserve[2]) %this.toolReserve[2] = %this.MaxReserve[2]; if(%this.toolReserve[3] > %this.maxReserve[3]) %this.toolReserve[3] = %this.MaxReserve[3]; if(%this.toolReserve[4] > %this.maxReserve[4]) %this.toolReserve[4] = %this.MaxReserve[4]; if(%this.toolReserve[0] < 0) %this.toolReserve[0] = 0; if(%this.toolReserve[1] < 0) %this.toolReserve[1] = 0; if(%this.toolReserve[2] < 0) %this.toolReserve[2] = 0; if(%this.toolReserve[3] < 0) %this.toolReserve[3] = 0; if(%this.toolReserve[4] < 0) %this.toolReserve[4] = 0; } function DisplayAmmo(%this) { %this.client.bottomprint("<just:right><color:FFFF00>Ammo <color:FFFFFF>:<color:FF0000>" SPC %this.toolReserve[%this.currTool], 3); } };activatePackage(AmmoReserve); --- End code --- |
| The Titanium:
Space, is there a way to make a model produce emitters via function/script instead of using states? For example, if I wanted an image to produce an emitter at WeaponImage::OnFire without using states? |
| Space Guy:
Not that I know of. You can spawn a projectile with an explosion near the barrel but that won't follow the barrel if the particle effect lasts for more than half a second or you're moving fast. |
| The Titanium:
Hm. Because I don't really want to use ImageAmmo to prevent weapons from firing, because that'd interfere with other mods, such as Support_AmmoGuns. I guess I'd have to do with what I've got. |
| Space Guy:
Well, not really. setImageAmmo only applies to Support_AmmoGuns if you actually set the stateScript parts to some of the functions I added e.g. "onLoadCheck", "onReloadCheck", "onReloaded". The idea is that you can script your weapon's reloading method to however you want. (all at once, single shells) |
| Navigation |
| Message Index |
| Next page |
| Previous page |