Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-28-2017, 11:01 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,731
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Control NPC for spawning custom baddies?

This is likely years away from what I'm capable of. I'm creating a custom baddy but I'd like to have new baddies spawn on a timer. Is there a way to create new enemies with their own behaviour without having to manually place every NPC? From my limited experience with GS1 I think it would have something to do with putnpc2, but I'm working in Gonstruct so I can't be certain.

On a sidenote, if anyone can help me get the offline editor to work that'd be appreciated.
__________________
Save Classic!
Reply With Quote
  #2  
Old 07-29-2017, 04:00 AM
Kamaeru Kamaeru is offline
Sandinista!
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
You can basically add a class that you join via your baddy that contains a function which runs a timer each time the baddy dies. Or just add the timer in the script, but if you do what I'm saying you can add other functions for like making the baddy drop gralats or items when it dies.

This is the old function they used on Graal2001:

NPC Code:
function domonsterdeath() {
setTimer(45);
if (strlen(#a)>0) {
player.clientr.monsterskilled++;
if (strlen(#p(0))>0) {
setstring clientr.mkills#p(0),#v(strtofloat(#s(clientr.mkill s#p(0)))+1);
setstring clientr.kills#p(0),#v(strtofloat(#s(clientr.kills# p(0)))+1);
}
}



So however your baddy death is handled, lets just assume it's really basic and you play the death animation and then do:

NPC Code:

hide();
doMonsterDeath();



and then the timeout part of your code would make it initialize again, so if your initialization is on creation of the NPC then just put onCreated(); in the onTimeout function

sorry for mixing up gs1 and gs2
__________________
3DS friendcode: 1118-0226-7975

Last edited by Kamaeru; 07-29-2017 at 04:16 AM..
Reply With Quote
  #3  
Old 07-31-2017, 12:21 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
Originally Posted by Kamaeru View Post
You can basically add a class that you join via your baddy that contains a function which runs a timer each time the baddy dies. Or just add the timer in the script, but if you do what I'm saying you can add other functions for like making the baddy drop gralats or items when it dies.

This is the old function they used on Graal2001:

NPC Code:
function domonsterdeath() {
setTimer(45);
if (strlen(#a)>0) {
player.clientr.monsterskilled++;
if (strlen(#p(0))>0) {
setstring clientr.mkills#p(0),#v(strtofloat(#s(clientr.mkill s#p(0)))+1);
setstring clientr.kills#p(0),#v(strtofloat(#s(clientr.kills# p(0)))+1);
}
}
} // you was missing a bracket might be intentional if you posting a code snibblet



So however your baddy death is handled, lets just assume it's really basic and you play the death animation and then do:

NPC Code:

hide();
doMonsterDeath();



and then the timeout part of your code would make it initialize again, so if your initialization is on creation of the NPC then just put onCreated(); in the onTimeout function

sorry for mixing up gs1 and gs2
NPC Code:

function domonsterdeath() {
setTimer(45);

if (player.account != NULL) { //Not sure how your class knows the player account (I just converted your code to GS2)
player.clientr.monsterskilled++;

if (params[0] > 0) {
clientr.("mkills"@params[0])++;
clientr.("kills"@params[0])++;
}
}
}



although I kinda think its weird you have 2 flags that do the same exact thing.

Regarding a NPC DataBase Spawner you could do.

NPC Code:
    
temp.entities = {"npc_class1", "npc_class2"};
temp.random_entity_index = int(random(0, temp.entities.size()));
temp.entity_id = this.entities[temp.random_entity_index];
temp.obj = putNPC2(0, 0, "join( \"" @ temp.entity_id @ "\");");
temp.obj.generated = true; //Tell the class its Generated
temp.obj.warpto(temp.lvl, temp.x, temp.y); //Warp the NPC where you want



you could easily check the map when they spawn to make sure you maintain a max amount that are spawned on your map. It could get ugly if you don't you will end up with thousands of NPCs.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.