RE: Combat System !? - stonecutter - 04-02-2012
Can you explain what this line will do ?
Quote: gun_target = (state == 1) ? entity : "";
Its the only line i dont understand how it works or what it will do !
RE: Combat System !? - Your Computer - 04-02-2012
(04-02-2012, 10:45 PM)stonecutter Wrote: Can you explain what this line will do ?
Quote: gun_target = (state == 1) ? entity : "";
Its the only line i dont understand how it works or what it will do !
?: is known as a ternary operator. It's practically an inline if-else statement.
The same can be re-written as
PHP Code: if (state == 1) gun_target = entity; else gun_target = "";
RE: Combat System !? - Cranky Old Man - 04-02-2012
Ruining the whole idea behind Amnesia aside, there's like one hundred FPS games on the market, and many of them are made through the excellent and free Unreal Development Kit. How come you settled on the HPL engine of all engines?
RE: Combat System !? - Statyk - 04-02-2012
(04-02-2012, 11:31 PM)Cranky Old Man Wrote: Ruining the whole idea behind Amnesia aside, there's like one hundred FPS games on the market, and many of them are made through the excellent and free Unreal Development Kit. How come you settled on the HPL engine of all engines? Sometimes it's fun to press the limitations of an engine. =]
RE: Combat System !? - Adny - 04-03-2012
Replace lantern model with a pistol/rifle with a flashlight on it = profit. Of course it would be very time consuming to make (judging by your model and texture creation skills) but it has potential.
RE: Combat System !? - stonecutter - 04-03-2012
Would be nice if someone can create a simple model of a hand holding a gun with integrated flashlight , cause i am just have the modelskills for that . Using both hands like this would be nice
Will try to integrate a hit-counter and a ammunition-counter today!
Is it possible to get the name of the entity that your a looking at or that causes the collide function ?
Anyone got an idea ? If not , i have to write the hitcounter and soundplays for every enemy in the map
RE: Combat System !? - stonecutter - 04-03-2012
Code: string gun_target = "";
void OnStart()
{
//Player
SetSanityDrainDisabled(true);
//Shooting Script
AddLocalVarInt("AmmoCounter", 15); // Amount of munition
GiveItemFromFile("lantern", "lantern.ent");
for (int i = 1; GetEntityExists("gun_target_"+i); ++i){
SetEntityPlayerLookAtCallback("gun_target_"+i, "SetGunTarget", false);
AddLocalVarInt("HitCounter_"+i+"", 0);
}
SetLanternLitCallback("FireGun");
}
void SetGunTarget(string &in entity, int state)
{
gun_target = (state == 1) ? entity : "";
}
void FireGun(bool lit)
{
if(GetLocalVarInt("AmmoCounter")>0){
if (gun_target != "")
{
//SetPropActiveAndFade(gun_target, false, 1);
PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false);
gun_target = "";
SetMessage("Messages", "Hit", 1);
SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1);
}
else
SetMessage("Messages", "Miss", 1);
PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false);
SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1);
}
else
SetMessage("Messages", "Empty", 1);
PlaySoundAtEntity("","empty.snt", "Player", 0, false);
if (!GetLanternActive())
{
SetLanternLitCallback("");
SetLanternActive(true, true);
SetLanternLitCallback("FireGun");
}
}
Now with munitioncounter !
RE: Combat System !? - stonecutter - 04-03-2012
[video=youtube]http://youtu.be/xuP9agineQY[/video]
Now with Munition Counter and Hitcounter ( 4 hits to fade the enemy )
"Daneben" means "miss" in german language. "Treffer" means "hit" !
Edit 1: It works with more than one enemy !!!!
finally the current script :
PHP Code: string gun_target = "";
void OnStart() { //Player & Items SetSanityDrainDisabled(true); GiveItemFromFile("lantern", "lantern.ent"); //SetLanternActive(true, true);
//Variables AddLocalVarInt("AmmoCounter", 50); // Amount of munition AddLocalVarInt("MonsterSelection", 0); // With this variable you select the monster you want to give damage AddLocalVarInt("MonsterHitCounter_1", 0);//Hitcounter for monster A. One for each monster
//LookAtCallbacks ..... One Callback for each enemy ! SetEntityPlayerLookAtCallback("gun_target_1", "SetGunTarget_1", false); SetEntityPlayerLookAtCallback("gun_target_2", "SetGunTarget_2", false); SetLanternLitCallback("FireGun"); }
void SetGunTarget_1(string &in entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 1); } void SetGunTarget_2(string &in entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 2); } //Shooting Script void FireGun(bool lit) { if(GetLocalVarInt("AmmoCounter")>0){ if (gun_target != "") { //SetPropActiveAndFade(gun_target, false, 1); PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false); gun_target = ""; SetMessage("Messages", "Hit", 1); SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1); switch( GetLocalVarInt("MonsterSelection") ) { case 1: SetLocalVarInt("MonsterHitCounter_1", GetLocalVarInt("MonsterHitCounter_1")+1); break; case 2: SetLocalVarInt("MonsterHitCounter_2", GetLocalVarInt("MonsterHitCounter_2")+1); break; } for (int i = 1; GetEntityExists("gun_target_"+i); ++i){ if(GetLocalVarInt("MonsterHitCounter_"+i)==4){ FadeEnemyToSmoke("gun_target_"+i, false); } } } else SetMessage("Messages", "Miss", 1); PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false); SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1); } else SetMessage("Messages", "Empty", 1); PlaySoundAtEntity("","empty.snt", "Player", 0, false);
if (!GetLanternActive()) { SetLanternLitCallback(""); SetLanternActive(true, true); SetLanternLitCallback("FireGun"); }
}
RE: Combat System !? - stonecutter - 04-03-2012
New Update
Able to pick up bullets to increase the amount of ammo you have and they will be removed after you shoot 15 bullets !
[video=youtube]http://youtu.be/oaZOkMXX-XU[/video]
PHP Code: string gun_target = "";
void OnStart() { //Player & Items SetSanityDrainDisabled(true); GiveItemFromFile("lantern", "lantern.ent"); //SetLanternActive(true, true);
//Variables AddLocalVarInt("AmmoCounter", 0); // Amount of munition AddLocalVarInt("BulletCounter", 0); // Counts the shooted bullets AddLocalVarInt("MonsterSelection", 0); // With this variable you select the monster you want to give damage AddLocalVarInt("MonsterHitCounter_1", 0);//Hitcounter for monster A. One for each monster
//LookAtCallbacks ..... One Callback for each enemy ! SetEntityPlayerLookAtCallback("gun_target_1", "SetGunTarget_1", false); SetEntityPlayerLookAtCallback("gun_target_2", "SetGunTarget_2", false); SetLanternLitCallback("FireGun"); }
void SetGunTarget_1(string &in entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 1); } void SetGunTarget_2(string &in entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 2); } //Shooting Script void FireGun(bool lit) { if(GetLocalVarInt("AmmoCounter")>0){ if (gun_target != "") { //SetPropActiveAndFade(gun_target, false, 1); PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false); gun_target = ""; SetMessage("Messages", "Hit", 1); SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1); SetLocalVarInt("BulletCounter", GetLocalVarInt("BulletCounter")+1); switch( GetLocalVarInt("MonsterSelection") ) { case 1: SetLocalVarInt("MonsterHitCounter_1", GetLocalVarInt("MonsterHitCounter_1")+1); break; case 2: SetLocalVarInt("MonsterHitCounter_2", GetLocalVarInt("MonsterHitCounter_2")+1); break; } for (int i = 1; i<=2; ++i){ if(GetLocalVarInt("MonsterHitCounter_"+i)==4){ FadeEnemyToSmoke("gun_target_"+i, false); } } if(GetLocalVarInt("BulletCounter")==15) // Remove bullets { SetLocalVarInt("BulletCounter",0); RemoveItem("ammo_box"); } } else SetMessage("Messages", "Miss", 1); PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false); SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1); SetLocalVarInt("BulletCounter", GetLocalVarInt("BulletCounter")+1); if(GetLocalVarInt("BulletCounter")==15) // Remove bullets { SetLocalVarInt("BulletCounter",0); RemoveItem("ammo_box"); } } else SetMessage("Messages", "Empty", 1); PlaySoundAtEntity("","empty.snt", "Player", 0, false);
if (!GetLanternActive()) { SetLanternLitCallback(""); SetLanternActive(true, true); SetLanternLitCallback("FireGun"); }
}
//PickUpAmmo
void AmmoPickUp(string &in asEntity) { SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")+15); GiveItem("ammo_box","","ammo_box","ammo_box_cover.jpg",1); }
RE: Working combat system ! - Datguy5 - 04-03-2012
Oh..My..God..I cant believe you actually created a gun in amnesia.NICE JOB.
|