|
Post by NicusorN5 on May 18, 2016 14:28:55 GMT
In my script , Zombie1HP don't decreases WTF?
void Main() { ///Main //Floats and ints float HP = OUT_0 ; HP =OUT_22; float WeaponDamage = 0 ; //Strings string Weapon = "null"; string Wep1 = "null"; string Wep2 = "null"; string Wep3 = "null"; string Wep4 = "null"; string Wep5 = "null"; string Wep6 = "null"; string Wep7 = "null"; string Wep8 = "null"; ///Wep Pickaxe Spawner Vector3 Cam,Weapon_Pickaxe; iObjectLocation(OBJ_66,Cam); iObjectLocation(OBJ_88,Weapon_Pickaxe); if (iVectorLength(Cam-Weapon_Pickaxe)<2) { iObjectShow(OBJ_44); iObjectRefresh(OBJ_44,".\\3DRad_res\\objects\\Skinmesh\\data\\CubeWars_Weapons_Melee_Pickaxe\\000_mesh.x"); iObjectHide(OBJ_88); iObjectStop(OBJ_110); iObjectStop(OBJ_132); Weapon = "pickaxe" ; WeaponDamage = -60; } ///Zombie 1 float Zombie1HP = 60; OUT_264 = Zombie1HP; OUT_156 =1 ; if (IN_198 ==1) { Zombie1HP += WeaponDamage ; } if (Zombie1HP <= 0 ) { iObjectStop(OBJ_220); iObjectStop(OBJ_154); } }
|
|
|
Post by cypermethrin on May 18, 2016 17:17:03 GMT
That's why -
///Zombie 1
float Zombie1HP = 60;
OUT_264 = Zombie1HP;
OUT_156 =1 ;
if (IN_198 ==1)
{
Zombie1HP += WeaponDamage ;
}
if (Zombie1HP <= 0 )
{
iObjectStop(OBJ_220);
iObjectStop(OBJ_154);
}
}
you set Zombie1HP back to 60 at every script cycle. If will only decrease on the cycle when the hit occurs then reset to 60, you will never see it happen
Declare your variable starting values in an "iInitializing" (or something similar, I'm rusty, look it up on the help) statement
|
|
|
Post by NicusorN5 on May 18, 2016 19:39:12 GMT
Oh i will try ! Thanks!
|
|
|
Post by cypermethrin on May 18, 2016 19:48:30 GMT
and I missed one, you also set your weapon damage to zero every cycle....same thing applies
|
|
|
Post by NicusorN5 on May 18, 2016 19:58:16 GMT
That's why - ///Zombie 1 float Zombie1HP = 60;
OUT_264 = Zombie1HP; OUT_156 =1 ; if (IN_198 ==1) { Zombie1HP += WeaponDamage ; } if (Zombie1HP <= 0 ) { iObjectStop(OBJ_220); iObjectStop(OBJ_154); } } you set Zombie1HP back to 60 at every script cycle. If will only decrease on the cycle when the hit occurs then reset to 60, you will never see it happen Declare your variable starting values in an "iInitializing" (or something similar, I'm rusty, look it up on the help) statement Declaring the variables outside Main() will also work?
|
|
|
Post by cypermethrin on May 18, 2016 21:41:05 GMT
Should do, try and find out, its the best way to learn
|
|
|
Post by NicusorN5 on May 19, 2016 15:59:47 GMT
LOL i tried using lower damage value , and Zombie1 don't die anymore. WTF? My Updated script:
float WeaponDamage = 0 ; //Strings string Weapon = "null"; string Wep1 = "null"; string Wep2 = "null"; string Wep3 = "null"; string Wep4 = "null"; string Wep5 = "null"; string Wep6 = "null"; string Wep7 = "null"; string Wep8 = "null"; void Main() { ///Main //Floats and ints float HP = OUT_0 ; HP =OUT_22;
///Wep Pickaxe Spawner Vector3 Cam,Weapon_Pickaxe; iObjectLocation(OBJ_66,Cam); iObjectLocation(OBJ_88,Weapon_Pickaxe); if (iVectorLength(Cam-Weapon_Pickaxe)<2) { iObjectShow(OBJ_44); iObjectRefresh(OBJ_44,".\\3DRad_res\\objects\\Skinmesh\\data\\CubeWars_Weapons_Melee_Pickaxe\\000_mesh.x"); iObjectHide(OBJ_88); iObjectStop(OBJ_110); iObjectStop(OBJ_132); Weapon = "pickaxe" ; WeaponDamage = -40; } ///Zombie 1 float Zombie1HP = 60; OUT_264 = Zombie1HP; OUT_156 =1 ; if (IN_198 ==1) { Zombie1HP += WeaponDamage ; } if (Zombie1HP <= 0 ) { iObjectStop(OBJ_220); iObjectStop(OBJ_154); } }
|
|
|
Post by NicusorN5 on May 19, 2016 16:12:51 GMT
LOL i fixed it myself i moved float Zombie1HP outside Main() function.Thanks for all the help.I closed this thread.
|
|