This tutorial uses a button to add mobs to the area. It spawns 4 monkeytoks at the character position. We had 300 mobs spawned in a minute to test features. You can easily change the spawn rate.
From the basic window tutorialMake basic window
here. This is a base window and will be used in many of my Tutorials. It uses the GUI pics from textures that all engines have. This can be skipped if you have the basic window already from another tutorial.
Make basic button
here. This will also be used in many of my tutorials.
_______________________________________________________________
In the DOM, create a new (client side) classname = TMP_Mobs
archtype = guicontrol
add a parent to the class, TMP_Window
click open scriptIn new (client side) script TMP_Mobs// create mob window
shared function Start()
var win = getMobsClass()
if win <> None
DestroyNode( win )
.
win = CreateNodeFromPrototype("TMP_Mobs")
win.build = true
MiscUtils:centerWindow(win)
.
// which button chosen
method onMouseClick(args references Class GUIMouseEvent)
target as NodeRef of Class GUIControl = args.source
when target.name
is "mobButton"
// call server E_NPCClassMethods:CreateMobs() // after server script is made, uncomment this line
.
.
.
//=================================================================================================
function getMobsClass() as NodeRef of Class TMP_Mobs
return FindGUIControlByName(None, "game.TMP_Mobs")
.
_______________________________________________________________
In new (XML) script TMP_Mobs<createControlType inheritFrom='TMP_Window' class='TMP_Mobs' type='TMP_Mobs' description='' treePath='' name="TMP_Mobs">
<size x="150" y="50"/>
<set name="TMP_Mobs.BGpanel">
<size x="142" y="42"/>
</set>
<_label name="title" text="Monkeytoks" dropShadowAlpha="1" justification="CENTER">
<defaultStatePresentation>
<color r="1" g="0" b="0"/>
</defaultStatePresentation>
<autoCenter horizontal="true"/>
</_label>
<tmp_button name="mobButton">
<position x="45" y="25"/>
<size x="60"/>
<autoCenter horizontal="true"/>
<set name='TMP_Mobs.mobButton.text' attribute='text' value="Make 4"/>
</tmp_button>
</createControlType>
_______________________________________________________________
In (server side) E_NPCClassMethods add:// player called - make mobs
untrusted function CreateMobs()
acct as NodeRef of Class E_playerAccount = SYSTEM.REMOTE.client
char as NodeRef of Class E_playerCharacter = acct.GetMyChar()
$CHAT.ChatWorld( "game", char.name+" is making Mobs" )
loop i from 1 to 4
var npc = $NPC._CreateSimpleHECharacter( "monkeytok", false )
npc._UpdatePosition(char.GetPosition())
.
.
_______________________________________________________________
In (client side) script E_PlayerAccountClassMethods under the chatwindow TMP_MobsClassMethods:Start()
Created using info from $NPC in the wiki (link wont function properly with $ in it)