- Quick Links - |
Visitor No.72282 |
- Random Picture - | ||||||
|
Giving Effects On Projectiles. (Stunning, blinding...)
This tutorial will explain how to assign effects to be caused by projectiles. As an example I'll make bryarbolt shots to stun other actors. Put original weap_bryar.cog and static.jkl in appropriate folders.
In here, we'll change the projectile template to the one we are going to create. Open weap_bryar.cog with a text editor. Change this, template projectile=+bryarbolt local to template projectile=+stunshot local all for the weapon cog.
Next, use CogWriter or with your own, create a cog named stunshot.cog(Cog Writer will give you all the fundamental lines automatically) Open it with a text editor or with CogWriter, add this, this cog will stun actors for a moment. touched: victim = GetSourceRef(); //The actor who got touched is the victim. SetActorFlags(victim, 0x40000); // Stun the victim KillTimerEx(victim); //If any previous timer is alive, kill it. SetTimerEx(5, victim, GetThingSignature(victim), 0); //Set the timer to release the victim from stunning. return; # ........................................................................................ timer: if(GetParam(0) == GetThingSignature(GetSenderId())) //Fail safe for timer. (Explained below) ClearActorFlags(GetSenderId(), 0x40000); //This will clear the stunning flag return; Don't forget to add all the symbols as well. Victim can be an int in the symbols section. This cog is done. Save and exit.
SetTimerEx(5, victim, GetThingSignature(victim), 0); This part in the timer message is a fail safe for the timer to act on certain characters. Which means that if I only put "SetTimer(5)" and "ClearActorFlags(victim, 0x40000)" in the timer message, when you hit another actor with the weapon to change the "victim" value to a new ID, the first stunned actor will never gets released. To stop that and have each characters its own timer, it needs different ID passed. if(GetParam(0) == GetThingSignature(GetSenderId())) And for the GetThingSignature part, that's another less likely to happen fail safe. The reason to get a unique number throughout the level for that character is that ID "victim" might be assigned on another created thing after the victim dies, before the timer arrives, thus a totally unique number for the victim is needed for a complete debug.
Now we are going to create the new template for the stun shot, and based on bryar bolt template, so what I did was basically paste every parents for the bryarbolt and itself, plus an extra line called "+stunshot" with a few parameters. Open the static.jkl with a text editor. Add this at the bottom of the file. ########################### Section: TEMPLATES World templates 10 #Name: Based On: Params: _weapon none orient=(0/0/0) type=weapon collide=1 move=physics thingflags=0x200 timer=10 mass=5 physflags=0x200 maxrotvel=90 damageclass=0x2 typeflags=0x1 _explosion none orient=(0/0/0) type=explosion typeflags=0x1 damageclass=0x4 +laserhit _explosion thingflags=0x1 light=0.2 timer=0.5 sprite=bryx.spr soundclass=exp_laserhit.snd typeflags=0x33 blasttime=0.3 maxlight=0.4 +smflash _explosion thingflags=0x1 light=0.4 timer=0.1 typeflags=0x0 +laserfleshhit +laserhit soundclass=exp_fleshy.snd +bryarbolt _weapon thingflags=0x201 light=0.4 model3d=bry0.3do size=0.001 movesize=0.001soundclass=bry.snd creatething=+smflash maxrotvel=0 vel=(0/4/0) explode=+laserhit fleshhit=+laserfleshhit damage=30 mindamage=10 typeflags=0x20440d rate=15 +stunshot +bryarbolt thingflags=0x20000401 cog=stunshot.cog
This is the end of editing. Now your bryar bolt will fire the same projectile but only to stun actors when it hits them. With using other flags and such you can make them blind, destroy weapon and anything. Launch Jedi Knight and choose bryar pistol, shoot and see enemies stay in its place for a while.(Though they still shoot at you)
|
This site is developed using PHP under Apache server Certain parts of this site require Cookie support. This site is best viewed with
Internet Explorer 5.5, Netscape 6.0, Opera 6.0 or Mozilla 1.0 and above |