Basic King of the Hill Triggers
by Brian Jansen · 08/12/2005 (5:27 pm) · 13 comments
This is my first post on gg.com and I am a modder in a game called Blockland and I really like King of the Hill so I made some triggers with the help of a few people in the GG.com IRC chatroom. This is not quite finished yet.
Step 1)
Just add this to the bottom of Triggers.cs
Step 2)
Delete the triggers.cs DSO file and start the game then when you go into the F11 mission editor and add a trigger choose either kingofthehilltrigger or newgame trigger and place/scale it accordingly.
Step 3)
Save the mission then go into the .mis file and one of these should be in the file
Step 4)
Now test it and go into the Kingofthehill trigger and wait 30 seconds then leave if you have around 30 points then it was a success.
Step 5) (Optional)
if you want to make the trigger give you a weapon or make a sound when you enter/exit add these to the functions onleavetrigger or onentertrigger
You can preview the sounds here:
On Hill Sound
Off Hill Sound
Final Thoughts
If you have any suggestions that can make this better or more functional please post them also right now there are some bugs. If you find any please let me know.
Anyone can use this freely but I would really like to have credit for this and Blockland people shouldn't have to worry because this was made for Blockland and is already in it.
Coming soon:
Team KOTH
Juggernaut
And many other Game modes
Special Thanks Go To:
Nick Matthews
Luquado
Click Here To Go To Team King Of the Hill
Step 1)
Just add this to the bottom of Triggers.cs
datablock TriggerData(kingofthehillTrigger)
{
tickPeriodMS = 1000;
//set to 1000 so it ticks every second
};
function kingofthehillTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$kingofthehill = %obj.client;
%obj.client.incScore(1);
messageAll('MsgClienthill','\c2 %1 is King of the Hill.',%obj.client.name);
//states that a person entered the hill
$KingsoftheHill++; //adds 1 to the variable that will count
// how many people are in the hill
if (%obj.client.score >= $Game::EndGameScore)
//checks to see if the max score has been reched
cycleGame();
//restarts game if score has been reached
}
function kingofthehillTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
%client = $kingofthehill;
%client.incScore(0);
messageAll('MsgClienthill','\c2 %1 has left the Hill.',%obj.client.name);
$KingsoftheHill--; //Lowers the variable by 1
//states that a person has left the hill
}
function kingofthehillTrigger::onTickTrigger(%this,%trigger,%obj)
{
if ($KingsoftheHill $= 1) { //Makes sure that there is only 1 person on the hill
%client = $kingofthehill;
%client.incScore(1);
//gives the person on the hill one point everytime the trigger ticks if there is
//only 1 person on the hill
}
}
datablock TriggerData(newgameTrigger)
{
tickPeriodMS = 1000;
};
function newgameTrigger::onEnterTrigger(%this,%trigger,%obj)
{
$kingofthehill = %obj.client;
%obj.client.setScore(0);
//resets the score to Start a new game of KOTH
}
function newgameTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
%client = $kingofthehill;
%client.setScore(0);
}
function newgameTrigger::onTickTrigger(%this,%trigger,%obj)
{
}Step 2)
Delete the triggers.cs DSO file and start the game then when you go into the F11 mission editor and add a trigger choose either kingofthehilltrigger or newgame trigger and place/scale it accordingly.
Step 3)
Save the mission then go into the .mis file and one of these should be in the file
new Trigger() {
position = "-33.3425 -182.184 107.193";
rotation = "1 0 0 0";
scale = "16 16 16";
dataBlock = "kingofthehillTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};new Trigger(scoreresetzone) {
position = "-264.293 -108.644 139.782";
rotation = "1 0 0 0";
scale = "55.9523 55.1906 30";
dataBlock = "newgameTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};Step 4)
Now test it and go into the Kingofthehill trigger and wait 30 seconds then leave if you have around 30 points then it was a success.
Step 5) (Optional)
if you want to make the trigger give you a weapon or make a sound when you enter/exit add these to the functions onleavetrigger or onentertrigger
%obj.mountImage(desiredweaponImage, 0); serverPlay3D(sounddatablock,%obj.getTransform());And don't froget to add this:
datablock AudioProfile(Hilloff)
{
filename = "~/data/sound/KOTHoff.wav";
description = "AudioClose3d";
preload = false;
};
datablock AudioProfile(Hillon)
{
filename = "~/data/sound/KOTHon.wav";
description = "AudioClose3d";
preload = false;
};You can get the KOTH sounds by downloading thisYou can preview the sounds here:
On Hill Sound
Off Hill Sound
Final Thoughts
If you have any suggestions that can make this better or more functional please post them also right now there are some bugs. If you find any please let me know.
Anyone can use this freely but I would really like to have credit for this and Blockland people shouldn't have to worry because this was made for Blockland and is already in it.
Coming soon:
Team KOTH
Juggernaut
And many other Game modes
Special Thanks Go To:
Nick Matthews
Luquado
Click Here To Go To Team King Of the Hill
#2
08/13/2005 (11:47 pm)
Works great! Good job.
#3
very well with some modifications.
08/14/2005 (2:46 pm)
I've been looking for an example of battlefield-style control points, this looks like it could workvery well with some modifications.
#4
kingofthehillTrigger::onEnterTrigger:
It'll always replace the current King with the most recent person in. This sort of game usually works in a way that the first one in is king until killed, then its the next person in after them or the person who killed the king... that part varies. Either way, this code isn't going to do that.
You may also need to track the order in which people entered the king-zone, so people can be promoted properly.
kingofthehillTrigger::onExitTrigger:
If they're the king, you need to pick a new king or clear king to null. If they're not the king, you need to take them out of the "line of succession".
I also don't know when onExitTrigger is fired in relation to when someone dies. If it doesn't go off until their corpse fades, you've got another problem (one you could script around without too much trouble in a player's "i just died" script).
Clean this up and I'll happily raise my rating.
08/15/2005 (11:14 am)
It looks like you've got a few bugs:kingofthehillTrigger::onEnterTrigger:
It'll always replace the current King with the most recent person in. This sort of game usually works in a way that the first one in is king until killed, then its the next person in after them or the person who killed the king... that part varies. Either way, this code isn't going to do that.
You may also need to track the order in which people entered the king-zone, so people can be promoted properly.
kingofthehillTrigger::onExitTrigger:
If they're the king, you need to pick a new king or clear king to null. If they're not the king, you need to take them out of the "line of succession".
I also don't know when onExitTrigger is fired in relation to when someone dies. If it doesn't go off until their corpse fades, you've got another problem (one you could script around without too much trouble in a player's "i just died" script).
Clean this up and I'll happily raise my rating.
#5
08/17/2005 (10:05 am)
I have worked on those problems for a while and they will hopefully be fixed soon
#6
08/20/2005 (12:02 pm)
wow this is great
#7
10/12/2005 (9:54 pm)
Nice job BJway! wait... BJway.. from BLOCKLAND?!
#8
10/13/2005 (1:56 pm)
Yeah
#9
11/14/2005 (6:54 am)
You need to make it so when someone enters, the number of people as koth goes up one ($KingsoftheHill++;). Then if they die, ($KingsoftheHill--;). Then on tick, if $KingsoftheHill >= 2 then dont give the point. BUT when someone enters you need to register them in an array. So then you can have loads of people in it, but when they are left with one, it gets the remaining person. But that BJ, is where your coding skills come in. Seeing as im not getting credited ;)
#10
11/14/2005 (3:58 pm)
first of all you just added like 3 lines of code but i can still give you credit and you have to admit i am pretty good at scripting and modding. Hell i am making my own game now. But that code you just gave me is something that someone in the chatrooom told me and it didn't work that well so if you have any more detailed suggestions please be my guest
#11
In theory it should work. Try echoing out what the tick trigger gets from $KingoftheHill and if it isnt 2 when 2 people are on the hill you got a problem with your $KingoftheHill++; bit. But its so short i dont see how there could be a problem. What exactly happens when you try using that code? You need to check if $KingoftheHill is actually increasing too. So echo out that var too.
11/16/2005 (6:54 am)
It depends on how you code it. It should work fine. And yeah you are ok at modding/coding.In theory it should work. Try echoing out what the tick trigger gets from $KingoftheHill and if it isnt 2 when 2 people are on the hill you got a problem with your $KingoftheHill++; bit. But its so short i dont see how there could be a problem. What exactly happens when you try using that code? You need to check if $KingoftheHill is actually increasing too. So echo out that var too.
#12
11/16/2005 (9:37 am)
ok I have it working out and I am going to edit the top
#13
08/09/2008 (5:18 am)
Coolness... 
Torque Owner Martin Schultz