PDA

View Full Version : Triggers don't work properly



Emilka
10th September 2016, 22:34
Hi all

I have got such a annoying bugs in my custom map with triggers: damage and use_touch

With triggers damage when I set them value like Melle_NO they still react on bash. Also when I have everything unselected, triggers won't work for any action (like shoot and bash) expect explosive. When I throw a granade into it, it suddenly works, but after that If I want to try bash or shoot again it still doesn't response.

With triggers use_touch problem is that they are able to work after few time. There is no icon to press F and no hintstring. Only after some time when I move around trigger, it starts work. Time is differenece sometimes I have to wait 10 sec or 60.

The majoriity of my triggers work properly but there are about 4 triggers that are bugged which I mentioned. I have around 50 triggers of all type (maybe amount is the problem).

IzNoGoD
11th September 2016, 01:16
What coordinates are these triggers on exactly? (xyz)

Emilka
11th September 2016, 09:57
Trigger use_touch: (-2574, -494, 60) and second (-2574 -494 60).
Triggers damage: (-1887, 861, 46)

I used origin to check the coordinates

kung foo man
11th September 2016, 20:57
I always disliked the Radiant triggers, so I created my own triggers, which I could also place in custom maps.

Random dump of the script files used to create custom triggers with example code just re-discovered via Everything.exe:

UTILS.gsc



spawnXmodel(name, position, dir)
{
model = spawn("script_model", position);
model.angles = (0, dir, 0);
model setModel(name);

return model;
}

entityToGround()
{
entity = self;

trace = bullettrace(entity.origin, entity.origin-(0,0,10000), false, undefined);
if (trace["fraction"] < 1)
entity.origin = trace["position"];
}


RANDOMBOX.gsc


#include maps\BTM\UTILS;
#include maps\BTM\TRIGGER;

precache()
{
// init()
game["hintstring_randombox_allies"] = &"^6Press {USE} to buy something!";
game["hintstring_randombox_axis"] = &"^6You cant buy something!";
// precache()
precacheModel("xmodel/furniture_bathtub");
precacheString(game["hintstring_randombox_allies"]);
precacheString(game["hintstring_randombox_axis"]);
}

addRandomBox(pos, dir)
{
box = spawnXmodel("xmodel/furniture_bathtub", pos, dir);
box.angles = (0, dir+90, 0);
box entityToGround();
box spawnUseTrigger(
::BOX_onUse,
game["hintstring_randombox_allies"],
game["hintstring_randombox_axis"]
);
}

BOX_onUse(player)
{
if (player.pers["team"] == "allies")
{
player iprintln("^6NICE DONE HUNTER");
player openMenu("weapon_german");
}
if (player.pers["team"] == "axis")
{
player iprintln("^6NICE DONE ZOMBIE");
}
}


TRIGGER.gsc



#include maps\BTM\UTILS;
#include maps\BTM\HINTSTRING;

spawnUseTrigger(function, hintstring_allies, hintstring_axis)
{
entity = self;

entity.useTrigger = true;

trigger = spawn("trigger_radius", entity.origin, 0, 50, 50);

entity.trigger = trigger; // for later movement/deletion etc.

while (1)
{
trigger waittill("trigger", player);

if (entity.useTrigger == false)
{
wait 0.10;
continue;
}

if (player.pers["team"] == "allies")
player thread displayHintString(hintstring_allies, entity);

if (player.pers["team"] == "axis")
player thread displayHintString(hintstring_axis, entity);

if (player safeUseButtonPressed())
{
entity [[function]](player);

while (player safeUseButtonPressed())
wait 0.05;
}
}
}

spawnRadiusTrigger(function)
{
entity = self;

entity.useTrigger = true;

trigger = spawn("trigger_radius", entity.origin, 0, 50, 50);

entity.trigger = trigger; // for later movement/deletion etc.

while (1)
{
trigger waittill("trigger", player);

if (entity.useTrigger == false)
{
wait 0.10;
continue;
}

entity [[function]](player);
wait 0.10;
}
}

spawnMeleeTrigger(function, hintstring_allies, hintstring_axis)
{
entity = self;

entity endon("endTriggerThread");

entity.useTrigger = true;

trigger = spawn("trigger_radius", entity.origin, 0, 50, 50);

entity.trigger = trigger; // for later movement/deletion etc.

while (1)
{
trigger waittill("trigger", player);

if (entity.useTrigger == false)
{
wait 0.10;
continue;
}

if (player.pers["team"] == "allies")
player thread displayHintString(hintstring_allies, entity);

if (player.pers["team"] == "axis")
player thread displayHintString(hintstring_axis, entity);

if (player safeMeleeButtonPressed())
{
entity [[function]](player);

while (player safeMeleeButtonPressed())
wait 0.05;
}
}
}


HINTSTRING.gsc



displayHintString(hintstring, entity)
{
player = self;

if ( ! isDefined(player))
return;

if ( ! isDefined(hintstring))
return;

if (isdefined(player.hintstring))
return;

player.hintstring = newClientHudElem(player);
player.hintstring.horzAlign = "fullscreen";
player.hintstring.vertAlign = "fullscreen";
player.hintstring.alignX = "center";
player.hintstring.alignY = "middle";
player.hintstring.x = 320; // 640
player.hintstring.y = 300; // 480
player.hintstring.fontScale = 1.6; // 1.1
player.hintstring.alpha = 1; // zero to one
player.hintstring setText(hintstring);

player thread deleteHintString(entity);
}

deleteHintString(entity)
{
player = self;

while (isdefined(player) && isdefined(player.hintstring))
{
if (player isTouching(entity.trigger))
{
wait 0.10;
continue;
}

player.hintstring destroy();
}
}



For the custom damage trigger stuff, libcod is needed: https://znation.nl/cod4script/setalive.htm