Little confused...

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Little confused...

Post by Gamemaker »

I'm kinda confused here... I made an enemy, attached a weapon to it via SetWeapon(); . If enemy dies, there's a RemoveWeapon(); . everything works fine, the weapon appears in right place and removes perfectly, BUT, how can I change it into an attribute after the pawn dies, I want the gun to be pick-upable... :?:
Kinda noobish question I think... I even searched Nirhis scripts, and all about this in forum but I couldnt reach it...:oops:
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

I got it work:
If you are at the distance, then RemoveWeapon(); and ModifyAttribute. Works fine for me, but it still would be better if gun isn't still at enemy's hands when he dies :D. I mean, it should fly away a little. :P
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

I didn't want to make another topic, but now I have other bad thing... I don't know if it's a bug, but I don't get it.
Here's the link, I made a video of it: http://www.youtube.com/watch?v=HY4Ur5EEpyk

And the script is here:

Code: Select all

{

WALK		[walk_s]
WATCH		[watch_s]
WRITE		[write_s]
IDLE		[idle_s]
HEALTHATTRIBUTE	[enemy_health]
HEALTH		[30]
TC			[0]
WEAPON		[pistol]


Spawn[()
{
Console(true);
SetFOV(240);
HostilePlayer(true);
HostileSame(false);
HostileDifferent(false);
SetGroup("Enemy");
AttributeOrder(HEALTHATTRIBUTE, HEALTH, "GoShootBlood");
SetWeapon(WEAPON);
NewOrder("LostTarget");
}]


LostTarget[()
{
FindTargetOrder(1500, "EnemySpotted", "health");
AddCollisionOrder("EnemySpotted");
PlayAnimation(WATCH, true, "");
RestartOrder();
}]



	Alert[()
	{
	AnimateStop(WATCH, 0, "");
	LowLevel("Attack");
	}]




	EnemySpotted[()
	{
	RotateToPlayer(IDLE, 120, false, "");
	LowLevel("Attack");
	}]



Attack[()
{
self.ThinkTime = 0;
self.yaw_speed = 100;
UpdateTarget();
UpdateEnemyVis();

if(self.enemy_vis=true)
{
	self.ideal_yaw=self.enemy_yaw;
	ChangeYaw();
	if(self.enemy_range>500)
	{
	SetHoldAtEnd(true);
	Animate("walk_s");
	self.think ="Walk";
	return 0;
	}
	else
	{
	TC=self.time;
	Animate("watch_s");
	self.think ="Stand";
	return 0;
	}
}
}]



Walk[()
{
self.ThinkTime=0.05;
if(self.health=0)
{
HighLevel("GoShootBlood");
return 0;
}
if(self.enemy_vis=true)
{
self.ideal_yaw=self.enemy_yaw;
ChangeYaw();
}

else

{
SetHoldAtEnd(false);
HighLevel("LostTarget");
return 0;
}

if(self.animate_at_end=false)
{
	

if(walkmove(self.ideal_yaw,90)=false)
{
if(random(1,10)>5)
{
ForceLeft(30);
}
else
{
ForceRight(30);
}
}
}
else
{
SetHoldAtEnd(false);
FireProjectile("pistol_shell","joint10",0,0,0,"health");
self.think="Attack";
return 0;
}
}]




Stand[()
{
self.ThinkTime=0.05;
if(self.health=0)
{
HighLevel("Death");
return 0;
}
if(self.enemy_vis=true)
{
self.ideal_yaw=self.enemy_yaw;
ChangeYaw();
}
else
{
HighLevel("LostTarget");
return 0;
}
if(self.time>TC+1)
{
FireProjectile("pistol_shell","joint10",0,0,0,"health");
self.think="Attack";
return 0;
}
}]

GoShootBlood[()
{
	LowLevel("ShootBlood");
}]

ShootBlood[()
{
SetTargetPoint(0, -100, 0);
FireProjectile("blood1", "joint10", 0, 0, 0, "");
HighLevel("Death");
}]

Death[()
{
	
DelCollisionOrder();
	switch(random(0,4))
{
	case 1
	{
	AnimateStop("die_s_1", 0, "");
	}
	case 2
	{
	AnimateStop("die_s_2", 0, "");
	}
	case 3
	{
	AnimateStop("die_s_3", 0, "");
	}
	case 4
	{
	AnimateStop("die_s_4", 0, "");
	}
}
NewOrder("Now");

}]


Now[()
{
AddCollisionOrder("GetWeapon");
}]


GetWeapon[()
{
ModifyAttribute("scattergun", 1, "player");
RemoveWeapon();
NewOrder("Cleanhim");
}]

Cleanhim[()
{
SetNoCollision();
RestartOrder();
}]



}


Thank you :)
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Little confused...

Post by darksmaster923 »

For the last order in your death, don't use restartorder()
Herp derp.
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

darksmaster923 wrote:For the last order in your death, don't use restartorder()
Sorry, but they're still acting the same way :S,
but thanks.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Little confused...

Post by darksmaster923 »

I don't actually think you need the cleanhim order, you can just add the Nocollision command to the end of the Getweapon order. You can try removing the Now order, and using self.player_range variable instead.
Herp derp.
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

You can try removing the Now order, and using self.player_range variable instead.
Thanks, but the problem is still there... :?
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Little confused...

Post by darksmaster923 »

Well, since the death animation is playing again, something is calling the order again. When he dies, pick up the weapon from the dead pawn, then drop that weapon. Then, if the death animation plays again, and you get another weapon, you know that it is an issue with the pickup order. Tbh, the easiest way to do this is delete the pawn after picking up the weapon.
Herp derp.
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

I'd like to play the game, if I see dead bodies too ...
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Little confused...

Post by darksmaster923 »

Try this

Code: Select all

    Death[()
    {
       
    DelCollisionOrder();
       switch(random(0,4))
    {
       case 1
       {
       AnimateStop("die_s_1", 0, "");
       }
       case 2
       {
       AnimateStop("die_s_2", 0, "");
       }
       case 3
       {
       AnimateStop("die_s_3", 0, "");
       }
       case 4
       {
       AnimateStop("die_s_4", 0, "");
       }
    }
    LowLevel("items");
    }]

	items[ ()
	{
		if(GetDistanceTo("Player")<50)
		{
			ModifyAttribute("scattergun", 1, "player");
			HighLevel("delete");
		}
	} ]
	delete[ ()
	{
		RemoveWeapon();
	} ]
Herp derp.
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

uhh, thanks ;) , but I got it work yesterday night :D.
I wrote a script all by myself from start to end. I got the same problem, but the script was different. I discovered that those men only woke up again after death, when I attacked them, while they were HighLevel, when they hadn't seen me yet, when I wasn't in the FOV. So I added "FindTargetOrder(0, "Idle", "");" into Die order.

So, here's the working script:

Code: Select all

{




Spawn[()
{
Console(true);
AttributeOrder("enemy_health", 30, "Die");
AddCollisionOrder("Foundtarget");
SetFOV(220);
HostileSame(false);
HostileDifferent(false);
HostilePlayer(true);
NewOrder("Idle");
}]



Idle[()
{
FindTargetOrder(600, "Foundtarget", "health");
PlayAnimation("idle_s", true, "");
RestartOrder();
}]



Foundtarget[()
{
SetWeapon("pistol");
RotateToPlayer("stand_alert", 300, false, "");
Delay("stand_shoot_s", 0.7, "");
LowLevel("Come");
}]





Come[()
{

		if(self.enemy_vis = true)
		{
			if(self.player_range < 600)
			{
			UpdateEnemyVis();
			UpdateTarget();
			FireProjectile("pistol_shell", "joint20", 0, 0, 0, "health");
			HighLevel("Foundtarget");
			}
			else
			{
			self.ideal_yaw = self.enemy_yaw;
			if(self.animate_at_end)
			{
			Animate("walk_s");
			}
			walkmove(ideal_yaw, 150);
				if(self.player_range > 1600)
				{
				HighLevel("Idle");
				}
			}
		}
		

		else
		{
		HighLevel("Idle");
		}
		


		if(self.health = 0)
		{
		HighLevel("Die");
		return 0;
		}	



}]


Die[()
{
SetNoCollision();
FindTargetOrder(0, "Idle", "");
LowLevel("Blood");
}]


Blood[()
{
SetTargetPoint(0, -90, 0);
	switch(random(1,4))
	{
		case 1
		{
		FireProjectile("blood1", "joint10", 0, 0, 0, "");
		}
		case 2
		{
		FireProjectile("blood2", "joint10", 0, 0, 0, "");
		}
		case 3
		{
		FireProjectile("blood3", "joint10", 0, 0, 0, "");
		}
		case 4
		{
		FireProjectile("blood4", "joint10", 0, 0, 0, "");
		}
	}



	switch(random(1,4))
{
	case 1
	{
	PlaySound("scientist/die1.wav");
	}
	case 2
	{
	PlaySound("scientist/die2.wav");
	}
	case 3
	{
	PlaySound("scientist/die3.wav");
	}
	case 4
	{
	PlaySound("scientist/die4.wav");
	}

}

HighLevel("Animation");

}]





Animation[()
{
	switch(random(1,4))
	{
		case 1
		{
		AnimateStop("die_s_1", 0, "");
		}
		case 2
		{
		AnimateStop("die_s_2", 0, "");
		}
		case 3
		{
		AnimateStop("die_s_3", 0, "");
		}
		case 4
		{
		AnimateStop("die_s_4", 0, "");
		}
	}

RemoveWeapon();
SetWeapon("pistol");
LowLevel("Weapon");
}]


Weapon[()
{
	if(self.player_range < 60)
	{
	ModifyAttribute("c8", 1, "player");
	PlaySound("takethegun.wav");
	HighLevel("Finish");
	}
}]


Finish[()
{
RemoveWeapon(true);
}]


}

I'm still working on rotating to player, when walkmove = true .


Sorry, I couldn't come online before and say that I've done this :)
BTW, I love your game :P , but a bit laggy :)
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Re: Little confused...

Post by darksmaster923 »

lol thanks
Herp derp.
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Little confused...

Post by Gamemaker »

darksmaster923 wrote:lol thanks
No problem :D
Post Reply