function modCreate_TorchLight() : CTorchLight {
return new CTorchLight in thePlayer;
}
statemachine class CTorchLight extends W3UsableItem {
// default modName = 'TorchLight';
// default modAuthor = "jack3459";
// default modUrl = "http://www.nexusmods.com/witcher3/mods/????/";
// default modVersion = '2.0';
private var inGameConfigWrapper : CInGameConfigWrapper;
private var active : bool;
private var resourcePath : string;
private var entityTemplate : CEntityTemplate;
var TLValue : float;
private var entity : CEntity;
editable var factAddedOnUse : string;
editable var factValue : int;
editable var removeFactOnHide : bool;
editable var factTimeValid : int;
event OnUsed(usedBy : CEntity) {
super.OnUsed(usedBy);
TLValue = StringToFloat(inGameConfigWrapper.GetVarValue('ModTorchLight', 'TLchoice'));
if(TLValue = 0) {
resourcePath = "dlc\dlcureal\data\items\usable\torch\torch.w2ent";
entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
}
if(TLValue = 1) {
resourcePath = "dlc\dlcureal\data\items\usable\torch\torch1.w2ent";
entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
}
if(TLValue = 2) {
resourcePath = "dlc\dlcureal\data\items\usable\torch\torch2.w2ent";
entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
}
if(TLValue = 3) {
resourcePath = "dlc\dlcureal\data\items\usable\torch\torch3.w2ent";
entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
}
//check if used by the Player and that fact does not exist, then proceed with instantiating the entity
if(usedBy == thePlayer && !FactsDoesExist("tlmod_used"))
//check if entity is already active (instantiated) then, if already instantiated (active), set active to false and proceed with destroying entity
if(active) {
active = false;
}
//entity is instatiated
active = true;
//add facts (set in kngwisp.w2ent) factAddedOnUse = kngwisp_used, factValue = 1, factTimeValid = -1
FactsAdd(factAddedOnUse, factValue, factTimeValid);
//instantiate entity from entityTemplate
entity = (CTorchLight)theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition() + Vector(0,0,2), thePlayer.GetWorldRotation());
//fail-safe, add a tag to the entity this should also be received from the .w2ent, but CDPR
entity.AddTag('tlmod');
}
// else if (!active) {
// FactsRemove(factAddedOnUse);
// entity = theGame.GetEntityByTag('tlmod');
// entity.RemoveTimer('FollowPlayer');
// entity.StopAllEffects();
// entity.DestroyAfter(0.1);
// }
}