Author Topic: Can't change the player's datablock all right and proper.  (Read 1794 times)

Here's my file.

This weapon, as it stands now, is basically just a Horse Ray that is set to change the player's datablock to the No-Jet player datablock.

Here's the strange part. When I hit a horse with it, it changes into a player. But if a player is hit with it, it changes him into... I think it's just a normal player. He can jet, certainly. He can also be hit with a normal horse ray, and changed back again with this.

Can someone take a look at my code and tell me if I did something wrong?

Thanks.

PS: Yes, I know it doesn't check for the no-jet player to be enabled, but I checked, and when I was testing it, nojet WAS enabled.

You need to parent and package it if your using damage.

You need to parent and package it if your using damage.
No.


From Weapon_Package_Rays that has the exact same thing in it.
Code: [Select]
function NoJetRayProjectile::Damage(%this,%col,%obj)
{
      if(%obj.getType() & $Typemasks::PlayerObjectType)
      {
            %obj.changeDatablock(PlayerNoJet);
      }
}

PROBLEM:

You used setDatablock.
« Last Edit: March 24, 2011, 03:11:57 PM by otto-san »

Really, ok well thats a little stange, I guess but whatever. Also he parented the one before it so he would need to package that to, or is there another wierd expeption.

...Are you under the impression that doing something like function BEAR::CROSS() automatically warrants a parent/package thing? It doesn't. Packaging and parenting is only for functions that already exist that you are making modifications to.

edit:

he packaged the one before it because of some odd weapon things.

i dont know how to explain it

Ok, I am not, all I was saying was it was the one before damage was parented. So he probably does need to package it or am I wrong again?

yes.


He doesn't want it to do damage.

Ok, thanks for being patient with me. I dont ussally deal with weapons.

So you're saying I should change changedatablock() to setdatablock(), or vice versa?

All that other stuff is unnecessary.


Just change setDatablock to changeDatablock.


You need to parent and package it if your using damage.
Parent in a package calls the original function. EMPImage::onFire shouldn't already exist in the default scripts, so he couldn't want that.
Parent outside of a package calls the parent class function, in this case, WeaponImage::onFire, which would play the standard shooting function. Even Weapon_Gun has a similar onFire format. In fact, it wouldn't be any different if he changed his code to
function EMPImage::onFire(%this,%obj,%slot)
{
   GunImage::onFire(%this,%obj,%slot);   
}

Now you know.



Here you go Giovan.

Code: [Select]
function EMPProjectile::Damage(%this,%obj,%col,%fade,%pos,%normal)
{
   if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %col.changeDataBlock(PlayerNoJet);

      if(isObject(%col.client))
         %col.client.applyBodyColors();

      if(%col.getMountedObject(0))
         %col.getMountedObject(0).getDataBlock().doDismount(%col.getMountedObject(0));
   }
}

This will make sure no one is still mounted if the player was originally a horse. I could be wrong on the slot, please correct me.
« Last Edit: March 24, 2011, 05:16:58 PM by Chrono »

I don't think it's working. I jump up high and shoot it down. It bounces up and hits me. I see the explosion effect on myself. I can still jet.

I'm using Copy-Paste exactly chrono's code.

Any help?

Do you have Self Damage turned on in the minigame?

I wasn't running a minigame at the time. Do I need to?