Ive been through the manuals several times and cannot find it anywhere. Say I have a boss that after its defeated, it drops a key that lets you leave the level. Is this possible? I think it has something to do with attributes but...
While were here... is there any way to get smoother shadows on objects? When I put a light underneath a pipe, the individual faces are visible, it looks odd, even for one of my levels. Is there anyway to make the shadow smoother?
Thanks in advanced!
How do you get an NPC to drop an item?
-
- Posts: 73
- Joined: Fri Dec 19, 2008 7:20 pm
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Re: How do you get an NPC to drop an item?
Place an Attribute entity in your level, fill in the TriggerName and activate that trigger from the Pawn's script when he dies (SetEventState). If you need to move the Attribute entity to the exact location of the Pawn you may use SetEntityPosition.realityfactoryusr wrote:Ive been through the manuals several times and cannot find it anywhere. Say I have a boss that after its defeated, it drops a key that lets you leave the level. Is this possible? I think it has something to do with attributes but...
In contrast to actors, level geometry is always flat shaded (i.e. based on the face normal).realityfactoryusr wrote:While were here... is there any way to get smoother shadows on objects? When I put a light underneath a pipe, the individual faces are visible, it looks odd, even for one of my levels. Is there anyway to make the shadow smoother?
-
- Posts: 73
- Joined: Fri Dec 19, 2008 7:20 pm
Re: How do you get an NPC to drop an item?
QuestofDreams:
Thank you for the reply, I KNEW it had something to do with the Attribute entity!
However, I added the attribute entity, named the trigger "dropkey". I used the cratea2.act model for the key model.
In the enemy script -> SetEventState (dropkey, true);
Upon defeat, the crate doesnt show up even with positioning.
Heres the script:
Death[()
{
DelTimerOrder(1);
AddPainOrder("PainToAlert", 0);
FindTargetOrder(0, "FoundTarget", DAMAGEATTRIBUTE);
DelTriggerOrder("IdleToAlert");
SetEventState (dropkey, true); --> Wherever I put this line, the script doesnt read past it. At this point, the NPC collision is still on, its animation keeps going, it doesnt fade out and is not removed.
SetNoCollision();
AnimateStop(DIE, DIEHOLD, "");
FadeOut(DIEFADE, 0);
Remove(true);
When the NPC "dies", the cratea2 model should appear shouldnt it?
Forgive me Im still learning how to understand the scripting and all.
Am I missing a step or something?
Thank you for the reply, I KNEW it had something to do with the Attribute entity!
However, I added the attribute entity, named the trigger "dropkey". I used the cratea2.act model for the key model.
In the enemy script -> SetEventState (dropkey, true);
Upon defeat, the crate doesnt show up even with positioning.
Heres the script:
Death[()
{
DelTimerOrder(1);
AddPainOrder("PainToAlert", 0);
FindTargetOrder(0, "FoundTarget", DAMAGEATTRIBUTE);
DelTriggerOrder("IdleToAlert");
SetEventState (dropkey, true); --> Wherever I put this line, the script doesnt read past it. At this point, the NPC collision is still on, its animation keeps going, it doesnt fade out and is not removed.
SetNoCollision();
AnimateStop(DIE, DIEHOLD, "");
FadeOut(DIEFADE, 0);
Remove(true);
When the NPC "dies", the cratea2 model should appear shouldnt it?
Forgive me Im still learning how to understand the scripting and all.
Am I missing a step or something?
-
- Posts: 73
- Joined: Fri Dec 19, 2008 7:20 pm
Re: How do you get an NPC to drop an item?
While I still have the chance.....
Is there anyway to make a level end AFTER completing a task? Say clearing a room down to the last enemy?
Or even better, after boss is defeated, the level simply ends, bypassing the whole "collect a key" problem.
Making a health bar appear over an enemies head?
Doors that ONLY open when player has the key for them?
Is there anyway to make a level end AFTER completing a task? Say clearing a room down to the last enemy?
Or even better, after boss is defeated, the level simply ends, bypassing the whole "collect a key" problem.
Making a health bar appear over an enemies head?
Doors that ONLY open when player has the key for them?
Re: How do you get an NPC to drop an item?
You need quotes around dropkey and DIE. If the command requires a string value then use quotes:realityfactoryusr wrote:SetEventState (dropkey, true); --> Wherever I put this line, the script doesnt read past it. At this point, the NPC collision is still on, its animation keeps going, it doesnt fade out and is not removed.
Code: Select all
SetEventState ("dropkey", true);
SetNoCollision();
AnimateStop("DIE", DIEHOLD, "");
FadeOut(DIEFADE, 0);
Remove(true);
Create a trigger entity that when activated will change the level. For this example I will call it LevelChangeTrigger. Add that trigger to the TriggerChange field of the ChangeLevel entity.realityfactoryusr wrote:Is there anyway to make a level end AFTER completing a task? Say clearing a room down to the last enemy?
Or even better, after boss is defeated, the level simply ends, bypassing the whole "collect a key" problem.
Then create a player attribute that keeps track of the number of enemies. For this example I'm going to use the attribute EnemyNumber. Set EnemyNumber to 0 in the player.ini.
Code: Select all
[EnemyNumber]
initial = 0
low = 0
high = 99999
Code: Select all
Spawn[()
{
ModifyAttribute("EnemyNumber", 1, "Player");
Code: Select all
Death[()
{
ModifyAttribute("EnemyNumber", -1, "Player");
if (GetAttribute("EnemyNumber","Player") = 0)
{
SetEventState("ChangeLevel", true);
}
I guess you can use the CheckArea() command to see if the enemy is visible on the screen and use a combination of the GetDistanceTo(), GetEntityScreenX(), GetEntityScreenY() commands to determine where to draw the health bar.realityfactoryusr wrote:Making a health bar appear over an enemies head?
You can make a flipbook with 100 images which represent each percentage of health. Then use the DrawFlipBookImage() command to display the flipbook image. Or maybe use the FillScreenArea() command and calculate the correct size of rectangle to draw.
Place a trigger on the door and when you get the key set the trigger to true. If the door's bNoCollide field is false then the door won't open until you collide with it. You won't be able to open the door unless the trigger is true.realityfactoryusr wrote:Doors that ONLY open when player has the key for them?
Note: I never tried any of this but it should work.