Page 1 of 1

some questions [RPG mode]

Posted: October 31st, 2011, 2:55 pm
by SUPERPORCO
Hello!

i'm new to sandobox.Started this week. I've been messing around with tuturials and wiki guide to cubescripting.

So far i did the following:

Spawned 2 NPC
Both NPC chat with me
NPC 1 will only say "you need help?" after i talked to NPC 2. if i dont talk to NPC 2 he will only tell me : "go talk to NPC2"

The player can also teleport to a diferent map by speaking with an NPC, and i discovered how to make NPC disapear after they talk to me. its nice


If anyone needs a tuturial on this i'll gladly help.

Now, some questions:

Can i make all NPC run away from me?
example: if $var1 != "test" they all run away.

How can i make them attack me? it keepssaying punch|shoot animation is not loaded

How can i put a 3rd person view in my player? i can only see me as a "first person shooter"

The italic question is the most relevant now. i can't find that answer in wiki or forum.

Thanks in advance

Re: some questions [RPG mode]

Posted: November 6th, 2011, 1:56 pm
by java.x.beast
To make them attack you, you can check out Hirato's RPG tutorial in the wiki. From the homepage, click on the 'RPG' link, then click on Tutorial. If you stick with it, by the time you finish, you'll be a guru and all your questions will have been answered.

As for making the view 3rd person, you have to run the engine, then put type this code in.

Code: Select all

/thirdperson 1
After that, the view will be third person.

Your first question, which happens to be the most important, is the one that I am unable to help you with. I'm sorry for this, but I don't think there is currently a way to make them run away from you. At the moment, there is only a way to make them run after you, in the instance that they are trying to attack you (more info on how they chase you is in Hirato's RPG tutorial.

Hope this helped answer most of your questions.

-Java

Re: some questions [RPG mode]

Posted: November 6th, 2011, 8:45 pm
by Hirato
whoa, I completely missed this one on my RSS feed...
Can i make all NPC run away from me?
example: if $var1 != "test" they all run away.
No. very little has been implemented in terms of AI, a flee directive as well as "fear" are things that haven't been implemented yet.
How can i make them attack me? it keepssaying punch|shoot animation is not loaded
the animation thing is irrelevant to your query (and I should probably fix them)
As for making them attack you, you need to give them an attack directive, Part 4 or 5 or so of the RPG tutorial on the wiki should explain this adequately
http://www.sandboxgamemaker.com/wiki/in ... ial#Part_5

Re: some questions [RPG mode]

Posted: November 7th, 2011, 5:20 am
by SUPERPORCO
Hey,

Thank you for your answers.
Tell me one more thing about the flee/"fear"/run away thing. I know there is a r_script_sight() function, by logic i understand that when in the vision radius of some entity they will do whathever i say them to do.
Using this r_script_sight() can i script the entity to move to coordenates (X,Y,Z)?

Example:

r_script_sight [
i=0
if (!= (r_get_faction self) (r_get_faction actor)) [ move to (10+$i,20+$i,30+$i)]
$i+1
]

Could this work? not like this of course. But can i use the coordenates and soem action to "move to"?

Re: some questions [RPG mode]

Posted: November 7th, 2011, 12:19 pm
by java.x.beast
The flee and fear directives have not yet been implemented into PAS's AI. As for the 'r_script_sight' command, I never knew it existed. Hirato will probably answer that for you. I'm not sure about the 'move to' action, but maybe you could use waypoints to set it up? This works the same way as the 'attack' directive, I think. They would follow the waypoints from one place to another. This probably isn't right, so Hirato will be available to answer your questions. Hope this helped!

-Java

Re: some questions [RPG mode]

Posted: November 7th, 2011, 7:40 pm
by Hirato
r_script_sight is an obsolete and removed script slot that was executed when the saw an entity in his update cycle.
We now require the creator to do r_cansee checks in the update cycle since moving to the new script/reference system

Re: some questions [RPG mode]

Posted: November 8th, 2011, 6:56 am
by SUPERPORCO
Ok, first things first ;)

I made some waypoints using de commands:

Debug 32
Dropwaypoints 1
savewaypoints test1.wpt (which goes into my_stuff folder)

My question is, how do i make my NPC use that saved waypoints. I tried "use","include" and "exec" commands onthe scripts folder but it does not work, and can't find this info anywhere.

Thank you very much for your help

Re: some questions [RPG mode]

Posted: November 8th, 2011, 9:27 pm
by Hirato
if the waypoints file has the same name as the map (which it will if you don't provide an explicit name), the waypoints will automatically be laoded when the map is.
to use them, a creature somewhere simply needs to travel somewhere and they will follow the waypoints to get there.

so basically, make your AI do something if you want them to use the waypoints

Re: some questions [RPG mode]

Posted: November 9th, 2011, 9:05 am
by SUPERPORCO
Hum..ok i understand. But can't i just make the creature use the saved waypoints? I mean, include the waypoints in the creature script .cfg

I want to make something like:

i = 0
Creature spots player [//with r_cansee
creature uses test%1.wpt //waypoint to escape somewhere
if($i = 20)[ //checks if reached last waypoint created (if i had created 20 waypoints)
i=0 // makes the creature return to waypoint test0.wpt
]
i= $i+1 //increments i
]

The code is not correct of course. Let me try to explain the idea:

If the creature sees the player, it runs till the end of waypoint test0
If the player goes near again, and it sees him, it runs till the end of waypoint test1
and so on...until it reaches waypoint test20. This test20.wpt ends where the test0.wpt beggins

So...this would make a sort of AI where the creature runs away from you "randomly" using the waypoints i created. It would only stop running once i reached X level or got X exp. Something like that.

I hope i explain it well. ;)

Re: some questions [RPG mode]

Posted: November 9th, 2011, 9:30 am
by Hirato
the waypoints are a map thing.

The AI is currently very basic, but what you want to do can be accomplished in tandem with the location entity.
Of the implemented directives, Wander and move require a location entity.
The RPG tutorial uses an example where several wolves are wandering around a location entity, so have a look at that