Beginner's corner |
Top Previous Next |
Slicing blades They're big, they're bad, they're ... the wicked, slicing blades! They will kill you if they touch you! How is this possible? First of all, you will have to create some blades. Make sure that the origin of the wmp blade is in the center, otherwise they won't look that good while rotating. Here's a picture of a blade in action: You can see that if we get the wmb blade to move like in the picture, we're ready to go! All the interesting stuff is in this action (attach it to one or more blades.wmb): action slicing_blades The blade is sensitive on impact, entity and push. If its event is triggered, function kill_player() will be executed. But what's with this piece of code? while (1)
function kill_player() If the entity that has collided with the blade is the player, a beep is heard (you should replace it with a play_sound instruction) and then the player dies (we set its health to zero). Here are a few more ideas: NPC Talk This piece of code will make a talkative guy out of any model! All you have to do is to approach the model and it will start saying "lines" one by one. The lines are stored in strings; there are 5 strings in my example (npc1_str... npc5_str) but you can add many more, of course. The strings are displayed using a text: text npc_txt Action npc1 will be attached to the model (guard.mdl): action npc1 Clip_size = 0 will show all the triangles for all the models, but decreases the speed a little. The other lines are used to rotate the npc towards the player all the time (you wouldn't like to talk to the npc and see it looking in another direction) ent_cycle("stand",my.skill9); The lines above are used to animate the guard using its stand animation; I've explained how this works several times. my.skill10 = vec_dist(my.x, player.x); When the player comes closer than 200 quants to the player, the npc will say a single line (npc_talks is executed only once) because my.skill11 will be set to 1 immediately after the approach, so my.skill11 = 0
if (my.skill10 < 200) The answer is no. When the player comes closer than 200 quants, npc_talks() would be executed all the time and the npc would "say" all its lines one by one in a few moments. What we want is to make the npc say a line, then wait for us to leave, then say a new line and so on. Function npc_talks() is simple: function npc_talks() We're using 5 strings for this npc; if the player approaches the npc more than 5 times, the npc will repeat its last "line". if (my.skill12 == 1) {npc_txt.string = npc1_str;} npc_txt.visible = on; } Npc_text is showed (visible = on) for 3 seconds. |