Page 1 of 2

HELP me please ...incendiary nades!!

Posted: Fri Aug 16, 2013 2:35 pm
by GR3KO
Hello im new here and im a noob in scriptining :D
Im here to ask for help and learn about Scripting and mapping :D

i found a pk3 (Incendiary Nades v2) and i want to add it to my mohaa sh but it doesnt work like i want.
When i kill someone with that nade it doesnt gave me 1 point for killing .

can someone help me (please) with this ? Cause i dont know what code to write to the script .



Thanks for your help :D

Gr3ko.

Re: HELP me please ...incendiary nades!!

Posted: Sat Aug 17, 2013 12:40 am
by BatteryAziz
does it work in mohaa but not spearhead, or neither? what exactly happens when you frag someone? can you give a download link for this pk3, i will take a look at it. :)

Re: HELP me please ...incendiary nades!!

Posted: Sun Aug 18, 2013 5:08 pm
by GR3KO
Thanks for your help :D

here the link http://medalofhonor.filefront.com/file/ ... ades;53728

thats the name of the nades " lebabouin_incendiary_nades_fixed "

Thanks again my friend !! :D

Re: HELP me please ...incendiary nades!!

Posted: Sun Aug 18, 2013 8:55 pm
by BatteryAziz
this is what the readme says:
Once flaming, the player drops his weapons and begins to loose health.
You can still shoot him to get the killpoint otherwise he burns untill death and
gets his killcount decreased with death message: playerX burned into a crisp.
So the mod is working like it should. To make the firestarter get the killpoint instead of the burn victim getting his killcount decreased, requires some extra scripting. Right now the script says this, scroll down:

Code: Select all

onFire:

	self waittill trigger
	local.player = parm.other
	if (!local.player.onFire){
		local.player.onFire = 1
		local.player.save_dmteam = local.player.dmteam
		local.player attachmodel models/emitters/firefill.tik "Bip01 Pelvis" 0.2 "ouille" "true" 6 -1 -1 -1 ( 0 0 0 ) //( -5 8 0)
		local.player weapdrop
		waitframe
		local.player takeall

		local.player playsound fire_large

		while((local.player.health > 0) && (local.player.dmteam == local.player.save_dmteam)){ 
			wait .5
			local.player hurt 10 lava
		}

		local.player stopsound
		local.player.onFire = 0
		local.player addkills -1      //  <---------- 
		local.player kill
	}
end
There's no player attached to the fire, meaning that the fire is "anonymous". See those last few lines? "local.player addkills -1" should be replaced with something like "$player[local.firestarter] addkills 1". However, I'm no scripting genius, so I don't know how to identify who started the fire. I'll look into it. I don't have spearhead so if I fix it, you're gonna have to test it yourself.

It says that the radiusdamage is 15 on impact with an incendiary. Can you test the following: If you throw an incendiary to a player with like 5 hp and he dies immediately, do you THEN get a killpoint or not?

Re: HELP me please ...incendiary nades!!

Posted: Sun Aug 18, 2013 9:37 pm
by GR3KO
OK thanks a lot my friend ^^

i give it a try.^^

Re: HELP me please ...incendiary nades!!

Posted: Sun Aug 18, 2013 10:14 pm
by BatteryAziz
try this:
https://dl.dropboxusercontent.com/u/419 ... dunnit.pk3

I simply used "parm.other" in order to identify the player that triggered the main thread. ("parm.other" is used when a player enables a trigger, like planting a bomb, so you can identify who it is). In this case, i'm not sure parm.other can be used like this, but it's worth a try.

The script is now as follows. the arrows indicate my additions.

Code: Select all

main:
	if(!self.exploded){
		self.exploded = 1
		local.firestarter = parm.other        // <-------------------
		while (self!=NULL && self!=NIL){
			local.kaboom = self.origin
			waitframe
		}
		if(local.kaboom!=( 0 0 0 ))
			thread incendiary local.kaboom local.firestarter     // <-------------------
	}

end


incendiary local.kaboom local.firestarter:

	local.fx1 = spawn emitters/explosion_mine_shockwave.tik "classname" "effectentity" "angles" "0 0 0" 
	local.fx1.origin = local.kaboom
	local.fx2 = spawn emitters/inferno.tik "classname" "effectentity" "scale" "3" "angles" "0 0 0" 
	local.fx2.origin = local.kaboom 
	local.fx2 droptofloor
	local.fx2.origin += ( 0 0 20 )
	local.flames = spawn models/emitters/t2l4_fire.tik "classname" "effectentity" 
	local.flames scale 3 
	local.flames.origin = local.kaboom 
	local.flames playsound nebelsmokegrenade_exp_start
	wait .5
	local.flames loopsound fire_large 
	local.flames droptofloor
	local.burning = spawn trigger_multiple
	local.burning.origin = local.flames.origin 
	local.burning setsize ( -150 -150 50 ) ( 150 150 51 )
	local.flames.origin += ( 0 0 60 )
	local.burning wait 0
	local.burning delay 0
	local.burning setthread onFire local.firestarter    // <-------------------
	wait 15
	local.flames stoploopsound
	local.flames remove
	local.burning remove
	local.fx1 remove
	local.fx2 remove

end

onFire local.firestarter:                 // <-------------------

	self waittill trigger
	local.burnvictim = parm.other
	if (!local.burnvictim.onFire){
		local.burnvictim.onFire = 1
		local.burnvictim.save_dmteam = local.burnvictim.dmteam
		local.burnvictim attachmodel models/emitters/firefill.tik "Bip01 Pelvis" 0.2 "ouille" "true" 6 -1 -1 -1 ( 0 0 0 ) //( -5 8 0)
		local.burnvictim weapdrop
		waitframe
		local.burnvictim takeall

		local.burnvictim playsound fire_large

		while((local.burnvictim.health > 0) && (local.burnvictim.dmteam == local.burnvictim.save_dmteam)){ 
			wait .5
			local.burnvictim hurt 10 lava
		}
		
		local.burnvictim stopsound
		local.burnvictim.onFire = 0
		// local.burnvictim addkills -1
		local.burnvictim kill
		$player[local.firestarter] addkills 1      // <-------------------
	}
end
Also in the last bit I changed "local.player" to "local.burnvictim" to make it easier to read. Again, it might not work for obvious reasons. If so, we'll have to ask around.

Re: HELP me please ...incendiary nades!!

Posted: Mon Aug 19, 2013 7:52 pm
by jv_map
I think the last bit should read:

Code: Select all

local.firestarter addkills 1

Re: HELP me please ...incendiary nades!!

Posted: Mon Aug 19, 2013 8:02 pm
by BatteryAziz
good catch, i forgot local.firestarter is carrying the entity rather than the player index, thanks.
GR3KO, try the same link again, it's updated now.

Re: HELP me please ...incendiary nades!!

Posted: Tue Aug 20, 2013 4:23 am
by GR3KO
I tryed it but doesnt work , there no fire ... the nade just explode .

:D

Re: HELP me please ...incendiary nades!!

Posted: Tue Aug 20, 2013 9:56 am
by BatteryAziz
must've been a typo. I found my spearhead CD, and fixed the script. Now it's working :D I also made it so, if you burn yourself, you get -1 kills ;) and the flame damage was very high imo (10 hp every 0.5 seconds), i lowered this to 5 hp every random between 0.5-1.4 seconds. hope that's ok?

https://dl.dropboxusercontent.com/u/419 ... es_FIX.zip

readme now includes:
- firestarter gets +1 kills instead of burnvictim -1 kills
- if firestarter burns himself, he gets -1 kills
- flame damage modified

working script is now:

Code: Select all

main:
	if(!self.exploded)
		{
		self.exploded = 1
		local.firestarter = parm.other
		while (self != NULL && self != NIL)
			{
			local.kaboom = self.origin
			waitframe
			}
		if(local.kaboom != ( 0 0 0 ))
			{
			thread incendiary local.kaboom local.firestarter
			}
		}

end


incendiary local.kaboom local.firestarter:

	local.fx1 = spawn emitters/explosion_mine_shockwave.tik "classname" "effectentity" "angles" "0 0 0" 
	local.fx1.origin = local.kaboom
	local.fx2 = spawn emitters/inferno.tik "classname" "effectentity" "scale" "3" "angles" "0 0 0" 
	local.fx2.origin = local.kaboom 
	local.fx2 droptofloor
	local.fx2.origin += ( 0 0 20 )
	local.flames = spawn models/emitters/t2l4_fire.tik "classname" "effectentity" 
	local.flames scale 3 
	local.flames.origin = local.kaboom 
	local.flames playsound nebelsmokegrenade_exp_start
	wait .5
	local.flames loopsound fire_large 
	local.flames droptofloor
	local.burning = spawn trigger_multiple
	local.burning.origin = local.flames.origin 
	local.burning setsize ( -150 -150 50 ) ( 150 150 51 )
	local.flames.origin += ( 0 0 60 )
	local.burning wait 0
	local.burning delay 0
	local.burning thread onFire local.firestarter
	wait 15
	local.flames stoploopsound
	local.flames remove
	local.burning remove
	local.fx1 remove
	local.fx2 remove

end

onFire local.firestarter:

	self waittill trigger
	local.burnvictim = parm.other
	if (!local.burnvictim.onFire)
		{
		local.burnvictim.onFire = 1
		local.burnvictim.save_dmteam = local.burnvictim.dmteam
		local.burnvictim attachmodel models/emitters/firefill.tik "Bip01 Pelvis" 0.2 "ouille" "true" 6 -1 -1 -1 ( 0 0 0 ) //( -5 8 0)
		local.burnvictim weapdrop
		waitframe
		local.burnvictim takeall

		local.burnvictim playsound fire_large

		while((local.burnvictim.health > 0) && (local.burnvictim.dmteam == local.burnvictim.save_dmteam))
			{ 
			wait ( .5 + ( randomint(10)/10 ) )
			local.burnvictim hurt 5 lava
			}
		
		local.burnvictim stopsound
		local.burnvictim.onFire = 0
		local.burnvictim kill
		
		if(local.burnvictim == local.firestarter) // if burning yourself
			{
			local.firestarter addkills -1
			}
		else
			{
			local.firestarter addkills 1
			}
		}
end

Re: HELP me please ...incendiary nades!!

Posted: Tue Aug 20, 2013 2:07 pm
by GR3KO
we tryed it therse fire but its not working . first time we were two and it gave me one point and minus 1 to my friend
sec time minus1 to me n minus 1 to my friend.
the tird time minus 1 for each other , we tryed to pass in our own nades it gave minus one the my friend and give me one point.
the fourth time there was a guest on our server n when i walk on the nade's fire of my friend it give the point to the guest .

:D

Re: HELP me please ...incendiary nades!!

Posted: Tue Aug 27, 2013 8:03 am
by BatteryAziz
Okayyy i finally figured it out. it's madness but i got it to work. Deleted some of my previous posts to keep it clean :P

Download: HERE (dead)

There were two issues that had to be tackled. Since it took me so long to get it to work, I'd like to explain my approach :D

1. It kept switching the players around, right? And I didn't know why exactly, until now. Before, I thought it simply wasn't passing the correct player from the main thread up to upping/lowering the killcount. I kept playing around with ways to track all the active players with arrays, but this wasn't enough. Basically the problem was that just using "parm.other" on an executed script (from the nade's .tik file) without a trigger-reference, simply doesn't work. Whoever last touched the flame trigger, became "parm.other". Meaning that after a kill, suddenly the pitcher was also the guy who last touched the fire trigger! So, the only way this was going to work, was to use a TRIGGER in the main thread as well.

The way I approached this problem: right after you throw, it approximates your position (origin x,y,z) from the origin and trajectory of the grenade and spawns a trigger right where you stand. You touch it instantly, after which the trigger gets removed again. NOW it has the correct player! :D.
While standing still, it gets the origin of the player very accurately. But there is a 1-frame delay in spawning and touching the trigger, and when running/jumping/falling, the trigger needs to be a certain size to account for this (otherwise it won't trigger and the script won't continue). I tweaked it so it *should* always work (and is small enough so it can't be accidentally triggered by a different player).

2. When the fire trigger is touched, it correctly identifies the burnvictim with "local.burnvictim = parm.other", but forgets all about local.firestarter. So simply trying to pass through local.firestarter to the "onFire" thread doesn't stick, since after "local.burnvictim = parm.other" local.firestarter becomes NIL for some reason.
To tackle this, the script keeps track of all current players and assigns the $player[local.i].idtag = some unique number which is also stored in an array at a specific index location. Simply check the player's idtag with the one in the array and you've found your pyromaniac. :D

Now, i've only been able to test this with 2 players so i'll gladly test it out further with more people.

I was so excited that it worked, that I did something extra, couldn't help it :roll: :roll: In yolo-mode (rcon set incendiary_yolo 1) when you're on fire, press "use" to blow yourself up. This causes massive damage and spawns a new fire. Also, with every incendiary you throw, you taunt "fire in the hole!". :D

Re: HELP me please ...incendiary nades!!

Posted: Fri Aug 30, 2013 11:27 pm
by GR3KO
Thanks again for your help^^

i tryed it ,everything was working well but find n other problem , when a teamates pass in my fire nade ...its give me a -1 point .

is it possible to take an other look plz :D

thanks to you !!

GR3KO

Re: HELP me please ...incendiary nades!!

Posted: Sat Aug 31, 2013 12:28 am
by BatteryAziz
oh that's on purpose, because you're not supposed to kill your teammates! :P I'll turn it off by default and give you the option to turn it on.

Re: HELP me please ...incendiary nades!!

Posted: Sat Aug 31, 2013 3:30 am
by BatteryAziz
updates:
- there are 2 pk3's: choose the pk3 with 2 or 3 seconds grenade lifetime. 3 seconds is normal, 2 seconds more fun and better for close range.
- added cvar incendiary_teamkill: friendly fire addkills -1 for firestarter in team-based mode (0 off, 1 on, default is off)
- added cvar incendiary_teamgod: immune to your own fires and those of teammates. only small healthdrop and no weapdrop. (0 off, 1 on, default is off)
- added "breakglass" sound effect like a molotov, hence the namechange

so now, with default settings, you shouldn't get -1 kills if a teammate steps in your fire.

https://dl.dropboxusercontent.com/u/419 ... lotovs.zip

will you please test:

after you throw the first nade, set in console
incendiary_debug 1
incendiary_teamgod 0 and 1, see if it works for everyone
incendiary_teamkill 0 and 1, see if it works and if the messages are correct

will you please also test:
incendiary_yolo 1 (when on fire press "use")
incendiary_yolo_snd "tick", "allah" and "wtf"

you should be able to quickly switch between these cvars by typing incendiary_ and then hitting [TAB].

let me know! :D



Script is now:

Here's the script:
https://dl.dropboxusercontent.com/u/419 ... meNade.txt